CPImageSprite

Companion object contains utility methods.

Companion:
class
Source:
CPImageSprite.scala
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(id: String, xf: CPCanvas => Int, yf: CPCanvas => Int, z: Int, img: CPImage, collidable: Boolean, shaders: Seq[CPShader]): CPImageSprite

A convenient shortcut constructor for the image sprite that works in adaptive scene.

A convenient shortcut constructor for the image sprite that works in adaptive scene.

Instead of concrete XY-coordinates this method takes two functions that each takes an instance of CPCanvas class and produce X or Y coordinate. This way this image sprite can update its position on the canvas on each frame. See CPScene on details about adaptive scenes.

Value parameters:
collidable

Whether or not this sprite has a collision shape. Default is false.

id

ID of the sprite.

img

The image to render. It can be changed later.

shaders

Optional sequence of shaders for this sprite. Default value is an empty sequence.

xf

X-coordinate producing function that takes CPCanvas parameter.

yf

Y-coordinate producing function that takes CPCanvas parameter.

z

Z-index at which to render the image.

See also:
Example:

See CPImageCarouselExample class for the example of using images.

See CPImageFormatsExample class for the example of using images.

Source:
CPImageSprite.scala