ARC semantic issue quot;multiple methods named #39;setRotation#39; quot; while archiving only(ARC语义问题“名为setRotation的多个方法仅归档时)
问题描述
我在 cocos2dv3 中的项目抛出 ARC Sematic Issue发现多个名为setRotation:"的方法的结果、参数类型或属性不匹配归档时(发布模式).它在部署到模拟器/设备(调试模式)时运行良好.在发布模式下,编译器会混淆 UIRotationGestureRecognizer
和 CCNode
中的旋转实现.当我在 CCBAnimationManager.m
中遇到错误时,我将调用选择器 setRotation 的对象类型转换为 (CCNode
*) 但随后错误在 CCActionInterval代码>.我希望有一个比在 cocos2d 库中到处进行类型转换更好的解决方案.
My project in cocos2dv3 is throwing ARC Sematic Issue
Multiple methods named 'setRotation:' found with mismatched result, parameter type or attributes
while archiving(release mode). It runs fine while deploying to simulator/device (debug mode).
In release mode compiler gets confused between the implementation of rotation in UIRotationGestureRecognizer
and CCNode
.
When I got the error in CCBAnimationManager.m
, I typecasted the object calling the selector setRotation to (CCNode
*) but then the error crept up in CCActionInterval
. I'm hoping there is a better solution than typecasting everywhere in cocos2d library.
我做错了什么?谢谢你的时间.
What am i doing wrong? Thankyou for your time.
编辑
@interface CCAction : NSObject <NSCopying> {
id __unsafe_unretained _originalTarget;
id __unsafe_unretained _target;
NSInteger _tag;
}
@property (nonatomic,readonly,unsafe_unretained) id target;
@property (nonatomic,readonly,unsafe_unretained) id originalTarget;
@property (nonatomic,readwrite,assign) NSInteger tag;
在
CCAction.m
@synthesize tag = _tag, target = _target, originalTarget = _originalTarget;
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
-(void) startWithTarget:(id)aTarget
{
_originalTarget = _target = aTarget;
}
类层次结构
@interface CCActionFiniteTime : CCAction <NSCopying>
@interface CCActionInterval: CCActionFiniteTime <NSCopying>
@interface CCBRotateTo : CCActionInterval <NSCopying>
CCBRotateTo.m {
-(void) startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
startAngle_ = [self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void) update: (CCTime) t
{
[self.target setRotation: startAngle_ + diffAngle_ * t];
}
}
推荐答案
这个问题让我很头疼.虽然我已经为我的旧项目升级了 cocos2d 到 v2.2 版本(更新到 v3 太复杂了),但我仍然收到这个警告.我在 SpriteBuilder 中使用旋转创建的任何动画都表现得很奇怪,正如我在这里描述的:使用 cocos2d 2.0 的 iPhone5S 上的旋转动画问题一个>
This problem gave me a big headache. Though I've upgraded cocos2d to v2.2 version for my old project (too complex to update to v3), I still got this warning. And any animation I created use rotation in the SpriteBuilder does act oddly, as I described here: Rotation animation issue on iPhone5S with cocos2d 2.0
最后我在 CCBAnimationManager.m 中使用类型转换来解决它
Finally I used type casting to solve it as following in CCBAnimationManager.m
@implementation CCBRotateTo
-(void)startWithTarget:(CCNode *)aTarget
{
[super startWithTarget:aTarget];
starAngle_ = [(CCNode *)self.target rotation];
diffAngle_ = dstAngle_ - startAngle_;
}
-(void)update:(ccTime)t
{
[(CCNode *)self.target setRotation: startAngle_ + diffAngle_ * t];
}
有了这个改动,现在我也可以支持 arm64 了.
With this change, now I can support arm64 too.
这篇关于ARC语义问题“名为'setRotation'的多个方法"仅归档时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ARC语义问题“名为'setRotation'的多个方法"仅归档时
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01