Hello Guest

Author Topic: 2-sided sprite?  (Read 8189 times)

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
2-sided sprite?
« on: October 06, 2013, 01:07:09 pm »
Hi,

can sprites have a "backside"? So can I flip a sprite (namely a card) over with a nice flip animation to reveal the card content (from a deck of cards all having the same backside image)?
I did Cocos2D/iOS before, and I could come up with a nice card distribution animation (see sample here) by having a card fly over to the target position, having a virtual camera revolve around it until halfway when only the side of the card was visible, then switched the sprite image to the actual card content and then flip it finally over to the destination pos. I suppose with 2D Toolkit being in "real" 3D space now should make that somewhat simpler, or?

Thanks, habitoti
« Last Edit: October 06, 2013, 01:11:54 pm by habitoti »
Checkout our homepage or visit the Rombos blog.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2-sided sprite?
« Reply #1 on: October 06, 2013, 05:35:27 pm »
Sprites can't have a back side, but the shader is what makes the sprite 2 sided. Changing "Cull Off" to "Cull Back" in the shader will make it one sided. You can now place a second sprite at the same position, rotated 180 on y and that'll now be the back of this sprite.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: 2-sided sprite?
« Reply #2 on: November 02, 2013, 09:12:01 pm »
The 1.9 release notes said something like "Physically double sided sprite option instead of relying on a double sided shader". However, above you refer to a shader modification. I haven't really found out how to use the "double sided" mesh renderer option in the sprite collection, and there is really not much information in the wild on this (including the documentation)…can you point me to some helpful info source for creation and handling of a double-sided sprite?

Thanks, habitoti
Checkout our homepage or visit the Rombos blog.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: 2-sided sprite?
« Reply #3 on: November 02, 2013, 10:03:58 pm »
The 2 sided sprite creates a physically 2 sided sprite, with a front and back face. Both display the same sprite - it is so both sides light correctly, not for the use case you're describing. Set it in the sprite collection editor - render mesh -> Double Sided.

What you're requesting is a real double sided sprite - as in 2 sprites back to back. Its easily doable - you just need to change the shader as I described in the previous post. Normally sprites are visible from both sides, but you want to make them single sided, so you can place 2 sprites back to back.

habitoti

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
    • Rombos Homepage
Re: 2-sided sprite?
« Reply #4 on: November 02, 2013, 11:15:49 pm »
Ok, got it…just tried it and it works like a charme…

Thanks for the instant support!
Checkout our homepage or visit the Rombos blog.

Finnegan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: 2-sided sprite?
« Reply #5 on: June 20, 2015, 03:40:44 am »
It's also possible to simply switch the sprite in the middle (localScale.x==0) of transition. ;)