Monday, August 8, 2011

cocos2d actions



m_SpriteBody = [[CCSprite alloc] initWithFile:@"catapultBody.png"];
[self addChild: m_SpriteBody];

m_SpriteSpoon = [[CCSprite alloc] initWithFile:@"catapultSpoon.png"];
m_SpriteSpoon.position = ccp(CATAPULTSPOONX, CATAPULTSPOONY);
m_SpriteSpoon.anchorPoint = ccp(0.76, 0.357);
m_SpriteSpoon.rotation = 80;
[m_SpriteBody addChild: m_SpriteSpoon z:-1];

m_SpriteDummyStone = [[CCSprite alloc] initWithFile:@"stone.png"];
m_SpriteDummyStone.position = ccp(-32, 2);
m_SpriteDummyStone.visible = NO;
[self addChild: m_SpriteDummyStone];

m_ActionThrow = [[CCRepeatForever actionWithAction:[CCSequence actions:
[CCEaseIn actionWithAction: [CCRotateBy actionWithDuration:0.5 angle:-90] rate:0.5],
[CCCallFunc actionWithTarget:self selector:@selector(showDummyStone)],
[CCDelayTime actionWithDuration:STONELOADTIME],
[CCEaseOut actionWithAction: [CCRotateBy actionWithDuration:0.1 angle:90] rate: 0.5],
[CCCallFunc actionWithTarget:self selector:@selector(throwStone)],
[CCCallFunc actionWithTarget:self selector:@selector(hideDummyStone)],
[CCRotateBy actionWithDuration:0.1 angle: -20],
[CCRotateBy actionWithDuration:0.1 angle: 20],
[CCRotateBy actionWithDuration:0.05 angle: -10],
[CCRotateBy actionWithDuration:0.05 angle: 10],
[CCRotateBy actionWithDuration:0.02 angle: -5],
[CCRotateBy actionWithDuration:0.02 angle: 5],
[CCDelayTime actionWithDuration:FIREDELAY],
nil]] retain];

m_ActionMoveDummy = [[CCSequence actions:
[CCFadeIn actionWithDuration:STONELOADTIME],
[CCMoveTo actionWithDuration:0.1 position: ccp(-5, 38)],
nil] retain];

m_ArrayStones = [[NSMutableArray alloc] initWithCapacity: STONECOUNT + 1];
for(int i = 0; i < STONECOUNT; i++)
{
Stone *n = [[Stone alloc] initWithStoneFileName:@"stone.png" andAngularVelocity:1.0f andDamage:5];
[m_ArrayStones addObject:n];
}


NSString *path = [[NSBundle mainBundle] pathForResource:@"bomb" ofType:@"wav"];
NSURL *filePath = [NSURL fileURLWithPath: path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &m_SoundBomb);

No comments:

Post a Comment

Followers