面白い形でクラッシュしています。私は次SKAction
のように設定します
-(id)initWithSize:(CGSize)size
{
if (self = [super initWithSize:size])
{
self.backgroundColor = [SKColor colorWithWhite:255 alpha:1];
[self createNinja];
[self setUpJump];
}
return self;
}
- (void)setUpJump
{
SKTextureAtlas *jumpAtlas = [SKTextureAtlas atlasNamed:@"Ninja_jump"];
SKTexture *jump1 = [jumpAtlas textureNamed:@"Ninja_jump_1"];
SKTexture *jump2 = [jumpAtlas textureNamed:@"Ninja_jump_2"];
SKTexture *jump3 = [jumpAtlas textureNamed:@"Ninja_jump_3"];
SKTexture *jump4 = [jumpAtlas textureNamed:@"Ninja_jump_4"];
SKAction *jumpUpAnimation = [SKAction animateWithTextures:@[jump1, jump2, jump3, jump4]
timePerFrame:0.07];
SKAction *jumpDownAnimation = [SKAction animateWithTextures:@[jump3, jump2, jump1, [SKTexture textureWithImageNamed:@"Ninja"]]
timePerFrame:0.07];
SKAction *wait = [SKAction waitForDuration:0.3];
self.jumpAction = [SKAction sequence:@[jumpUpAnimation, wait, jumpDownAnimation]];
}
しかし、最初SKScene
にこのアクションを実行せずに他のに移動するSKScene
と、同じアクションを設定するとクラッシュします
しかし、最初SKScene
にこのアクションを実行すると、次はすべて問題ありませんSKScene
。
に問題はありSpriteKit
ますSKTexture
か?
そのように私のアクションを実行します
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches)
{
CGPoint location = [touch locationInNode:self];
SKSpriteNode *ninja = (SKSpriteNode *)[self childNodeWithName:@"ninja"];
if (location.x > 230 &&
(location.x < 419 && location.y > 500))
{
[ninja runAction:self.jumpAction];
}
}
}