0

PopuupScene Layer

@interface PopupScene : CCLayer <CCRGBAProtocol>

Error Message

Feb 22 11:06:31 unknown MyProject[443] : -[PopupScene setOpacity:]: unrecognized selector sent to instance 0xa68ca80 Feb 22 11:06:31 unknown MyProject[443] : * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PopupScene setOpacity:]: unrecognized selector sent to instance

CCRGBAProtocol has setOpacity method, but error occurred...

How can I fade in & out CCLayer? (opacity animation, CCFadeIn & CCFadeOut)

ChangUZ
  • 5,380
  • 10
  • 46
  • 64
  • Have you added definition for setOpacity/opacity methods in PopupScene implementation. As you will need to implement the protocol. From where you are calling setOpacity method or its being called from system libraries? – Ravin Feb 22 '12 at 04:00
  • @ChangUZ : just added more info on you you could set opacity. My bad, did not know about this subclass until today. – YvesLeBorg Feb 23 '12 at 15:09

1 Answers1

0

CCLayer does not implement that protocol (look in CCLayer.h). If you 'really' need to set transparency on a layer, you will have to do it by hand ( as @Ravin suggests ). Basically declare and implement a setOpacity method, and within that method do what you think must be done to set the layer's opacity. You may find it can be tricky to get the result you are trying to accomplish if your layer embeds superimposed sprites, and other objects that dont implement the protocol.

I just found (urghhh) that if you are using cocos2d version 1.0.1 , there is a

CCLayerColor is a subclass of CCLayer that implements the CCRGBAProtocol protocol.

All features from CCLayer are valid, plus the following new features:

opacity

RGB colors

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48