Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by doobdargent

Hey all,
I'm using Animation.angle to "rotate" my sprites, but when I modify one of my Animation, all the other are also modified.

I'm making a tower defense and I have lots of turrets.
EntityTurret = EntitySelectable.extend({
        base: new ig.Image('media/tower-arrow-base.png'),
        gun: new ig.Animation(new ig.AnimationSheet('media/tower-arrow-gun.png', 40, 40), 1, [0]),
        lookTo: function( mob ){
            var theta = Math.PI;
            this.gun.angle = theta;
        },
   ...
});

Am I doing something wrong here?
Cheers!

1 decade ago by netmute

You instantiate an ig.Animation on the class level. Thay way, all of your EntityTurret entities are using the same animation instance.

Simply create your animation in the init method:

init: function( x, y, settings ) {
  this.parent( x, y, settings );
  this.addAnim( 'gun', 1, [0] );
},

1 decade ago by doobdargent

Pretty quick reply !
You just taught me something, thank you netmute.

I was going crazy on this.
Thank you again.
Page 1 of 1
« first « previous next › last »