module:Sprite

module:Sprite

Sprite class
sprite demo

Constructor

# new module:Sprite(positionDefinition, url, frames, optionsopt)

Sprite constructor

Parameters:
Name Type Attributes Description
positionDefinition PositionDefinition
url String
frames Array.<FrameData>
options SpriteOptions <optional>

Drawing options

Extends

Classes

Spritesheet

Members

# (static) defaultOptions :SpriteOptions

Type:
  • SpriteOptions

# (static) events :SpriteEvents

Type:
  • SpriteEvents

Methods

# (static) from(definition) → {Sprite}

Parameters:
Name Type Description
definition Object
Returns:
Type
Sprite

# (async, static) sheet(url) → {Spritesheet}

Load and return a spritesheet json file

Parameters:
Name Type Description
url String

Url to the file

Returns:
Type
Spritesheet

# pause() → {Sprite}

Put the sprite on pause

Returns:

Itself

Type
Sprite

# play(speedopt) → {Sprite}

Play the sprite animation

Parameters:
Name Type Attributes Description
speed Number <optional>

Choose a play speed

Returns:

Itself

Type
Sprite

# setFrame(frame) → {Sprite}

Parameters:
Name Type Description
frame Number

Number of the frame to set

Returns:

Itself

Type
Sprite

Type Definitions

# Frame

Type:
  • Object
Properties
Name Type Description
x Number

Horizontal position

y Number

Vertical position

w Number

Width

h Number

Height

# FrameData

Type:
  • Object
Properties
Name Type Description
frame Frame

Data about this frame in the sprite-sheet

spriteSourceSize Frame

Data about the original file

# SpriteEvents

Type:
  • Object
Properties
Name Type Description
start String
frame String
end String

# SpriteOptions

Type:
  • Object
Properties
Name Type Attributes Default Description
speed Number <optional>
1
loop Boolean <optional>
true