AlexArroyoDuque Posted February 16, 2014 Share Posted February 16, 2014 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 More sharing options...
Zaidar Posted February 16, 2014 Share Posted February 16, 2014 this is weird, in your create function, shouldn't your code be like this ?this.player = this.game.add.sprite(200, 400, "player"); Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 Yes Zaidar is: this.player = this.game.add.sprite(200, 400, 'player'); Edit my post. Any idea about my problem? Link to comment Share on other sites More sharing options...
Zaidar Posted February 16, 2014 Share Posted February 16, 2014 nope, do you got any error in the console ? Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 I haven't any error... Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 My collisions are not working properly. Collision is detected but does not call the appropriate function. All this did not happen in version 1.1.3. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 If I comment this line: this.player.body.setRectangle(75, 160, 0, 0); The sprite is positioned where I want, but I can not define the size of collision ... I also have problems when my player falls. The gravity of the image of the sprite and the collision zone is different. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 I have this problems with all my sprites... I dont't undertand what is happenning. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 Sorry I was using the wrong API for rendering. I still have the problem when I use setRectangle. Why is the sprite is positioned at the position (0, 0)? this.player.body.setRectangle (75, 160, 0, 0); Greetings. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 16, 2014 Author Share Posted February 16, 2014 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 More sharing options...
Recommended Posts