tarr11 Posted March 17, 2014 Share Posted March 17, 2014 Hi - I'm moving some code over to 2.0, and I've noticed that when I turn on enableBody=true for a group, it moves the sprites down slightly. Is this expected? Here's a sample of this code:http://plnkr.co/edit/q5LYI6 You can repro the behavior by commenting out line 57 in game.js - Doug Link to comment Share on other sites More sharing options...
rich Posted March 17, 2014 Share Posted March 17, 2014 Depending on which system you use it's probably because they've had their anchors changed to 0.5. Link to comment Share on other sites More sharing options...
tarr11 Posted March 17, 2014 Author Share Posted March 17, 2014 It seems to happen regardless of using P2 or Arcade. I'm creating these sprites using createFromObjects, maybe it's related to that. Link to comment Share on other sites More sharing options...
rich Posted March 17, 2014 Share Posted March 17, 2014 Yes almost certainly, I'm pretty sure object coordinates in Tiled JSON related to their bottom-left point. Should be easy enough to determine. Link to comment Share on other sites More sharing options...
tarr11 Posted March 17, 2014 Author Share Posted March 17, 2014 I can verify this is happening by manually placing a new sprite at the same coordinates. they don't match against Tiled. This wasn't happening in 1.6, so Im not sure if this is a bug or feature :-) Should I reset my sprite locations to a different offset somehow? Link to comment Share on other sites More sharing options...
rich Posted March 17, 2014 Share Posted March 17, 2014 Looking at the createFromObjects code I was remembering rightly, Tiled does assume a bottom-left placement and I appear to have resolved that by setting the object anchor to x: 0, y: 1, which now conflicts with the Body setting using the anchor as an offset. You can verify this by checking the anchor of mushrooms.children[0] for example. What needs to happen is when createFromObjects runs, it looks-up the tile height and then adjusts the y coordinate by that amount. I'll add it to the list! Link to comment Share on other sites More sharing options...
rich Posted March 17, 2014 Share Posted March 17, 2014 Ok in the dev branch I've updated the TilemapParser so it now adjusts the y coordinates by the tile height, and Tilemap no longer sets the anchor to 0,1 either. Link to comment Share on other sites More sharing options...
Recommended Posts