0

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

执行在动画执行时中断。

4

1 回答 1

0

Piece课堂上

更改此行:

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

NSString *imageName = [NSString stringWithFormat:@"%@-1",[self baseImageName]];
于 2013-10-19T13:19:23.987 回答