2D Toolkit Forum

2D Toolkit => Support => Topic started by: Teboto on May 03, 2013, 10:05:15 pm

Title: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto on May 03, 2013, 10:05:15 pm
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!
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware 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.
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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?
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware 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?
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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.
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware 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)
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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.
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware on May 04, 2013, 12:06:33 am
Are you using a perspective camera?
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto on May 04, 2013, 12:09:20 am
Nope I'm using the tk2d camera, which has to be orthographic.
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware 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.
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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?
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: Teboto 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!
Title: Re: Overlaying a semi-transparent sprite on top of another sprite
Post by: unikronsoftware 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.