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

8 years ago by zouzouek

Help with the drop game example,

I'm trying to change the game size from [64,96] to [576,1024] and then scaling it with the scale command to each device. But i'm very lost with the scaling process. For example how to scale a player entity with the following
EntityPlayer = ig.Entity.extend({
        size: {
            x: 4,
            y: 4
        },
        checkAgainst: ig.Entity.TYPE.B,
        animSheet: new ig.AnimationSheet('media/player.png',4,4),
        maxVel: {
            x: 50,
            y: 300
        },
        friction: {
            x: 600,
            y: 0
        },
        speed: 300,
        bounciness: 0.5,
        sound: new ig.Sound('media/bounce.ogg'),
        init: function(x, y, settings) {
            this.addAnim('idle', 0.1, [0]);
            this.parent(x, y, settings);
        },
        update: function() {
            if (ig.input.state('left')) {
                this.accel.x = -this.speed;
            } else if (ig.input.state('right')) {
                this.accel.x = this.speed;
            } else {
                this.accel.x = 0;
            }
            this.parent();
        },
        handleMovementTrace: function(res) {
            if (res.collision.y && this.vel.y > 32) {
                this.sound.play();
            }
            this.parent(res);
        },
        check: function(other) {
            other.pickup();
        }
    });

and therefore what is the correlation of x and y in size in accordance with the height and width.

Sorry for the high noob level, but i'm trying to wrap my head around the game world dimensions in impactjs.

8 years ago by Joncom

Check out the ig.main line here:
http://impactjs.com/documentation/class-reference/game#synopsis

The last argument 2 represents the game scale.

Increase that and your game gets drawn bigger.

Decrease that and your game gets drawn smaller.

If your game is 320x240 pixels, and you give it a scale of 2, that means width and height will both be doubled.

Basically your game will be stretched to 640x480 pixels.

You don't really scale individual entities because everything is scaled together.
Page 1 of 1
« first « previous next › last »