Phaser

Szubrycht Kamil

free and fast 2D game framework

Phaser.Game

var game = new  Phaser.Game(800, 600, Phaser.AUTO, 'my-game', { 
  preload: preload, create: create, update: update 
});

function preload() {
};

function create() {
};

function update() {
}; 

preload()

function preload() {
    game.load.image('enemy', 'enemy.jpg');
    game.load.spritesheet('tankSprite', 'tank_sprite.png', 40, 40);
    game.load.atlas('tankAtlas', 'tank.png', 'tank.json');
};

create()

function create() {

    game.physics.startSystem(Phaser.Physics.ARCADE);
    game.world.enableBody = true;

    var image = game.add.image(10, 10, 'enemy');
    image.anchor.setTo(0.5, 0.5);

    tank = game.add.sprite(25, 25, 'tankSprite', 1);
    tank.animations.add('move', [0, 1, 2], 15, true);
};

update()

function update() {
    if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
        tank.body.velocity.y = -10;
        tank.angle -= 0.5;
        tank.animations.play('move');
    }

    game.physics.arcade.collide(tank, enemy);
    game.physics.arcade.overlap(tank, enemy, boom);
    function boom(tank, enemy) { ... }
};

Summary

  • open source
  • beginner friendly
  • support for desktop and mobile
  • physics system
Made with Slides.com