room_RepExec is blocking controls

Started by ToothpasteBruva, Sun 13/12/2015 05:49:18

Previous topic - Next topic

ToothpasteBruva

Hi
I'm hoping this is a pretty basic issue. I have a character hitting a golfball, which is a separate object and I have them animating in a room_RepExec() function so their animations will loop. The trouble is if I add Wait functions to sync the golfball and character animations it blocks the player from playing. Here is the code so far.
Code: ags

function room_RepExec()
{
  cMurray.Animate(0, 5, eOnce, eNoBlock);
  Wait(45); 
  GolfBall.Animate(0, 3, eOnce, eNoBlock);
  GolfBall.Move(10, 10, 4);
  Wait(120); 
}

Khris

You shouldn't put this code in room_RepExec() at all, at least not without any conditional wrappers or the like.
room_RepExec is executed 40 times per second and should only be used if the code you want to put inside actually has to run every single game frame.

If you want the character to continuously hit the ball in the background, just move the code to room_AfterFadein, use eRepeat instead of eOnce, then implement the delays as frame delays in the view you use for the animation.
In other words, open the view assigned to the golfball, then set the first frame's delay to 45.

ToothpasteBruva

#2
Awesome!
Thanks Kris. It's working perfectly now.

SMF spam blocked by CleanTalk