CCLayersetOpacity:] 无法识别的选择器
PopuupScene层
@interface PopupScene : CCLayer <CCRGBAProtocol>
错误消息
2 月 22 日 11:06:31 未知 MyProject[443] : -[PopupScene setOpacity:]: 无法识别的选择器发送到实例 0xa68ca80 2 月 22 日 11:06:31 未知 MyProject[443] :* 由于以下原因终止应用程序 未捕获的异常'NSInvalidArgumentException',原因:'-[PopupScene setOpacity:]: 无法识别的选择器发送到实例
CCRGBAProtocol 有 setOpacity 方法,但发生错误...
我如何淡入 &出CCLayer? (不透明度动画、CCFadeIn 和 CCFadeOut)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CCLayer 没有实现该协议(查看 CCLayer.h)。如果您“确实”需要在图层上设置透明度,则必须手动完成(正如@Ravin建议的那样)。基本上声明并实现 setOpacity 方法,并在该方法中执行您认为必须执行的操作来设置图层的不透明度。您可能会发现,如果您的图层嵌入了叠加的精灵以及其他不实现该协议的对象,那么获得您想要实现的结果可能会很困难。
我刚刚发现(呃),如果您使用的是 cocos2d 版本 1.0.1 ,则有一个
CCLayerColor 是 CCLayer 的子类,它实现了 CCRGBAProtocol 协议。
CCLayer 的所有功能均有效,此外还有以下新功能:
不透明度
RGB 颜色
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