I having some trouble removing an entity correctly. I can remove what I want, but it's generating subsequent errors that make me believe that I'm doing something wrong.
I'm using this code from the examples (at least as far as pointer/mouse movements go):
http://melonjs.github.io/melonJS/examples/shapes/
The idea being that when I move this object to the place I intend, It spawns an entirely different object that is stationary, and the object I was originally moving should disappear or be destroyed rather, which I do with a call to a function that is in the shape's "parent" (if your looking at the example above it would be the equivalent game.ShapeObject ) class. Much like the footprint of a building in starcraft or similar.
The function is just this:
destroy: function(){
me.game.world.removeChild(this);
}
Which is called in the onRelease function of the same class.
However, doing so yields the error
"Uncaught TypeError: Cannot read property 'getBounds' of undefined"
And it retriggers repeatedly the same error if I mouse over the area where the shape was.
I cannot for the life of me get this error to stop. It's obvious that it's trying to get the bounds of something that is no longer there, but It shouldn't be trying to get those bounds in the first place because that entity should be all gone, or so I'd thought.
Any help is as always so very much appreciated!
me.input.releasePointerEvent('pointerdown', this);
Though change pointerdown to which ever event you need to remove :).
I believe what's happening is the event is still registered for that place on the screen, but the entity is gone.
me.input.registerPointerEvent('pointermove', this, this.pointerMove.bind(this));
So far so good! I'm a little unsure of the implication though, is it now no longer bound to the global pointer move event, but uhh... locally ?
--
You received this message because you are subscribed to a topic in the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/melonjs/Yi0g07urRTk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to melonjs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.