diff --git a/animate.html b/animate.html new file mode 100644 index 0000000..a16c97d --- /dev/null +++ b/animate.html @@ -0,0 +1,177 @@ + +
++ -(id)initWithSize:(CGSize)size { + if (self = [super initWithSize:size]) { + /* Setup your scene here */ + + + + self.backgroundColor = [SKColor colorWithRed:0.05 green:0.05 blue:0.3 alpha:1.0]; + self.view.backgroundColor = [UIColor clearColor]; + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Spaceship.png"]]; + + SKLabelNode *myLabel = [SKLabelNode labelNodeWithFontNamed:@"HelveticaNeue"]; + + myLabel.text = @"How To Build A Rocket"; + myLabel.fontSize = 15; + myLabel.position = CGPointMake(CGRectGetMidX(self.frame), + CGRectGetMidY(self.frame)); + + [self addChild:myLabel]; + } + return self; + } ++
+ -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + /* Called when a touch begins */ + + for (UITouch *touch in touches) { + CGPoint location = [touch locationInNode:self]; + + SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"nosecone"]; + + sprite.position = location; + + SKAction *action = [SKAction rotateByAngle:M_PI duration:1]; + + [sprite runAction:[SKAction repeatActionForever:action]]; + + [self addChild:sprite]; + } + } +
+ -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + /* Called when a touch moves */ + + for (UITouch *touch in touches) { + CGPoint location = [touch locationInNode:self]; + + SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"spacecraft"]; + + sprite.position = location; + + SKAction *action = [SKAction rotateByAngle:M_PI duration:1]; + + [sprite runAction:[SKAction repeatActionForever:action]]; + + [self addChild:sprite]; + } + } ++
+ -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + /* Called when a touch ends */ + + for (UITouch *touch in touches) { + CGPoint location = [touch locationInNode:self]; + + SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"trunk"]; + + sprite.position = location; + + SKAction *action = [SKAction rotateByAngle:M_PI duration:1]; + + [sprite runAction:[SKAction repeatActionForever:action]]; + + [self addChild:sprite]; + } + } ++