Drawable

sfml.graphics.Drawable
See theDrawable companion object
trait Drawable

Abstract base class for objects that can be drawn to a render target.

Drawable is a very simple base class that allows objects of derived classes to be drawn to a RenderTarget.

All you have to do in your derived class is to override the draw function.

Note that inheriting from Drawable is not mandatory, but it allows this nice syntax window.draw(object) rather than object.draw(window), which is more consistent with other SFML classes.

class MyDrawable(sprite: Sprite) extends Drawable:
   override def draw(target: RenderTarget, states: RenderStates): Unit =
       // You can draw other high-level objects
       target.draw(sprite, states)

Attributes

See also
Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait Shape
trait CircleShape
trait Sprite
trait Text

Members list

Value members

Abstract methods

def draw(target: RenderTarget, states: RenderStates): Unit

Draw the object to a render target.

Draw the object to a render target.

This is a function that has to be implemented by the derived class to define how the drawable should be drawn.

Value parameters

states

Current render states

target

Render target to draw to

Attributes