jtbdevelopment Posted July 8, 2016 Share Posted July 8, 2016 I have a simple battleship style game previously working on 2.4.3. As part of setting up the ships you can rotate them by double clicking. For overlap and edge detection, during this phase I enable arcade physics. Pretty simple stuff game wise. Recently tried upgrading to 2.5.0 and discovered some odd behaviour in setup screen that I traced back to body position after rotation and eventually traced back to 2.4.8 though trial and error. The sprite starts horizontal (and how the underlying image was drawn) and the body is good. Rotating the sprite (and resizing the body to flip width/height) to vertical causes the body to be offset from the image. Rotating back fixes it. The amount offset depends on size of image, but the longer images get further offset both x and y (even though images only have differences in size in one dimension). I note I am using a non-0 anchor (because I want the ship to rotate around it's center when I do rotate it) I tried undoing the most obvious set of changes in Arcade.Body preupdate as part of that release but that doesn't appear to be it. Here's a set of screenshots after rotating one ship. The body debug has been enabled and you can see the difference in 2.4.7 vs 2.4.8. The code is at https://github.com/jtbdevelopment/TwistedBattleship/blob/master/ui/app/scripts/services/shipGridV2.js - the relevant rotation is at line 304, you may also want to look at line 170 in placeShip function which is where sprites are initialized. Any help appreciated. (please no poking fun of my art asset - an artiste I am not :)) Link to comment Share on other sites More sharing options...
Tom Atom Posted July 8, 2016 Share Posted July 8, 2016 Look at this issue: https://github.com/photonstorm/phaser/issues/2490 or this post: It is fixed since version 2.4.9. Link to comment Share on other sites More sharing options...
jtbdevelopment Posted July 8, 2016 Author Share Posted July 8, 2016 Thanks but this is not the issue. I do not have negative scale and I initially noticed issue when running 2.5 Link to comment Share on other sites More sharing options...
drhayes Posted July 8, 2016 Share Posted July 8, 2016 What are your ships' anchors and pivots? Link to comment Share on other sites More sharing options...
Tom Atom Posted July 8, 2016 Share Posted July 8, 2016 @drhayes is right. Link I posted is not only about negative scale, but also about anchors - look that forum post. On images there is behavior in Phaser 2.4.7, 2.4.8 and 2.4.9 ( ) Link to comment Share on other sites More sharing options...
jtbdevelopment Posted July 9, 2016 Author Share Posted July 9, 2016 ah yes, its the second link that was more useful. Also took me a while to work my head around the math (which in my case works out to 0 since my body and image are the same size). Thanks for the info Link to comment Share on other sites More sharing options...
Recommended Posts