Class: Spine
Hierarchy
-
↳
Spine
Constructors
constructor
• new Spine(data
, resourceBase
, layout
, parentElement
, options
): Spine
Parameters
Name | Type |
---|---|
data |
Spine |
resourceBase |
string |
layout |
LayoutInstance |
parentElement |
Element |
options |
LayoutCreateOptions |
Returns
Overrides
Properties
activeData
• activeData: Spine
Overrides
activeState
• activeState: string
Inherited from
alpha
• Protected
alpha: number
Inherited from
animationState
• Private
animationState: string
animationsCache
• Private
Optional
animationsCache: Record
<string
, Animation
[]>
children
• Optional
children: Element
[]
Inherited from
contentSize
• Private
contentSize: Size
currentLoopingAnimation
• Private
currentLoopingAnimation: string
data
• data: Spine
Overrides
dirtyFlag
• Protected
dirtyFlag: DirtyFlag
Inherited from
eventCancels
• Optional
eventCancels: Record
<string
, () => void
[]>
Inherited from
filters
• Protected
filters: null
| Filter
[]
Inherited from
flip
• Protected
flip: number
Inherited from
isVisible
• Protected
isVisible: boolean
Inherited from
layout
• layout: LayoutInstance
Inherited from
mask
• Protected
mask: null
| Element
Inherited from
name
• name: string
Inherited from
parent
• parent: null
| Element
Inherited from
pixiDebug
• pixiDebug: null
| Graphics
Inherited from
pixiSpine
• pixiSpine: null
| Spine
size
• Protected
size: Size
Inherited from
transform
• Protected
transform: default
Inherited from
translateMatrix
• Private
translateMatrix: Matrix
DEBUG_ALPHA
▪ Static
DEBUG_ALPHA: number
= 0.5
Inherited from
DEBUG_COLOR
▪ Static
DEBUG_COLOR: number
= 0xff0000
Inherited from
isMute
▪ Static
isMute: boolean
= false
Inherited from
Accessors
cacheAsBitmap
• get
cacheAsBitmap(): boolean
Returns
boolean
Inherited from
Element.cacheAsBitmap
• set
cacheAsBitmap(value
): void
Parameters
Name | Type |
---|---|
value |
boolean |
Returns
void
Inherited from
Element.cacheAsBitmap
Methods
adjust
▸ adjust(realScreenSize
, logicalScreenSize
, parentSize
, parentOffset?
): void
Parameters
Name | Type |
---|---|
realScreenSize |
Size |
logicalScreenSize |
Size |
parentSize |
Size |
parentOffset? |
Size |
Returns
void
Inherited from
adjustChildren
▸ adjustChildren(realScreenSize
, logicalScreenSize
, nodeSize
): void
Parameters
Name | Type |
---|---|
realScreenSize |
Size |
logicalScreenSize |
Size |
nodeSize |
Size |
Returns
void
Inherited from
adjustHierarchy
▸ adjustHierarchy(container
, offset
): number
Parameters
Name | Type |
---|---|
container |
Container <DisplayObject > |
offset |
number |
Returns
number
Inherited from
animate
▸ animate(state
, animateStart
, animateEnd
, instant
): null
| Node
Parameters
Name | Type |
---|---|
state |
string |
animateStart |
() => void |
animateEnd |
() => void |
instant |
boolean |
Returns
null
| Node
Inherited from
cancelLocalEvent
▸ cancelLocalEvent(eventName
): boolean
Parameters
Name | Type |
---|---|
eventName |
string |
Returns
boolean
Inherited from
createChildren
▸ createChildren(create
, options
): void
Parameters
Name | Type |
---|---|
create |
(data : Node , options : LayoutCreateOptions ) => Element |
options |
LayoutCreateOptions |
Returns
void
Inherited from
destroy
▸ destroy(): void
Returns
void
Overrides
destroySpine
▸ destroySpine(): void
Returns
void
dirty
▸ dirty(flag
, recursive?
): void
Mark the element as dirty. When the element is marked DIRTY
the layout will be marked as
requiring adjustment and all the parents of the element will be marked as CHILD_DIRTY
unless they are already DIRTY
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
flag |
DirtyFlag |
undefined |
The dirty flag to set for the element |
recursive |
boolean |
true |
If disabled the flag will only be set for this element |
Returns
void
Inherited from
getAttachment
▸ getAttachment<T
>(type
, slotName
, attachmentName
): null
| T
Type-safe helper for getting an attachment from a Spine object. Throws an error if the attachment is not found or is of invalid type.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
type |
Type <T > |
Attachment type |
slotName |
string |
Slot containing the attachment |
attachmentName |
string |
The attachment to get |
Returns
null
| T
getContentSize
▸ getContentSize(): Size
Returns
Overrides
getDebugTitle
▸ getDebugTitle(): string
Returns
string
Inherited from
getDirty
▸ getDirty(): DirtyFlag
Get the current dirty status of the element.
Returns
Inherited from
getMask
▸ getMask(): null
| Element
Returns
null
| Element
Inherited from
getNode
▸ getNode(this
, matcher
): undefined
| Element
Returns the first node from the hierarchy, including this one, that matches the filtering options.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
matcher |
Matcher <Element > |
Filtering options |
Returns
undefined
| Element
Inherited from
▸ getNode(this
, filter
): undefined
| Element
Returns the first node from the hierarchy, including this one, whose name matches the provided filter.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
undefined
| Element
Inherited from
▸ getNode<T2
>(this
, type
): undefined
| T2
Returns the first node from the hierarchy, including this one, whose type matches the provided type.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
Returns
undefined
| T2
Inherited from
▸ getNode<T2
>(this
, type
, filter
): undefined
| T2
Returns the first node from the hierarchy, including this one, whose type matches the provided type and name matches the provided filter.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
undefined
| T2
Inherited from
getPixiObject
▸ getPixiObject(): null
| Spine
Returns
null
| Spine
Overrides
isWorldVisible
▸ isWorldVisible(): boolean
Check whether the element is visible or not. Because of the hierarchy optimizations it is
not possible to use DisplayObject.worldVisible
to check for the visibility as non-visible
nodes will still have the old parent reference.
Returns
boolean
Inherited from
localEvent
▸ localEvent(states
, params?
): Promise
<void
>
Parameters
Name | Type |
---|---|
states |
string | Event [] |
params? |
EventParams |
Returns
Promise
<void
>
Inherited from
match
▸ match(this
, «destructured»
): boolean
Test node type and/or name for a match.
Parameters
Name | Type |
---|---|
this |
Element |
«destructured» |
Matcher <Element > |
Returns
boolean
Inherited from
nodes
▸ nodes(this
): Generator
<Element
, any
, unknown
>
Iterate over all nodes in the hierarchy, including this one.
Parameters
Name | Type |
---|---|
this |
Element |
Returns
Generator
<Element
, any
, unknown
>
Inherited from
▸ nodes(this
, matcher
): Generator
<Element
, any
, unknown
>
Iterate over all nodes in the hierarchy, including this one. Can optionally filter the nodes based on type and/or name.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
matcher |
Matcher <Element > |
Filtering options |
Returns
Generator
<Element
, any
, unknown
>
Inherited from
▸ nodes(this
, filter
): Generator
<Element
, any
, unknown
>
Iterate over all nodes in the hierarchy, including this one. The iterator skips nodes whose name does not match the provided filter.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
Generator
<Element
, any
, unknown
>
Inherited from
▸ nodes<T2
>(this
, type
): Generator
<T2
, any
, unknown
>
Iterate over all nodes in the hierarchy, including this one. The iterator skips nodes whose type does not match the provided type.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
Returns
Generator
<T2
, any
, unknown
>
Inherited from
▸ nodes<T2
>(this
, type
, filter
): Generator
<T2
, any
, unknown
>
Iterate over all nodes in the hierarchy, including this one. The iterator skips nodes whose type does not match the provided type or name does not match the provided filter.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
Generator
<T2
, any
, unknown
>
Inherited from
offClick
▸ offClick(): void
Unregister the previously registered click handler. It is safe to call this even when no click handler is registered.
Returns
void
Inherited from
offDrag
▸ offDrag(): void
Unregister the previously registered drag handler. It is safe to call this even when no drag handler is registered.
Returns
void
Inherited from
offHover
▸ offHover(): void
Unregister a previously registered hover handler. It is safe to call this even when no hover handler is registered.
If the cursor is hovering on the element when offHover
is called the leave state will be
triggered to reset the visual states. However the registered leave callback will not be
called.
Returns
void
Inherited from
onClick
▸ onClick<T
>(this
, callback
, eventParams?
): void
Register a click handler with a callback. If the element data has a click
trigger an event
with that name will be automatically triggered when the callback is called. If a click
handler has already been registered it will be cleared with a warning.
Type parameters
Name | Type |
---|---|
T |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
T |
- |
callback |
ClickCallback <T > |
The callback to call when the element is clicked |
eventParams? |
EventParams |
Optional event parameters for the click event |
Returns
void
Inherited from
onDrag
▸ onDrag<T
>(this
, callback?
): void
Register a drag handler with a callback. Whether the element dragging acts as scroll or drag
is determined by the dragX
and dragY
settings in the trigger data. By default the
callback is called with the drag offset but if dragStepsX
or dragStepsY
is enabled the
value will be the index of the step for the respective axis. If a drag handler has already
been registered it will be cleared with a warning.
Type parameters
Name | Type |
---|---|
T |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
T |
- |
callback? |
DragCallback <T > |
Optional callback to call when the element is dragged |
Returns
void
Inherited from
onHover
▸ onHover<T
>(this
, callbacks?
): void
Register a hover handler with enter and leave callbacks. If the element data has
hoverEnter
or hoverLeave
triggers the corresponding states will be automatically set
when the callbacks are called. If a hover handler has already been registered it will be
cleared with a warning.
Type parameters
Name | Type |
---|---|
T |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
T |
- |
callbacks? |
Partial <HoverCallbacks <T >> |
Optional callbacks to call when the cursor enters or leaves the element |
Returns
void
Inherited from
registerStates
▸ registerStates(register
): void
Parameters
Name | Type |
---|---|
register |
(state : string ) => void |
Returns
void
Overrides
requireNode
▸ requireNode(this
, matcher
): Element
Returns the first node from the hierarchy, including this one, that matches the filtering options. Throws an error if the node is not found.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
matcher |
Matcher <Element > |
Filtering options |
Returns
Inherited from
▸ requireNode(this
, filter
): Element
Returns the first node from the hierarchy, including this one, whose name matches the provided filter. Throws an error if the node is not found.
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
Inherited from
▸ requireNode<T2
>(this
, type
): T2
Returns the first node from the hierarchy, including this one, whose type matches the provided type. Throws an error if the node is not found.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
Returns
T2
Inherited from
▸ requireNode<T2
>(this
, type
, filter
): T2
Returns the first node from the hierarchy, including this one, whose type matches the provided type and name matches the provided filter. Throws an error if the node is not found.
Type parameters
Name | Type |
---|---|
T2 |
extends Element |
Parameters
Name | Type | Description |
---|---|---|
this |
Element |
- |
type |
Type <T2 > |
Type for filtering the nodes |
filter |
Filter |
String or RegExp for filtering the nodes |
Returns
T2
Inherited from
resetAnimation
▸ resetAnimation(): void
Reset the animation to what is defined in the layout data.
Returns
void
resetSpine
▸ resetSpine(): void
Returns
void
setAnimation
▸ setAnimation(animationName
, looping?
, mixTime?
, timeScale?
): void
Set animation for the Spine object. By default the animation will loop and use a mix time
of 0.25 seconds but this can be overridden with the mixTime
parameter.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
animationName |
string |
undefined |
Animation to set |
looping |
boolean |
true |
Plays indefinitely if set |
mixTime |
number |
0.25 |
Override for the default mix time |
timeScale |
number |
1 |
Animation playback speed |
Returns
void
setDebug
▸ setDebug(debug
): void
Parameters
Name | Type |
---|---|
debug |
boolean |
Returns
void
Inherited from
setDragOffset
▸ setDragOffset(offset
, duration?
, easing?
): Promise
<void
>
Set drag offset. By default the offset is set instantly but a transition effect can be enabled by providing duration and an easing function.
The returned promise resolves once the target offset is reached, or if another
setDragOffset
call or manual dragging interrupts the transition.
Parameters
Name | Type | Description |
---|---|---|
offset |
Size |
Offset in logical screen coordinates or snap steps |
duration? |
number |
Duration of the transition in seconds |
easing? |
Easing |
Easing function for the transition |
Returns
Promise
<void
>
Inherited from
setLocalState
▸ setLocalState(state
, options?
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
state |
string |
options? |
Object |
options.instant? |
boolean |
options.skipChildren? |
boolean |
options.validate? |
boolean |
Returns
Promise
<boolean
>
Inherited from
setMask
▸ setMask(mask
): void
Parameters
Name | Type |
---|---|
mask |
Element |
Returns
void
Inherited from
setSkin
▸ setSkin(skinName
, initial?
): void
Set skin or skins for this Spine object. Ignores skins that are not found. Multiple skins
can be set by either providing an array of skin names or a string with comma-separated
values, ie. skin1,skin2,...
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
skinName |
string | string [] |
undefined |
Skin or skins to set |
initial |
boolean |
false |
Used internally for the very first skin set |
Returns
void
setSpine
▸ setSpine(spineData
, skinName?
, animationName?
, looping?
): void
Parameters
Name | Type | Default value |
---|---|---|
spineData |
null | SkeletonData |
undefined |
skinName? |
string | string [] |
undefined |
animationName? |
string |
undefined |
looping |
boolean |
true |
Returns
void
setState
▸ setState(state
, animateStart
, animateEnd
, instant
): boolean
Parameters
Name | Type |
---|---|
state |
string |
animateStart |
() => void |
animateEnd |
() => void |
instant |
boolean |
Returns
boolean
Overrides
updateAlpha
▸ updateAlpha(alpha
, parentAlpha
): boolean
Parameters
Name | Type |
---|---|
alpha |
number |
parentAlpha |
number |
Returns
boolean
Inherited from
updateInteractions
▸ updateInteractions(group
): void
Parameters
Name | Type |
---|---|
group |
GroupContainer |
Returns
void
Inherited from
updatePixiObject
▸ updatePixiObject(realScreenSize
, logicalScreenSize
, transform
, size
, flip
, alpha
): void
Parameters
Name | Type |
---|---|
realScreenSize |
Size |
logicalScreenSize |
Size |
transform |
Transform |
size |
Size |
flip |
number |
alpha |
number |
Returns
void
Overrides
updateStateCache
▸ updateStateCache(): void
Returns
void
Overrides
bindAnimationAudioListener
▸ bindAnimationAudioListener(spine
): void
Add an animation state listener which handles playing audio from animation events
WARNING: This static version is meant for Spine object that are not part of any layout. Spine elements add this automatically.
Parameters
Name | Type | Description |
---|---|---|
spine |
Spine |
Spine to which to add the listener |
Returns
void
collectResources
▸ collectResources(data
, resourceBase
, resources
): void
Parameters
Name | Type |
---|---|
data |
Spine |
resourceBase |
string |
resources |
Resource [] |
Returns
void
Overrides
getAttachment
▸ getAttachment<T
>(type
, spine
, slotName
, attachmentName
): T
Type-safe helper for getting an attachment from a Spine object. Throws an error if the attachment is not found or is of invalid type.
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
type |
Type <T > |
Attachment type |
spine |
Spine |
Spine to get the attachment from |
slotName |
string |
Slot containing the attachment |
attachmentName |
string |
The attachment to get |
Returns
T
setAnimation
▸ setAnimation(spine
, animationName
, looping?
, mixTime?
): boolean
Set animation for the Spine object. By default the animation will loop and use a mix time
of 0.25 seconds but this can be overridden with the mixTime
parameter.
WARNING: This static version is meant for Spine object that are not part of any layout. Use the instance method for ui Spine elements as it updates the looping animation information properly for the layout system!
Parameters
Name | Type | Default value | Description |
---|---|---|---|
spine |
Spine |
undefined |
Spine to set the animation for |
animationName |
string |
undefined |
Animation to set |
looping |
boolean |
true |
Plays indefinitely if set |
mixTime |
number |
0.25 |
Override for the default mix time |
Returns
boolean
setDebugColor
▸ setDebugColor(debugColor
, debugAlpha?
): void
Parameters
Name | Type | Default value |
---|---|---|
debugColor |
number |
undefined |
debugAlpha |
number |
1 |
Returns
void
Inherited from
setGlobalMute
▸ setGlobalMute(isMute
): void
Parameters
Name | Type |
---|---|
isMute |
boolean |
Returns
void
Inherited from
setSkin
▸ setSkin(spine
, skinName
, initial?
): void
Set skin or skins for a PIXI.Spine object. Ignores skins that are not found. Multiple skins
can be set by either providing an array of skin names or a string with comma-separated
values, ie. skin1,skin2,...
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
spine |
Spine |
undefined |
Spine to set the skin for |
skinName |
string | string [] |
undefined |
Skin or skins to set |
initial |
boolean |
false |
Used internally for the very first skin set |
Returns
void
toStandardPoly
▸ toStandardPoly(poly?
, object?
): null
| number
[]
Convert a PIXI.spine.core.ArrayLike
polygon into a standard number[]
polygon. If an
object is provided the polygon will be converted into global screen coordinates using the
object’s transform. Returns null
if called with an empty poly
parameter.
Parameters
Name | Type | Description |
---|---|---|
poly? |
ArrayLike_2 <number > |
Array-like polygon to convert |
object? |
DisplayObject |
Optional object to use for global transform |
Returns
null
| number
[]