-
Notifications
You must be signed in to change notification settings - Fork 341
Sprites
Yuxiao Mao edited this page Oct 16, 2024
·
4 revisions
DEPRECATION NOTE:
h2d.Sprite
is nowh2d.Object
. Sprite type is still accessible but is actually a typedef ofh2d.Object
in the API. It has been kept for compatibility reasons.
The following documentation is not maintained.
The following properties and methods can be accessed on any Sprite:
-
x
andy
: the position in pixels relative to the parent Sprite (or in the Scene) -
rotation
: the rotation of the sprite in radians -
scaleX
andscaleY
: the horizontal and vertical scaling values for this Sprite (default to (1,1)). You can uniformaly increase the current scales by calling sprite.scale(1.1) or set them to give value by using sprite.setScale(value). -
visible
: when visible is set to false, a sprite is still updated (position is calculated and animation still plays) but the sprite and all its children are not displayed -
parent
: the current parent Sprite, or null if it has not been added -
remove()
: remove the sprite from its parent. This will prevent it from being updated and displayed -
addChild()
: adds the specified sprite to the children list -
for( s in sprite ) {...}
: iterates over all the current children
Sprite instances have other properties and methods which can be discovered by visiting the h2d.Sprite
API section.