1 decade ago by garfnarf
Hi i try to resize an animationsheet, depending on the position on the Screen.
In the game i want to spawn much Entities.
main.js:
Here i can call my entities
This code works a little bit wrong. Everytime an new entity spawn all entities will scale down.
In the game i want to spawn much Entities.
main.js:
var settings = {imgscale:0.5,enableResize:true};
ig.game.spawnEntity(EntityKreuzer, spawnX, spawnY,settings);
Here i can call my entities
EntityKreuzer = EntityShip.extend({
type: ig.Entity.TYPE.A,
animSheet: new ig.AnimationSheet('media/ships/kreuzer2.png', 600, 240),
speed: 100,
size: {x: 600, y: 240},
allEnemys: [],
flip: false,
init: function (x, y, settings) {
this.parent(x, y, settings);
this.vel.x = this.speed;
this.addAnim('idle', 1, [0, 1, 0, 1]);
this.addAnim('pain', 0.3, [0, 1, 0, 1], true);// stop at the last frame
if(this.enableResize){
this.size.x *= this.imgscale;
this.size.y *= this.imgscale;
this.animSheet.width *= this.imgscale;
this.animSheet.height *= this.imgscale;
this.animSheet.image.resize(this.imgscale);
this.enableResize = false;
}
this.currentAnim = this.anims.idle;
},
This code works a little bit wrong. Everytime an new entity spawn all entities will scale down.
