Game Development Reference
In-Depth Information
really doesn't matter much for this game if you're unable to send another spider falling
down for a few seconds. That said, if you check out the DoodleDrop03 project, you'll
see I added a logging statement that will print out how many retries it took to find an
idle spider.
Because the movement sequence is the only action the spiders perform, you simply
check whether the spider is running any actions at all, and if not, assume it's idle. And
that brings us to the runSpiderMoveSequence in Listing 4-11 .
Listing 4-11 . Spider Movement Is Handled by an Action Sequence
-(void) runSpiderMoveSequence:(CCSprite*)spider
{
// Slowly increase the spider speed over time.
numSpidersMoved++;
if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f)
{
spiderMoveDuration - = 0.1f;
}
// This is the sequence which controls the spiders' movement.
CGPoint belowScreenPosition = CGPointMake(spider.position.x,←
-spider.texture.contentSize.height);
CCMoveTo* move = [CCMoveTo actionWithDuration:spiderMoveDuration
position:belowScreenPosition];
CCCallBlock* callDidDrop = [CCCallBlock actionWithBlock:^void(){
// move the droppedSpider back up outside the top of the screen
CGPoint pos = spider.position;
CGSize screenSize = [CCDirector sharedDirector].winSize;
pos.y = screenSize.height + spider.texture.contentSize.height;
spider.position = pos;
}];
CCSequence* sequence = [CCSequence actions:move, callDidDrop, nil];
[spider runAction:sequence];
}
 
 
Search Nedrilad ::




Custom Search