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
// For example, if you ArcToPoint and want to find out where the arc ends | |
// so that you can begin the next path, use this | |
CGPoint current = CGPathGetCurrentPoint(pathing); | |
//And if you want to log that | |
NSLog(@"%@", NSStringFromCGPoint(current); |
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
/* The layers in a scene. */ | |
typedef enum : uint8_t { | |
WorldLayerGround = 0, | |
WorldLayerBelowCharacter, | |
WorldLayerCharacter, | |
WorldLayerAboveCharacter, | |
WorldLayerTop, | |
kWorldLayerCount | |
} WorldLayer; |
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
- (void)update:(NSTimeInterval)currentTime | |
{ | |
[characterLayer enumerateChildNodesWithName:@"soldier" usingBlock: ^(SKNode *node, BOOL *stop) { | |
[(Soldier*)node updatePosition]; | |
}]; | |
} | |
// And then in the Soldier class | |
- (void)updatePosition { | |
self.zPosition = 10000 - self.position.y; |
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
class Formation { | |
array soliders = [] | |
function addSoldier(soldier) { | |
soldier.formation = self; // This is the line in question | |
self.soldiers.push(soldier); | |
} | |
} |
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
SKLightNode* sun = [[SKLightNode alloc] init]; | |
sun.position = CGPointMake(500,500); | |
// These 3 lines are critical | |
sun.enabled = YES; // Toggles the light source on and off. | |
sun.categoryBitMask = 1; // Defines the category of this light source. | |
[your_scene addChild:sun]; // Must be added to the world to work. |
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
node.shadowCastBitMask = 1; | |
node.lightingBitMask = 1; | |
node.shadowedBitMask = 1; |
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
if let scene = Foothills.unarchiveFromFile("Foothills") as? SKScene { | |
Foothills.loadSceneAssetsWithCompletionHandler({ | |
// Configure the view. | |
let skView = self.view as SKView | |
skView.showsFPS = true | |
skView.showsNodeCount = true | |
/* Sprite Kit applies additional optimizations to improve rendering performance */ |
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
class func loadSceneAssetsWithCompletionHandler(handler:()->()) { | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), { | |
MySprite.loadSharedAssets() | |
dispatch_async(dispatch_get_main_queue(), { | |
handler() | |
}) | |
}) | |
} |
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
class Flag : SKSpriteNode { | |
struct FlagSingleton { | |
static var texture = SKTexture[]() | |
static var onceToken: dispatch_once_t = 0 | |
} | |
class func loadSharedAssets() { | |
dispatch_once(&FlagSingleton.onceToken, { | |
FlagSingleton.textures.append(SKTexture(imageNamed:"flag_castle")) |
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
class func loadSceneAssetsWithCompletionHandler(handler:()->()) { | |
} |