コード例 #1
0
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);
}
コード例 #2
0
ProgressTimer* ProgressTimer::create(Sprite* sp)
{
    ProgressTimer *pProgressTimer = new ProgressTimer();
    if (pProgressTimer->initWithSprite(sp))
    {
        pProgressTimer->autorelease();
    }
    else
    {
        delete pProgressTimer;
        pProgressTimer = NULL;
    }        

    return pProgressTimer;
}
コード例 #3
0
ProgressTimer* ProgressTimer::create(Sprite* sp)
{
    ProgressTimer *progressTimer = new ProgressTimer();
    if (progressTimer->initWithSprite(sp))
    {
        progressTimer->autorelease();
    }
    else
    {
        delete progressTimer;
        progressTimer = nullptr;
    }        

    return progressTimer;
}
コード例 #4
0
ProgressTimer* ProgressTimer::create(Sprite* sp)
{
    sp->setCascadeOpacityEnabled(true);
    ProgressTimer *progressTimer = new (std::nothrow) ProgressTimer();
    if (progressTimer->initWithSprite(sp))
    {
        progressTimer->autorelease();
        progressTimer->setCascadeOpacityEnabled(true);
    }
    else
    {
        delete progressTimer;
        progressTimer = nullptr;
    }        
    
    return progressTimer;
}
コード例 #5
0
ファイル: SkillItem.cpp プロジェクト: duongbadu/FightGame
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) );


}
コード例 #6
0
// 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);
}
コード例 #7
0
void Histogram1DDataBlock::ComputeTemplate(const TOCBlock* source,
                                           uint64_t iLevel) {
  // compute histogram by iterating over all bricks of the given level
  UINT64VECTOR3 bricksInSourceLevel = source->GetBrickCount(iLevel);

  size_t iCompcount = size_t(source->GetComponentCount());
  T* pTempBrickData = new T[size_t(source->GetMaxBrickSize().volume())
                            *iCompcount];

  uint32_t iOverlap =source->GetOverlap();

  ProgressTimer timer;
  timer.Start();

  for (uint64_t bz = 0;bz<bricksInSourceLevel.z;bz++) {
    for (uint64_t by = 0;by<bricksInSourceLevel.y;by++) {
      for (uint64_t bx = 0;bx<bricksInSourceLevel.x;bx++) {
        UINT64VECTOR4 brickCoords(bx,by,bz,iLevel);
        source->GetData((uint8_t*)pTempBrickData, brickCoords);
        UINTVECTOR3 bricksize = UINTVECTOR3(source->GetBrickSize(brickCoords));

        for (uint32_t z = iOverlap;z<bricksize.z-iOverlap;z++) {
          for (uint32_t y = iOverlap;y<bricksize.y-iOverlap;y++) {
            for (uint32_t x = iOverlap;x<bricksize.x-iOverlap;x++) {
              // TODO: think about what todo with multi component data
              //       right now we only pick the first component
              size_t val = size_t(pTempBrickData[iCompcount*(x+y*bricksize.x+z*bricksize.x*bricksize.y)]);
              m_vHistData[val]++;
            }
          }
        }
      }
    }

    float progress = float(bz)/float(bricksInSourceLevel.z);
    MESSAGE("Computing 1D Histogram %5.2f%% (%s)", 
            progress * 100.0f,
            timer.GetProgressMessage(progress).c_str());
  }
  delete [] pTempBrickData;
}
コード例 #8
0
ファイル: skillCd.cpp プロジェクト: mengjiangtao/Cocos2dx
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;
}
コード例 #9
0
ファイル: GameScene.cpp プロジェクト: wzit/game_new
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);
}
コード例 #10
0
ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{    
    Size size = Director::getInstance()->getWinSize();
    
    ProgressTimer* node = ProgressTimer::create(texture->getSprite());
    
    // but it is flipped upside down so we flip the sprite
    node->getSprite()->setFlippedY(true);
    node->setType( ProgressTimer::Type::BAR );
    
    node->setMidpoint(Vector2(0.5f, 0.5f));
    node->setBarChangeRate(Vector2(1, 1));
    
    node->setPercentage(100);
    node->setPosition(Vector2(size.width/2, size.height/2));
    node->setAnchorPoint(Vector2(0.5f,0.5f));
    
    return node;
}
コード例 #11
0
ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(RenderTexture* texture)
{
    Size size = Director::getInstance()->getWinSize();
    
    ProgressTimer* node = ProgressTimer::create(texture->getSprite());
    
    // but it is flipped upside down so we flip the sprite
    node->getSprite()->setFlippedY(true);
    node->setType( ProgressTimer::Type::RADIAL );
    
    //    Return the radial type that we want to use
    node->setReverseDirection(true);
    node->setPercentage(100);
    node->setPosition(Vector2(size.width/2, size.height/2));
    node->setAnchorPoint(Vector2(0.5f,0.5f));
    
    return node;
}
コード例 #12
0
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }
    

    _tileMap = TMXTiledMap::create("ai_map.tmx");
    //_tileMap->initWithTMXFile("ai_map.tmx");
    _background = _tileMap->getLayer("Background");
    
    _foreground_1 = _tileMap->getLayer("Foreground_1");
    _foreground_2 = _tileMap->getLayer("Foreground_2");
    _meta = _tileMap->getLayer("Meta");
    _meta->setVisible(false);
    
    this->addChild(_tileMap);
    
    
    TMXObjectGroup *objectGroup = _tileMap->getObjectGroup("Objects");
    CCASSERT(NULL != objectGroup, "SpawnPoint object not found");
    auto spawnPoint = objectGroup->getObject("SpawnPoint");
    CCASSERT(!spawnPoint.empty(), "SpawnPoint object not found");
    //CCDictionary *spawnPoint = objectGroup->objectNamed("SpawnPoint");
    
    //int x = ((CCString)spawnPoint.valueForKey("x")).intValue();
    //int y = ((CCString)spawnPoint.valueForKey("y")).intValue();
    int x = spawnPoint["x"].asInt();
    int y = spawnPoint["y"].asInt();
    
    // player
    _player = Sprite::create("egg.png");
    _player->setTag(5);
    _player->setPosition(x,y);
    addChild(_player);
    setViewPointCenter(_player->getPosition());
    
    // patrol enemy
    searching_enemy = Enemys::createWithLayer(this);
    searching_enemy->setGameLayer(this);
    auto enemy = objectGroup->getObject("EnemySpawn1");
    int x_1 = enemy["x"].asInt();
    int y_1 = enemy["y"].asInt();
    addEnemyAtPos(Point(x_1,y_1));
    _enemies.pushBack(searching_enemy);
    
    // archer
    archer = Sprite::create("Kiwi.png");
    archer->setPosition(positionForTileCoord(Point(12, 4)));
    archer->setTag(23);
    archer->setScale(1.0);
    this->addChild(archer,1);
    _enemies.pushBack(archer);
    
    //boss
    boss = Sprite::create("patrol.png");
    boss->setPosition(positionForTileCoord(Point(26,9)));
    boss->setTag(26);
    boss->setScale(1.7);
    this->addChild(boss);

    _enemies.pushBack(boss);
    
    //a princess
    princess = Sprite::create("Princess.png");
    princess->setPosition(positionForTileCoord(Point(28, 10)));
    princess->setScale(0.6);
    this->addChild(princess);
    
    
    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);
    listener->onTouchBegan     = [&](Touch* touch, Event* unused_event)->bool { return true;  };
    listener->onTouchEnded     = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
    this->_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    
    // a pause button
    auto pauseItem = MenuItemImage::create("pause.png","",CC_CALLBACK_1(HelloWorld::onPause, this));
    auto menu = Menu::create(pauseItem,NULL);
    
    pauseItem->setScale(0.2);
    pauseItem->setPosition(positionForTileCoord(Point(27, 1)));
    
    menu->setPosition(Point::ZERO);
    this->addChild(menu,1,5);

    // add background music
    //CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("SummerNight.wav");
    
    // navigation button:up, down, left and right and an attacking button
    auto left_btn = Sprite::create("left.png");
    left_btn->setScale(0.3);
    left_btn->setPosition(Point(100, 125));
    left_btn->setTag(TAG_LEFT);
    this->addChild(left_btn,1);
    
    auto right_btn = Sprite::create("right.png");
    right_btn->setScale(0.3);
    right_btn->setPosition(Point(250, 125));
    right_btn->setTag(TAG_RIGHT);
    this->addChild(right_btn,1);
    
    auto up_btn = Sprite::create("up.png");
    up_btn->setScale(0.3);
    up_btn->setPosition(Point(175, 200));
    up_btn->setTag(TAG_UP);
    this->addChild(up_btn,1);
    
    auto down_btn = Sprite::create("down.png");
    down_btn->setScale(0.3);
    down_btn->setPosition(Point(175, 50));
    down_btn->setTag(TAG_DOWN);
    this->addChild(down_btn,1);

    auto attack_btn = Sprite::create("attack.png");
    attack_btn->setScale(0.5);
    attack_btn->setPosition(positionForTileCoord(Point(25,16)));
    attack_btn->setTag(ATTACK);
    this->addChild(attack_btn,1);
    
    //hero hp
    Sprite *heroEmHP = Sprite::create("empty.png");
    heroEmHP->setPosition(Point(150, 600));
    heroEmHP->setScale(1.5);
    this->addChild(heroEmHP);
    Sprite* heroFuHP = Sprite::create("full.png");
    ProgressTimer *pBlood = ProgressTimer::create(heroFuHP);
    pBlood->setType(kCCProgressTimerTypeBar);
    pBlood->setMidpoint(Point(0, 0));
    pBlood->setBarChangeRate(Point(1, 0));
    pBlood->setPercentage(100.0f);
    pBlood->setPosition(Point(150, 600));
    pBlood->setScale(1.5);
    this->addChild(pBlood, 1, 6);
    auto hero =Sprite::create("hero.png");
    hero->setPosition(Point(50, 600));
    hero->setScale(0.3);
    this->addChild(hero);
    
    //patrol monster hp
    Sprite *enEmHP = Sprite::create("empty.png");
    enEmHP->setPosition(Point(150, 550));
    enEmHP->setScale(1.5);
    this->addChild(enEmHP,1,7);
    Sprite* enFuHP = Sprite::create("full.png");
    ProgressTimer *enpBlood = ProgressTimer::create(enFuHP);
    enpBlood->setType(kCCProgressTimerTypeBar);
    enpBlood->setMidpoint(Point(0, 0));
    enpBlood->setBarChangeRate(Point(1, 0));
    enpBlood->setPercentage(100.0f);
    enpBlood->setPosition(Point(150, 550));
    enpBlood->setScale(1.5);
    this->addChild(enpBlood, 1,8);
    auto monster = Sprite::create("monster.png");
    monster->setPosition(Point(50,550));
    monster->setScale(0.1);
    monster->setTag(9);
    this->addChild(monster);

    //archer
    Sprite *arEmHP = Sprite::create("empty.png");
    arEmHP->setPosition(Point(350, 600));
    arEmHP->setScale(1.5);
    this->addChild(arEmHP,1,10);
    Sprite* arFuHP = Sprite::create("full.png");
    ProgressTimer *arpBlood = ProgressTimer::create(arFuHP);
    arpBlood->setType(kCCProgressTimerTypeBar);
    arpBlood->setMidpoint(Point(0, 0));
    arpBlood->setBarChangeRate(Point(1, 0));
    arpBlood->setPercentage(100.0f);
    arpBlood->setPosition(Point(350, 600));
    arpBlood->setScale(1.5);
    this->addChild(arpBlood, 1,11);
    auto armonster = Sprite::create("archer_icon.png");
    armonster->setPosition(Point(250,600));
    armonster->setScale(0.1);
    armonster->setTag(12);
    this->addChild(armonster);

    //boss
    Sprite *boEmHP = Sprite::create("empty.png");
    boEmHP->setPosition(Point(350, 550));
    boEmHP->setScale(1.5);
    this->addChild(boEmHP,1,13);
    Sprite* boFuHP = Sprite::create("full.png");
    ProgressTimer *bopBlood = ProgressTimer::create(boFuHP);
    bopBlood->setType(kCCProgressTimerTypeBar);
    bopBlood->setMidpoint(Point(0, 0));
    bopBlood->setBarChangeRate(Point(1, 0));
    bopBlood->setPercentage(100.0f);
    bopBlood->setPosition(Point(350, 550));
    bopBlood->setScale(1.5);
    this->addChild(bopBlood, 1,14);
    auto bomonster = Sprite::create("boss_icon.png");
    bomonster->setPosition(Point(250,550));
    bomonster->setScale(0.2);
    bomonster->setTag(15);
    this->addChild(bomonster);

    this->schedule(schedule_selector(HelloWorld::shooting), 2.5f);
    this->schedule(schedule_selector(HelloWorld::bulletCollision));
    this->schedule(schedule_selector(HelloWorld::getPrincess));
    this->schedule(schedule_selector(HelloWorld::bossAttacking),1.0f);
    return true;
}
コード例 #13
0
ファイル: GameScene.cpp プロジェクト: yw920/dota
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);
    
    
}