animateobjectex skips whole animation

Started by spook1, Mon 22/03/2004 16:14:45

Previous topic - Next topic

spook1

I have an object animated with "animateobjectex" command.

if (start_final_animation ==1){
  SetObjectView(0,10);
  AnimateObjectEx(0,1,10,0,0,1);
  Display("Game Over");
  QuitGame(0);
}

Running this code will indeed get me the animation and after it the game stops.

When I do change the last 1 in a 0 (set the animation in the non-blocking mode), the whole animation is skipped.
And the game stops immediately.

Adding the code: while((IsObjectAnimating(10)==1) Wait(1);
results in the whole animation being played, but in a blocking way ....

Any suggestions??

Darth Mandarb

#1
So you want the animation to run, then display Game Over?

Have you tried this?

if (start_final_animation ==1){
SetObjectView(0,10);
AnimateObject(0,1,10,0);
while (IsObjectAnimating(0)==1) {
 wait(1);
}
Display("Game Over");
QuitGame(0);
}

- Doesn't use AnimateObjectEx (since you don't really need to)
- Puts back in the While statement
This does basically the same thing as what you have ... but it's worth a try I guess.

Also, by "The game stops" do you mean it doesn't Quit out of the game?  It just hangs up?

spook1

Thanks for replying. i tried it immediately. Unfortunately, now I still cannot do anything when the object is animation. Exactly what problem is with the blocking turned on.

Excuse me for being vague, by "it stops" I mean that is quits in the correct way, no problem here.

Regards,
martijn

Ben

So you don't want the animation to be blocking, but still wait before the "game over" message is displayed? Have you tried using SetTimer and IsTimerExpired?

spook1

Thanks for the timer suggestion. it has been quite a while since programmed my latest game in AGS 2.4, so I was not really aware of the power of this feature.

Still, it leaves me with the problem: how can I make anything happen while the timer is ticking?

I want to be able to DO soemthing WHILE the animation is running....
The animation completely being skipped when I select the non=-blocking option is stange, there might be a clue in there; probably something stupid I am afraid :-)

Ben

SetTimer is non-blocking. You can do anything you want while it's running. Just put

if (IsTimerExpired(x)==1) { Display('GAME OVER"); QuitGame(0); }

in the repeatedly_execute_always section of your room script, and the game qill quit when it's supposed to, while still allowing actions in the background.

spook1

Ok, I understand. leaves me with the problem: I cannot do anything while the animation is running. If there is a timer running, the ANIMATION is still the one blocking my game. I cannot select anything hwile the ANIMATION is running.
Only when the animation has stopped (and the final explosion is shown) I get back control. Then it is too late ......

TYhe bootom thing here is: How can I make an animation run and AT THE SAME TIME be able to select an other object.

Thanks for being so patient with me ;-)

artijn

Ben

If you don't want it to be blocking, just use AnimateObject by itself. DON'T use the "while(IsObjectAnimating.." line. That's what's blocking the rest of the game, and you don't need it when you have the timer.

a-v-o

#8
maybe this works without a timer:

in the interaction which starts the animation:
if (start_final_animation == 1)
{
SetObjectView(0,10);
AnimateObject(0,1,10,0);
}

in repeatedly_execute:
if ((start_final_animation == 1) && (IsObjectAnimating (0) == 0))
{
Display("Game Over");
QuitGame(0);
}

in object interaction to stop timer:
start_final_animation = 0;
SetObjectView (0, NORMAL_VIEW);

spook1

I really appreciate you all thinkingalong with me, but I have not solved my issue.

I get to think my error is too trivial, so I cannot communicate it effectively:

let me refrase: How can I make an animation in such a way that I have control over the rest of the game WHILE the animation is running.

The suggestions you make are really smart, but as long as I cannot influence the start_final_animation parameter, all code that makes use of this parameter won't work either.

regards with excuses for me bothering you so frequently,

martijn


SSH

OK, here's what to do:

TRY A-V-O's code: it will work and do exactly what you want.
12

spook1

Thanks, it did the trick indeed.

Does this mean that the consequence of an animation cannot be in the same instruction part (between the same brackets) or the same function as the animation itself?

Thanks again!

Alynn

Ok I think you are just confused about blocking and non blocking functions

Quote from: spook1 on Mon 22/03/2004 16:14:45
I have an object animated with "animateobjectex" command.

if (start_final_animation ==1){
  SetObjectView(0,10);
  AnimateObjectEx(0,1,10,0,0,1);
  Display("Game Over");
  QuitGame(0);
}

Running this code will indeed get me the animation and after it the game stops.

When I do change the last 1 in a 0 (set the animation in the non-blocking mode), the whole animation is skipped.
And the game stops immediately.

Yes, when it is set for blocking, nothing else in the game will run until the animation is finished, hence the term blocking, it blocks everything else. When you set it for non blocking (to 0) it doesn't have to wait for the animation to finish So it displays the Game over and quits the game.

Quote
Adding the code: while((IsObjectAnimating(10)==1) Wait(1);
results in the whole animation being played, but in a blocking way ....

Any suggestions??

Again basicly you turned it into a blocking function with that line of code

What it seemed to me with the rest of the posts, is that you were still blocking the animation. And thus couldn't do anything while it was running.

QuoteDoes this mean that the consequence of an animation cannot be in the same instruction part (between the same brackets) or the same function as the animation itself?

It really depends on what you want to do. In that particular case, where you have an animation running that if it ends, the game is over it must be done in this way. If you just have an incidental animation (Like the character flips a switch and a door opens) you can put the animation in the same instruction block, and you probably want it blocking.

So the answer to that question is, it all depends on the situation.

spook1

Wonderfull comments,
Thank you for taking the time to explain it. I am learning fast and this really helps in structuring my thoughts.
Martijn

a-v-o

looking at the code again, I think it should better be like this:

anywhere in the script outside the functions and before the following function:
int start_final_animation = 0;

in the interaction which starts the animation:
SetObjectView(0,10);
AnimateObject(0,1,10,0);
start_final_animation = 1;

After the animation is started, control is given back to the player. At the same time the following is executed:

in repeatedly_execute:
if ((start_final_animation == 1) && (IsObjectAnimating (0) == 0))
{
Display("Game Over");
QuitGame(0);
}

in object interaction to stop animation:
start_final_animation = 0;
SetObjectView (0, NORMAL_VIEW);

spook1

actually that is what did!
The first code still resulted in  an hourglass, by setting this parameter after the animation has been started and checking it in the repeatedly loop, I got the thing working.
If interested in the demo: http://www.xs4all.nl/~koops/ags/spacespy_devel13.zip
cheers
Martijn

SMF spam blocked by CleanTalk