Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: onizuka666 on Sat 08/03/2014 21:57:34

Title: continuous animating object while controling character
Post by: onizuka666 on Sat 08/03/2014 21:57:34
Hello guys!

In my game I introduced a fogg animation loop as an object into a room which is as large as the room itself.
The problem is while the continuous animation of the fogg object runs in the background I cannot move/controll my character anymore because the waiting cursor is always shown!
Does anyone know how I can circumvent this problem?

Thanks in advance!
Title: Re: continuous animating object while controling character
Post by: Ghost on Sat 08/03/2014 22:20:33
One simple way would be to check the object's graphic in a repeatedly_execute_always function made for this room, and advance it/roll it over. That way you won't ever have the loop blocked; repeatedly_execute_always is run even when a blocking function is executed.

Ideally you have the sprites imported continuously, so you can create a check like:

Code (ags) Select

int firstsprite = 12;
int lastsprite = 16;
if (OBJECT.graphic < lastsprite)
{
  OBJECT.Graphic++;
}
else
{
  OBJECT.Graphic = firstsprite;
}


Title: Re: continuous animating object while controling character
Post by: onizuka666 on Sat 08/03/2014 22:37:56
Sry, I don't get it!

that's what I got so far...

function room_RepExec()
{
  object[4].Clickable = 0;
  object[4].SetView(9, 0);
  object[4].Animate(0, 1);
  object[4].Solid = 0;
}
Title: Re: continuous animating object while controling character
Post by: Ghost on Sat 08/03/2014 23:07:09
No, wait. Is this what you are already using? Because if that is the case I can see where your problem comes from.

RepeatedlyExecute is repeatedly executed. Once per tic. So you are constantly setting values and calling animation commands. That's bound not to work.

If possible, post your whole code. Or tell us* if what you posted is your currently used code. That way we* can track down the problem better, and offer more help.

_
* That's a "forum us/we". Not the royal one. That would be creepy.
Title: Re: continuous animating object while controling character
Post by: Khris on Sun 09/03/2014 14:22:57
It is always a good idea to look up a command in the manual first.

Quote from: manualObject.Animate(int loop, int delay, optional RepeatStyle, optional BlockingStyle, optional Direction)

Just use this:  oFog.Animate(0, 1, eRepeat, eNoBlock);

Note the eNoBlock parameter which should instantly fix your problem.
Title: Re: continuous animating object while controling character
Post by: onizuka666 on Sun 09/03/2014 17:12:30
Thanks Khris for your reply.

when I use the eNoBlock command at the end I can move my character again but now the fog is not animating in the background anymore...
Title: Re: continuous animating object while controling character
Post by: Khris on Sun 09/03/2014 19:11:47
You have to move those commands out of room_RepExec and into "enters screen before fadein" / room_Load(), otherwise the animation is started 40 times per second, which will never allow it to even progress to the 2nd frame. (Ghost already mentioned this.)
Title: Re: continuous animating object while controling character
Post by: onizuka666 on Sun 09/03/2014 21:26:00
Yesss, now it works!
Thanks both of you!