0

I copied the code found here:

http://www.cocos2d-iphone.org/forum/topic/12557

To create a successful "scratch off" effect, i.e. when my burnsprite visits the top layer image it makes it transparent in the spot the burnsprite is in, revealing the bottom layer under it.

I want to do the opposite. I want the top layer to start off transparent and have it become visible in the spot the burnsprite visits.

Below I list what I've tried to do:

I changed the burnsprite blend function to {GL_ZERO, GL_ONE} . I think this is the correct thing to do. I don't know if it works or not though because my top layer does not start off transparent.

I changed [topLayer clear:0.0f g:0.0f b:0.0f a:1.0f] to [topLayer clear:0.0f g:0.0f b:0.0f a:0.0f] and nothing happened. It was not transparent.

I then did topLayer.sprite.opacity = 0.0; Then is seemed to be only partially transparent. Still not what I wanted.

Please help.

DD_
  • 7,230
  • 11
  • 38
  • 59
user2012741
  • 89
  • 1
  • 8

1 Answers1

1

Your desired scenario seems to be exactly the same as the "scratch-off" scenario, but where the "scratch" layer is below instead of above.

If you switch the layers, you will get the effect you desire.

  • In the original example layerA is visible and layerB is behind it (i.e. not visible). When layerA is scratched layerB is shown. I still want layerA to be visible and layerB to be not visible. However there are other sprites interacting with the layers and for my game to make sense layerB has to have a higher z value then layerA. Thus I need layerB on top. If I switch layers and scratch layerB instead that would be fine but I would need layerB to be invisible originally and become visible when scratched. I can't simply switch layers. – user2012741 Feb 02 '13 at 17:51