continuous animating object while controling character

Started by onizuka666, Sat 08/03/2014 21:57:34

Previous topic - Next topic

onizuka666

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!

Ghost

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

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



onizuka666

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;
}

Ghost

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.

Khris

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:
Code: ags
  oFog.Animate(0, 1, eRepeat, eNoBlock);


Note the eNoBlock parameter which should instantly fix your problem.

onizuka666

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...

Khris

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.)


SMF spam blocked by CleanTalk