Class: SpineGameObject

SpineGameObject

A Spine Game Object is a Phaser level object that can be added to your Phaser Scenes. It encapsulates a Spine Skeleton with Spine Animation Data and Animation State, with helper methods to allow you to easily change the skin, slot attachment, bone positions and more.

Spine Game Objects can be created via the Game Object Factory, Game Object Creator, or directly. You can only create them if the Spine plugin has been loaded into Phaser.

The quickest way is the Game Object Factory:

let jelly = this.add.spine(512, 550, 'jelly', 'jelly-think', true);

Here we are creating a new Spine Game Object positioned at 512 x 550. It's using the jelly Spine data, which has previously been loaded into your Scene. The jelly-think argument is an optional animation to start playing on the skeleton. The final argument true sets the animation to loop. Look at the documentation for further details on each of these options.

For more control, you can use the Game Object Creator, passing in a Spine Game Object Configuration object:

let jelly = this.make.spine({
    x: 512, y: 550, key: 'jelly',
    scale: 1.5,
    skinName: 'square_Green',
    animationName: 'jelly-think', loop: true,
    slotName: 'hat', attachmentName: 'images/La_14'
});

Here, you've got the ability to specify extra details, such as the slot name, attachments or overall scale.

If you wish to instantiate a Spine Game Object directly you can do so, but in order for it to update and render, it must be added to the display and update lists of your Scene:

let jelly = new SpineGameObject(this, this.spine, 512, 550, 'jelly', 'jelly-think', true);
this.sys.displayList.add(jelly);
this.sys.updateList.add(jelly);

It's possible to enable Spine Game Objects for input, but you should be aware that it will use the bounds of the skeletons current pose to create the hit area from. Sometimes this is ok, but often not. Make use of the InputPlugin.enableDebug method to view the input shape being created. If it's not suitable, provide your own shape to the setInteractive method.

Due to the way Spine handles scaling, it's not recommended to enable a Spine Game Object for physics directly. Instead, you should look at creating a proxy body and syncing the Spine Game Object position with it. See the examples for further details.

If your Spine Game Object has black outlines around the different parts of the texture when it renders then you have exported the files from Spine with pre-multiplied alpha enabled, but have forgotten to set that flag when loading the Spine data. Please see the loader docs for more details.


new SpineGameObject(scene, pluginManager, x, y [, key] [, animationName] [, loop])

Parameters:
Name Type Argument Default Description
scene Phaser.Scene

A reference to the Scene that this Game Object belongs to.

pluginManager SpinePlugin

A reference to the Phaser Spine Plugin.

x number

The horizontal position of this Game Object in the world.

y number

The vertical position of this Game Object in the world.

key string <optional>

The key of the Spine Skeleton this Game Object will use, as stored in the Spine Plugin.

animationName string <optional>

The name of the animation to set on this Skeleton.

loop boolean <optional>
false

Should the animation playback be looped or not?

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 23)

Members


alpha :number

The alpha value of the Skeleton.

A value between 0 and 1.

This is a global value, impacting the entire Skeleton, not just a region of it.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 313)

<readonly> blendMode :number

A default Blend Mode. You cannot change the blend mode of a Spine Game Object.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 225)

blue :number

The amount of blue used when rendering the Skeleton.

A value between 0 and 1.

This is a global value, impacting the entire Skeleton, not just a region of it.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 412)

bounds :any

This object holds the calculated bounds of the current pose, as set when a new Skeleton is applied.

Type:
  • any
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 167)

displayOriginX :number

The calculated Display Origin of this Game Object.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 196)

displayOriginY :number

The calculated Display Origin of this Game Object.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 205)

drawDebug :boolean

A Game Object level flag that allows you to enable debug drawing to the Skeleton Debug Renderer by toggling it.

Type:
  • boolean
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 177)

green :number

The amount of green used when rendering the Skeleton.

A value between 0 and 1.

This is a global value, impacting the entire Skeleton, not just a region of it.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 382)

plugin :SpinePlugin

A reference to the Spine Plugin.

Type:
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 113)

preMultipliedAlpha :boolean

A flag that stores if the texture associated with the current Skin being used by this Game Object, has its alpha pre-multiplied into it, or not.

Type:
  • boolean
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 214)

red :number

The amount of red used when rendering the Skeleton.

A value between 0 and 1.

This is a global value, impacting the entire Skeleton, not just a region of it.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 352)

root :spine.Bone

A reference to the root bone of the Skeleton.

Type:
  • spine.Bone
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 158)

scaleX :number

The horizontal scale of this Game Object, as applied to the Skeleton it is using.

Type:
  • number
Since: 3.19.0
Default Value:
  • 1
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 809)

scaleY :number

The vertical scale of this Game Object, as applied to the Skeleton it is using.

Type:
  • number
Since: 3.19.0
Default Value:
  • 1
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 833)

skeleton :spine.Skeleton

The Spine Skeleton this Game Object is using.

Type:
  • spine.Skeleton
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 122)

skeletonData :spine.SkeletonData

The Spine Skeleton Data associated with the Skeleton this Game Object is using.

Type:
  • spine.SkeletonData
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 131)

state :spine.AnimationState

The Spine Animation State this Game Object is using.

Type:
  • spine.AnimationState
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 140)

stateData :spine.AnimationStateData

The Spine Animation State Data associated with the Animation State this Game Object is using.

Type:
  • spine.AnimationStateData
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 149)

timeScale :number

The factor to scale the Animation update time by.

Type:
  • number
Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 187)

Methods


addAnimation(trackIndex, animationName [, loop] [, delay])

Adds an animation to be played after the current or last queued animation for a track. If the track is empty, it is equivalent to calling setAnimation.

Animations are referenced by a unique string-based key, as defined in the Spine software.

The delay is a float. If > 0, sets delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration (from the AnimationStateData) plus the specified delay (ie the mix ends at (delay = 0) or before (delay < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration.

Parameters:
Name Type Argument Default Description
trackIndex integer

The track index to add the animation to.

animationName string

The string-based key of the animation to add.

loop boolean <optional>
false

Should the animation be looped when played?

delay integer <optional>
0

A delay, in ms, before which this animation will start when played.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1037)
Returns:

A track entry to allow further customization of animation playback.

Type
spine.TrackEntry

angleBoneToXY(bone, worldX, worldY [, offset] [, minAngle] [, maxAngle])

Takes a Bone object and a position in world space and rotates the Bone so it is angled towards the given position. You can set an optional angle offset, should the bone be designed at a specific angle already. You can also set a minimum and maximum range for the angle.

Parameters:
Name Type Argument Default Description
bone spine.Bone

The bone to rotate towards the world position.

worldX number

The world x coordinate to rotate the bone towards.

worldY number

The world y coordinate to rotate the bone towards.

offset number <optional>
0

An offset to add to the rotation angle.

minAngle number <optional>
0

The minimum range of the rotation angle.

maxAngle number <optional>
360

The maximum range of the rotation angle.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1337)
Returns:

This Game Object.

Type
SpineGameObject

clearTrack(trackIndex)

Removes all animations from the track, leaving skeletons in their current pose.

It may be desired to use setEmptyAnimation to mix the skeletons back to the setup pose, rather than leaving them in their current pose.

Parameters:
Name Type Description
trackIndex integer

The track index to add the animation to.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1095)
Returns:

This Game Object.

Type
SpineGameObject

clearTracks()

Removes all animations from all tracks, leaving skeletons in their current pose.

It may be desired to use setEmptyAnimation to mix the skeletons back to the setup pose, rather than leaving them in their current pose.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1115)
Returns:

This Game Object.

Type
SpineGameObject

findAnimation(animationName)

Finds an animation by comparing each animation's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
animationName string

The name of the animation to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1466)
Returns:

The Animation. May be null.

Type
spine.Animation

findBone(boneName)

Finds a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
boneName string

The name of the bone to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1370)
Returns:

The bone, or null.

Type
spine.Bone

findBoneIndex(boneName)

Finds the index of a bone by comparing each bone's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
boneName string

The name of the bone to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1386)
Returns:

The bone index. Or -1 if the bone was not found.

Type
integer

findEvent(eventDataName)

Finds an event by comparing each events's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
eventDataName string

The name of the event to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1450)
Returns:

The Event Data. May be null.

Type
spine.EventData

findIkConstraint(constraintName)

Finds an IK constraint by comparing each IK constraint's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
constraintName string

The name of the constraint to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1482)
Returns:

The IK constraint. May be null.

Type
spine.IkConstraintData

findPathConstraint(constraintName)

Finds a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
constraintName string

The name of the constraint to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1514)
Returns:

The path constraint. May be null.

Type
spine.PathConstraintData

findPathConstraintIndex(constraintName)

Finds the index of a path constraint by comparing each path constraint's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
constraintName string

The name of the constraint to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1530)
Returns:

The constraint index. Or -1 if the constraint was not found.

Type
integer

findSkin(skinName)

Finds a skin by comparing each skin's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
skinName string

The name of the skin to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1434)
Returns:

The Skin. May be null.

Type
spine.Skin

findSlot(slotName)

Finds a slot by comparing each slot's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
slotName string

The name of the slot to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1402)
Returns:

The Slot. May be null.

Type
spine.Slot

findSlotIndex(slotName)

Finds the index of a slot by comparing each slot's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
slotName string

The name of the slot to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1418)
Returns:

The slot index. Or -1 if the Slot was not found.

Type
integer

findTransformConstraint(constraintName)

Finds an transform constraint by comparing each transform constraint's name. It is more efficient to cache the results of this method than to call it multiple times.

Parameters:
Name Type Description
constraintName string

The name of the constraint to find.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1498)
Returns:

The transform constraint. May be null.

Type
spine.TransformConstraintData

getAnimationList()

Returns an array containing the names of all the animations in the Skeleton Data.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 929)
Returns:

An array containing the names of all the animations in the Skeleton Data.

Type
Array.<string>

getAttachment(slotIndex, attachmentName)

Finds an attachment by looking in the skin and defaultSkin using the slot index and attachment name. First the skin is checked and if the attachment was not found, the default skin is checked.

Parameters:
Name Type Description
slotIndex integer

The slot index to search.

attachmentName string

The attachment name to look for.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1216)
Returns:

The Attachment, if found. May be null.

Type
spine.Attachment

getAttachmentByName(slotName, attachmentName)

Finds an attachment by looking in the skin and defaultSkin using the slot name and attachment name.

Parameters:
Name Type Description
slotName string

The slot name to search.

attachmentName string

The attachment name to look for.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1234)
Returns:

The Attachment, if found. May be null.

Type
spine.Attachment

getBoneList()

Returns an array containing the names of all the bones in the Skeleton Data.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 857)
Returns:

An array containing the names of all the bones in the Skeleton Data.

Type
Array.<string>

getBounds()

Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose.

The returned object contains two properties: offset and size:

offset - The distance from the skeleton origin to the bottom left corner of the AABB. size - The width and height of the AABB.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1546)
Returns:

The bounds object.

Type
any

getCurrentAnimation( [trackIndex])

Returns the current animation being played on the given track, if any.

Parameters:
Name Type Argument Default Description
trackIndex integer <optional>
0

The track to return the current animation on.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 954)
Returns:

The current Animation on the given track, or undefined if there is no current animation.

Type
spine.Animation

getRootBone()

Gets the root bone, or null.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1324)
Returns:

The root bone, or null.

Type
spine.Bone

getSkinList()

Returns an array containing the names of all the skins in the Skeleton Data.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 882)
Returns:

An array containing the names of all the skins in the Skeleton Data.

Type
Array.<string>

getSlotList()

Returns an array containing the names of all the slots in the Skeleton.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 907)
Returns:

An array containing the names of all the slots in the Skeleton.

Type
Array.<string>

play(animationName [, loop] [, ignoreIfPlaying])

Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never applied to a skeleton, it is replaced (not mixed from).

Animations are referenced by a unique string-based key, as defined in the Spine software.

Parameters:
Name Type Argument Default Description
animationName string

The string-based key of the animation to play.

loop boolean <optional>
false

Should the animation be looped when played?

ignoreIfPlaying boolean <optional>
false

If this animation is already playing then ignore this call.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 976)
Fires:
Returns:

This Game Object. If you need the TrackEntry, see setAnimation instead.

Type
SpineGameObject

<protected> preDestroy()

Internal destroy handler, called as part of the destroy process.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1583)

<protected> preUpdate(time, delta)

Internal update handler.

Parameters:
Name Type Description
time number

The current timestamp.

delta number

The delta time, in ms, elapsed since the last frame.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1564)

refresh()

Refreshes the data about the current Skeleton.

This will reset the rotation, position and size of the Skeleton to match this Game Object.

Call this method if you need to access the Skeleton data directly, and it may have changed recently.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 674)
Returns:

This Game Object.

Type
SpineGameObject

setAlpha( [value])

Set the Alpha level for the whole Skeleton of this Game Object.

The alpha controls the opacity of the Game Object as it renders.

Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.

Parameters:
Name Type Argument Default Description
value number <optional>
1

The alpha value used for the whole Skeleton.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 278)
Returns:

This Game Object instance.

Type
SpineGameObject

setAnimation(trackIndex, animationName [, loop] [, ignoreIfPlaying])

Sets the current animation for a track, discarding any queued animations. If the formerly current track entry was never applied to a skeleton, it is replaced (not mixed from).

Animations are referenced by a unique string-based key, as defined in the Spine software.

Parameters:
Name Type Argument Default Description
trackIndex integer

The track index to play the animation on.

animationName string

The string-based key of the animation to play.

loop boolean <optional>
false

Should the animation be looped when played?

ignoreIfPlaying boolean <optional>
false

If the animation specified by the track index is already playing then ignore this call.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 999)
Fires:
Returns:

A track entry to allow further customization of animation playback.

Type
spine.TrackEntry

setAttachment(slotName, attachmentName)

A convenience method to set an attachment by finding the slot with findSlot, finding the attachment with getAttachment, then setting the slot's attachment.

Parameters:
Name Type Description
slotName string

The slot name to add the attachment to.

attachmentName string

The attachment name to add.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1250)
Returns:

This Game Object.

Type
SpineGameObject

setBonesToSetupPose()

Sets the bones and constraints to their setup pose values.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1309)
Returns:

This Game Object.

Type
SpineGameObject

setColor( [color] [, slotName])

Sets the color on the given attachment slot. Or, if no slot is given, on the whole skeleton.

Parameters:
Name Type Argument Default Description
color integer <optional>
0xffffff

The color being applied to the Skeleton or named Slot. Set to white to disable any previously set color.

slotName string <optional>

The name of the slot to set the color on. If not give, will be set on the whole skeleton.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 442)
Returns:

This Game Object instance.

Type
SpineGameObject

setEmptyAnimation(trackIndex [, mixDuration])

Sets an empty animation for a track, discarding any queued animations, and sets the track entry's mixDuration. An empty animation has no timelines and serves as a placeholder for mixing in or out.

Mixing out is done by setting an empty animation with a mix duration using either setEmptyAnimation, setEmptyAnimations, or addEmptyAnimation. Mixing to an empty animation causes the previous animation to be applied less and less over the mix duration. Properties keyed in the previous animation transition to the value from lower tracks or to the setup pose value if no lower tracks key the property. A mix duration of 0 still mixes out over one frame.

Mixing in is done by first setting an empty animation, then adding an animation using addAnimation and on the returned track entry, set the mixDuration. Mixing from an empty animation causes the new animation to be applied more and more over the mix duration. Properties keyed in the new animation transition from the value from lower tracks or from the setup pose value if no lower tracks key the property to the value keyed in the new animation.

Parameters:
Name Type Argument Description
trackIndex integer

The track index to add the animation to.

mixDuration integer <optional>

Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData getMix based on the animation before this animation (if any).

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1066)
Returns:

The returned Track Entry.

Type
spine.TrackEntry

setMix(fromName, toName [, duration])

Sets the mix duration when changing from the specified animation to the other.

Parameters:
Name Type Argument Description
fromName string

The animation to mix from.

toName string

The animation to mix to.

duration number <optional>

Seconds for mixing from the previous animation to this animation. Defaults to the value provided by AnimationStateData getMix based on the animation before this animation (if any).

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1197)
Returns:

This Game Object.

Type
SpineGameObject

setOffset( [offsetX] [, offsetY])

Sets the offset of this Game Object from the Skeleton position.

You can use this method to adjust how the position of this Game Object relates to the Skeleton it is using.

Parameters:
Name Type Argument Default Description
offsetX number <optional>
0

The horizontal offset of the Skeleton from its x and y coordinate.

offsetY number <optional>
0

The vertical offset of the Skeleton from its x and y coordinate.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 738)
Returns:

This Game Object.

Type
SpineGameObject

setSize( [width] [, height] [, offsetX] [, offsetY])

Sets the size of this Game Object.

If no arguments are given it uses the current skeleton data dimensions.

You can use this method to set a fixed size of this Game Object, such as for input detection, when the skeleton data doesn't match what is required in-game.

Parameters:
Name Type Argument Default Description
width number <optional>

The width of the Skeleton. If not given it defaults to the Skeleton Data width.

height number <optional>

The height of the Skeleton. If not given it defaults to the Skeleton Data height.

offsetX number <optional>
0

The horizontal offset of the Skeleton from its x and y coordinate.

offsetY number <optional>
0

The vertical offset of the Skeleton from its x and y coordinate.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 702)
Returns:

This Game Object.

Type
SpineGameObject

setSkeleton(atlasDataKey, skeletonJSON [, animationName] [, loop])

Sets this Game Object to use the given Skeleton based on its cache key.

Typically, once set, the Skeleton doesn't change. Instead, you change the skin, or slot attachment, or any other property to adjust it.

Parameters:
Name Type Argument Default Description
atlasDataKey string

The key of the Spine data to use for this Skeleton.

skeletonJSON object

The JSON data for the Skeleton.

animationName string <optional>

Optional name of the animation to set on the Skeleton.

loop boolean <optional>
false

Should the animation, if set, loop or not?

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 505)
Returns:

This Game Object.

Type
SpineGameObject

setSkeletonFromJSON(atlasDataKey, skeletonJSON [, animationName] [, loop])

Sets this Game Object to use the given Skeleton based on the Atlas Data Key and a provided JSON object that contains the Skeleton data.

Parameters:
Name Type Argument Default Description
atlasDataKey string

The key of the Spine data to use for this Skeleton.

skeletonJSON object

The JSON data for the Skeleton.

animationName string <optional>

Optional name of the animation to set on the Skeleton.

loop boolean <optional>
false

Should the animation, if set, loop or not?

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 486)
Returns:

This Game Object.

Type
SpineGameObject

setSkin(newSkin)

Sets the skin used to look up attachments before looking in the defaultSkin.

Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no old skin, each slot's setup mode attachment is attached from the new skin.

After changing the skin, the visible attachments can be reset to those attached in the setup pose by calling setSlotsToSetupPose. Also, often apply is called before the next time the skeleton is rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin.

Parameters:
Name Type Argument Description
newSkin spine.Skin <nullable>

The Skin to set. May be null.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1165)
Returns:

This Game Object.

Type
SpineGameObject

setSkinByName(skinName)

Sets the skin used to look up attachments before looking in the defaultSkin.

Attachments from the new skin are attached if the corresponding attachment from the old skin was attached. If there was no old skin, each slot's setup mode attachment is attached from the new skin.

After changing the skin, the visible attachments can be reset to those attached in the setup pose by calling setSlotsToSetupPose. Also, often apply is called before the next time the skeleton is rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin.

Parameters:
Name Type Description
skinName string

The name of the skin to set.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1133)
Returns:

This Game Object.

Type
SpineGameObject

setSlotsToSetupPose()

Sets the slots and draw order to their setup pose values.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1294)
Returns:

This Game Object.

Type
SpineGameObject

setToSetupPose()

Sets the bones, constraints, slots, and draw order to their setup pose values.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 1279)
Returns:

This Game Object.

Type
SpineGameObject

updateSize()

Internal method that syncs all of the Game Object position and scale data to the Skeleton. It then syncs the skeleton bounds back to this Game Object.

This method is called automatically as needed internally, however, it's also exposed should you require overriding the size settings.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 764)
Returns:

This Game Object.

Type
SpineGameObject

willRender(camera [, container])

Returns true if this Spine Game Object both has a skeleton and also passes the render tests for the given Camera.

Parameters:
Name Type Argument Description
camera Phaser.Cameras.Scene2D.Camera

The Camera that is rendering the Game Object.

container SpineContainer <optional>

If this Spine object is in a Spine Container, this is a reference to it.

Since: 3.19.0
Source: plugins/spine/src/gameobject/SpineGameObject.js (Line 244)
Returns:

true if this Game Object should be rendered, otherwise false.

Type
boolean