Jump to content

Emitter lives after sprite is killed


Kristoffer Darj
 Share

Recommended Posts

I'm basically trying to make this gamemechanicexplorer example into a game. http://gamemechanicexplorer.com/#homingmissiles-4

 

When a missile collide with another sprite (my hero), both the missile and hero is killed but a smoke emitter attached to the missile still keeps emitting smoke.

 

On the other hand, when a missile hits a solid obstacle on thte screen, the missile is also killed in the same fashion and then the emitter stops.

 

Any thought?

 

Missile code: http://pastebin.com/RKBvmSP0

Protagonist code: http://pastebin.com/2sQSN5Ky

The game: http://pastebin.com/V0X9QR67

Link to comment
Share on other sites

It seems you're missing the bit which turns the emitter off when the missile is dead:

    // If this missile is dead, don't do any of these calculations    // Also, turn off the smoke emitter    if (!this.alive) {        this.smokeEmitter.on = false;        return;    } else {        this.smokeEmitter.on = true;    }

This should go right at the top of the missile's update function, to prevent any other logic being run for dead missiles.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...