The semantic issue of ARC is "multiple methods named" setRotation "" when archiving only

My project in cocos2dv3 throws an ARC Sematic Issue Several methods called "setRotation:" were found with inconsistent result, parameter type or attributes during archiving (release mode). It works great when deployed to a simulator / device (debug mode). In release mode, the compiler gets confused between the implementation of rotation in UIRotationGestureRecognizerand CCNode. When I got the error in CCBAnimationManager.m, I came up with an object that calls the setRotation ( CCNode*) selector , but then the error crept in CCActionInterval. I hope cocos2d library has a better solution than type casting.

What am I doing wrong? Thank you for your time.

EDIT

@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;

at

CCAction.m
@synthesize tag = _tag, target = _target, originalTarget = _originalTarget;


-(void) startWithTarget:(id)aTarget
{
    _originalTarget = _target = aTarget;
}

-(void) startWithTarget:(id)aTarget
{
    _originalTarget = _target = aTarget;
}

Class hierarchy

@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];
   }

}
+4
source share
2 answers

This problem caused me a big headache. Although I upgraded cocos2d to v2.2 for my old project (too complicated to upgrade to version 3), I still got this warning. And any animation that I created uses rotation in SpriteBuilder, it works weirdly, as I described here: Problem with rotation animation on iPhone5S with cocos2d 2.0

Finally, I used type casting to solve it, as described 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];
}

With this change, I can now also support arm64.

+7
source

upgrade your cocos2dv3 to the latest version (RC4 now).

Xcode 5.0 cocos2dv3 RC1 . Xcode 5.1 . cocos2dv3 RC4, .

cocos 2d .

0

Source: https://habr.com/ru/post/1531866/


All Articles