Hello Guest

Author Topic: Sprites that override front sprite  (Read 5972 times)

cs3d

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Sprites that override front sprite
« 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 ?
 
 

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites that override front sprite
« Reply #1 on: July 10, 2012, 09:06:25 pm »
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.

cs3d

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Sprites that override front sprite
« Reply #2 on: July 11, 2012, 01:29:32 am »
 
  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.

cs3d

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Sprites that override front sprite
« Reply #3 on: July 11, 2012, 01:53:41 am »
   
    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 .
« Last Edit: July 11, 2012, 01:56:22 am by cs3d »

cs3d

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Sprites that override front sprite
« Reply #4 on: July 11, 2012, 02:32:50 am »
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  ?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprites that override front sprite
« Reply #5 on: July 11, 2012, 08:41:13 am »
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.