Making scripts functions finish before continuing?

Talk about making games.

Making scripts functions finish before continuing?

Postby livens » Sun Feb 12, 2012 4:01 am

Hi,

I has a problem with my game where I needed the script to finish a moveto function before continuing to the next line of code. I needed my character to not move while the view was being moved. I ended up using a timer to get around this problem.

So is there way to get the moveto to finish before doing anything else? Or a better way to stop an actors movements while a moveto with a rather slow velocity (I needed the player to notice which way the view was moving instead of just flashing over instantly) is being completed?

Thanks,

livens
livens
 
Posts: 13
Joined: Thu Feb 09, 2012 1:34 am
Score: 0 Give a positive score

Re: Making scripts functions finish before continuing?

Postby skydereign » Sun Feb 12, 2012 4:11 am

There is an event called move finish. So if you don't want code to trigger while the MoveTo is going, you can disable those events and enable them when the move finish event triggers. In your case it'd look something like this.
Code: Select all
EventDisable("player", EVENTALL);
MoveTo("view", 0, 0, 5, "Game Center", "(none)");


view -> Move Finish -> Script Editor
Code: Select all
EventEnable("player", EVENTALL);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Making scripts functions finish before continuing?

Postby livens » Sun Feb 12, 2012 2:48 pm

Thanks skydereign

That is a MUCH better way to handle this. Using the timer was clunky and I had to adjust the timer duration to kind of match the velocity of the MoveTo.
livens
 
Posts: 13
Joined: Thu Feb 09, 2012 1:34 am
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest