我正在開發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