SKAction上的EXC_BAD_ACCESS

时间:2013-10-19 12:40:55

标签: ios objective-c exc-bad-access sprite-kit skaction

我正在开发一款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

执行在动画执行上有所作为。

1 个答案:

答案 0 :(得分:0)

Piece班级

更改此行:

NSString *imageName = [NSString stringWithFormat:@"%@-1%@",[self baseImageName],imageResolution];

NSString *imageName = [NSString stringWithFormat:@"%@-1",[self baseImageName]];