A Sprite component is a simple image or flipbook animation that is displayed on screen.
The Sprite component can use either an Atlas or a Tile Source for it’s graphics.
Apart from the properties Id, Position and Rotation the following component specific properties exist:
The Blend Mode property defines how the component graphics should be blended with the graphics behind it. These are the available blend modes and how they are calculated:
src.a * src.rgb + (1 - src.a) * dst.rgb
src.rgb + dst.rgb
src.rgb * dst.rgb
src.rgb - dst.rgb * dst.rgb
You can manipulate sprites in runtime through a number of different functions and properties (refer to the API docs for usage). Functions:
sprite.play_flipbook()
- Play an animation on a sprite component.sprite.set_hflip()
and sprite.set_vflip()
- Set horizontal and vertical flipping on a sprite’s animation.A sprite also has a number of different properties that can be manipulated using go.get()
and go.set()
:
cursor
number
).image
hash
). You can change this using an atlas or tile source resource property and go.set()
. Refer to the API reference for an example.material
hash
). You can change this using a material resource property and go.set()
. Refer to the API reference for an example.playback_rate
number
).scale
vector3
).size
vector3
) (READ ONLY).The default sprite material has the following constants that can be changed using go.set() or go.animate() (refer to the Material manual for more details). Examples:
go.set("#sprite", "tint", vmath.vector4(1,0,0,1))
go.animate("#sprite", "tint", go.PLAYBACK_LOOP_PINGPONG, vmath.vector4(1,0,0,1), go.EASING_LINEAR, 2)
tint
vector4
). The vector4 is used to represent the tint with x, y, z, and w corresponding to the red, green, blue and alpha tint.The game.project file has a few project settings related to sprites.
Did you spot an error or do you have a suggestion? Please let us know on GitHub!
GITHUB