-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1497e1
commit cb91adf
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+918 Bytes
(100%)
...roj/project.xcworkspace/xcuserdata/bogdanvladu.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// LoadSkeletonPosesScene.h | ||
// GameDevHelperAPI-SpriteKit | ||
// | ||
|
||
// Copyright (c) 2013 Bogdan Vladu. All rights reserved. | ||
// | ||
|
||
#import <SpriteKit/SpriteKit.h> | ||
|
||
#import "GameDevHelper.h" | ||
|
||
@interface LoadSkeletonPosesScene : SKScene | ||
{ | ||
GHSkeleton* skeleton; | ||
int currentPose; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// | ||
// LoadSkeletonPosesScene.m | ||
// GameDevHelperAPI-SpriteKit | ||
// | ||
// Created by Bogdan Vladu on 6/14/13. | ||
// Copyright (c) 2013 Bogdan Vladu. All rights reserved. | ||
// | ||
|
||
#import "LoadSkeletonPosesScene.h" | ||
|
||
@implementation LoadSkeletonPosesScene | ||
|
||
-(id)initWithSize:(CGSize)size { | ||
if (self = [super initWithSize:size]) { | ||
/* Setup your scene here */ | ||
|
||
self.backgroundColor = [SKColor colorWithRed:0.15 green:0.15 blue:0.3 alpha:1.0]; | ||
|
||
|
||
[self buildWorld]; | ||
|
||
SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; | ||
myLabel.text = @"Load skeleton poses using Sprite Kit"; | ||
myLabel.fontSize = 12; | ||
myLabel.position = CGPointMake(CGRectGetMidX(self.frame), | ||
CGRectGetMidY(self.frame)); | ||
|
||
SKLabelNode *myLabel2 = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; | ||
myLabel2.text = @"from SpriteHelper 2 generated files."; | ||
myLabel2.fontSize = 12; | ||
myLabel2.position = CGPointMake(CGRectGetMidX(self.frame), | ||
CGRectGetMidY(self.frame)-12); | ||
|
||
|
||
[self addChild:myLabel]; | ||
[self addChild:myLabel2]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)buildWorld { | ||
|
||
// Configure physics for the world. | ||
self.physicsWorld.gravity = CGPointMake(0, -2); // no gravity | ||
|
||
self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; | ||
} | ||
|
||
|
||
|
||
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { | ||
/* Called when a touch begins */ | ||
|
||
for (UITouch *touch in touches) { | ||
CGPoint location = [touch locationInNode:self]; | ||
|
||
if(skeleton == nil){ | ||
skeleton = [GHSkeleton skeletonWithFile:@"Officer_Officer" | ||
directory:@"skeletons"]; | ||
|
||
skeleton.position = location; | ||
|
||
[self addChild:skeleton]; | ||
} | ||
else{ | ||
[self changePose]; | ||
} | ||
} | ||
} | ||
|
||
-(void)changePose{ | ||
|
||
NSArray *poseNames = [NSArray arrayWithObjects: | ||
@"DefaultPose", | ||
@"BowPose", | ||
@"DeathPose", | ||
@"HatWave", | ||
@"IdlePose", | ||
@"PushPose", | ||
@"ShootPose", | ||
nil]; | ||
|
||
NSString* finalPoseName = [poseNames objectAtIndex:currentPose]; | ||
++currentPose; | ||
|
||
if(currentPose >= [poseNames count]) | ||
currentPose = 0; | ||
|
||
[skeleton setPoseWithName:finalPoseName]; | ||
} | ||
|
||
|
||
-(void)update:(CFTimeInterval)currentTime { | ||
/* Called before each frame is rendered */ | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters