Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ARC semantic issue "multiple methods named 'setRotation' " while archiving only

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.

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;

in

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

}
like image 349
Abhineet Prasad Avatar asked Mar 20 '23 05:03

Abhineet Prasad


1 Answers

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

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

With this change, now I can support arm64 too.

like image 187
ArtS Avatar answered Mar 22 '23 18:03

ArtS