Hello Guest

Author Topic: Overlaying a semi-transparent sprite on top of another sprite  (Read 8402 times)

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Hi Unikron Software,

Great work on this toolkit. Is it possible for me to overlay a semi-transparent sprite from one sprite collection on top of a non-transparent sprite from another sprite collection on the same game object? This way you can see the non-transparent sprite through the transparent one that's on top. If so, what would be the best way to achieve this effect? Thanks in advance!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #1 on: May 03, 2013, 10:56:33 pm »
Not on the same game object, but can't you just create the second sprite and attach it as a child of the first one? Wouldn't that work?
Maybe I'm missing something in your explanation here.

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #2 on: May 03, 2013, 11:41:37 pm »
Thanks for the quick reply. That worked, though I can't believe that I hadn't thought of that :P

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #3 on: May 03, 2013, 11:46:23 pm »
Hm I seem to have replied prematurely. So it seems I can see the transparent sprites in the scene view, but not in the game view. Any ideas as to why this might be?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #4 on: May 03, 2013, 11:50:45 pm »
No idea - it could be because of any number of things.
Is it in the cameras view? If you replace it with a solid image can you see it?

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #5 on: May 03, 2013, 11:57:55 pm »
Yes but it gets displayed behind the solid image instead of in front of it. This happens regardless of my z position value. Transparent images have this problem too. I found this out by increasing their scale so that they're bigger than their solid image parents.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #6 on: May 04, 2013, 12:01:34 am »
And you're got a different z value on the object you want in front?
Base Object
   Overlaid object (z = -0.01 or something)

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #7 on: May 04, 2013, 12:03:05 am »
Yes. Also I overlooked something. It turns out that solid images appear in front just fine, while transparent images always appear behind. Assuming their Z value is set so that they're located in the front of course.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #8 on: May 04, 2013, 12:06:33 am »
Are you using a perspective camera?

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #9 on: May 04, 2013, 12:09:20 am »
Nope I'm using the tk2d camera, which has to be orthographic.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #10 on: May 04, 2013, 12:13:33 am »
I have no idea.
There is no known issue like this, so I'm guessing something is set up incorrectly.

I could probably look into it if you can create a repro case for me. support at unikronsoftware.com if you want to do that.

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #11 on: May 04, 2013, 12:27:50 am »
Ok I'll consider it if I have a lot of trouble. I noticed that adjusting the z value on any object attached to a parent doesn't have any effect on visibility whatsoever. Do you think this is also related to my possibly incorrect camera setup?

Teboto

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #12 on: May 04, 2013, 01:21:04 am »
I figured out the problem! Parent objects must have a z value (depth) > 0 for their children's z values to visibly matter. Thanks for the help!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Overlaying a semi-transparent sprite on top of another sprite
« Reply #13 on: May 04, 2013, 10:44:25 am »
That can't be the problem.
Maybe your sprite is just about clipping the camera far clip plane? You can check by selecting the camera and setting far clip plane to a larger number. Or perhaps the camera is too close to the sprite, in that case move it further away.