我正在开发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 2014-08-31 19:18:23
这是一个很好的视频,涵盖了你想要的内容https://www.youtube.com/watch?v=6eAwWDje7ks – DogCoffee 2014-09-01 07:56:19
@ michaelD33我的回答对你有帮助。 – 2015-06-08 11:18:41