Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create: function()
- {
- // Scaling options
- this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
- // Center the game
- this.scale.pageAlignHorizontally = true;
- this.scale.pageAlignVertically = true;
- // Auto screen size
- this.scale.setScreenSize(true);
- // We're going to be using physics, so enable the Arcade Physics system
- this.physics.startSystem(Phaser.Physics.ARCADE);
- // Tilesets
- this.stage.backgroundColor = '#00C12A';
- map = this.add.tilemap('outsideJson');
- // The first parameter is the tileset name, as specified in the Tiled map editor (and in the tilemap json file)
- // The second parameter maps this name to the Phaser.Cache key 'tiles'
- map.addTilesetImage('outside_spritesheet3_small', 'outside_tiles');
- layer = map.createLayer('background');
- //layer = map.createLayer('path');
- //layer = map.createLayer('obstacles');
- // This resizes the game world to match the layer dimensions
- layer.resizeWorld();
- // The player and its settings
- // param: posX, posY, sprite
- player = this.add.sprite(game.world.width/ 2, game.world.height /2, 'dude');
- // We need to enable physics on the player
- this.physics.arcade.enable(player);
- player.body.gravity.y = 300;
- player.body.collideWorldBounds = true;
- // Our two animations, walking left and right.
- // param: name, frames, FPS, loops
- player.animations.add('left', [0, 1, 2, 3], 10, true);
- player.animations.add('right', [5, 6, 7, 8], 10, true);
- // Create the game input (keyboard)
- cursors = game.input.keyboard.createCursorKeys();
- // Touch controls are default
- // HUD text
- scoreText = this.add.text(460, 10, 'score: 0', { fontSize: '22px', fill: '#000' });
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement