Sign in to follow this  
LordBarbadass

Some containers are offset when they shouldn't

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)

Share this post


Link to post
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.

Share this post


Link to post
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).

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.