Extends BBMOD_State
Implements BBMOD_IEventListener
constructor
new BBMOD_AnimationState(_name, _animation[, _loop])
A state of an animation state machine.
Name | Type | Description |
---|---|---|
_name | String |
The name of the state. |
_animation | Struct.BBMOD_Animation |
The animation played while the is active. |
_loop | Bool |
If true then the animation will be looped. Defaults to false . |
Name | Description |
---|---|
Animation | The animation played while the state is active. |
Loop | If true then the animation is played in loops. |
The following code shows examples of animation states which together make a simple locomotion state machine.
stateIdle = new BBMOD_AnimationState("Idle", animIdle, true);
stateIdle.OnUpdate = method(self, function () {
if (in_air())
{
animationStateMachine.change_state(stateJump);
return;
}
if (speed > 0)
{
animationStateMachine.change_state(stateWalk);
return;
}
});
animationStateMachine.add_state(stateIdle);
stateWalk = new BBMOD_AnimationState("Walk", animWalk, true);
stateWalk.OnUpdate = method(self, function () {
if (in_air())
{
animationStateMachine.change_state(stateJump);
return;
}
if (speed == 0)
{
animationStateMachine.change_state(stateIdle);
return;
}
});
animationStateMachine.add_state(stateWalk);
stateJump = new BBMOD_AnimationState("Jump", animJump, true);
stateJump.OnUpdate = method(self, function () {
if (!in_air())
{
animationStateMachine.change_state(stateLanding);
return;
}
});
animationStateMachine.add_state(stateJump);
stateLanding = new BBMOD_AnimationState("Landing", animLanding);
stateLanding.on_event(BBMOD_EV_ANIMATION_END, method(self, function () {
animationStateMachine.change_state(stateIdle);
}));
Copyright © 2022, BlueBurn. Built on December 31, 2022 using GMDoc.