Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. create: function()
  2. {
  3. // Scaling options
  4. this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
  5. // Center the game
  6. this.scale.pageAlignHorizontally = true;
  7. this.scale.pageAlignVertically = true;
  8. // Auto screen size
  9. this.scale.setScreenSize(true);
  10. // We're going to be using physics, so enable the Arcade Physics system
  11. this.physics.startSystem(Phaser.Physics.ARCADE);
  12.  
  13. // Tilesets
  14. this.stage.backgroundColor = '#00C12A';
  15. map = this.add.tilemap('outsideJson');
  16. // The first parameter is the tileset name, as specified in the Tiled map editor (and in the tilemap json file)
  17. // The second parameter maps this name to the Phaser.Cache key 'tiles'
  18. map.addTilesetImage('outside_spritesheet3_small', 'outside_tiles');
  19. layer = map.createLayer('background');
  20. //layer = map.createLayer('path');
  21. //layer = map.createLayer('obstacles');
  22. // This resizes the game world to match the layer dimensions
  23. layer.resizeWorld();
  24.  
  25. // The player and its settings
  26. // param: posX, posY, sprite
  27. player = this.add.sprite(game.world.width/ 2, game.world.height /2, 'dude');
  28. // We need to enable physics on the player
  29. this.physics.arcade.enable(player);
  30. player.body.gravity.y = 300;
  31. player.body.collideWorldBounds = true;
  32.  
  33. // Our two animations, walking left and right.
  34. // param: name, frames, FPS, loops
  35. player.animations.add('left', [0, 1, 2, 3], 10, true);
  36. player.animations.add('right', [5, 6, 7, 8], 10, true);
  37.  
  38. // Create the game input (keyboard)
  39. cursors = game.input.keyboard.createCursorKeys();
  40. // Touch controls are default
  41.  
  42. // HUD text
  43. scoreText = this.add.text(460, 10, 'score: 0', { fontSize: '22px', fill: '#000' });
  44. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement