1 decade ago by TrexKikBut
I want to make the rocket flip when the player is facing the other way, but I can't seem to get it to work. Here is the code:
So how can I get it to flip?
EntityRocket = ig.Entity.extend({ size:{x:18, y:7}, animSheet: new ig.AnimationSheet( 'media/rocket.png', 18, 7), maxVel: {x: 200, y: 0}, type: ig.Entity.TYPE.NONE, checkAgainst: ig.Entity.TYPE.B, collides: ig.Entity.COLLIDES.PASSIVE, init: function( x, y, settings ) { this.parent( x + (settings.flip ? -4 : 12) , y+4, settings ); this.vel.x = this.accel.x = (settings.flip ? -this.maxVel.x : this.maxVel.x); this.addAnim( 'idle', 0.2, [0] ); }, handleMovementTrace: function( res ) { this.parent( res ); if( res.collision.x || res.collision.y ){ this.kill(); } }, check: function( other ) { other.receiveDamage( 10, this ); this.kill(); }, kill: function(){ for(var i = 0; i < 20; i++) ig.game.spawnEntity(EntityGrenadeParticle, this.pos.x, this.pos.y); this.parent(); } });
So how can I get it to flip?