void Enemy::moveUp(int px) { Action GoUp; GoUp.is_blocking = true; GoUp.thread_id = 1; Action AnimReset; AnimReset.is_blocking = true; AnimReset.thread_id = 1; GoUp.action = get_action([this, px](sf::Time dt) { if (getAnimationState() != static_cast<int>(Animations::GoUp)) { animation.play(); changeAnimation(static_cast<int>(Animations::GoUp)); getAnimation().play(); } return goUpUntil(px, dt); }); AnimReset.action = get_action([this](sf::Time dt) { animation.reset(); return false; }); action_tree.push(GoUp); action_tree.push(AnimReset); }
void Npc::moveUp(int px) { Action GoUp; Action AnimReset; GoUp.action = get_action<Npc>([this, px](Npc &npc, sf::Time dt) { if (getAnimationState() != static_cast<int>(Animations::GoUp)) { animation.play(); changeAnimation(static_cast<int>(Animations::GoUp)); getAnimation().play(); } return goUpUntil(px); }); AnimReset.action = get_action<Npc>([this](Npc &npc, sf::Time dt) { animation.reset(); return false; }); action_queue.push(GoUp); action_queue.push(AnimReset); }
void Game::createScene() { sinbad = new GameObject("sinbad", "Sinbad.mesh", mSceneMgr->getRootSceneNode(), mSceneMgr); sinbad->setVelocity(Ogre::Vector3(25, 0, 25)); auto ent = static_cast<Ogre::Entity*>(sinbad->getNode()->getAttachedObject("sinbad")); ent->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE); const auto setupAnimPair = [&](int i, const std::string& name) { animStates[i] = ent->getAnimationState(name + "Base"); animStates[i + 1] = ent->getAnimationState(name + "Top"); for (int j = i; j < i + 1; ++j) { animStates[j]->setLoop(true); animStates[j]->setEnabled(false); } }; setupAnimPair(0, "Idle"); setupAnimPair(2, "Run"); }
void Enemy::die() { Action die; die.thread_id = 0; die.action = get_action([this](sf::Time dt) { if (getAnimationState() != static_cast<int>(Animations::Die)) { changeAnimation(static_cast<int>(Animations::Die)); animation.play(); } return animation.isEndLoop(); }); action_tree.push(die); }
void LLFloaterAO::onComboBoxCommit(LLUICtrl* ctrl, void* userdata) { LLComboBox* box = (LLComboBox*)ctrl; if(box) { if (box->getName() == "stand") { stand_iterator = box->getCurrentIndex(); if (mAOStandTimer) mAOStandTimer->reset(); ChangeStand(TRUE); } else { std::string stranim = box->getValue().asString(); for (std::vector<struct_combobox>::iterator iter = mComboBoxes.begin(); iter != mComboBoxes.end(); ++iter) { if (box->getName() == iter->name) { gSavedPerAccountSettings.setString("PhoenixAODefault"+iter->name,stranim); int boxstate = iter->state; for (std::vector<struct_default_anims>::iterator iter = mAODefaultAnims.begin(); iter != mAODefaultAnims.end(); ++iter) { if (boxstate == iter->state) { iter->ao_id = GetAnimIDByName(stranim); if (getAnimationState() == boxstate) // only play anim for the current state, change sits for example { startAOMotion(iter->ao_id,TRUE,TRUE); } return; } } } } } } }
//--------------------------------------------------------------------- AnimationStateSet::AnimationStateSet(const AnimationStateSet& rhs) : mDirtyFrameNumber(std::numeric_limits<unsigned long>::max()) { // lock rhs OGRE_LOCK_MUTEX(rhs.OGRE_AUTO_MUTEX_NAME); for (AnimationStateMap::const_iterator i = rhs.mAnimationStates.begin(); i != rhs.mAnimationStates.end(); ++i) { AnimationState* src = i->second; mAnimationStates[src->getAnimationName()] = OGRE_NEW AnimationState(this, *src); } // Clone enabled animation state list for (EnabledAnimationStateList::const_iterator it = rhs.mEnabledAnimationStates.begin(); it != rhs.mEnabledAnimationStates.end(); ++it) { const AnimationState* src = *it; mEnabledAnimationStates.push_back(getAnimationState(src->getAnimationName())); } }