|
|
 |
Idle Animation

Earthworm Jim Remains King of...
Feb.25.2004 - 5:56 pm
Idle animations are the animations that play when your character just
stands. Idley. This is a basic idea which could be added to in many
ways. You could for example have animations cycle by keeping count or
let the character stand for awhile before they do anything. This
example will just show how to have instant animation in 4 directions.
(Original script created for Flippy D)
|
|
 |
 |
Idle Animation

Standard procedure.
Feb.25.2004 - 5:56 pm - Revised Mar.07.2004
This code will go inside the repeatedly execute function. If you don't
know what that is LEAVE! No, but it may be a good idea to come back
when you have a better understanding of AGS stuff...
function repeatedly_execute() {
/*** Global Repeatedly Execute ***/
if((character[EGO].walking==0)&&(character[EGO].animating==0)){
  if(character[EGO].loop==0){ //Down
   SetCharacterView(EGO, VIEW!!!!!!);
   AnimateCharacter(EGO, LOOP!!, SPEED!!, REPEAT?!?!);
}
else if(character[EGO].loop==1){ //Left
   SetCharacterView(EGO, VIEW!!!!!!);
   AnimateCharacter(EGO, LOOP!!, SPEED!!, REPEAT?!?!);
}
else if(character[EGO].loop==2){ //Right
   SetCharacterView(EGO, VIEW!!);
   AnimateCharacter(EGO, LOOP!, SPEED!, REPEAT?!?!);
}
else if(character[EGO].loop==3){ //Up
   SetCharacterView(EGO, VIEW!!);
   AnimateCharacter(EGO, LOOP!!!, SPEED!!, REPEAT?!?!);
  }
  }
}
|
Okay. So, of course it needs minor changes for it to acctually work so
you can't just paste it in your game and BAM fireworks! But here's how
it goes. Ignore the first few lines cause that is just to show you were
it goes. The script starts here:
|
if((character[EGO].walking==0)&&(character[EGO].animating==0)){
|
This first checks if character (EGO) is moving AND if they are animating
if not then:
|
if(character[EGO].loop==0){ //Down
|
Check if the character is facing down (or up or left). If they are
facing down:
|
SetCharacterView(EGO, VIEW!!!!!!);
|
Before you animate a character you must set it to the view with the
animation so if the animation is in view 4 change 'VIEW!!!!!' to 4.
|
AnimateCharacter(EGO, LOOP!!, SPEED!!, REPEAT?!?!);
|
Now that the view is set we animate 'em. First we say what loop the
animation is (If it is 1 set it to 1..). Then the speed (The higher
the number the slower the animation will play). Last if you want it
to repeat (1 if yes, 0 if no). Then finish it off with the last brace
( '}' ) and that is the script. Like always what is said above can be
applied to all four directions while modifying the VIEW and LOOP values
to play the right animations for each direction.
|
|
 |
 |
Problems?

This script assumes your main characters script name
is the default script name (EGO) if you have changed it
make sure you change the script in all the needed places.
If the animation won't play/wrong animation is playing
double check VIEW and LOOP settings and make sure they
are the correct values.
You set the values like this:
|
SetCharacterView(EGO, 2);
|
Not like this:
|
SetCharacterView(EGO, View==2);
|
Any other problems contact me ( sylpher@sylpher.com )
|
|
 |
|
|