Guest User

phaser 2.0-2.0.1 movement problem

a guest
Mar 25th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');
  2.  
  3. var main_state = {
  4.  
  5.     preload: function() {
  6.       this.game.load.image('test', 'bird.png');
  7.     },
  8.  
  9.     create: function() {
  10.       this.game.physics.startSystem(Phaser.Physics.ARCADE);
  11.       this.bird = this.game.add.sprite(100, 245, 'test');
  12.       this.game.physics.enable(this.bird, Phaser.Physics.ARCADE);
  13.       this.game.input.onDown.addOnce(this.move_it, this);
  14.     },
  15.  
  16.     move_it: function() {
  17.       //this.bird.body.x = 105; // this line works on 2.0 not in 2.0.1
  18.       this.bird.x = 105; // this lines moves it in 2.0.1 but doesn't stop in 105, keeps velocity
  19.     }
  20.  
  21. };
  22.  
  23. // Add and start the 'main' state to start the game
  24. game.state.add('main', main_state);
  25. game.state.start('main');
Advertisement
Add Comment
Please, Sign In to add comment