Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ScottDoom on Fri 20/01/2006 05:30:21

Title: Move While Object Animating?
Post by: ScottDoom on Fri 20/01/2006 05:30:21
When a button is pressed an object starts animating but I want the character to still be able to move around while this is happening, and be able to go back and turn the switch off... Is this possible?

This is my code (in room's repeatedly execute):
{ if (player.InventoryQuantity[12] > 0) {
object[8].SetView(10);
object[8].Visible = true;
object[8].Animate(0, 4, eRepeat, eBlock, eForwards);
object[8].Visible= false;
return; }


Hmm...
Title: Re: Move While Object Animating?
Post by: Gilbert on Fri 20/01/2006 06:19:07
You need some small tweaks.

1. On top of your room's script add:

Ã,  Ã,  bool objanimated=false;

2. Modify your repeatedly execute codes to:

if ((player.InventoryQuantity[12] > 0)&&(objanimated==false) {
Ã,  object[8].SetView(10);
Ã,  object[8].Visible = true;
Ã,  objanimated=true;
Ã,  object[8].Animate(0, 4, eRepeat, eNoBlock, eForwards);
}
if (object[8].Visible&&object[8].Animating==false) object[8].Visible= false;
Title: Re: Move While Object Animating?
Post by: ScottDoom on Fri 20/01/2006 06:23:07
*looks at code*

Hmm... Some new stuff in there I don't know too much about really...

How many times will this animate the object? Just once through the loop or forever? And if forever, will it still allow the character to move and thus turn off the loop through a switch?

I actually decided to just have it play for a bit and then stop automatically but I'd still like to know how to have an object animate while a player moves.
Title: Re: Move While Object Animating?
Post by: Gilbert on Fri 20/01/2006 06:36:28
I just copied your lines and didn't change your animating your animation setting, I only changed eBlock to eNoBlock.
According to your current setting, since you set RepeatStyle to eRepeat, that means the animation will go on forever. If you want it to repeat only once, change it to eOnce or 2 according to your needs (read the manual about the difference).

Apart from that, there're nothing new, the boolean variable objectanimated was just used to track whether the animation had been played yet, and if it's played (the first time the animation is played it's set to true), the animation will not be replayed anymore.
Title: Re: Move While Object Animating?
Post by: Ashen on Fri 20/01/2006 10:23:58
QuoteI'd still like to know how to have an object animate while a player moves.
That would be the Blocking parameter. Blocked means no other scripts can be run (e.g. processing the mouse click to move the character) untill the current one has finished. The manual entry 'Understanding Block Scripts' has more detail. (http://www.adventuregamestudio.co.uk/manual/BlockingScripts.htm)

Since you want it to happen / stop happening when you flick a switch - why is it in rep_ex?

Keep the bool, or an int, and move the code to the interaction for the switch (changing eBlock to eNoBlock since you don't want it blocking):

if (player.InventoryQuantity[12] > 0 && objanimated == false) {
  object[8].SetView(10);
  object[8].Visible = true;
  object[8].Animate(0, 4, eRepeat, eNoBlock, eForwards);
  objanimated = true;
}
else if (objanimated == true) {
  object[8].StopAnimating();
  object[8].Visible = false;
  objanimated = false;
}