LordBarbadass Posted December 6, 2018 Share Posted December 6, 2018 Hi, I have 3 containers containing only square sprites as children of stage. Starting from the 3rd, every new container I add is offset by 8,8 visually but all of their properties say they aren't. To achieve the expected result I have to set the position of the 3rd Container to -8,-8 or else the black shape is offset. When I check getGlobalPosition of the container or the sprites in it they tell me they're not offset when they clearly are. (game.layers is just a POJO that contains references to the containers) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 6, 2018 Share Posted December 6, 2018 cacheAsBitmap can make everything wrong, it turns off calculations of child transforms. Global position of any element is calculated through its position and parents position. If you didnt change position , but changed, for example, coordinates of graphics, you wont get the result you want. drawRect(200, 200, 300, 300) does not mean that that position is (200,200) ,position is still zero. Quote Link to comment Share on other sites More sharing options...
LordBarbadass Posted December 6, 2018 Author Share Posted December 6, 2018 4 minutes ago, ivan.popelyshev said: cacheAsBitmap can make everything wrong, it turns off calculations of child transforms. Global position of any element is calculated through its position and parents position. If you didnt change position , but changed, for example, coordinates of graphics, you wont get the result you want. drawRect(200, 200, 300, 300) does not mean that that position is (200,200) ,position is still zero. Yeah I know I mostly used EaselJS in the past and that behaviour seems mostly the same. This happens even when I don't cache the container. The 3rd container is just offset by 8,8 and I really can't see why. I don't do anything to it that I don't do to the the first 2 containers. All the Graphics are placed with their position property and drawRect(0,0,16,16). Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 6, 2018 Share Posted December 6, 2018 it should work. please make a fiddle. https://pixiplayground.com . zip-file is also fine Quote Link to comment Share on other sites More sharing options...
LordBarbadass Posted December 6, 2018 Author Share Posted December 6, 2018 1 hour ago, ivan.popelyshev said: it should work. please make a fiddle. https://pixiplayground.com . zip-file is also fine Yeah that's the problem, I've been trying (and failing) to replicate it to show. I don't feel like trying to gradually strip my whole project to find what causes it exactly. My code is available on Github : https://github.com/terrygonguet/naga If you want to look into it I'll gladly give any info you want but I understand if you don't have time. It's easy enought to workaround, just set the containers to -8,-8. If it becomes too much of a problem I'll try harder to identify it. Thanks anyway Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 7, 2018 Share Posted December 7, 2018 I can browse it later, maybe I'll see something suspicious Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.