setPositionZ - min of only -15?

Hi All,

I’m using setPositionZ for parallaxing. It’s working well, but I’m limited to -15 as the maximum value.
Anything beyond -15 simply disappears from the scene. I’m using cocos2d-x v3.1.1

Any ideas?
Thanks

Maybe you have some element (background…) on scene, that have z-order greater than -15? so if you put z-order to -15, priority will have element which is drawn first?

Hi,

Thanks for the response… I forgot to mention that I’m using box2d and in order to match the PTM_RATIO I have my whole scene scaled down 1/32. I’m wondering if the small scale value is preventing me from using z values beyond -15.

If I increase the scale factor on my scene, then I can see objects placed beyond z = -15.
Not really sure how best to address this…

I noticed a similar issue related to scaling up/down a tilemap and certain layers disappearing. One way to address this would be to change your z values to a smaller range (you can use fractional values: 1.15, -4.434)

If your project is using orthographic 2D projection then the default is (-1024, 1024). Check out CCDirector.cpp inside the method Director::setProjection(). As a workaround on one project I have set this to the range (-3072, 3072) because it was one change instead of changing a bunch of values in data files and in code, but that doesn’t seem like the right solution. Probably better to adjust your z values based on the scene scale, or maybe it’s a bug - or feature :slight_smile: ?

it’s good to bring it up so that either we can get documentation around how to manage global z order going forward, or if there is a bug related to scaling affecting the z-axis component of various transforms.

Thanks for the response @stevetranby,

Unfortunately, since I’m using the Z value for parallaxing (with 3D projection) I can’t use fractional values because the parallax movement becomes less noticeable (i.e. i need my layers further apart).

Thanks for the hint on Director::setProjection() - I’ll give that a try next.

Also, I agree, some clear documentation would be awesome =]

Just a quick update…

Increasing the zFarPlane value in Director::setProjection() on Mat4::createPerspective() fixes the problem for me.

Thanks!