ARC语义问题“名为'setRotation'的多个方法"仅归档时 [英] ARC semantic issue "multiple methods named 'setRotation' " while archiving only

查看:13
本文介绍了ARC语义问题“名为'setRotation'的多个方法"仅归档时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 cocos2dv3 中的项目抛出 ARC Sematic Issue发现多个名为setRotation:"的方法的结果、参数类型或属性不匹配归档时(发布模式).它在部署到模拟器/设备(调试模式)时运行良好.在发布模式下,编译器会混淆 UIRotationGestureRecognizerCCNode 中的旋转实现.当我在 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'的多个方法"仅归档时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆