Beispiel #1
0
void Enemy:: SetDemage(float val,bool isBoom){
    CCString *str = CCString::createWithFormat("-%.f",val);
  //  CCLog(str->getCString());
    float font = 30;
    if (isBoom) {
        font = 60;
    }
   CCLabelTTF* demageLab = CCLabelTTF::create(str->getCString(),  "Marker Felt", font);
    if (isBoom) {
         demageLab->setColor(ccYELLOW);
    }else
    demageLab->setColor(ccRED);
    float x = CCRANDOM_0_1()*40;
    float y = CCRANDOM_0_1()*40;
    demageLab->setPositionX(x);
    demageLab->setPositionY(y);
    this->addChild(demageLab);
   CCActionInterval* scale=CCScaleTo::create(10, 0.5);
//    CCActionInterval* scale1 = CCScaleTo::create(0.25, 0.2);
    CCActionInterval *fade = CCFadeOut::create(0.5);
   // CCCallFunc *call = CCCallFunc::create(this, callfunc_selector(Enemy::clearDemageLab));
 
    //创建不断重复的动画,并让heroSprite播放
    
    demageLab->runAction(CCSpawn::create(scale,fade,NULL));
    CCAnimate * animate = BoomReady();
    if (animate==NULL) {
        return;
    }
    CCCallFunc* callfun = CCCallFunc::create(this,callfunc_selector(Enemy::boomNow));
    actionSprite->runAction(CCSequence::create(animate,callfun));
}
void GameLayer::_showAudioPlaying()
{
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* lblMusic = CCLabelTTF::create(CCString::createWithFormat("Playing %s", _music.description)->getCString(), FONT_GAME, 35.0f, CCSizeMake(winSize.width * 0.85f, winSize.height * 0.15f), kCCTextAlignmentRight, kCCVerticalTextAlignmentTop);
    
    lblMusic->setPositionX(origin.x + visibleSize.width * 0.55f);
    lblMusic->setPositionY(origin.y - visibleSize.height * 0.25f);
    
    CCMoveTo* ac1 = CCMoveTo::create(1.0f, ccp(lblMusic->getPositionX(), origin.y + visibleSize.height * 0.05f));
    
    CCDelayTime* ac2 = CCDelayTime::create(2.1f);
    
    CCFadeOut* ac3 = CCFadeOut::create(0.9f);
    
    CCCallFuncN* ac4 = CCCallFuncN::create(this, callfuncN_selector(GameLayer::_removeNode));
    
    addChild(lblMusic, kDeepGameFinish);
    
    lblMusic->runAction(CCSequence::create(ac1, ac2, ac3, ac4, NULL));
    
    SimpleAudioEngine::sharedEngine()->playBackgroundMusic(_music.bg_music, true);
    
}
Beispiel #3
0
CCSprite* CreditsScreen::createPerson(const std::string& name, const std::string& twitterLink, const std::string& fbLink)
{
    const float iconSize = 32;
    
    bool useTwitter = !twitterLink.empty();
    bool useFB = !fbLink.empty();
    
    CCSprite* person = CCSprite::create();
    
    CCLabelTTF* nameLabel = CCLabelTTF::create(name.c_str(), default_font.c_str(), FONT_SIZE_PERSON);
    nameLabel->setPositionX(nameLabel->getContentSize().width / 2);
    
    float totalWidth = nameLabel->getContentSize().width;
    float totalHeight = MAX(nameLabel->getContentSize().height, iconSize);
    
    if(useTwitter || useFB){
        totalWidth += PADDING_AFTER_NAME;
    }
    
    if(useTwitter){
        totalWidth += iconSize + PADDING_PERSON;
        
        urls.push_back(twitterLink);
        Button* twitterButton = ButtonFactory::imageButton(TWITTER_ICON_INACTIVE, TWITTER_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        twitterButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        twitterButton->setPositionY(totalHeight / 2);

        person->addChild(twitterButton);
    }
    
    if(useFB) {
        totalWidth += iconSize + PADDING_PERSON;

        urls.push_back(fbLink);
        Button* fbButton = ButtonFactory::imageButton(FB_ICON_INACTIVE, FB_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        
        fbButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        fbButton->setPositionY(totalHeight / 2);
        
        person->addChild(fbButton);
    }
    
    person->setContentSize(CCSizeMake(totalWidth, totalHeight));
    nameLabel->setPositionY(totalHeight / 2);
    person->addChild(nameLabel);
    
    return person;
}
Beispiel #4
0
void BaseScene::addTipBoard(const char* tip)
{
    CCSprite* tipBoard = CCSprite::createWithSpriteFrameName("tip_board");
    tipBoard->setAnchorPoint(ccp(0.0f, 1.0f));
    
    //tipBoard->cocos2d::CCNode::setPosition(SCALED_VALUE(12.0f), SCALED_VALUE(368.0f));
    PlaceNode(tipBoard, 0.02, 0.764);
    this->addChild(tipBoard);
    
    CCLabelTTF* tipLabel = CCLabelTTF::create(tip, "Arial", SCALED_VALUE(20.0f));
    tipLabel->setColor(ccc3(33, 33, 33));
    tipLabel->setAnchorPoint(ccp(0.5f, 1.0f));
    tipLabel->setDimensions(CCSizeMake(tipBoard->getContentSize().width * 0.8, tipBoard->getContentSize().height * 0.8));
    
    float py = 0.0f;
    py = tipBoard->getPositionY();
    py = py - SCALED_VALUE(127.0f);
    tipLabel->setPositionY(py);
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    tipBoard->setScaleY(1.20f);
    
    if (AppDelegate::SCREEN_HEIGHT > 400.0f)
    {
        tipLabel->setPositionY(py + SCALED_VALUE(10.0f));
    }
    else
    {
        tipLabel->setPositionY(py - SCALED_VALUE(5.0f));
    }
    
    
#else
    //PlaceNode(tipLabel, 0.04, 0.55);
#endif
    
    //tipLabel->setPositionY(py);
    
    float pX = tipBoard->getPositionX() + tipBoard->getContentSize().width/2;
    tipLabel->setPositionX(pX);
    
    this->addChild(tipLabel);
}