bandrei2408 Posted February 19, 2014 Share Posted February 19, 2014 Hello,I have a game which have 4 states : starts with Boot state which then loads Preload state and after Menu State. On the menu state i do something on update function. When the player presses spacebar it loads the Play state. On the Play state i set the body of the player to a rectangle smaller then the actual sprite. Something like this:this.player = game.add.sprite(700,200,'player');...this.player.body.setRectangle(10,10,20,20);After that i set the game.camera to follow the player. However, the player spawns everytime at the (0,0) point.Found two things that would solve my problem, but those solutions are not good since i will delete code that I will actually need. I will post here those two solutions in case it helps you figure out what the problem is. Here they are :1. Not doing anything on update function in menu state, makes the player spawn at the right position. However, i need to do things on the update function of the Menu state.2. Removing this.player.body.setRectangle(10,10,20,20) would solve my problem, but i still need to set the player body smaller then the actual sprite for a better collision system.I would like to mention that i used debug on render to see the body of the player and it is correct.Any idea what may cause this problem ? Link to comment Share on other sites More sharing options...
bandrei2408 Posted February 19, 2014 Author Share Posted February 19, 2014 Came back with a link to GitHub. In case it helps seeing my code : https://github.com/bandrei2408/flappyclone Link to comment Share on other sites More sharing options...
Recommended Posts