-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battery.m
52 lines (40 loc) · 1.27 KB
/
Battery.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Battery.m
// RoboBird Space IOS 7
//
// Created by JOSH AND SARI on 7/25/14.
// Copyright (c) 2014 josue. All rights reserved.
//
#import "Battery.h"
#import "MyScene.h"
#import "SKTUtils.h"
@implementation Battery
-(instancetype)initWithImageNamed:(NSString *)name {
if (self = [super initWithImageNamed:name]) {
float rotateDuration = 4.0;
[self configurePhysicBody];
[self runAction:[SKAction repeatActionForever:[SKAction rotateByAngle:DegreesToRadians(360) duration:rotateDuration]]];
}
return self;
}
-(void)configurePhysicBody {
self.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:(self.size.width )/2];
self.physicsBody.affectedByGravity = NO;
self.physicsBody.categoryBitMask = CollisionCategoryBatteryGreen;
self.physicsBody.collisionBitMask = 0;
self.physicsBody.contactTestBitMask = 0;
}
-(void)collidedWith:(SKPhysicsBody *)body contact:(SKPhysicsContact *)contact {
[self destroy];
__weak MyScene *scene = (MyScene *)self.scene;
scene.powerActivated = YES;
scene.powerButtonOn.hidden = NO;
if (scene.volume == YES) {
[self runAction:scene.battery];
}
}
-(void)cleanup {
[super cleanup];
}
-(void)update:(CFTimeInterval)dt {
}@end