cruzlutor Posted September 16, 2016 Share Posted September 16, 2016 Hello, I have an issue with the createLayer() function, My player anchor point is 0.5 but the Tiles in the layer comes with default anchor How I can set all my layer tiles anchor to 0.5? this is the current result (The big red square is the player) And this is the expected thanks Link to comment Share on other sites More sharing options...
Milton Posted September 16, 2016 Share Posted September 16, 2016 Maybe layer.anchor.set(0.5); Link to comment Share on other sites More sharing options...
cruzlutor Posted September 16, 2016 Author Share Posted September 16, 2016 Thanks @Milton, but it doesn`t work Link to comment Share on other sites More sharing options...
Milton Posted September 16, 2016 Share Posted September 16, 2016 Yeah, sorry, I was just guessing Pretty stupid suggestion actually... Ok, next guess: layer.cameraOffset.x = ...; and then use half a tilewidth. Link to comment Share on other sites More sharing options...
drhayes Posted September 16, 2016 Share Posted September 16, 2016 What are you trying to do? I mean, what is setting the tile anchor to (0.5) a solution for? The tiles are not individual sprites once they're rendered on the screen, so you can't really set each anchor individually. Are you trying to reposition your player sprite to the center of the tile? Would setting it as player.x = tileX + player.width / 2; not be acceptable? Link to comment Share on other sites More sharing options...
cruzlutor Posted September 18, 2016 Author Share Posted September 18, 2016 On 9/16/2016 at 1:40 PM, drhayes said: What are you trying to do? I mean, what is setting the tile anchor to (0.5) a solution for? The tiles are not individual sprites once they're rendered on the screen, so you can't really set each anchor individually. Are you trying to reposition your player sprite to the center of the tile? Would setting it as player.x = tileX + player.width / 2; not be acceptable? Yes, I think that is the best solution, thanks : ) Link to comment Share on other sites More sharing options...
Recommended Posts