A sprite class.
0.1.0
.Constructor
Variables
read onlyelements:Array<Array<BatchElement>> = []
The h2d.SpriteBatch.BatchElement
associated with this sprite.
Example: elements[2][1]
returns the element used for displaying the 1st layer of the 2nd frame.
Methods
addAnimation(name:String, frames:Array<Int>, reverse:Bool = false, defaultDuration:Int = 100):AnimData
Adds an animation data.
Parameters:
name | A name for the animation. |
---|---|
frames | The frame indexes to display, in order. |
reverse | Whether the animation should play reversed. |
defaultDuration | The default frame duration. |
loadImage(image:Image, ?w:Int, ?h:Int, toFormat:PixelFormat = hxd.PixelFormat.RGBA, ?flipY:Bool, ?index:Int):Void
Loads an image resource.
Parameters:
image | The image resource to display. |
---|---|
w | Width of the image to display. If it is lower than the resource image size, the image is understood as a spritesheet. |
h | Height of the image to display. If it is lower than the resource image size, the image is understood as a spritesheet. |
toFormat | The pixel format to convert the bytes to, if not a gif image. |
flipY | Set to |
index | Index used to read image data from a Dds file. |
inlinepauseAnimation():Bool
Toggles the current animation's paused status, then returns true if it's paused,
false` otherwise.
update(dt:Float):Void
The update function that gets called every frame by nb.Manager
.
When overriding, you should call super.update
for animations to work.