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 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:
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.

1 decade ago by Joncom

The reason you&039;re having this issue is because you define #animSheet prior to the init call. This means that all EntityKreuzer&039;s share a common #animSheet. This should fix it...

EntityKreuzer = EntityShip.extend({

    animSheet: null,
    ...

    init: function(x, y, settings) {
        this.parent(x, y, settings);
        this.animSheet = new ig.AnimationSheet(
            'media/ships/kreuzer2.png', 600, 240);
        ...
    }

    ...
});

1 decade ago by garfnarf

Ah thx i will try this.

1 decade ago by garfnarf

Hm sry same problem.

I used kreuzer2.png as well for the Enemy class "EntityKreuze_cpu".
and this will be Resized aswell.

can it be an problem, that i use the same Basic class "EntityShip.extend"?
Page 1 of 1
« first « previous next › last »