Open djipco opened 7 years ago
You aren't calling the constructor of SpriteContainer when you create each Enemy.
Have a look at the inheritance examples here: http://www.createjs.com/tutorials/Inheritance/
Importantly the extend
and promote
methods rename overridden constructors and methods so that you can call them using the convention this.SpriteContainer_constructor()
, which indeed should be the first line of your Enemy constructor above.
As you haven't done that, a lot of the container's internal properties will be attached to the prototype object which is shared between all of your Enemy instances.
@MannyC Of course!!! Thanks a lot. I was able to get away with simply adding the following line at the top of the Enemy
constructor:
createjs.Sprite.call(this);
I'm not sure I understand the benefits of using promote()
over what I did. I guess I will have to look at it in more details.
Thanks again!
When I create different sprites that use the same sprite sheet and add them to a
Stage
,SpriteStage
orStageGL
(I tried all of them), the sprite's animations get screwed up. However, if I add a single sprite, it works perfectly.I am providing a zip which contains a simplified version of the problem. It basically boils down to the code below. If you want to see how the animation is supposed to look, just comment out
setInterval()
and uncomment the line right below it.I'm not sure if this is a bug or totally my fault but I just can't wrap my head around it. Thoughts?