4

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

}
James Webster
  • 31,873
  • 11
  • 70
  • 114
Abhineet Prasad
  • 1,271
  • 2
  • 11
  • 14

2 Answers2

7

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.

Community
  • 1
  • 1
ArtS
  • 1,730
  • 1
  • 20
  • 43
0

update your cocos2dv3 to latest (RC4 for now).

I was using Xcode 5.0 and cocos2dv3 RC1 with no problem. But updating Xcode to 5.1 I had this problem. So I updated the cocos2dv3 to RC4 and now it's working fine.

You can find cocos 2d latest versions from here.

Krishna Raj Salim
  • 7,331
  • 5
  • 34
  • 66
Marion
  • 1
  • 2
  • @marion: from where i get the rc4 version ...can you give me link for it? – Dhaval Bhadania Apr 11 '14 at 10:30
  • @DhavalBhadania here you go. it's updated to rc5 now and you can [Get latest version](http://www.cocos2d-iphone.org/getting-started/#id-latest) or you can still [download rc4 from github](https://github.com/cocos2d/cocos2d-iphone/tree/release-3.0-rc4) – Marion Apr 12 '14 at 03:30