void ASGame::energyBarAnimation(){ //1.显示行动力的圆形底座 CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png"); energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha)); addChild(energyBall,4); //2.行动力数量 string perStr = int2string(moveCount); CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32); per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha)); addChild(per,5,1*10000000+26); //3.能量条 CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png"); CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite); energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha)); energyBar->setType(kCCProgressTimerTypeRadial); energyBar->setPercentage(moveCount*20); addChild(energyBar,4,1*10000000+20); //4.攻击按钮底座 CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png"); CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png"); CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer)); energyContainer->setScale(1.05); energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135)); CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL); energyContainerMenu->setPosition(CCPointZero); if (moveCount < moveToFight) energyContainerMenu->setTouchEnabled(false); addChild(energyContainerMenu,2,1*10000000+27); //5.攻击按钮充值槽 CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png"); CCProgressTimer* attackButton = CCProgressTimer::create(barSprite); attackButton->setScale(1.05); attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135)); attackButton->setType(kCCProgressTimerTypeBar); attackButton->setMidpoint(ccp(0.5, 0)); attackButton->setBarChangeRate(ccp(0, 1)); attackButton->setPercentage(100*moveCount/moveToFight); addChild(attackButton,3,1*10000000+25); //4.能量的盖子 CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png"); energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135)); energyBarCover->setOpacity(0); //addChild(energyBarCover,4,1*10000000+28); }
//碰撞检测 void game_bj::auto_pz(char id) { CCSprite *sprinte_11 = (CCSprite*)getChildByTag(11); CCSprite *sprinte_12 = (CCSprite*)getChildByTag(12); CCSprite *sprinte_13 = (CCSprite*)getChildByTag(13); CCSprite *sprinte_14 = (CCSprite*)getChildByTag(14); CCSprite *sprinte_15 = (CCSprite*)getChildByTag(15); CCSprite *sprinte_11_a = (CCSprite*)getChildByTag(21); CCSprite *sprinte_12_a = (CCSprite*)getChildByTag(22); CCSprite *sprinte_13_a = (CCSprite*)getChildByTag(23); CCSprite *sprinte_14_a = (CCSprite*)getChildByTag(24); CCSprite *sprinte_15_a = (CCSprite*)getChildByTag(25); CCSprite *sprinte_11_b = (CCSprite*)getChildByTag(31); CCSprite *sprinte_12_b = (CCSprite*)getChildByTag(32); CCSprite *sprinte_13_b = (CCSprite*)getChildByTag(33); CCSprite *sprinte_14_b = (CCSprite*)getChildByTag(34); CCSprite *sprinte_15_b = (CCSprite*)getChildByTag(35); CCSprite *sprinte_11_y_a = (CCSprite*)getChildByTag(41); CCSprite *sprinte_12_y_a = (CCSprite*)getChildByTag(42); CCSprite *sprinte_13_y_a = (CCSprite*)getChildByTag(43); CCSprite *sprinte_14_y_a = (CCSprite*)getChildByTag(44); CCSprite *sprinte_15_y_a = (CCSprite*)getChildByTag(45); CCSprite *sprinte_11_y_b = (CCSprite*)getChildByTag(51); CCSprite *sprinte_12_y_b = (CCSprite*)getChildByTag(52); CCSprite *sprinte_13_y_b = (CCSprite*)getChildByTag(53); CCSprite *sprinte_14_y_b = (CCSprite*)getChildByTag(54); CCSprite *sprinte_15_y_b = (CCSprite*)getChildByTag(55); for (int ii = 101; ii<=112; ii++) { CCSprite *sprinte_xxx = (CCSprite*)getChildByTag(ii); if(sprinte_xxx) { // CCLOG("44"); bool ret_1 = false; bool ret_2 = false; bool ret_3 = false; bool ret_4 = false; bool ret_5 = false; if(sprinte_11) { ret_1 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_11->boundingBox()); } if(sprinte_12) { ret_2 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_12->boundingBox()); } if(sprinte_13) { ret_3 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_13->boundingBox()); } if(sprinte_14) { ret_4 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_14->boundingBox()); } if(sprinte_15) { ret_5 = CCRect::CCRectIntersectsRect(sprinte_xxx->boundingBox(), sprinte_15->boundingBox()); } if(ret_1) { CCPoint point = sprinte_11->getPosition(); // CCLOG("1"); // this->removeChild(sprinte_11, true); // this->removeChild(sprinte_11_a, true); // this->removeChild(sprinte_11_b, true); // this->removeChild(sprinte_11_y_a, true); // this->removeChild(sprinte_11_y_b, true); int new_value_11 = game_bj::e_11-10; if(new_value_11 <= 0) { this->removeChild(sprinte_11, true); this->removeChild(sprinte_11_a, true); this->removeChild(sprinte_11_b, true); this->removeChild(sprinte_11_y_a, true); this->removeChild(sprinte_11_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(71); if(pt) { this->removeChild(pt, true); } game_bj::e_11 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(71); if(pt) { pt->setPercentage(game_bj::e_11); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_11); pt->runAction(to); game_bj::e_11 = game_bj::e_11-10; } else { CCSprite *sprinte_11 = (CCSprite*)getChildByTag(11); if(sprinte_11) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_11); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,71); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_11); pt->runAction(to); game_bj::e_11 = game_bj::e_11-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,61); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_2) { CCPoint point = sprinte_12->getPosition(); CCLOG("2"); this->removeChild(sprinte_12, true); this->removeChild(sprinte_12_a, true); this->removeChild(sprinte_12_b, true); this->removeChild(sprinte_12_y_a, true); this->removeChild(sprinte_12_y_b, true); CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,62); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_3) { CCPoint point = sprinte_13->getPosition(); int new_value = game_bj::e_13-10; CCLOG("%i",new_value); if(new_value <= 0) { this->removeChild(sprinte_13, true); this->removeChild(sprinte_13_a, true); this->removeChild(sprinte_13_b, true); this->removeChild(sprinte_13_y_a, true); this->removeChild(sprinte_13_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(73); if(pt) { this->removeChild(pt, true); } game_bj::e_13 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(73); if(pt) { pt->setPercentage(game_bj::e_13); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value); pt->runAction(to); game_bj::e_13 = game_bj::e_13-10; } else { CCSprite *sprinte_13 = (CCSprite*)getChildByTag(13); if(sprinte_13) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_13); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,73); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value); pt->runAction(to); game_bj::e_13 = game_bj::e_13-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,63); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_4) { CCPoint point = sprinte_14->getPosition(); // CCLOG("4"); // this->removeChild(sprinte_14, true); // this->removeChild(sprinte_14_a, true); // this->removeChild(sprinte_14_b, true); // this->removeChild(sprinte_14_y_a, true); // this->removeChild(sprinte_14_y_b, true); int new_value_14 = game_bj::e_14-10; if(new_value_14 <= 0) { this->removeChild(sprinte_14, true); this->removeChild(sprinte_14_a, true); this->removeChild(sprinte_14_b, true); this->removeChild(sprinte_14_y_a, true); this->removeChild(sprinte_14_y_b, true); CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(74); if(pt) { this->removeChild(pt, true); } game_bj::e_14 = 100; } CCProgressTimer *pt = (CCProgressTimer*)getChildByTag(74); if(pt) { pt->setPercentage(game_bj::e_14); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_14); pt->runAction(to); game_bj::e_14 = game_bj::e_14-10; } else { CCSprite *sprinte_14 = (CCSprite*)getChildByTag(14); if(sprinte_14) { CCProgressTimer *pt = CCProgressTimer::progressWithSprite(CCSprite::create("hatchling_exp_02.png")); pt->setPercentage(game_bj::e_14); pt->setPosition( ccp(point.x, point.y-20) ); pt->setType(kCCProgressTimerTypeBar); pt->setScale(0.4); pt->setMidpoint(ccp(0,0)); pt->setBarChangeRate(ccp(1,0)); this->addChild(pt,0,74); CCFiniteTimeAction *action_1 = CCMoveTo::create((7*(point.y-1))/520,ccp(point.x,1)); pt->runAction(action_1); CCProgressTo *to = CCProgressTo::actionWithDuration(0.1, new_value_14); pt->runAction(to); game_bj::e_14 = game_bj::e_14-10; } } CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(point.x, point.y) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,64); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } if(ret_5) { CCPoint point = sprinte_15->getPosition(); CCLOG("5"); this->removeChild(sprinte_15, true); this->removeChild(sprinte_15_a, true); this->removeChild(sprinte_15_b, true); this->removeChild(sprinte_15_y_a, true); this->removeChild(sprinte_15_y_b, true); CCSprite *item_gb = new CCSprite(); item_gb->initWithFile("item_coin.png"); item_gb->setPosition( ccp(130, 340) ); item_gb->setScale(game_bj::scale); this->addChild(item_gb, 0,64); CCJumpTo* mJumpTo = CCJumpTo::actionWithDuration(2.0f, ccp(280, 1), 230.0f, 1); CCActionInterval* seq_aa = (CCActionInterval*)(CCSequence::actions(mJumpTo, NULL)); item_gb->runAction(seq_aa); } CCPoint a = sprinte_xxx->getPosition(); if( a.y>=477) { this->removeChild(sprinte_xxx, true); if(ii==101) { game_bj::a=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("a", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==102) { game_bj::b=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("b", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==103) { game_bj::c=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("c", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==104) { game_bj::d=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("d", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==105) { game_bj::e=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("e", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==106) { game_bj::f=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("f", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==107) { game_bj::g=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("g", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==108) { game_bj::h=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("h", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==109) { game_bj::i=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("i", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==110) { game_bj::j=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("j", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==111) { game_bj::k=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("k", 1); // CCUserDefault::sharedUserDefault()->flush(); } else if(ii==112) { game_bj::l=1; // CCUserDefault::sharedUserDefault()->setIntegerForKey("l", 1); // CCUserDefault::sharedUserDefault()->flush(); } } } } for (int i=11; i<=15; i++) { CCSprite *sprinte_yyy = (CCSprite*)getChildByTag(i); CCSprite *sprinte_yyy_a = (CCSprite*)getChildByTag(i+10); CCSprite *sprinte_yyy_b = (CCSprite*)getChildByTag(i+20); CCSprite *sprinte_yyy_y_a = (CCSprite*)getChildByTag(i+30); CCSprite *sprinte_yyy_y_b = (CCSprite*)getChildByTag(i+40); CCSprite *sprinte_item_gb = (CCSprite*)getChildByTag(i+50); CCSprite *sprinte_pt = (CCSprite*)getChildByTag(i+60); if(sprinte_yyy) { CCPoint a = sprinte_yyy->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy, true); } } if(sprinte_yyy_a) { CCPoint a = sprinte_yyy_a->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_a, true); } } if(sprinte_yyy_b) { CCPoint a = sprinte_yyy_b->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_b, true); } } if(sprinte_yyy_y_a) { CCPoint a = sprinte_yyy_y_a->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_y_a, true); } } if(sprinte_yyy_y_b) { CCPoint a = sprinte_yyy_y_b->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_yyy_y_b, true); } } if(sprinte_item_gb) { CCPoint a = sprinte_item_gb->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_item_gb, true); } } if(sprinte_pt) { CCPoint a = sprinte_pt->getPosition(); if( a.y <= 10) { this->removeChild(sprinte_pt, true); game_bj::e_11 = 100; game_bj::e_12 = 100; game_bj::e_13 = 100; game_bj::e_14 = 100; game_bj::e_15 = 100; } } } }