void BattleFieldUI::angryChange(Actor* angry)
{//show the effect when angry change
	auto percent = angry->getAngry() / angry->getAngryMax() * 100;
	auto progressTo = ProgressTo::create(0.3, percent);
	auto progressToClone = ProgressTo::create(1, percent + 2);

	ProgressTimer* bar;
	if (angry->getname() == KnightValues._name)
	{
		bar = KnightAngry;
		if (percent >= 100)
			KnightAngryFullSignal->setVisible(true);
		else if (percent == 0)
			KnightAngryFullSignal->setVisible(false);
	}
	else if (angry->getname() == ArcherValues._name)
	{
		bar = ArcherAngry;
		if (percent >= 100)
			ArcherAngryFullSignal->setVisible(true);
		else if (percent == 0)
			ArcherAngryFullSignal->setVisible(false);
	}
	else if (angry->getname() == MageValues._name)
	{
		bar = MageAngry;
		if (percent >= 100)
			MageAngryFullSignal->setVisible(true);
		else if (percent == 0)
			MageAngryFullSignal->setVisible(false);
	}
	bar->runAction(progressTo);
}
Exemple #2
0
void SkillButton::cool(float time) {
    ProgressTimer *prog = static_cast<ProgressTimer *>(this->getChildByTag(PROGRESS_TAG));
    //判断之前是否已经设置了冷却效�?
    if (!prog) {
        prog = ProgressTimer::create(Sprite::create("image/1.png"));
        prog->setType( ProgressTimer::Type::RADIAL);
        prog->setTag(PROGRESS_TAG);
        this->addChild(prog);
        prog->setAnchorPoint(Vec2(0.f, 0.f));
        prog->setPosition(0.f, 0.f);
        prog->setScale(this->getContentSize().width / prog->getContentSize().width); //调整到和图标一样大�?
    }

    auto to1 = Sequence::createWithTwoActions(ProgressTo::create(0, 100.f),
                                              ProgressTo::create(time, 0.f));
    prog->runAction(to1);
}
Exemple #3
0
void SkillItem::onSkillStarted()
{
    this->setEnabled(false);
    
    ProgressTo *to1 = ProgressTo::create(getSkillCDTime(), 100);
    ProgressTimer *sprite = ProgressTimer::create(Sprite::create(this->getDisableIcon().c_str()));
    sprite->setType(ProgressTimer::Type::RADIAL);
    
    auto tint = Sequence::create(TintTo::create(getSkillCDTime(), 60, 255, 180),
                                 NULL);

    
    sprite->setPosition(Point(getContentSize().width / 2, getContentSize().height / 2));
    sprite->setBarChangeRate(Point(0, 1));
    addChild(sprite, 0, SKILL_ITEM_CHILD_TAG);
    sprite->runAction(Sequence::create(Spawn::create(to1, tint, NULL),CallFunc::create( CC_CALLBACK_0( SkillItem::onSkillCDFinished, this)) ,NULL) );


}
// TransitionProgress
void TransitionProgress::onEnter()
{
    TransitionScene::onEnter();

    setupTransition();
    
    // create a transparent color layer
    // in which we are going to add our rendertextures
    Size size = Director::getInstance()->getWinSize();

    // create the second render texture for outScene
    RenderTexture *texture = RenderTexture::create((int)size.width, (int)size.height);
    texture->getSprite()->setAnchorPoint(Vector2(0.5f,0.5f));
    texture->setPosition(Vector2(size.width/2, size.height/2));
    texture->setAnchorPoint(Vector2(0.5f,0.5f));

    // render outScene to its texturebuffer
    texture->beginWithClear(0, 0, 0, 1);
    _sceneToBeModified->visit();
    texture->end();


    //    Since we've passed the outScene to the texture we don't need it.
    if (_sceneToBeModified == _outScene)
    {
        hideOutShowIn();
    }
    //    We need the texture in RenderTexture.
    ProgressTimer *node = progressTimerNodeWithRenderTexture(texture);

    // create the blend action
    ActionInterval* layerAction = (ActionInterval*)Sequence::create(
        ProgressFromTo::create(_duration, _from, _to),
        CallFunc::create(CC_CALLBACK_0(TransitionScene::finish,this)),
        nullptr);
    // run the blend action
    node->runAction(layerAction);

    // add the layer (which contains our two rendertextures) to the scene
    addChild(node, 2, kSceneRadial);
}
Exemple #5
0
bool skillCd::init()
{
	if (!Layer::init())
		return false;
	Size visibleSize = Director::getInstance()->getVisibleSize();

	ProgressTo *to = ProgressTo::create(3.0f, 100);
	
	Sprite *skill_icon = Sprite::create("icon.png");
	ProgressTimer *skill = ProgressTimer::create(skill_icon);
	skill->setType(kCCProgressTimerTypeRadial);
	skill->setPosition(visibleSize.width / 2, visibleSize.height / 2);
	addChild(skill);

	Sprite *skill_icon_back = skill_icon;
	skill_icon_back->setPosition(visibleSize.width / 2, visibleSize.height / 2);
	skill_icon_back->setOpacity(100);
	addChild(skill_icon_back);
	skill->runAction(to);
	return true;
}
Exemple #6
0
void GameScene::addTouchListener()
{
    
    auto touchListener = EventListenerTouchOneByOne::create();
    touchListener->onTouchBegan = [this](Touch* t,Event* e)->bool{
        auto menuCoo = menu->convertToNodeSpace(t->getLocation());
        Rect oldAABB =  buttonCoco->getBoundingBox();
        Vec2 oldVec = oldAABB.origin;
        Vec2 newVec = oldVec-buttonCoco->getContentSize()/2;
        Rect newAABB(newVec.x,newVec.y,oldAABB.size.width,oldAABB.size.height);
        
        if(mpProgressTimer->getPercentage()==100.0f&&newAABB.containsPoint(menuCoo)){
            isMagic = true;
            coco->playAnimation(BaseSprite::State::magic);
            if(!eff){
             eff = EffSprite::create("pfca/effect/eff_point_Coco_ult.fca", "effect/eff_point_Coco_ult");
            this->addChild(eff);
            }
            eff->setVisible(true);
            eff->setPosition(0-_director->getWinSize().width/2,0);
            eff->playAnimation(BaseSprite::State::magic,CallFunc::create(CC_CALLBACK_0(GameScene::effectCallback, this)));
            
            mpProgressTimer->setPercentage(0.f);
            
        }
        
        return true;
    };
    
    auto hurtLisener = EventListenerCustom::create("hurt", [this](EventCustom* e)->void{
      
        auto hurtObject = (BaseSprite*)e->getUserData();
        Label* l = nullptr;
       ProgressTimer* hp = nullptr;
        if(hurtObject==boss){
            l = l1;
            hp = effectHpProgressTimer[0];
            
        }else{
            l  = l2;
            hp = effectHpProgressTimer[1];
        }
        if(dynamic_cast<TreeBoss*>(hurtObject)){
            l->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+200));
            hp->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+180));
            
        }
        else{
              l->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+100));
            hp->setPosition(hurtObject->getPosition()+Vec2(_director->getWinSize().width/2,_director->getWinSize().height/2+130));
        }
       
        hp->setPercentage((hurtObject->getProperty().curLife/hurtObject->getProperty().maxLife)*100);

        
        
        l->setString("-"+Value((int)hurtObject->getCurHurt()).asString());
        if(!l->getParent()){
           
            this->addChild(l,3);
        }
        if(!hp->getParent()){
            this->addChild(hp,3);
        }
        hp->setVisible(true);
        if(!l->isVisible()){
            l->setVisible(true);
            l->setOpacity(255);
        }
        auto move = MoveBy::create(0.5f, Vec2(0,20));
        auto fade = FadeOut::create(0.5f);
        
        l->runAction(Sequence::create(move, fade,CallFunc::create(std::bind(&GameScene::lableCallback, this,l)),nullptr));
        
        hp->runAction(Sequence::create(DelayTime::create(1.0f),CallFuncN::create([](Node* n){
            n->setVisible(false);
        }), NULL));
    });
    
    
    _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener,buttonCoco);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(hurtLisener,this);
    
    
}