(NO.00001)iOS游戏SpeedBoy Lite成形记(十)
来源:互联网 发布:linux退出编辑模式 编辑:程序博客网 时间:2024/05/21 04:21
上篇最后遇到是神马问题呢?
原来由于现在seq动作的时间变得不确定了,jump的持续时间不能对应发生变化,导致可能选手在比赛后边就没有跳跃动作了!这虽不影响整个代码逻辑,却多少有些让玩家不爽.
一种解决办法就是,将jump动作设置为永久重复动作,然后在回调block中将其关闭即可.因为Obj-C中的block是闭包(不太清楚闭包的童鞋请自行度娘),所以在block中引用外面的jump都不是个事儿.
下面是完整的matchRun方法的实现:
-(void)matchRun{ CCLOG(@"%@ invoke!",NSStringFromSelector(_cmd)); if (_matching) { return; } [self matchReset]; _matching = YES; for (Player *player in _players) { CCTime duration = (CCRANDOM_0_1() * 500.0/100) + 5.0; CCActionMoveBy *moveBy = [CCActionMoveBy actionWithDuration:duration position:ccp(0.9f, 0)]; CCActionJumpBy *jump = [CCActionJumpBy actionWithDuration:duration position:ccp(0, 0) height:0.05 jumps:20]; CCActionRepeatForever *repeat = [CCActionRepeatForever actionWithAction:jump]; CCActionCallBlock *blk = [CCActionCallBlock actionWithBlock:^{ _finishedCount++; [player endMatch]; [player stopAction:repeat]; if (_finishedCount == 1) { _bestElapsedTime = player.elapsedTime; } CCLabelTTF* label = (CCLabelTTF*)_labelArray[player.playerNumber-1]; NSTimeInterval intervalOffset = player.elapsedTime - _bestElapsedTime; if (intervalOffset > 0) { label.string = [NSString stringWithFormat:@"NO.%d +%.4f s",_finishedCount,intervalOffset]; }else{ label.string = [NSString stringWithFormat:@"NO.%d %.4f s",_finishedCount,player.elapsedTime]; } label.visible = YES; if (_finishedCount == PlayerCount) { _finishedCount = 0; _matching = NO; } }]; CCActionSequence *seq = [CCActionSequence actionWithArray:@[moveBy,blk]]; player.speed = [CCActionSpeed actionWithAction:seq speed:1.0]; [player runAction:player.speed]; [player runAction:repeat]; [player startMatch]; }}
0 0
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二十)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(一)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(二)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(三)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(四)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(五)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(六)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(七)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(八)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(九)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十一)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十二)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十三)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十四)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十五)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十六)
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十七)
- ubuntu下如何查找某个文件的路径
- linux 查看系统信息命令(比较全)
- leetcode之Remove Duplicates from Sorted Array
- POJ 3087 Shuffle'm Up
- 写代码要注意的细节
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十)
- 十进制计数器的设计
- Java中特殊字符处理(转义字符)
- AsyncTask简介及使用
- Python3.4对Excel和Word的操作----win32com
- IAR EW6.30版本下建立STM32工程(芯片型号STM32F105VC)
- Spring注解的基础用法
- 计步器
- 基于PHPnow搭建Eclipse开发环境