-
Notifications
You must be signed in to change notification settings - Fork 2
/
Fish.mm
80 lines (75 loc) · 1.91 KB
/
Fish.mm
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Fish.m
// DoodleFalling
//
// Created by lim byeong cheol on 11. 9. 21..
// Copyright 2011년 SK M&S. All rights reserved.
//
#import "Fish.h"
@implementation Fish
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
isActive=NO;
gameObjectType=kTypeFish;
scaleNum=0.7;
self.scale=scaleNum;
[self schedule:@selector(tick) interval:15.0f];
}
return self;
}
-(void)tick
{
self.isActive=YES;
[self unschedule:_cmd];
[self schedule:@selector(tick2) interval:3.0];
}
-(void)tick2
{
[self changeState:kStateEatUpItemWearOff];
//[self unscheduleAllSelectors];
[self unschedule:_cmd];
}
-(CCAnimation *)setAnimation
{
CCAnimation *anim=[self loadPlistForAnimationWithName:@"fishAnim" className:@"Actor"];
if (anim==NULL) {
CCLOG(@"fish animation loading failed");
}
return anim;
}
-(void)changeState:(ObjectStates)state
{
[self setObjectState:state];
switch (state) {
case kStateEatUpItem:
self.isActive=NO;
self.position=ccp(-100, -100);
[self unschedule:@selector(tick2)];
[self schedule:@selector(tick2) interval:6.0f];
break;
case kStateEatUpItemWearOff:
[self schedule:@selector(tick) interval:15.0f];
break;
default:
break;
}
}
-(void)updateState:(ccTime)dt gameObjects:(CCArray *)obj
{
}
-(CGRect)modifiedBoundingBox
{
CGRect ItemBox=[self boundingBox];
float xOffset=self.contentSize.width*0.3*scaleNum;
CGPoint pos=self.position;
CGSize size=self.contentSize;
// float xOffset=self.contentSize.width*0.1;
float widthSize=size.width*kModifiedBoundingBoxFactorXForSpeedUpItem*scaleNum;
float heightSize=size.height*kModifiedBoundingBoxFactorY;
ItemBox=CGRectMake(pos.x-xOffset, pos.y, widthSize,heightSize);
return ItemBox;
}
@end