Create a new SpriteComponent instance.
The ComponentSystem that created this Component.
The Entity that this Component is attached to.
The Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Gets the name of the clip to play automatically when the component is enabled.
Sets the name of the clip to play automatically when the component is enabled.
Gets the batch group for the sprite.
Sets the batch group for the sprite (see BatchGroup). Default is -1 (no group).
Gets the dictionary that contains SpriteAnimationClips.
Sets the dictionary that contains SpriteAnimationClips.
Gets the current clip being played.
Gets the draw order of the component.
Sets the draw order of the component. A higher value means that the component will be rendered on top of other components in the same layer. This is not used unless the layer's sort order is set to SORTMODE_MANUAL.
Gets the enabled state of the component.
Sets the enabled state of the component.
Gets whether to flip the X axis when rendering a sprite.
Sets whether to flip the X axis when rendering a sprite.
Gets whether to flip the Y axis when rendering a sprite.
Sets whether to flip the Y axis when rendering a sprite.
Gets which frame from the current sprite asset to render.
Sets which frame from the current sprite asset to render.
Gets the height of the sprite when rendering using 9-Slicing.
Sets the height of the sprite when rendering using 9-Slicing. The width and height are only used when the render mode of the sprite asset is Sliced or Tiled.
Gets the opacity of the sprite.
Sets the opacity of the sprite.
Gets the global speed modifier used when playing sprite animation clips.
Sets the global speed modifier used when playing sprite animation clips.
Gets the type of the SpriteComponent.
Sets the type of the SpriteComponent. Can be:
Defaults to SPRITETYPE_SIMPLE.
Gets the width of the sprite when rendering using 9-Slicing.
Sets the width of the sprite when rendering using 9-Slicing. The width and height are only used when the render mode of the sprite asset is Sliced or Tiled.
Creates and adds a new SpriteAnimationClip to the component's clips.
Data for the new animation clip.
The new clip that was added.
Get an animation clip by name.
The name of the clip.
The clip.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Plays a sprite animation clip by name. If the animation clip is already playing then this will do nothing.
The name of the clip to play.
The clip that started playing.
Static
EVENT_Fired when an animation clip stops playing because it reached its end. The handler is passed the SpriteAnimationClip that ended.
Static
EVENT_Fired when an animation clip reached the end of its current loop. The handler is passed the SpriteAnimationClip that looped.
Static
EVENT_Fired when an animation clip is paused. The handler is passed the SpriteAnimationClip that was paused.
Static
EVENT_Fired when an animation clip starts playing. The handler is passed the SpriteAnimationClip that started playing.
Static
EVENT_Fired when an animation clip is resumed. The handler is passed the SpriteAnimationClip that was resumed.
Static
EVENT_Fired when an animation clip is stopped. The handler is passed the SpriteAnimationClip that was stopped.
Enables an Entity to render a simple static sprite or sprite animations.