Я работаю над проектом в Objective-C/Sprite Kit и не могу заставить действия Sprite Kit работать, я пробовал все, что видел, но ничего не сработало.Sprite Kit SKActions не срабатывает
Вот код:
myscene.h
@property (strong, nonatomic) SKAction *jumpAction;
@property (strong, nonatomic) SKAction *kneelAction;
@property (strong, nonatomic) SKAction *runAction;
myscene.m (INIT ж/Метод размер)
[self setupCharacter];
[self createDpad];
[self spawnStartupClouds];
//self.physicsWorld.gravity = CGVectorMake(0.2,-2);
self.physicsWorld.gravity = CGVectorMake(0.2 ,-2);
self.physicsWorld.contactDelegate = self;
[self setupActions];
myscene.m (метод setupActions)
-(void) setupActions{
SKTextureAtlas *jumpAtlas = [SKTextureAtlas atlasNamed:@"jump"];
SKTexture *jumpTex1 = [jumpAtlas textureNamed:@"jump1.png"];
SKTexture *jumpTex2 = [jumpAtlas textureNamed:@"jump2.png"];
SKTexture *jumpTex3 = [jumpAtlas textureNamed:@"jump3.png"];
NSArray *jumpAtlasTexture = @[jumpTex1, jumpTex2, jumpTex3];
SKAction* jumpAtlasAnimation = [SKAction animateWithTextures:jumpAtlasTexture timePerFrame:0.1];
SKAction* wait = [SKAction waitForDuration:0.5];
jumpAction = [SKAction sequence:@[jumpAtlasAnimation, wait]];
BBCharacter* leader = (BBCharacter*)[self childNodeWithName:@"character1"];
}
-(void)setupCharacter{
NSLog(@"Setup character");
leader = [BBCharacter node];
leader.position = CGPointMake(100, 230);
[self addChild:leader];
}
Это также кажется (в setupActions
) он не может «видеть» SKAction
jumpAction
...
Попробуйте self.jumpAction вместо jumpAction. – 0x141E
Это хорошее видео, охватывающее то, что вы хотите https://www.youtube.com/watch?v=6eAwWDje7ks – DogCoffee
@ michaelD33 мой ответ вам полезен или нет. –