mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Changed from New BSD to a custom license. The new license requires a Spine license to use the code. If you have a valid Spine license, you can do whatever you like with the code. This should not be a problem for anyone using the runtimes with Spine, nothing changes. If using the runtimes without a Spine license, you now need a Spine license. This is because the runtimes were created explicitly to be used with Spine.
50 lines
1.4 KiB
Objective-C
50 lines
1.4 KiB
Objective-C
|
|
|
|
#import "ExampleLayer.h"
|
|
|
|
@implementation ExampleLayer
|
|
|
|
+ (CCScene*) scene {
|
|
CCScene *scene = [CCScene node];
|
|
[scene addChild:[ExampleLayer node]];
|
|
return scene;
|
|
}
|
|
|
|
-(id) init {
|
|
self = [super init];
|
|
if (!self) return nil;
|
|
|
|
animationNode = [CCSkeletonAnimation skeletonWithFile:@"spineboy.json" atlasFile:@"spineboy.atlas" scale:1];
|
|
[animationNode setMixFrom:@"walk" to:@"jump" duration:0.2f];
|
|
[animationNode setMixFrom:@"jump" to:@"walk" duration:0.4f];
|
|
[animationNode setAnimation:@"walk" loop:NO];
|
|
[animationNode addAnimation:@"jump" loop:NO afterDelay:0];
|
|
[animationNode addAnimation:@"walk" loop:YES afterDelay:0];
|
|
animationNode.timeScale = 0.3f;
|
|
animationNode.debugBones = true;
|
|
|
|
CGSize windowSize = [[CCDirector sharedDirector] winSize];
|
|
[animationNode setPosition:ccp(windowSize.width / 2, 20)];
|
|
[self addChild:animationNode];
|
|
|
|
#if __CC_PLATFORM_MAC
|
|
[self setMouseEnabled:YES];
|
|
#endif
|
|
|
|
return self;
|
|
}
|
|
|
|
#if __CC_PLATFORM_MAC
|
|
- (BOOL) ccMouseDown:(NSEvent*)event {
|
|
CCDirector* director = [CCDirector sharedDirector];
|
|
NSPoint location = [director convertEventToGL:event];
|
|
location.x -= [[director runningScene]position].x;
|
|
location.y -= [[director runningScene]position].y;
|
|
location.x -= animationNode.position.x;
|
|
location.y -= animationNode.position.y;
|
|
if (CGRectContainsPoint(animationNode.boundingBox, location)) NSLog(@"Clicked!");
|
|
return YES;
|
|
}
|
|
#endif
|
|
|
|
@end |