Different Animations for one character

Started by AmOrPhIsSs, Sat 26/10/2013 22:08:21

Previous topic - Next topic

AmOrPhIsSs

Hi All,

I need help in assigning different animations to the same character.
I want it to move to a certain position on the screen THEN start walking, my code below just ignores the first step and goes walking directly...Can somebody instruct me how to put this code correctly in a room?

 
Code: ags

  cEagle.Move(800, 400, eNoBlock, eAnywhere);
  Wait(1);
  cEagle.Walk(300, 300, eNoBlock, eAnywhere);
  

Ghost

As I see it, calling Move with eBlock should do the trick.

AmOrPhIsSs

Thanks.that did the trick though I don't know why :)

Crimson Wizard

#3

Khris

To give a quick explanation:

When a command like .Move or .Walk is executed with the eBlock parameter, the game waits until the object has reached its target before proceeding with the next command. eNoBlock means that AGS continues with the next command immediately afterwards, while the movement happens in the background, at the same time.
If you call two eNoBlock commands on the same entity, the first one is therefore pretty much ignored, because it basically gets "overwritten" by the second one.

AmOrPhIsSs

what if I wanna make 2 animations for the same entity but without blocking the scene ?
How can I manage to do that ?

Khris

You'd have to use a repeatedly_execute function.
The basic idea is to start the first animation, and set a variable. In repeatedly_execute, which is a function called each frame (40 times per second by default), you'd check whether the variable is set but the first animation has stopped. At that point you'd start the second one.

It's simply a way to tell AGS to do something not right now but at some arbitrary point in the future, when some game state has been reached.

Crimson Wizard

Also, if by "animations" you mean moving/walking character, then you can use "Character.Moving" property, for example:

Code: ags

cEagle.Move(800, 400, eNoBlock, eAnywhere);
while (cEagle.Moving)
{
   // keep looping while eagle is moving;
   // calling "Wait" here actually lets the game do other stuff on background
   Wait(1);
}
cEagle.Walk(300, 300, eNoBlock, eAnywhere);


What solution to use depends on what you want to achieve, of course.

SMF spam blocked by CleanTalk