我正在开发一个 Spritekit 游戏。
触摸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
执行在动画执行时中断。