PDA

View Full Version : [AS2] how to put in a wait function


eric922
02-08-2009, 03:21 AM
Someone download my game i made, open it up in flash and look at my actions on the green lazer. Its a simple game. I need to know how to put in a wait function. When your guy dies, he just re-spawns real fast. I need to make it so you have to wait 3 seconds or so, then he re-spawns. Please post the code that will do this, i haven't been able to find any thing that works, it should be a simple code but im not much of a coder.

kkbbcute
02-08-2009, 06:11 AM
Check out senocular's tutorial on kirupa (http://www.kirupa.com/developer/actionscript/setinterval2.htm).

If you are not familiar with setInterval, you can always use an onEnterFrame function to help you. For example:

//This is in AS2
var i:Number = 1

onEnterFrame = function(){
if (playerIsDead == true) {
i++
if (i > 250) {
i = 1
//Add your player respawn function here
playerIsDead = false
}
}
}

Assuming that your framerate is 25 fps, then your player would respawn after 10 seconds, as 25*10 = 250 Change the number 250 to whatever number you want.

Cheers!

justyn
02-08-2009, 10:46 AM
thanks i might use that sometime.