<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                1.第一步,添加爆炸動畫 ~~~ //添加玩家飛機飛行動畫 id _playerFlyAction; id _playerBlowupAnimation; //戰機爆炸動畫 id _enemyBlowupAnimation;//敵機爆炸動畫 BOOL _isEnemyCollodable; //敵機是否可碰撞 BOOL _isPlayerCollodable;//玩家飛機是否可碰撞 ~~~ 2.制作精靈表單 ![](https://box.kancloud.cn/2016-08-22_57bab559080c9.jpg) ![](https://box.kancloud.cn/2016-08-22_57bab5592bd57.jpg) 3.初始化爆炸量 ~~~ //初始化爆炸效果的量 _playerBlowupAnimation = [self getAnimationByName:@"plane_bao_" delay:0.08 animNum:5]; [_playerBlowupAnimation retain]; _enemyBlowupAnimation = [self getAnimationByName:@"plane2_bao_" delay:0.08 animNum:5]; [_enemyBlowupAnimation retain]; _isEnemyCollodable = YES; _isPlayerCollodable = YES; ~~~ 4.添加獲取動畫幀的圖片 的方法 ~~~ #pragma mark 飛機飛行和爆炸動畫 - (CCAnimation *)getAnimationByName:(NSString *)animName delay:(float)delay animNum:(int)num { NSMutableArray *animFrames = [NSMutableArray arrayWithCapacity:num]; for (int i=1; i<= num; ++i) { NSString *frameName = [NSString stringWithFormat:@"%@%d.png",animName,i]; CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:frameName]; [animFrames addObject:frame]; } CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animFrames delay:delay]; return animation; } ~~~ 5.修改碰撞 ~~~ -(void) collisionDetection:(ccTime)dt{ CCSprite *enemy; // CGRect bulletRect = [self rectOfSprite:_bulletSprite]; CCARRAY_FOREACH(_enemySprites, enemy) { if (enemy.visible && _isEnemyCollodable ) { _isEnemyCollodable = NO; //1.bullet & enemy collision det?ection // CGRect enemyRect = [self rectOfSprite:enemy]; if (_bulletSprite.visible && CGRectIntersectsRect(enemy.boundingBox, _bulletSprite.boundingBox)) { //使用CCspawn 動作組合 id ac1 = [CCScaleTo actionWithDuration:1.0 scale:1.2]; id ac2 = [CCRotateBy actionWithDuration:1.0 angle:720]; id ac3 = [CCFadeOut actionWithDuration:1.0]; id ac4 = [CCHide action]; id blowup = [CCAnimate actionWithAnimation:_enemyBlowupAnimation ]; id block = ^(){ _isEnemyCollodable = YES; }; id ac5 = [CCSequence actions:ac3,ac4,[CCCallBlock actionWithBlock:block], nil]; id action = [CCSpawn actions:ac1,ac2,ac5,blowup, nil]; [enemy stopAllActions]; [enemy runAction:action]; enemy.visible = NO; _bulletSprite.visible = NO; _totalScore += 100; if (_totalScore >= 1000) { [_gameEndLabel setString:@"游戲勝利!"]; _gameEndLabel.visible = YES; id scaleTo = [CCScaleTo actionWithDuration:1.0 scale:1.2f]; [_gameEndLabel runAction:scaleTo]; [self unscheduleUpdate]; [self performSelector:@selector(onRestartGame) withObject:nil afterDelay:2.0f]; } [_bulletSprite stopAllActions]; [enemy stopAllActions]; CCLOG(@"collision bullet"); break; } //2.enemy & player collision detection CCSprite *playerSprite = [self getPlayerSprite]; // CGRect playRect = [self rectOfSprite:playerSprite]; if (playerSprite.visible && _isPlayerCollodable && playerSprite.numberOfRunningActions == 0 && CGRectIntersectsRect(enemy.boundingBox, playerSprite.boundingBox)) { enemy.visible = NO; _isPlayerCollodable = NO; _totalLives -= 1; if (_totalLives <= 0) { [_gameEndLabel setString:@"游戲失敗!"]; _gameEndLabel.visible = YES; id scaleTo = [CCScaleTo actionWithDuration:1.0 scale:1.2f]; [_gameEndLabel runAction:scaleTo]; [self unscheduleUpdate]; [self performSelector:@selector(onRestartGame) withObject:nil afterDelay:3.0f]; } id blink = [CCBlink actionWithDuration:2.0 blinks:4]; id blowup = [CCAnimate actionWithAnimation:_playerBlowupAnimation]; id action = [CCSequence actions:blowup,blink,[CCCallBlock actionWithBlock:^(){ _isPlayerCollodable = YES;[playerSprite stopAllActions]; [playerSprite runAction:_playerFlyAction]; playerSprite.opacity = 255; playerSprite.visible = YES;}], nil]; [playerSprite stopAllActions]; [playerSprite runAction:action]; CCLOG(@"collision player"); break; } } } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看