SpriteRuntimeObject

SpriteRuntimeObject

The SpriteRuntimeObject represents an object that can display images.

Constructor

new SpriteRuntimeObject(runtimeScene, spriteObjectData)

Parameters:
Name Type Description
runtimeScene

The scene the object belongs to

spriteObjectData

The object data used to initialize the object

Source:

Methods

extraInitializationFromInitialInstance(initialInstanceData)

Initialize the extra parameters that could be set for an instance.

Parameters:
Name Type Description
initialInstanceData

The extra parameters

Source:

getAngle()

Get the angle of the object.

Returns:
Type Description

The angle, in degrees.

Source:

getAnimation()

Get the index of the animation being played.

Returns:
Type Description

The index of the new animation being played

Source:

getAnimationFrame()

Get the index of the current frame displayed by the animation

Returns:
Type Description

newFrame The index of the frame being displayed

Source:

getAnimationName()

Get the name of the animation being played.

Returns:
Type Description

The name of the new animation being played

Source:

getCenterX()

Get the X position of the center of the object, relative to top-left of the texture of the object (getDrawableX).

Returns:
Type Description

X position of the center of the object, relative to getDrawableX().

Source:

getCenterY()

Get the Y position of the center of the object, relative to top-left of the texture of the object (getDrawableY).

Returns:
Type Description

Y position of the center of the object, relative to getDrawableY().

Source:

getColor()

Get the tint of the sprite object.

Returns:
Type Description

The color, in RGB format ("128;200;255").

Source:

getDrawableX()

Get the X position, on the scene, of the origin of the texture of the object.

Returns:
Type Description

the X position, on the scene, of the origin of the texture of the object.

Source:

getDrawableY()

Get the Y position, on the scene, of the origin of the texture of the object.

Returns:
Type Description

the Y position, on the scene, of the origin of the texture of the object.

Source:

getHeight()

Get the height of the object.

Returns:
Type Description

The height of the object, in pixels.

Source:

getOpacity()

Get the transparency of the object.

Returns:
Type Description

The opacity, between 0 (transparent) and 255 (opaque).

Source:

getPointPosition(name)

Get the positions on X and Y axis on the scene of the given point.

Parameters:
Name Type Description
name

The point name

Returns:
Type Description

An array of the position on X and Y axis on the scene of the given point.

Source:

getPointX(name)

Get the position on X axis on the scene of the given point.

Parameters:
Name Type Description
name

The point name

Returns:
Type Description

the position on X axis on the scene of the given point.

Source:

getPointY(name)

Get the position on Y axis on the scene of the given point.

Parameters:
Name Type Description
name

The point name

Returns:
Type Description

the position on Y axis on the scene of the given point.

Source:

getScale()

Get the scale of the object (or the average of the X and Y scale in case they are different).

Returns:
Type Description

the scale of the object (or the average of the X and Y scale in case they are different).

Source:

getScaleX()

Get the scale of the object on X axis.

Returns:
Type Description

the scale of the object on X axis

Source:

getScaleY()

Get the scale of the object on Y axis.

Returns:
Type Description

the scale of the object on Y axis

Source:

getWidth()

Get the width of the object.

Returns:
Type Description

The width of the object, in pixels.

Source:

hasAnimationEnded()

Return true if animation has ended.

Source:

hide(enable)

Hide (or show) the object

Parameters:
Name Type Description
enable

true to hide the object, false to show it again.

Source:

setAngle(angle)

Set the angle of the object.

Parameters:
Name Type Description
angle

The new angle, in degrees.

Source:

setAnimation(newAnimation)

Change the animation being played.

Parameters:
Name Type Description
newAnimation

The index of the new animation to be played

Source:

setAnimationFrame(newFrame)

Change the current frame displayed by the animation

Parameters:
Name Type Description
newFrame

The index of the frame to be displayed

Source:

setAnimationName(newAnimationName)

Change the animation being played.

Parameters:
Name Type Description
newAnimationName

The name of the new animation to be played

Source:

setColor(rgbColor)

Change the tint of the sprite object.

Parameters:
Name Type Description
rgbColor

The color, in RGB format ("128;200;255").

Source:

setDirectionOrAngle(The)

Change the angle (or direction index) of the object

Parameters:
Name Type Description
The

new angle (or direction index) to be applied

Source:

setHeight(height)

Change the height of the object. This changes the scale on Y axis of the object.

Parameters:
Name Type Description
height

The new height of the object, in pixels.

Source:

setOpacity(opacity)

Change the transparency of the object.

Parameters:
Name Type Description
opacity

The new opacity, between 0 (transparent) and 255 (opaque).

Source:

setScale(newScale)

Change the scale on X and Y axis of the object.

Parameters:
Name Type Description
newScale

The new scale (must be greater than 0).

Source:

setScaleX(newScale)

Change the scale on X axis of the object (changing its width).

Parameters:
Name Type Description
newScale

The new scale (must be greater than 0).

Source:

setScaleY(newScale)

Change the scale on Y axis of the object (changing its width).

Parameters:
Name Type Description
newScale

The new scale (must be greater than 0).

Source:

setWidth(width)

Change the width of the object. This changes the scale on X axis of the object.

Parameters:
Name Type Description
width

The new width of the object, in pixels.

Source:

setX(x)

Set the X position of the (origin of the) object.

Parameters:
Name Type Description
x

The new X position.

Source:

setY(y)

Set the Y position of the (origin of the) object.

Parameters:
Name Type Description
y

The new Y position.

Source:

turnTowardObject(obj, scene)

Parameters:
Name Type Description
obj

The target object

scene

The scene containing the object

Deprecated:
  • Yes

Source:

update()

Update the current frame of the object according to the elapsed time on the scene.

Source:

updateHitBoxes()

Update the hit boxes for the object. Fallback to the default implementation (rotated bounding box) if there is no custom hitboxes defined for the current animation frame.

Source:

updatePreRender()

Ensure the sprite is ready to be displayed: the proper animation frame is set and the renderer is up to date (position, angle, alpha, flip, blend mode...).

Source: