API Docs for: v0.1.0
Show:

Text Class

Extends Sprite
Defined in: src\text\Text.js:1

A Text Object will create a line(s) of text to split a line you can use "\n" see PIXI.Text for more information.

Constructor

Text

(
  • text
  • [style]
)

Defined in src\text\Text.js:1

Parameters:

  • text String

    The copy that you would like the text to display

  • [style] Object optional

    The style parameters

    • [font] String optional

      default "bold 20pt Arial" The style and size of the font

    • [fill="black"] Object optional

      A canvas fillstyle that will be used on the text eg "red", "#00FF00"

    • [align="left"] String optional

      An alignment of the multiline text ("left", "center" or "right")

    • [stroke] String optional

      A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"

    • [strokeThickness=0] Number optional

      A number that represents the thickness of the stroke. Default is 0 (no stroke)

    • [wordWrap=false] Boolean optional

      Indicates if word wrap should be used

    • [wordWrapWidth=100] Number optional

      The width at which text will wrap

Methods

addAnimation

(
  • name
  • frames
  • [speed]
  • [loop]
)
Sprite chainable

Adds a new animation to this animated sprite

Parameters:

  • name String

    The string name of the animation

  • frames Array

    The array of texture frames

  • [speed] Number optional

    The animation speed

  • [loop] Boolean optional

    Loop the animation or not

Returns:

Sprite:

Returns itself.

clone

() Sprite

Creates a new Sprite instance with the same values as this one

Returns:

Sprite:

Returns the new sprite

destroy

()

Removes this sprite from the stage and the physics system

emit

(
  • type
  • data
)
Mixed chainable

Emits an event which will run all registered listeners for the event type

Parameters:

  • type String

    The event name to emit

  • data Mixed

    Any data you want passed along with the event

Returns:

Mixed:

Returns itself.

goto

(
  • frame
  • [name]
)
Sprite chainable

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 Number

    The index of the frame to start on

  • [name] String optional

    The string name of the animation to go to

Returns:

Sprite:

Returns itself.

hide

() Sprite chainable

Sets the sprite to visible = false

Returns:

Sprite:

Returns itself.

off

(
  • type
  • listener
)
Mixed chainable

Removes a listener function for an event type

Parameters:

  • type String

    The event name to emit

  • listener Function

    The function to remove

Returns:

Mixed:

Returns itself.

on

(
  • type
  • listener
)
Mixed chainable

Registers a listener function to be run on an event occurance

Parameters:

  • type String

    The event name to listen for

  • listener Function

    The function to execute when the event happens

Returns:

Mixed:

Returns itself.

once

(
  • type
  • listener
)
Mixed chainable

Registers a one-time callback for an event

Parameters:

  • type String

    The event name to listen for

  • listener Function

    the callback to call when the event occurs

Returns:

Mixed:

Returns itself.

play

() Sprite chainable

Starts playing the currently active animation

Returns:

Sprite:

Returns itself.

show

() Sprite chainable

Sets the sprite to visible = true

Returns:

Sprite:

Returns itself.

stop

() Sprite chainable

Stops playing the currently active animation

Returns:

Sprite:

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

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 String

    The animation that has completed

frame

Fired when a new frame of the running animation is shown

Event Payload:

  • animation String

    The animation name that is playing

  • frameId Number

    The 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