Version: stable
MESSAGE | |
---|---|
spine_animation_done | reports the completion of a Spine animation |
spine_event | reports an incoming event from the Spine animation |
This message is sent when a Spine animation has finished playing back to the script that started the animation. No message is sent if a completion callback function was supplied when the animation was started. No message is sent if the animation is cancelled with model.cancel(). This message is sent only for animations that play with the following playback modes:
go.PLAYBACK_ONCE_FORWARD
go.PLAYBACK_ONCE_BACKWARD
go.PLAYBACK_ONCE_PINGPONG
animation_id |
hash |
the id of the completed animation |
playback |
constant |
the playback mode of the completed animation |
EXAMPLES
function on_message(self, message_id, message, sender) if message_id == hash("spine_animation_done") then if message.animation_id == hash("run") and message.playback == go.PLAYBACK_ONCE_FORWARD then -- The animation "run" has finished running forward. end end end
This message is sent when Spine animation playback fires events. These events
has to be defined on the animation track in the Spine animation editor. An event
can contain custom values expressed in the fields integer
, float
and string
.
event_id |
hash |
the id of the event. |
animation_id |
hash |
the id of the animation. |
t |
number |
the time of the event in seconds, relative to the start of the animation. |
blend_weight |
|
[type:number the blend weight (between 0.0-1.0) of the current animation at time t. |
integer |
number |
user defined integer value for the event |
float |
number |
user defined floating point value for the event |
string |
hash |
user defined string value (hashed) for the event |
node |
node |
the source spine gui node if the event originated from gui, otherwise nil |
EXAMPLES
The following example assumes that an animation sends event messages with the id"footstep"
and that the integer
field is used to distinguish between left and right foot (values 0 and 1).
function on_message(self, message_id, message, sender) if message_id == hash("spine_event") then -- Receiving animation event from Spine. Play footsteps. if message.event_id == hash("footstep") and message.integer == 0 then msg.post("#sound_footstep_right", "play_sound") elseif message.event_id == hash("footstep") and message.integer == 1 then msg.post("#sound_footstep_left", "play_sound") end end