Author Topic: [READ ME] Very usefull tip when you're overwritting kill()  (Read 874 times)

Foxtacy

  • Aspiring Indie Game Developer, Prototype Musician, Lame Pixel Artist
  • Member
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
    • Need songs? :3
GUYS!

Important tip!

At some point on your game, you might want to overwrite the kill() method of FlxSprite.

Assuming you will use the "object pool" idea as a good practice, here's a killer tip:

When creating the group, you will have to turn the object off (alive = false, exists = false). AND FOR GOD'S SAKE! DO NOT CALL YOUR OVERWRITTEN kill(), or it might turn out killing you, of a heart attack caused by stress.

If you do not do this, and forget to turn the objects off, strange things might happen.

I'm telling you this, because i just wasted 4 hours of my life trying to correct a strange null pointer exception that made NO SENSE, and because i do not want any of you guyz to suffer over this.

Hope that helps!
Waiting is wasting

KunoNoOni

  • "Never tell me the odds"
  • Active Member
  • ***
  • Posts: 170
  • Karma: +0/-0
  • Code is Love
    • View Profile
Good tip, thanks for the advice :)


-KunoNoOni

pixelomatic

  • Active Member
  • ***
  • Posts: 131
  • Karma: +0/-0
    • View Profile
Did you accidentally forgot to call super.kill(); in your overridden kill() function? Because I had no problem with this approach, it doesn't make sense.