Jump to content

More problems 1.1.3 to1.1.4, sprites position


AlexArroyoDuque
 Share

Recommended Posts

Hello! 

I am having several problems upgrading from version 1.1.3 to 1.1.4. Now I am not able to position some of my sprites in the game when they are created. They always seem to appear at position (0, 0). 

 

However, I have a group of sprites that are positioned correctly and I do not understand why. 

 

Here's the code from one of my sprites: 

preloader: 

  this.load.spritesheet ('player', 'assets / character / player-sprite.png', 120, 180); 

 

create: 

             this.player = this.game.add.sprite(200, 400, 'player');

             this.player.body.gravity.y = 160; 

             this.player.body.setRectangle (75, 160, 0, 0); 

             this.player.anchor.setTo (0.5, 0.5); 

 

As I said, I'm having difficulties in changing version. I'm blocked. Any help would be great. 

 

Greetings!

Link to comment
Share on other sites

My solution has been to define the position of the sprite after using setRectangle. 

 

             this.game.add.sprite this.player = (200, 150, 'player'); 

             this.player.body.setRectangle (75, 160, 0, 0); 

             this.player.body.x = 200; 

             this.player.body.y = 150;

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...