日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

(NO.00001)iOS游戏SpeedBoy Lite成形记(十)

發布時間:2024/9/20 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 (NO.00001)iOS游戏SpeedBoy Lite成形记(十) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

上篇最后遇到是神馬問題呢?

原來由于現在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];} }

總結

以上是生活随笔為你收集整理的(NO.00001)iOS游戏SpeedBoy Lite成形记(十)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。