Ejemplo n.º 1
0
void Role::updateJumping(EffectState state)
{
    bool doNext = false;
    float y = 0.0f;
    Action *temp = nullptr;
    switch (state)
    {
        case EFFECT_START:
            mJumpingState = EFFECT_PLAYING;
            stopActionByTag(ID_ACTION_MOVING);
            
            doNext = mEventDispatcher(this, EVENT_JUMP, EFFECT_START, mEventDispatcherParam);
            if (!doNext)
            {
                mJumpingState = EFFECT_STOP;
                break;
            }
            
            temp = runAction(RepeatForever::create(getJumpAnimate()));
            temp->setTag(ID_ACTION_JUMPING);
            mJumpingY = getJumpScope();
            break;
            
        case EFFECT_PLAYING:
            doNext = mEventDispatcher(this, EVENT_JUMP, EFFECT_PLAYING, mEventDispatcherParam);
            if (!doNext)
            {
                mJumpingState = EFFECT_STOP;
                break;
            }
            
            if (mJumpingY > 0)
            {
                y = getJumpSpeed();
                mJumpingY -= y;
                
                if (mJumpingY <= 0.0f) mJumpingY = -getJumpScope();
            }
            else
            {
                y = -getJumpSpeed();
                mJumpingY -= y;
                if (mJumpingY > 0.0f) mJumpingY = 0.0f;
            }
            
            if (0.0f == mJumpingY) mJumpingState = EFFECT_STOP;
            setPosition(getPosition() + Vec2(0.0f, y));
            break;
            
        case EFFECT_STOP:
            mJumpingState = EFFECT_NONE;
            stopActionByTag(ID_ACTION_JUMPING);
            mMovingState = MOVING_RUN;
            idle();
            mEventDispatcher(this, EVENT_JUMP, EFFECT_STOP, mEventDispatcherParam);
            break;
    }
}
Ejemplo n.º 2
0
void Fish::beCaught(){
	stopActionByTag(k_Action_MoveTo);
	CCCallFunc* callFunc = CCCallFunc::create(this,callfunc_selector(Fish::beCaught_CallFunc));
	CCSequence* sequence = CCSequence::create(CCDelayTime::create(1.0f),callFunc,NULL);
	CCBlink* blink = CCBlink::create(1.0f,5);
	CCSpawn* spawn = CCSpawn::create(sequence, blink, NULL);
	_fishSprite->runAction(spawn);
}
Ejemplo n.º 3
0
void HeroSprite::onKeyReleased(EventKeyboard::KeyCode keyCode, Event* unused_event) {
    switch (keyCode) {
    case EventKeyboard::KeyCode::KEY_UP_ARROW:
		stopActionByTag(10);
    	getPhysicsBody()->resetForces();
		break;
	default:
		break;
	}
}
Ejemplo n.º 4
0
void Role::idle()
{
    if (mMovingState == MOVING_NONE) return;
    if (EFFECT_NONE != mJumpingState) return;
    
    mMovingState = MOVING_NONE;
    stopActionByTag(ID_ACTION_MOVING);
    auto temp = runAction(RepeatForever::create(getIdleAnimate()));
    temp->setTag(ID_ACTION_MOVING);
}
Ejemplo n.º 5
0
void MaterialNode::setShadowZIndexAnimated(float value, float duration) {
	if (_shadowIndex != value) {
		stopActionByTag(1);
		auto a = ShadowAction::create(duration, value);
		if (a) {
			a->setTag(1);
			runAction(a);
		}
	}
}
Ejemplo n.º 6
0
void CCRookieGuide::enableRegionCheckAfter(float seconds) {
    // ensure previous action is stopped
    stopActionByTag(TAG_ENABLE_REGION_CHECK);
    
    // now run a new action
    setShouldCheckRegion(false);
    CCAction* a = CCSequence::createWithTwoActions(CCDelayTime::create(seconds),
                                                   CCCallFunc::create(this, callfunc_selector(CCRookieGuide::markShouldCheckRegion)));
    a->setTag(TAG_ENABLE_REGION_CHECK);
    runAction(a);
}
Ejemplo n.º 7
0
void BrickBonus::animateDestroyBonus()
{
	_type = EBACKGROUND;
	_id = BNone;
	stopActionByTag(ANIM_TAG);
	removeChildByTag(ANIM_TAG);
	if (_bonusSprite)
	{
		_bonusSprite->removeFromParent();
		_bonusSprite = nullptr;
	}
}
Ejemplo n.º 8
0
void CCScrollBar::onUIScrollViewEvent(CCObject* sender, ScrollviewEventType e) {
	if(e == SCROLLVIEW_EVENT_SCROLLING) {
		ScrollView* scrollView = (ScrollView*)sender;
		syncThumbPositionForUIScrollView(scrollView);
        
        // reset timer to fade out
        stopActionByTag(TAG_FADE_OUT);
        CCUtils::setOpacityRecursively(this, 255);
        m_fadingOut = false;
        m_fadeOutTimer = 0;
	}
}
Ejemplo n.º 9
0
 void MenuItemLabel::unselected()
 {
     // subclass to change the default action
     if(m_isEnabled) {
         MenuItem::unselected();
         stopActionByTag(kZoomActionTag);
         
         Action *zoomAction = new ScaleTo(0.1f, m_originalScale);
         zoomAction->setTag(kZoomActionTag);
         runAction(zoomAction);
     }
 }
Ejemplo n.º 10
0
void CCScrollBar::scrollViewDidScroll(CCScrollView* view) {
    syncThumbPositionForCCScrollView(view);
    
    // reset timer to fade out
    stopActionByTag(TAG_FADE_OUT);
    CCUtils::setOpacityRecursively(this, 255);
    m_fadingOut = false;
    m_fadeOutTimer = 0;
    
    // to old
    if(m_oldCCDelegate)
        m_oldCCDelegate->scrollViewDidScroll(view);
}
void FloatingActionButton::animateDeselection() {
	stopActionByTag(123);
	auto a = construct<ProgressAction>(0.25, [this] (ProgressAction *a, float time) {
		if (_tapAnimationPath) {
			_tapAnimationPath->setFillOpacity(32 * (1.0f - time));
		}
	}, nullptr, [this] (ProgressAction *a) {
		if (_tapAnimationPath) {
			_drawNode->removePath(_tapAnimationPath);
			_tapAnimationPath = nullptr;
		}
	});
	a->setTag(123);
	runAction(a);
}
void FloatingActionButton::animateSelection() {
	if (!_tapAnimationPath) {
		_tapAnimationPath = construct<draw::Path>();
		_tapAnimationPath->setStyle(stappler::draw::Path::Style::Fill);
		_tapAnimationPath->setFillColor(Color4B(Color::White, 32));
		_drawNode->addPath(_tapAnimationPath);
	}

	_tapAnimationPath->clear();
	stopActionByTag(123);
	auto a = construct<ProgressAction>(0.15, [this] (ProgressAction *a, float time) {
		if (_tapAnimationPath) {
			_tapAnimationPath->clear();
			_tapAnimationPath->setFillOpacity(32);
			_tapAnimationPath->addCircle(48.0f, 48.0f, 24.0f + (24.0f * time));
		}
	});
	a->setTag(123);
	runAction(a);
}
Ejemplo n.º 13
0
Archivo: Gear.cpp Proyecto: ff78/son
void Gear::exitState(int currState)
{
    switch (currState) {
        case ACTORSTATE::ATTACK:
        {
            waitTimeOut = false;
            auto func = CallFunc::create(CC_CALLBACK_0(FightActor::waitTimeEnough, this));
            
            stopActionByTag(WAIT_TIMEOUT_TAG);
            auto s = Sequence::create(DelayTime::create(waitDuration),func, NULL);
            s->setTag(WAIT_TIMEOUT_TAG);
            runAction(s);
            
        }
            break;
            
        default:
            break;
    }
}
Ejemplo n.º 14
0
void CHPBar::toHPScale(float scale,float time){
    
    
    
    m_pNowHP->setScale(scale/100,1);
    
    if(scale == 0)
    {
        setVisible(false);
        return;
    }
    else
    {
        setVisible(true);
        Sequence *visibleAction =Sequence::create(DelayTime::create(5),Hide::create(), NULL);
        visibleAction->setTag(VISIBLE_ACTION_TAG);
        
        stopActionByTag(VISIBLE_ACTION_TAG);
        runAction(visibleAction);
    }
}
Ejemplo n.º 15
0
void RoundedProgress::setProgress(float value, float anim) {
	if (value < 0.0f) {
		value = 0.0f;
	} else if (value > 1.0f) {
		value = 1.0f;
	}
	if (_progress != value) {
		if (anim == 0.0f) {
			_progress = value;
			_contentSizeDirty = true;
		} else {
			stopActionByTag(129);
			auto a = construct<ProgressAction>(anim, value, [this] (ProgressAction *, float time) {
				_progress = time;
				_contentSizeDirty = true;
			});
			a->setSourceProgress(_progress);
			a->setTag(129);
			runAction(a);
		}
	}
}
Ejemplo n.º 16
0
void Guardian::exitState(int currState)
{
    switch (currState) {
        case IDLE:
        {
            
        }
            break;
            
        case CHASE:
        {
            stopActionByTag(MOVE_ACTION_TAG);
        }
            break;
        case SKILL:
        {
            
        }
            break;
        default:
            break;
    }
}
Ejemplo n.º 17
0
void Role::run(DirectState dir)
{
    switch (dir)
    {
        case DIRECT_RUN_LEFT:
            if (!mIsFaceLeft) setFaceLeft(true);
            break;
            
        case DIRECT_RUN_RIGHT:
            if (mIsFaceLeft) setFaceLeft(false);
            break;

		default:
			return;
    }
    
    if (MOVING_RUN == mMovingState) return;
    if (EFFECT_NONE != mJumpingState) return;
    
    mMovingState = MOVING_RUN;
    stopActionByTag(ID_ACTION_MOVING);
    auto temp = runAction(RepeatForever::create(getRunAnimate()));
    temp->setTag(ID_ACTION_MOVING);
}
Ejemplo n.º 18
0
void GalleryScroll::setProgress(float value) {
	if (value * _progress < 0.0f) {
		value = 0.0f;
	}

	float p = _primaryId + value;

	if (value <= -1.0f) {
		// move back
		_progress = 0.0f;

		if (!_secondary) {
			_secondaryId = _primaryId - 1;
			_secondary = construct<GalleryImage>(_images.at(_secondaryId), _imageCallback);
			_secondary->setAnchorPoint(Vec2(0.5f, 0.5f));
			_secondary->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
			_secondary->setContentSize(_contentSize);
			addChild(_secondary, int(_images.size() - _secondaryId));
		}

		_primary->removeFromParent();
		_primaryId = _secondaryId;
		_primary = _secondary;
		_secondary = nullptr;

		_primary->setPositionX(_contentSize.width/2.0f + - _progress * _contentSize.width);
		_primary->setOpacity(255);
		_primary->setScale(1.0f);
		stopActionByTag("GalleryScrollProgress"_tag);
	} else if (value >= 1.0f) {
		//move forvard
		_progress = 0.0f;

		if (!_secondary) {
			_secondaryId = _primaryId + 1;
			if (_secondaryId < _images.size()) {
				_secondary = construct<GalleryImage>(_images.at(_secondaryId), _imageCallback);
				_secondary->setAnchorPoint(Vec2(0.5f, 0.5f));
				_secondary->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
				_secondary->setContentSize(_contentSize);
				addChild(_secondary, int(_images.size() - _secondaryId));
			}
		}

		_primary->removeFromParent();
		_primaryId = _secondaryId;
		_primary = _secondary;
		_secondary = nullptr;

		_primary->setPositionX(_contentSize.width/2.0f + - _progress * _contentSize.width);
		_primary->setOpacity(255);
		_primary->setScale(1.0f);
		stopActionByTag("GalleryScrollProgress"_tag);
	} else if (value == 0.0f) {
		_progress = value;
		if (_secondary) {
			_secondary->removeFromParent();
			_secondary = nullptr;
		}

		_primary->setPositionX(_contentSize.width/2.0f + - _progress * _contentSize.width);
		_primary->setOpacity(255);
		_primary->setScale(1.0f);
	} else {
		if (_progress == 0) {
			if (_secondary) {
				_secondary->removeFromParent();
				_secondary = nullptr;
			}

			if (value > 0) {
				_secondaryId = _primaryId + 1;
			} else {
				_secondaryId = _primaryId - 1;
			}

			if (_secondaryId < _images.size()) {
				_secondary = construct<GalleryImage>(_images.at(_secondaryId), _imageCallback);
				_secondary->setAnchorPoint(Vec2(0.5f, 0.5f));
				_secondary->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
				_secondary->setContentSize(_contentSize);
				addChild(_secondary, int(_images.size() - _secondaryId));
			}
		}
		_progress = value;

		if (_progress > 0) {
			_primary->setPositionX(_contentSize.width/2.0f + - _progress * _contentSize.width);

			if (_secondary) {
				_secondary->setPositionX(_contentSize.width/2.0);
				_secondary->setOpacity(progress(0, 255, _progress));
				_secondary->setScale(progress(0.75f, 1.0f, _progress));
			}
		} else {
			if (_secondary) {
				_secondary->setPositionX(_contentSize.width/2.0f + ((-1.0 - _progress) * _contentSize.width));
			}

			_primary->setPositionX(_contentSize.width/2.0);
			_primary->setOpacity(progress(0, 255, 1.0f + _progress));
			_primary->setScale(progress(0.75f, 1.0f, 1.0f + _progress));
		}
	}

	if (_positionCallback) {
		_positionCallback(p);
	}
}
Ejemplo n.º 19
0
void GameScene::onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event){
    
    pointList.clear();

    
    Point location = touch->getLocation();
    cur_point = location;
    if((pre_point - cur_point).getLengthSq()>25){
        seg.p1=pre_point;
        seg.p2=cur_point;
        segment.push_back(seg);
        pre_point=cur_point;
    }
    if (p_2dPath.size() < 1){
        return ;
    }
    RecognitionResult result = g_rGemertricRecognizer->recognize(p_2dPath);
    p_2dPath.clear();
    if (result.score<0.70) {
        return;
    }
    size_t len = curWave.size();
    ValueVector temp_vec;
    log(" 剩余数量 :%zd ",curWave.size());
    for (int i =0; i < len; i ++) {
        auto em = curWave.at(i);         // 获取enmey数组  主要目的是获取signarr
        auto emy = curEnWave.at(i);      // 获取sprite
        auto sign = em->getSignArr().back();  // 获取signarr中最上层的一个
        
        //判断最上层标志是否与手势相符
        log("界面图片%d:用户手势%d",sign->getSignType(),this->resultTypeByName(Value(result.name)));
        if (sign->getSignType()==this->resultTypeByName(Value(result.name))) {
            log(" em->getSignArr().capacity()-BEFORE:%zd getSignArrBEFORE:%zd ",emy->getChildrenCount(),em->getSignArr().size());
            emy->removeChildByTag(sign->getTag());
            Vector<Sign*> arr = em->getSignArr();
            arr.eraseObject(sign);
            em->setSignArr(arr);
            arr.clear();
            log(" em->getSignArr().capacity():%zd getSignArr:%zd",emy->getChildrenCount(),em->getSignArr().size());
            if (emy->getChildrenCount() == 0) {               // 移除之后判断有无子精灵
//                em->removeFromParent();      // 没有则销毁该精灵
//                emy->removeFromParent();
//                curWave.eraseObject(em);
//                curEnWave.eraseObject(emy);
                temp_vec.push_back(Value(i));

            }else{
                emy->stopActionByTag(DropActionTag);
                GameScene::startDrop(10.f, emy,true);
            }
        }
        
    }
    //
    size_t curLen = len;
    for(Value val:temp_vec){
        int curIndex = val.asInt();
        this->curWave.at(curIndex)->removeFromParent();
        this->curEnWave.at(curIndex)->removeFromParent();
        this->curWave.erase(curIndex);
        this->curEnWave.erase(curIndex);
        curLen--;
        if (curLen == 0) {
            waveCount++;
            this->curWave.clear();
            this->curEnWave.clear();
            if (waveCount>=1&&waveCount<=3) {
                lvl = 1;
            }else if(waveCount>=4&&waveCount<=8){
                lvl = 2;
            }else if (waveCount>=9&&waveCount<=14){
                lvl = 3;
            }else if (waveCount>14){
                lvl = 4;
            }
            GameScene::addNewEnemyByLevel(lvl);
        }
    }
    temp_vec.clear();
}
Ejemplo n.º 20
0
void HeroSprite::onTouchEnded(Touch *touch, Event *event) {
	stopActionByTag(10);
	getPhysicsBody()->resetForces();
}
Ejemplo n.º 21
0
void Player::update(float dt) {
	//////////爆風に当たってたらゲームオーバーにする///////////
	if (scene->mapcontrol->getblock(getPosition())->firenull() == false) {
		gameover();
	}
	///////enterキーでボム設置///////////////
	if (obsevekey->getkey((Observekey::Key)playerkey.bomset) == 2
		&& bomcon->getChildrenCount()<maximumbom) {
		bomset();
	}
	//////主人公移動////////////////////////
	//主人公がmoveアニメーションしていないとき
	if (getActionByTag(1) == nullptr) {
		static int x = 0, y = 0;
		if (obsevekey->getkey((Observekey::Key)playerkey.right) != 0) {

			if (x == 16 && y == 0) {}
			else {
				setTexture("シロボン右.png");
				stopActionByTag(2);
				runAction(action[RIGHT]);
				x = 16; y = 0;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.left) != 0) {
			if (x == -16 && y == 0) {}
			else {
				setTexture("シロボン左.png");
				stopActionByTag(2);
				runAction(action[LEFT]);
				x = -16; y = 0;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.up) != 0) {
			if (x == 0 && y == 16) {}
			else {
				setTexture("シロボン前.png");
				stopActionByTag(2);
				runAction(action[FRONT]);
				x = 0; y = 16;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.down) != 0) {
			if (x == 0 && y == -16) {}
			else {
				setTexture("シロボン後.png");
				stopActionByTag(2);
				runAction(action[BACK]);
				x = 0; y = -16;
			}
		}
		else { stopActionByTag(2); x = 0; y = 0; return; }
		//移動先に障害物がないとき
		if (scene->mapcontrol->getblock(Vec2(getPositionX() + x,getPositionY() + y))->obstaclecheck() == false) {
			//1ブロック分移動
			auto move = MoveBy::create(speed, Vec2(x, y));
			move->setTag(1);
			runAction(move);
		}

	}
}
Ejemplo n.º 22
0
void StopActionTest::stopAction()
{
    auto sprite = getChildByTag(kTagGrossini);
    sprite->stopActionByTag(kTagSequence);
}