Jump to content

Some containers are offset when they shouldn't


LordBarbadass
 Share

Recommended Posts

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.snake_offset.png.7313331f69e4ed4c09bfac2494a60ded.png990496235_offsetconsole.png.f2980ba7c12c34ad5feaeae7340e13c1.png

(game.layers is just a POJO that contains references to the containers)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...