CCLayersetOpacity:] 无法识别的选择器

发布于 2025-01-08 01:01:53 字数 530 浏览 6 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱本泡沫多脆弱 2025-01-15 01:01:53

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文