Skip to content

Commit c8f9114

Browse files
Fix type errors. Add a sample code. (SpriteKit)
1 parent 4036e72 commit c8f9114

18 files changed

Lines changed: 134 additions & 110 deletions

File tree

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKAction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
+ (SKAction *)playSoundFileNamed:(NSString *)soundFile waitForCompletion:(BOOL)wait;
4848
+ (SKAction *)colorizeWithColor:(SKColor *)color colorBlendFactor:(CGFloat)colorBlendFactor duration:(NSTimeInterval)sec;
4949
+ (SKAction *)colorizeWithColorBlendFactor:(CGFloat)colorBlendFactor duration:(NSTimeInterval)sec;
50-
+ (SKAction *)followPath:(CGPathRef)path duration:(NSTimeInterval)sec;
51-
+ (SKAction *)followPath:(CGPathRef)path asOffset:(BOOL)offset orientToPath:(BOOL)orient duration:(NSTimeInterval)sec;
50+
+ (SKAction *)followPath:(id)path duration:(NSTimeInterval)sec;
51+
+ (SKAction *)followPath:(id)path asOffset:(BOOL)offset orientToPath:(BOOL)orient duration:(NSTimeInterval)sec;
5252
+ (SKAction *)speedBy:(CGFloat)speed duration:(NSTimeInterval)sec;
5353
+ (SKAction *)speedTo:(CGFloat)speed duration:(NSTimeInterval)sec;
5454
+ (SKAction *)waitForDuration:(NSTimeInterval)sec;

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsBody.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333

3434
+ (SKPhysicsBody *)bodyWithCircleOfRadius:(CGFloat)r;
3535
+ (SKPhysicsBody *)bodyWithRectangleOfSize:(CGSize)s;
36-
+ (SKPhysicsBody *)bodyWithPolygonFromPath:(CGPathRef)path;
36+
+ (SKPhysicsBody *)bodyWithPolygonFromPath:(id)path;
3737
+ (SKPhysicsBody *)bodyWithEdgeFromPoint:(CGPoint)p1 toPoint:(CGPoint)p2;
38-
+ (SKPhysicsBody *)bodyWithEdgeChainFromPath:(CGPathRef)path;
39-
+ (SKPhysicsBody *)bodyWithEdgeLoopFromPath:(CGPathRef)path;
38+
+ (SKPhysicsBody *)bodyWithEdgeChainFromPath:(id)path;
39+
+ (SKPhysicsBody *)bodyWithEdgeLoopFromPath:(id)path;
4040
+ (SKPhysicsBody *)bodyWithEdgeLoopFromRect:(CGRect)rect;
4141

4242
- (void)applyForce:(CGVector)force;

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsJointFixed.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#pragma clang diagnostic push
1313
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1414

15-
@property CGFloat upperDistanceLimit;
16-
@property BOOL shouldEnableLimits;
17-
@property (retain) SKPhysicsBody *bodyA;
18-
@property CGFloat lowerAngleLimit;
19-
@property CGFloat frictionTorque;
20-
@property CGFloat frequency;
21-
@property CGFloat damping;
22-
@property CGFloat lowerDistanceLimit;
23-
@property CGFloat maxLength;
24-
@property (retain) SKPhysicsBody *bodyB;
25-
@property CGFloat upperAngleLimit;
26-
2715
+ (SKPhysicsJointFixed *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchor:(CGPoint)anchor;
2816

2917
#pragma clang diagnostic pop

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsJointLimit.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#pragma clang diagnostic push
1313
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1414

15-
@property CGFloat upperDistanceLimit;
16-
@property BOOL shouldEnableLimits;
17-
@property (retain) SKPhysicsBody *bodyA;
18-
@property CGFloat lowerAngleLimit;
19-
@property CGFloat frictionTorque;
20-
@property CGFloat frequency;
21-
@property CGFloat damping;
22-
@property CGFloat lowerDistanceLimit;
23-
@property CGFloat maxLength;
24-
@property (retain) SKPhysicsBody *bodyB;
25-
@property CGFloat upperAngleLimit;
26-
2715
+ (SKPhysicsJointLimit *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorB;
2816

2917
#pragma clang diagnostic pop

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsJointPin.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#pragma clang diagnostic push
1313
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1414

15-
@property CGFloat upperDistanceLimit;
16-
@property BOOL shouldEnableLimits;
17-
@property (retain) SKPhysicsBody *bodyA;
18-
@property CGFloat lowerAngleLimit;
19-
@property CGFloat frictionTorque;
20-
@property CGFloat frequency;
21-
@property CGFloat damping;
22-
@property CGFloat lowerDistanceLimit;
23-
@property CGFloat maxLength;
24-
@property (retain) SKPhysicsBody *bodyB;
25-
@property CGFloat upperAngleLimit;
26-
2715
+ (SKPhysicsJointPin *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchor:(CGPoint)anchor;
2816

2917
#pragma clang diagnostic pop

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsJointSliding.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#pragma clang diagnostic push
1313
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1414

15-
@property CGFloat upperDistanceLimit;
16-
@property BOOL shouldEnableLimits;
17-
@property (retain) SKPhysicsBody *bodyA;
18-
@property CGFloat lowerAngleLimit;
19-
@property CGFloat frictionTorque;
20-
@property CGFloat frequency;
21-
@property CGFloat damping;
22-
@property CGFloat lowerDistanceLimit;
23-
@property CGFloat maxLength;
24-
@property (retain) SKPhysicsBody *bodyB;
25-
@property CGFloat upperAngleLimit;
26-
2715
+ (SKPhysicsJointSliding *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchor:(CGPoint)anchor axis:(CGVector)axis;
2816

2917
#pragma clang diagnostic pop

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKPhysicsJointSpring.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
#pragma clang diagnostic push
1313
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
1414

15-
@property CGFloat upperDistanceLimit;
16-
@property BOOL shouldEnableLimits;
17-
@property (retain) SKPhysicsBody *bodyA;
18-
@property CGFloat lowerAngleLimit;
19-
@property CGFloat frictionTorque;
20-
@property CGFloat frequency;
21-
@property CGFloat damping;
22-
@property CGFloat lowerDistanceLimit;
23-
@property CGFloat maxLength;
24-
@property (retain) SKPhysicsBody *bodyB;
25-
@property CGFloat upperAngleLimit;
26-
2715
+ (SKPhysicsJointSpring *)jointWithBodyA:(SKPhysicsBody *)bodyA bodyB:(SKPhysicsBody *)bodyB anchorA:(CGPoint)anchorA anchorB:(CGPoint)anchorB;
2816

2917
#pragma clang diagnostic pop

Classes/iOS/FrameworkSupport/SpriteKit/JSBSKTexture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
+ (SKTexture *)textureWithImageNamed:(NSString *)name;
1818
+ (SKTexture *)textureWithRect:(CGRect)rect inTexture:(SKTexture *)texture;
19-
+ (SKTexture *)textureWithCGImage:(CGImageRef)image;
19+
+ (SKTexture *)textureWithCGImage:(id)image;
2020
+ (SKTexture *)textureWithImage:(UIImage *)image;
2121
+ (SKTexture *)textureWithData:(NSData *)pixelData size:(CGSize)size;
2222
+ (SKTexture *)textureWithData:(NSData *)pixelData size:(CGSize)size rowLength:(unsigned int)rowLength alignment:(unsigned int)alignment;

Classes/iOS/FrameworkSupport/SpriteKit/JSBSpriteKit.m

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,38 @@
2727

2828
@import ObjectiveC;
2929

30+
BOOL _allowSleep(id self, SEL _cmd)
31+
{
32+
return YES;
33+
}
34+
35+
void set_allowSleep(id self, SEL _cmd, BOOL arg1)
36+
{
37+
38+
}
39+
3040
@implementation JSBSpriteKit
3141

3242
+ (void)addScriptingSupportToContext:(JSContext *)context
3343
{
3444
#pragma clang diagnostic push
3545
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
46+
#pragma clang diagnostic ignored "-Wundeclared-selector"
47+
BOOL result;
48+
NSString *types;
49+
50+
Class cls = NSClassFromString(@"PKPhysicsBody");
51+
Class metaClass = object_getClass(cls);
52+
53+
types = [NSString stringWithFormat:@"%s%s%s", @encode(BOOL), @encode(id), @encode(SEL)];
54+
result = class_addMethod(metaClass, @selector(_allowSleep), (IMP)_allowSleep, types.UTF8String);
55+
56+
types = [NSString stringWithFormat:@"%s%s%s%s", @encode(void), @encode(id), @encode(SEL), @encode(BOOL)];
57+
result = class_addMethod(metaClass, @selector(set_allowSleep:), (IMP)set_allowSleep, types.UTF8String);
58+
59+
class_addProtocol([SKPhysicsBody class], @protocol(JSBSKPhysicsBody));
60+
context[@"SKPhysicsBody"] = [SKPhysicsBody class];
61+
3662
class_addProtocol([SKAction class], @protocol(JSBSKAction));
3763
context[@"SKAction"] = [SKAction class];
3864

@@ -42,9 +68,6 @@ + (void)addScriptingSupportToContext:(JSContext *)context
4268
class_addProtocol([UITouch class], @protocol(JSBUITouch));
4369
context[@"UITouch"] = [UITouch class];
4470

45-
class_addProtocol([SKPhysicsBody class], @protocol(JSBSKPhysicsBody));
46-
context[@"SKPhysicsBody"] = [SKPhysicsBody class];
47-
4871
class_addProtocol([SKPhysicsContact class], @protocol(JSBSKPhysicsContact));
4972
context[@"SKPhysicsContact"] = [SKPhysicsContact class];
5073

@@ -107,6 +130,8 @@ + (void)addScriptingSupportToContext:(JSContext *)context
107130

108131
class_addProtocol([SKScene class], @protocol(JSBSKScene));
109132
context[@"SKScene"] = [SKScene class];
133+
134+
context[@"SKColor"] = [SKColor class];
110135

111136
#pragma clang diagnostic pop
112137
}

Classes/iOS/FrameworkSupport/SpriteKit/JSBUITouch.h

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)