Class: SpriteElement

SpriteElement

SpriteElement class, extending Element

new SpriteElement(options)

constructs an SpriteElement instance
Parameters:
Name Type Description
options Object the options object to be merged with defaults

Extends

Methods


align(parentElement, mode)

Aligns the Element instance, based on it's parent bounds or specified parentElement bounds and mode parameter
Parameters:
Name Type Description
parentElement Object | null if null, it considers the actual Element instance parent, otherwise it aligns in base of the specified parentElement
mode String can be a set of one or two strings (blank separated) in any order, for horizontalModes (left, center, right), for verticalModes (top, middle, bottom)
Inherited From:
Returns:
to make chainable the method
Type
Element

animate(options)

animates the sprite
Parameters:
Name Type Description
options Object the animate options including
Properties
Name Type Description
animationName String the animation name in the spritesheet json to start
function
Returns:
Type
SpriteElement

bindEvents()

binds all events specified in the settings object for the Element instance, it supports all DrawJS classes events (eg. click, mouseover, etc...)
Inherited From:

draw()

draws all graphic elements of the Element instance
Inherited From:

drawElements()

draws all graphic elements of the SpriteElement instance

getComputedBounds()

returns the actual computed bounds of the Element instance, including scale factor and top, right, bottom, left coordinates
Inherited From:
Returns:
the actual Element instance computed bounds object
  {
    {
      top: number,
      right: number,
      bottom: number,
      left: number,
      x: number,
      y: number,
      width: number,
      height: number
    }
  }
Type
Object

init()

empty init method, to be overriden in classes that extends Element, to use for all those initializations you might need after having rendered the Element
Inherited From:

initData()

initializes data object for the Element instance
Inherited From:

initDefaults()

Initialize default settings for SpriteElement
Overrides:

initSettings(options)

initializes settings object for the Element instance
Parameters:
Name Type Description
options Object the options object to be merged with defaults
Inherited From:

setCache(cacheOptions, force)

sets or updates the Cache of the Element instance
Parameters:
Name Type Description
cacheOptions Object | Shadow ..
force Boolean ....
Inherited From:
Returns:
to make chainable the method
Type
Element

setComputedBounds(boundsOptions)

sets or updates the bounds of the Element instance
Parameters:
Name Type Description
boundsOptions Object | Number ...
Inherited From:
Returns:
to make chainable the method
Type
Element

setMask(maskOptions, force)

sets or updates the Mask of the Element instance
Parameters:
Name Type Description
maskOptions Object | Shadow can be an object with {color, x, y, blur}
or directly an instance of Shadow (DrawJS)
force Boolean ....
Inherited From:
Returns:
to make chainable the method
Type
Element

setPosition( [positionOptions] [, override] [, force])

sets or updates the position of the Element instance
Parameters:
Name Type Argument Default Description
positionOptions Object <optional>
null can contain x and y or only one or them
Properties
Name Type Argument Default Description
x Number <optional>
0 the x position
y Number <optional>
0 the y position
override Boolean <optional>
false specify to override actual Element position
force Boolean <optional>
true ...
Inherited From:
Returns:
to make chainable the method
Type
Element

setReg()

sets to center/middle the regPoint of the Element instance
Inherited From:

setScale(scaleOptions)

sets or updates the scaling of the Element instance
Parameters:
Name Type Description
scaleOptions Object | Number can be an object with x and y couple or only a number to be used for both
Inherited From:
Overrides:
Returns:
to make chainable the method
Type
Element

setShadow(shadowOptions, force)

sets or updates the Shadow of the Element instance
Parameters:
Name Type Description
shadowOptions Object | Shadow can be an object with {color, x, y, blur}
or directly an instance of Shadow (DrawJS)
force Boolean ....
Inherited From:
Returns:
to make chainable the method
Type
Element