我正在开发一款Spritekit游戏。
当touchind尝试运行某个操作的节点时,我接收到EXEC_BAD_ACCESS
异常
此功能触及
-(void)selectNodeForTouch:(CGPoint)location {
SKNode *touchedNode = (SKNode *)[self nodeAtPoint:location];
NSLog(@"touched : %@",touchedNode.name);
if([[touchedNode name] isEqualToString:@"piece"]){
Piece *piece = (Piece *)[self nodeAtPoint:location];
if ([piece isRotated])
[piece rotateToFront];
else
[piece rotateToBack];
}
}
对象片段方法rotateBack
:
-(void)rotateToBack{
SKAction *rotationToBack = [SKAction animateWithTextures:[self animationFrames] timePerFrame:0.11];
[self runAction:rotationToBack withKey:@"rotation-to-back"];
[self setRotated:YES];
};
[self animationFrames]是一个NSMutable数组,用
转换为NSArray[self setAnimationFrames:[NSArray arrayWithArray:frames]];
最后,框架是NSMutableArray
,其中包含一些SKTextures
执行在动画执行上有所作为。
答案 0 :(得分:0)
在Piece
班级
更改此行:
NSString *imageName = [NSString stringWithFormat:@"%@-1%@",[self baseImageName],imageResolution];
到
NSString *imageName = [NSString stringWithFormat:@"%@-1",[self baseImageName]];