/** * Generated from the Phaser Sandbox * * //phaser.io/sandbox/ngGhhwKj * * This source requires Phaser 2.6.2 */ var game = new Phaser.Game(600, 450, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.baseURL = 'http://examples.phaser.io/assets/'; game.load.crossOrigin = 'anonymous'; game.load.image('sky', 'particlestorm/sky10.png'); game.load.image('ground', 'sprites/platform.png'); game.load.image('star', 'games/starstruck/star2.png'); game.load.spritesheet('dude', 'games/starstruck/dude.png', 32, 48); } // (A valiable of the group contains the ground and the 2 ledges) var platforms; function create() { // We're going to be using physics, so enable the Arcade Physics system game.physics.startSystem(Phaser.Physics.ARCADE); // A simple background for our game let sky = game.add.sprite(0, 0, 'sky'); // (Scale it to fit the game screen.) sky.scale.setTo(0.75, 0.75); // The platforms group contains the ground and the 2 ledges we can jump on platforms = game.add.group(); // We will enable physics for any object that is created in this group platforms.enableBody = true; // Here we create the ground. let ground = platforms.create(0, game.world.height - 32, 'ground'); // Scale it to fit the width of the game (the original sprite is 400x32 in size) ground.scale.setTo(1.5, 0.5); // This stops it from falling away when you jump on it ground.body.immovable = true; // Now let's create two ledges let ledge = platforms.create(300, 300, 'ground'); ledge.scale.setTo(0.75, 0.5); ledge.body.immovable = true; ledge = platforms.create(-110, 185, 'ground'); ledge.scale.setTo(0.75, 0.5); ledge.body.immovable = true; } function update() { } function render() { }