Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var game = new Phaser.Game(640, 360, Phaser.CANVAS, "content", { preload: preload, create: create, update: update, render: render});
  2.  
  3. var steve;
  4.  
  5. function preload() {
  6.     this.load.image('background', 'assets/clouds.jpg');
  7.     this.load.atlasJSONHash('guy', 'assets/steve.png', 'assets/steve.json');
  8. }
  9.  
  10. function create() {
  11.  
  12.     this.physics.startSystem(Phaser.Physics.ARCADE);
  13.  
  14.     this.background = this.game.add.tileSprite(0, 0, this.game.world.width, this.game.world.height, 'background');
  15.     // this.background.autoScroll(-10, 0);
  16.  
  17.     // Steve Sprite
  18.     steve = this.add.sprite(0, 225, 'guy');
  19.     walk = steve.animations.add('walk');
  20.     steve.animations.play('walk', 8, true);
  21.  
  22.     steve.anchor.setTo(0.5);
  23.  
  24.     // Add physics to Steve
  25.     this.physics.enable(steve, Phaser.Physics.ARCADE);
  26.     steve.body.collideWorldBounds = true;
  27.  
  28.     // Tween on Steve
  29.     tween = game.add.tween(steve);
  30.     tween.from({ x: 300 }, 5000, 'Linear', true, 0);
  31.  
  32. }
  33.  
  34. function update() {
  35.  
  36.     // steve.x += 2;
  37.  
  38.     // if (steve.body.right >= this.world.bounds.right) {
  39.     //  steve.x = 0;
  40.     //  steve.scale.x = -1;
  41.        
  42.     //  steve.x -= 1;
  43.     // }
  44.  
  45. }
  46.  
  47. function render() {
  48.  
  49.     game.debug.body(steve);
  50.     game.debug.spriteInfo(steve, 16, 16);
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement