Intro::Intro(){ #ifndef WIN32 JNIUtil::jni_music_play("title.ogg"); #endif #ifdef FONT width1_=(m_pFontAtlas->GetFont(AHB_36)->GetWidth("TOUCH TO START")); #endif numframes=sizeof(intro_sequence)/sizeof(const unsigned int); loadTextures(); loops=0; Animation* animation=new Animation(); animation->currentFrame=0; animations.push_back(animation); pos=Vector2D<float>(0,0); myTween.setup(120, 0.3f, -0.7f, Easing::SineEaseInOut,0,2); myTween.play(); //myTween2.setup(30, 0.5f, -0.5f, Easing::SineEaseInOut,0,2); //myTween2.play(); }
///-------------------------------------------------------------- void Scene2::updateEnter() { leaveSceneTimer.reset(); leaveSceneTimer.setup(SettingsManager::getInstance().sceneIdleTimeToArtists * 1000); ofAddListener(leaveSceneTimer.TIMER_COMPLETE , this, &Scene2::leaveSceneTimerCompleteHandler); leaveSceneTimer.start(false); currentClipIndex = (artistIndex * artistOffset) + (artistOffset/2) + SettingsManager::getInstance().abletonFirstClipIndex; ofAddListener(TUIOHandler::getInstance().eventTouchDown, this, &Scene2::tuioPressed); ofAddListener(TUIOHandler::getInstance().eventTouchUp, this, &Scene2::tuioReleased); ofAddListener(TUIOHandler::getInstance().eventTouchDrag, this, &Scene2::tuioDragged); ofAddListener(TUIOHandler::getInstance().eventTouchDownCursor, this, &Scene2::tuioReceiverPressed); ofAddListener(TUIOHandler::getInstance().eventTouchUpCursor, this, &Scene2::tuioReceiverReleased); ofAddListener(TUIOHandler::getInstance().eventTouchDragCursor, this, &Scene2::tuioReceiverDragged); // Request tempo in order to set it on objects ofAddListener(AbletonManager::getInstance().eventTempoChanged, this, &Scene2::tempoChanged); AbletonManager::getInstance().requestTempo(); AbletonManager::getInstance().requestVolumeUpdates(); AbletonManager::getInstance().requestGridUpdates(); switch(backgroundMode) { case SceneBgModeVideo: { videoPlayer.play(); break; } case SceneBgModeImages: { float delay = 0.0f; float duration = 8.0f; float minScale = 1.0f; float maxScale = 1.02f; Tweenzor::add(&bgImageScale, minScale, maxScale, delay, duration, EASE_IN_OUT_SINE); Tween *tweenScale = Tweenzor::getTween(&bgImageScale); tweenScale->setRepeat(-1, true); float minAlpha = 255.0f; float maxAlpha = 0.0f; duration *= 0.7f; Tweenzor::add(&bgImageAlpha, minAlpha, maxAlpha, delay, duration, EASE_IN_OUT_SINE); Tween *tweenAlpha = Tweenzor::getTween(&bgImageAlpha); tweenAlpha->setRepeat(-1, true); break; } case SceneBgModeNone: default: break; } for (unsigned int i=0; i< numObjects; ++i) objects[i]->setup(); AbletonManager::getInstance().playScene(currentClipIndex); BaseScene::updateEnter(); }
Tween *Tween::create(Bone *bone) { Tween *pTween = new (std::nothrow) Tween(); if (pTween && pTween->init(bone)) { pTween->autorelease(); return pTween; } CC_SAFE_DELETE(pTween); return nullptr; }
void TweenManager::Update() { Tween *tween; for(int i=0;i<tweens.size();i++) { if(tweens[i]->isComplete()) { if(tweens[i]->repeat) { tweens[i]->Reset(); return; } else { tween = tweens[i]; tweens.erase(tweens.begin()+i); tween->doOnComplete(); // delete tween; return; } } } }
bool Intro::update(float time) { std::vector<Animation*>::iterator iter = animations.begin(); while (iter != animations.end()) { if(loops%2==0){ (*iter)->currentFrame++; } if((*iter)->currentFrame>=numframes){ (*iter)->currentFrame=0; } iter++; } myTween.update(); //myTween2.update(); loops++; return true; }
void ArmatureAnimation::play(const std::string& animationName, int durationTo, int loop) { if (animationName.empty()) { CCLOG("_animationData can not be null"); return; } // CCASSERT(_animationData, "_animationData can not be null"); _movementData = _animationData->getMovement(animationName); if (nullptr == _movementData) { CCLOG("_movementData can not be null"); return; } // CCASSERT(_movementData, "_movementData can not be null"); //! Get key frame count _rawDuration = _movementData->duration; _movementID = animationName; _processScale = _speedScale * _movementData->scale; //! Further processing parameters durationTo = (durationTo == -1) ? _movementData->durationTo : durationTo; int durationTween = _movementData->durationTween == 0 ? _rawDuration : _movementData->durationTween; cocos2d::tweenfunc::TweenType tweenEasing = _movementData->tweenEasing; loop = (loop < 0) ? _movementData->loop : loop; _onMovementList = false; ProcessBase::play(durationTo, durationTween, loop, tweenEasing); if (_rawDuration == 0) { _loopType = SINGLE_FRAME; } else { if (loop) { _loopType = ANIMATION_TO_LOOP_FRONT; } else { _loopType = ANIMATION_NO_LOOP; } _durationTween = durationTween; } MovementBoneData *movementBoneData = nullptr; _tweenList.clear(); const Map<std::string, Bone*>& map = _armature->getBoneDic(); for(auto& element : map) { Bone *bone = element.second; movementBoneData = static_cast<MovementBoneData *>(_movementData->movBoneDataDic.at(bone->getName())); Tween *tween = bone->getTween(); if(movementBoneData && movementBoneData->frameList.size() > 0) { _tweenList.push_back(tween); movementBoneData->duration = _movementData->duration; tween->play(movementBoneData, durationTo, durationTween, loop, tweenEasing); tween->setProcessScale(_processScale); if (bone->getChildArmature()) { bone->getChildArmature()->getAnimation()->setSpeedScale(_processScale); } } else { if(!bone->isIgnoreMovementBoneData()) { //! this bone is not include in this movement, so hide it bone->getDisplayManager()->changeDisplayWithIndex(-1, false); tween->stop(); } } } _armature->update(0); }
int Worker::handleRequest(queue<double> &inData) { double d; int status = readDouble(coordSocketFd, d); if (status == 0) { inData.push(d); } if (inData.size() >= 3) { int frameNumber = (int)inData.front(); inData.pop(); int column = (int)inData.front(); inData.pop(); int numWorkers = (int)inData.front(); inData.pop(); // cerr << "BEFORE " << mView << endl; // cerr << "FRAME NUMBER " << frameNumber << endl; for (list<Tween*>::iterator it = mTweens.begin(); it != mTweens.end(); it++) { Tween* tween = *it; tween->init(); // cerr << "FRAME NUMBER1 " << frameNumber << endl; // cerr << "FRAME NUMBER2 " << frameNumber << endl; if (tween->type == Tween::TRANSLATE) { Vector3D translateDelta = tween->getTweenDelta(frameNumber); // cerr << "translateDelta " << translateDelta << endl; mEye = mEye + translateDelta; } else if (tween->type == Tween::ROTATE) { // cerr << "BEFORE " << mView << endl; Vector3D rotateDelta = tween->getTweenDelta(frameNumber); // cerr << "DELTA " << rotateDelta << endl; mView = mView + rotateDelta; mSide = mView.cross(mUp); // cerr << "AFTER " << mView << endl; } } WorkPool workPool; for (int i = column; i < this->width; i += numWorkers) { workPool.addJob(i); } pthread_mutex_t lock; pthread_mutex_init(&lock, NULL); struct worker_thread_args args; args.sendLock = &lock; args.workPool = &workPool; args.renderer = this->r; args.height = this->height; args.coordSocketFd = coordSocketFd; vector<pthread_t *> workerThreads; int numThreads = numCPUs; for (int i = 0; i < numThreads; i++) { pthread_t *thread = new pthread_t(); pthread_create(thread, NULL, &testMethod, &args); workerThreads.push_back(thread); } for (int i = 0; i < numThreads; i++) { pthread_t *thread = workerThreads[i]; pthread_join(*thread, NULL); delete thread; } return 1; } return status; }
// // TweenerTests.cpp // // // Created by Ricardo Amores Hernández on 12/6/16. // // #include "catch.hpp" #include "Tween.hpp" TEST_CASE("Test Tween API", "[App]") { SECTION("Initialization setups correct values") { Tween t(0, 10.0, 20.0, Linear::easeIn); REQUIRE_FALSE(t.hasStarted()); REQUIRE_FALSE(t.hasFinished()); REQUIRE_FALSE(t.isRunning()); REQUIRE(t.initialValue() == 0); REQUIRE(t.endValue() == 10); REQUIRE(t.currentValue() == 0); REQUIRE(t.durationMs() == 20.0); } SECTION("Tween needs to be started to work") { Tween t(0, 10.0, 20.0, Linear::easeIn); t.Update(100);
void operator()(int delta) { //but->anim = (int)t.go(delta); int val = (int)t.go(delta); but->setX(150 - (val/2)); but->setWidth(300 + val); }
animate(button* b) { but = b; t.bounds(-20, 20).transition(Tween::TRANSITION_QUAD | Tween::EASING_BOTH).duration(250).loop(); }
//-------------------------------------------------------------- void Tweenzor::add(Tween& tween) { removeTweens(tween.getProperty() ); __instance->_tweens.push_back(&tween ); }