2D Toolkit Forum
2D Toolkit => Support => Topic started by: cs3d on July 10, 2012, 08:32:34 pm
-
Hi !
I m having problem with some sprites that are behind of others but they appering over the sprites that would be in front.
The sprites are from the same collection.
Can I control the order that sprites must render ?
-
Hi, the sort order is dependent on the z distance to the camera. It also depends on the camera type, if it is orthographic (tk2dCamera is orthographic) or perspective.
A screenshot of this would greatly help me make any recommendations, I'm not exactly sure how this is going wrong here.
-
Is a perspective camera . TK2D works with perspective too , ok ?
Yeah the objects have a diferent distances from the camera . in Edit mode is allright but when I comit some distant sprites appear in front of nearest sprites. I ll try some pictures to you see.
-
one more thing is that I m using sprite batcher to do this . When I commit it causes the problem.
When I change the material tk2d/blendVertexColor to tk2d/CutOutVertexColor the sprite stays in correct position but this material is not good to me .
-
I think that I discovered the problem . Correct me if I m saying something wrong please :
When I use spritebatcher all sprites batched will now have the same point localization like one single object .
So the calculation of depth ll take this point then if I move camera to the sides the problem appear.
I ll only use sprite batcher to distant background sprites.
If I dont use spritebatcher and use only simple sprites I ll continuing to have less drawcall ?
-
You are right. The static sprite batcher will sort to one location, and as such, you can't draw sprites in between layers. The best option is to try and separate into two batchers, foreground and background.