From Game Editor
int ChangeAnimation(char *actorName, char *animationName, int state);
This changes the animation of a specified actor and sets the animation's initial state (FORWARD, BACKWARD, STOPPED, NO_CHANGE). Returns 1 if successful, 0 if error.
ChangeAnimation Input
actorName
- "Event Actor": Actor that is receiving the current event.
- "Parent Actor": Event Actor's parent, if actor has a parent.
- "Creator Actor": Event Actor's creator, if Event Actor has been created in some "Create Actor" action.
- "Collide Actor": Actor that collided with the event Actor.
- Any Actor name or clonename in the game.
animationName
- Valid animation name for the actor.
state
- FORWARD: Runs the animation from the first frame (animpos=0).
- BACKWARD: Runs the animation in reverse frame order (animpos=nframes-1).
- STOPPED: Changes animation to the first frame, and stops it (animpos=0).
- NO_CHANGE: Changes the animation, and keeps the same state as previous animation (FORWARD, BACKWARD, STOPPED). Does not change the animations animpos.
Example:
Change the player's animation to jump animation when jump key is pressed.
player -> KeyDown space (repeat disabled) -> Script Editor
if(jump>0) { yvelocity-=15; switch(dir) { case 0: // right ChangeAnimaton("Event Actor", "r_jump", FORWARD); break; case 1: // left ChangeAnimaton("Event Actor", "l_jump", FORWARD); break; } }