gpt4 book ai didi

ios - ARC 语义问题 "multiple methods named ' setRotation'“仅在归档时

转载 作者:可可西里 更新时间:2023-11-01 05:21:31 28 4
gpt4 key购买 nike

我在 cocos2dv3 中的项目抛出 ARC 语义问题发现多个名为“setRotation:”的方法具有不匹配的结果、参数类型或属性存档时( Release模式)。它在部署到模拟器/设备( Debug模式)时运行良好。在 Release模式下,编译器会混淆 UIRotationGestureRecognizerCCNode 中的旋转实现。当我在 CCBAnimationManager.m 中遇到错误时,我将调用选择器 setRotation 的对象类型转换为 (CCNode*) 但随后错误在 CCActionInterval 。我希望有比在 cocos2d 库中到处进行类型转换更好的解决方案。

我做错了什么?谢谢你的时间。

编辑

@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 中使用旋转创建的任何动画都表现得很奇怪,正如我在此处描述的那样: Rotation animation issue on iPhone5S with cocos2d 2.0

最后我在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 了。

关于ios - ARC 语义问题 "multiple methods named ' setRotation'“仅在归档时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22416971/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com