GuiItem Class
The base GuiItem that represents an element of a gui on the screen.
Constructor
GuiItem
-
texture
-
interactive
Parameters:
-
texture
TextureThe texture to set the sprite to
-
interactive
BooleanWhether this item should repsond to mouse events
Item Index
Methods
Properties
Methods
addAnimation
-
name
-
frames
-
[speed]
-
[loop]
Adds a new animation to this animated sprite
Parameters:
-
name
StringThe string name of the animation
-
frames
ArrayThe array of texture frames
-
[speed]
Number optionalThe animation speed
-
[loop]
Boolean optionalLoop the animation or not
Returns:
Returns itself.
clone
()
Sprite
Creates a new Sprite instance with the same values as this one
Returns:
Returns the new sprite
destroy
()
Removes this sprite from the stage and the physics system
emit
-
type
-
data
Emits an event which will run all registered listeners for the event type
Parameters:
-
type
StringThe event name to emit
-
data
MixedAny data you want passed along with the event
Returns:
Returns itself.
goto
-
frame
-
[name]
Goes to a frame and starts playing the animation from there. You can optionally pass the name of a new aniamtion to start playing.
Parameters:
-
frame
NumberThe index of the frame to start on
-
[name]
String optionalThe string name of the animation to go to
Returns:
Returns itself.
mousedown
-
evt
Function that is called whenever a mousedown event occurs. This is used to handle dragging for GUI items.
Parameters:
-
evt
InteractionEventThe interaction event
mousemove
-
evt
Function that is called whenever a mousemove event occurs. This is used to handle dragging for GUI items.
Parameters:
-
evt
InteractionEventThe interaction event
mouseup
-
evt
Function that is called whenever a mouseup event occurs. This is used to handle dragging for GUI items.
Parameters:
-
evt
InteractionEventThe interaction event
off
-
type
-
listener
Removes a listener function for an event type
Parameters:
-
type
StringThe event name to emit
-
listener
FunctionThe function to remove
Returns:
Returns itself.
on
-
type
-
listener
Registers a listener function to be run on an event occurance
Parameters:
-
type
StringThe event name to listen for
-
listener
FunctionThe function to execute when the event happens
Returns:
Returns itself.
once
-
type
-
listener
Registers a one-time callback for an event
Parameters:
-
type
StringThe event name to listen for
-
listener
Functionthe callback to call when the event occurs
Returns:
Returns itself.
play
()
Sprite
chainable
Starts playing the currently active animation
Returns:
Returns itself.
stop
()
Sprite
chainable
Stops playing the currently active animation
Returns:
Returns itself.
updateTransform
()
private
Called by PIXI to update our textures and do the actual animation
Properties
animations
Object
The registerd animations for this AnimatedSprite
currentAnimation
String
The currently playing animation
currentFrame
Number
The current frame being shown
draggable
Boolean
Sets whether or not you can drag the GuiItem around
Default: false
dragging
Object
Describes if the current item is being dragged or not, if it is this object will hold the last local position of the mouse (relative to this object's parent)
Default: false
lifetime
Number
private
The lifetime of the sprite. Once it reaches 0 (after being set) the sprite's visible property is set to false, so that it will no longer be rendered. NOT YET IMPLEMENTED
Default: Infinity
loop
Boolean
Whether or not to loop the animations. This can be overriden on a per-animation level
Default: false
name
String
The name of the sprite
Default: ''
playing
Boolean
Whether or not the animation is currently playing
speed
Number
The animation speed for this sprite
Default: 1
Events
click
A callback that is used when the users clicks on the sprite with their mouse
Event Payload:
-
interactionData
InteractionData
complete
Fired when the running animation completes
Event Payload:
-
animation
StringThe animation that has completed
frame
Fired when a new frame of the running animation is shown
Event Payload:
-
animation
StringThe animation name that is playing
-
frameId
NumberThe frame that is being shown
mousedown
A callback that is used when the user clicks the mouse down over the sprite
Event Payload:
-
interactionData
InteractionData
mousemove
A callback that is used when the user moves the mouse while over the sprite
Event Payload:
-
interactionData
InteractionData
mouseout
A callback that is used when the users mouse leaves the sprite
Event Payload:
-
interactionData
InteractionData
mouseover
A callback that is used when the users mouse rolls over the sprite
Event Payload:
-
interactionData
InteractionData
mouseup
A callback that is used when the user releases the mouse that was over the sprite for this callback to be fired the mouse must have been pressed down over the sprite
Event Payload:
-
interactionData
InteractionData
mouseupoutside
A callback that is used when the user releases the mouse that was over the sprite but is no longer over the sprite for this callback to be fired, The touch must have started over the sprite
Event Payload:
-
interactionData
InteractionData
tap
A callback that is used when the users taps on the sprite with their finger basically a touch version of click
Event Payload:
-
interactionData
InteractionData
touchend
A callback that is used when the user releases a touch over the sprite
Event Payload:
-
interactionData
InteractionData
touchendoutside
A callback that is used when the user releases the touch that was over the sprite for this callback to be fired, The touch must have started over the sprite
Event Payload:
-
interactionData
InteractionData
touchstart
A callback that is used when the user touch's over the sprite
Event Payload:
-
interactionData
InteractionData