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
SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"DINCond-RegularAlternate"]; |
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) loadSound { | |
NSError *error; | |
NSURL * backgroundMusicURL = [[NSBundle mainBundle] URLForResource:@"otto_basetrack" withExtension:@"mp3"]; | |
backgroundMusicPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:backgroundMusicURL error:&error]; | |
backgroundMusicPlayer.numberOfLoops = -1; | |
[backgroundMusicPlayer prepareToPlay]; | |
[backgroundMusicPlayer play]; | |
} |
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) loadVideo { | |
SKVideoNode* introVideo = [SKVideoNode videoNodeWithVideoFileNamed:@"gameandcode_mockup_forryan.mov"]; | |
introVideo.position = CGPointMake(CGRectGetMidX(self.frame), | |
CGRectGetMidY(self.frame)); | |
[self addChild: introVideo]; | |
[introVideo play]; | |
} |
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
// Calling a function that has no parameters | |
[self performSelector:@selector(doImageFade) withObject:nil afterDelay:0.1]; | |
// Calling a function that has one parameter. | |
// Notice the ':' after doImageFade and the use of withObject | |
[self performSelector:@selector(doImageFade:) withObject:img afterDelay:0.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
NSString *burstPath = [[NSBundle mainBundle] pathForResource:@"Snow" ofType:@"sks"]; | |
SKEmitterNode *burstEmitter = [NSKeyedUnarchiver unarchiveObjectWithFile:burstPath]; | |
burstEmitter.position = CGPointMake(CGRectGetMidX(self.frame), | |
CGRectGetMidY(self.frame)); | |
[self addChild:burstEmitter]; |
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
// Replace NAMEOFSCENE in code | |
-(void) switchScene { | |
SKTransition *reveal = [SKTransition fadeWithDuration:3]; | |
SKScene *scene = [NAMEOFSCENE sceneWithSize:self.view.bounds.size]; | |
scene.scaleMode = SKSceneScaleModeAspectFill; | |
[self.view presentScene:scene transition:reveal]; | |
} |
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
// Imagine shooting an arrow to a point | |
CGMutablePathRef path = CGPathCreateMutable(); | |
// This will move an invisible path marker to a starting point | |
// In my case, the node is a child node of a sprite, so it is the local coords and not the screen coords | |
CGPathMoveToPoint(path, NULL, 10, 0); | |
// The 3-8th parameters are x/y coords. The arrow iwll first hit x:100 and y:50. | |
// It will then raise up a bit as it keeps going and finally drop to the target at x:300 y:0 | |
CGPathAddCurveToPoint(path, NULL, |
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
SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"DINCond-RegularAlternate"]; | |
myLabel.text = @"it's happening"; | |
myLabel.fontColor = [SKColor colorWithRed:0.271 green:0.271 blue:0.271 alpha:1]; /*#454545*/ | |
myLabel.fontSize = 30; | |
myLabel.position = CGPointMake(CGRectGetMidX(self.frame), | |
CGRectGetMidY(self.frame)); | |
[self addChild:myLabel]; |
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
// in header file | |
BOOL isDying; | |
// in subclass where object is referenced | |
// for example, enemy = (Character*)target | |
if(enemy->isDying) { | |
} | |
// VS a getter in header |
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
// Instead of a switch on each name, use string directly. | |
_thisClass = NSClassFromString(@"DynamicStringRepresentingClass"); |
OlderNewer