Created
March 21, 2017 19:25
-
-
Save simonwhitehouse/6f73847ab9daf5dd6e0e3c2a792b45d3 to your computer and use it in GitHub Desktop.
Part of code for Outer Clouds
This file contains hidden or 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)startSpawning { | |
[self runAction:[SKAction repeatActionForever: | |
[SKAction sequence:@[ | |
[SKAction performSelector:@selector(spawnPlanets) | |
onTarget:self], | |
[SKAction waitForDuration:[self getSpawnLength]]]]]]; | |
[self runAction:[SKAction repeatActionForever: | |
[SKAction sequence:@[ | |
[SKAction performSelector:@selector(createFuel) | |
onTarget:self], | |
[SKAction waitForDuration:[self getSpawnLength]*5]]]]]; | |
} | |
-(int)getSpawnLength { | |
return _spawnLength; | |
} | |
-(SKEmitterNode*)createStartField:(float)speed | |
lifetime:(float)lifetime | |
scale:(float)scale | |
birthdRate:(float)birthRate | |
color:(SKColor*)color { | |
SKLabelNode *star = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"]; | |
star.fontSize = 80.0f; | |
star.text = @"★"; | |
SKTexture *texture; | |
SKView *textureview = [SKView new]; | |
texture = [textureview textureFromNode:star]; | |
texture.filteringMode = SKTextureFilteringNearest; | |
SKEmitterNode *emmiterNode = [SKEmitterNode new]; | |
emmiterNode.particleTexture = texture; | |
emmiterNode.particleBirthRate = birthRate; | |
emmiterNode.particleColor = color; | |
emmiterNode.particleLifetime = lifetime; | |
emmiterNode.particleSpeed = speed; | |
emmiterNode.particleScale = scale; | |
emmiterNode.particleBlendMode = 1; | |
emmiterNode.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMaxY(self.frame)); | |
emmiterNode.particlePositionRange = CGVectorMake(CGRectGetMaxX(self.frame), 0); | |
emmiterNode.particleSpeedRange = 10.0; | |
[emmiterNode advanceSimulationTime:lifetime]; | |
return emmiterNode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment