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'的多个方法"仅归档时
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01