The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsHello. I've got a small problem, which stops me from doing my next game...
I want to make my hero invincible for 2secs after he is hit by a bullet.
My code for player is (of course it is in onEnterFrame):
if (hit) {
waiting = function(){
hit = false;
}
}
bleh = setInterval(waiting, 2000);
And for the bullet:
if (this.hitTest(_root.player)) {
if(_root.player.hit == false){
_root.player.hit = true;
}
}
And it works.
But only one time.
If the bullet touches me second time, my hero is hit as long as the bullet touches him, not these 2 secs I wanted.
Does anyone know, what to do?
I hope You will understand me ;)
you need to clearInterval(); when you're done being invincible
At 3/1/11 10:41 AM, Tygerman wrote: you need to clearInterval(); when you're done being invincible
But where should I add it?
I tried here:
if (hit) {
waiting = function(){
hit = false;
<strong>clearInterval(bleh);</strong>
}
}
bleh = setInterval(waiting, 2000);
But it didn't work.
Sorry for <*strong> , I thought it can be used in code...
Why isn't there 'Preview' option?
;)
you're clearing the interval before he turns invincible >.>
You need to make it so that after the 2 seconds, in a function, put invincible = false and clearInterval(bleh)
I think that's clear interval for as2, or maybe it's bleh.clearInterval(); idk...
AS3 programmer.
Learn AS3, it's for your own good.
So here it is:
if (hit) {
invincible = true;
hit = false;
waiting = function(){
invincible = false;
clearInterval(bleh);
}
}
bleh = setInterval(waiting,2000);
Still doesn't work more than once.
Maybe I'm just so silly, that I don't understand, what you are trying to say ;x