Author Topic: question about destroy(),When will it happened?  (Read 720 times)


  • Member
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
I have used gamemaker before,I know when use instance_destroy(),It will cause "destroy" event.

And in flixel 2.5,What cause the destroy() be override?
For instance,I use kill() in an object,will it active the destroy()?Then I can override destroy()?
override public function destroy():void

Sorry ,my english is poor


  • Active Member
  • ***
  • Posts: 205
  • Karma: +1/-0
    • View Profile
Re: question about destroy(),When will it happened?
« Reply #1 on: Sun, Jun 5, 2011 »
The current state will call destroy on all it's members when you switch it for a new one (using FlxG.switchState).

This only happens once.

The kill() method only flips a few flags for update and draw logic, nothing more.

You can override destroy, but the override should only contain code you want to have run once, at the end of the sprites life cycle.