Author Topic: object.flicker() won't stops flickering  (Read 1700 times)

relinwar

  • Member
  • **
  • Posts: 17
  • Karma: +0/-0
    • View Profile
object.flicker() won't stops flickering
« on: Wed, Aug 31, 2011 »
I wants to make my player recieves damage and flicker for just one second after it hits an object but the flicker just continue flickering forever. I have checked that i called the function only once.

Code: [Select]
protected function hit_enemy(Object1:FlxObject,Object2:FlxObject):void
{
Object2.exists = false;
Object1.flicker(1);
player_life -=  1;
}

Could it be that the flicker timer inside FlxObject isn't counting down at all? Please help thx!

relinwar

  • Member
  • **
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #1 on: Thu, Sep 1, 2011 »
Anybody experienced this problem before can tell me the solution or help me try out the .flicker function? Please. Thank you.

!8bit!man

  • Active Member
  • ***
  • Posts: 210
  • Karma: +0/-0
  • Hack Hack Hack!!
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #2 on: Thu, Sep 1, 2011 »
do this:

delete Object1.flicker(1)
write Object1.hurt()<==here you put the damage amount

and in the class of that object override a function called hurt(Damage:Number):void
here you write:

if (flickering) return; <== it doesn't do anything if it's flickering
flicker(1);
super.hurt(Damage); 

relinwar

  • Member
  • **
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #3 on: Thu, Sep 1, 2011 »
do this:

delete Object1.flicker(1)
write Object1.hurt()<==here you put the damage amount

and in the class of that object override a function called hurt(Damage:Number):void
here you write:

if (flickering) return; <== it doesn't do anything if it's flickering
flicker(1);
super.hurt(Damage);


Hey thanx for replying, the object is actually a FlxSprite so i overrided the hurt function in FlxSprite class and changed flicker(1) to hurt(0) but it still doesn't work, my sprite object still flicks forever..

Hmm.. and did you try using object.flicker(1); and it doesn't stop too? I tried flicker(-1) to stop the flicker but it doesn't work too.

!8bit!man

  • Active Member
  • ***
  • Posts: 210
  • Karma: +0/-0
  • Hack Hack Hack!!
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #4 on: Thu, Sep 1, 2011 »
Mmm... it's strange... in theory when a second is ended it must stop flickering....

did you put "if (flickering) return;" before "flicker(1)"?  because, if you didn't put it, i think the flicker never ends, as it update continuosly and he read every time "flicker(1);"

relinwar

  • Member
  • **
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #5 on: Thu, Sep 1, 2011 »
Mmm... it's strange... in theory when a second is ended it must stop flickering....

did you put "if (flickering) return;" before "flicker(1)"?  because, if you didn't put it, i think the flicker never ends, as it update continuosly and he read every time "flicker(1);"

Yea !8bit!man, I did put the "if (flickering) return;" This my function, exactly like yours.

Code: [Select]
override public function hurt(Damage:Number):void
{
if (flickering) return;
flicker(1);
super.hurt(Damage); 
}

I have tried setting flickering back to -1 or 0 and the function in FlxObject

 
Code: [Select]
override public function preUpdate():void
{
_ACTIVECOUNT++;
if(_flickerTimer != 0)
{
if(_flickerTimer > 0)
{
_flickerTimer = _flickerTimer - FlxG.elapsed;
if(_flickerTimer <= 0)
{
_flickerTimer = 0;
_flicker = false;
}
}
}.....

should off the flickering, could it be that flixel didn't auto call preUpdate()? I'm not sure I'm just guessing. So does anyone else has this problem or is it just me?

relinwar

  • Member
  • **
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: object.flicker() won't stops flickering
« Reply #6 on: Fri, Sep 2, 2011 »
.. found my stupid error. I didn't freaking call super.update() in my game state.. sigh.. so dumb of me..