本文整理汇总了C++中setAnimation函数的典型用法代码示例。如果您正苦于以下问题:C++ setAnimation函数的具体用法?C++ setAnimation怎么用?C++ setAnimation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setAnimation函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: find_target
void AGENT::update_fight(GROUP* target_group)
{
// get target
AGENT * t = find_target(target_group); //group->is_single_unit() ? find_target(target_group) : find_target_random(target_group);
if (!t) return; // didn't find one
// fight
move_mult(collision ? 3.0 : 1.0);
set_dest(t->get_x(), t->get_y());
if (dist_dest() > (t->getRadius() + getRadius()) * 2) { // move to target
fight_timer--;
if (!collision) move((int)get_dest_x(), (int)get_dest_y(), true); // move
else collision_avoid(); // collision avoid
state = AGENT::READY_FIGHT;
setAnimation(is_stuckcounter() ? ANIMATION_DATA::STAND : ANIMATION_DATA::MOVE, true);
} else { // at target
move_stop();
state = AGENT::FIGHTING;
if (is_near_dest_angle(45)) { // deal damage
set_dest(x, y);
t->hurt_by(unitData->damage, this);
setAnimation(ANIMATION_DATA::ATTACK, true);
} else { // face target
fight_timer--;
rotate_towards((int)get_angle_dest());
if (!is_near_dest_angle(90)) setAnimation(ANIMATION_DATA::STAND, true);
}
}
// single units sync group position with their own
if (group->is_single_unit()) group->sync_to(this);
// update gemeric stuff
update();
}
开发者ID:destrojan,项目名称:wotwar,代码行数:35,代码来源:agent.cpp
示例2: setAnimation
void Arrow::load_animations(AnimationHolder *animHolder)
{
if (dir_facing & DIR_LEFT)
setAnimation(animHolder->get_anim(ANIM_ARROW_LEFT));
else
setAnimation(animHolder->get_anim(ANIM_ARROW_RIGHT));
}
开发者ID:happypandaface,项目名称:sdl_wii,代码行数:7,代码来源:arrow.cpp
示例3: init
void CC3PODMeshNode::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez )
{
init();
setPodIndex( aPODIndex );
SPODNode* pmn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez );
//LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn));
setName( pmn->pszName );
setPodContentIndex( pmn->nIdx );
setPodParentIndex( pmn->nIdxParent );
if ( pmn->pfAnimPosition )
setLocation( *(CC3Vector*)pmn->pfAnimPosition );
if ( pmn->pfAnimRotation )
setQuaternion( *(CC3Quaternion*)pmn->pfAnimRotation );
if ( pmn->pfAnimScale )
setScale( *(CC3Vector*)pmn->pfAnimScale );
if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)pmn) )
setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)pmn, aPODRez->getAnimationFrameCount() ) );
else if (aPODRez->shouldFreezeInanimateNodes())
setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) );
// If this node has a mesh, build it
if (getPodContentIndex() >= 0) {
setMesh( aPODRez->getMeshAtIndex( getPodContentIndex() ) );
}
// If this node has a material, build it
setPodMaterialIndex( pmn->nIdxMaterial );
if (getPodMaterialIndex() >= 0)
setMaterial( (CC3PODMaterial*)aPODRez->getMaterialAtIndex( getPodMaterialIndex() ) );
}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:33,代码来源:CC3PODMeshNode.cpp
示例4: setAnimation
void Robot_Soldier::updateGameObject(float delta) {
if (AI_STATE != AI_DEAD) {
if (HP <= 0) {
AI_STATE = AI_DEAD;
auto audio = CocosDenshion::SimpleAudioEngine::getInstance();
audio->setEffectsVolume(0.2f);
audio->playEffect("explosion.aif");
if (hsp >= 0) {
setAnimation("robSol_Dead");
player_sprite->setScaleX(1);
}
else {
setAnimation("robSol_Dead");
player_sprite->setScaleX(-1);
}
return;
}
if (hsp > 0) {
setAnimation("robSol_WalkRight");
player_sprite->setScaleX(1);
}
else {
setAnimation("robSol_WalkLeft");
player_sprite->setScaleX(-1);
}
}
else {
hsp *= 0.98;
}
}
开发者ID:Cedfelt,项目名称:Outer-Space-2D,代码行数:34,代码来源:Robot_Soldier.cpp
示例5: setAnimation
void CSimpleEnemy::updateAnimationsCallback(const Ogre::Real fTime) {
for (CWorldEntity *pEnt : dynamic_cast<CharacterControllerPhysics*>(mCCPhysics)->getCollidingWorldEntities()) {
if (dynamic_cast<CCharacter*>(pEnt) && dynamic_cast<CCharacter*>(pEnt)->getFriendOrEnemyState() == FOE_FRIENDLY) {
pEnt->hit(CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis()));
}
}
CSimpleEnemyController::EKIState eKIState = dynamic_cast<CSimpleEnemyController*>(m_pCharacterController)->getCurrentKIState();
if (eKIState == CSimpleEnemyController::KI_PATROLING || eKIState == CSimpleEnemyController::KI_WALK_TO_PLAYER) {
if (m_uiAnimID != SE_ANIM_WALK) {
setAnimation(SE_ANIM_WALK, true);
}
}
else if (eKIState == CSimpleEnemyController::KI_SCOUTING) {
if (m_uiAnimID != SE_ANIM_SCOUT) {
setAnimation(SE_ANIM_SCOUT, true);
}
}
const Ogre::Vector3 vDir = m_pBodyEntity->getParentNode()->convertLocalToWorldOrientation(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedOrientation()).yAxis();
const Ogre::Vector3 vPos = m_pBodyEntity->getParentNode()->convertLocalToWorldPosition(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedPosition());
DebugDrawer::getSingleton().drawLine(vPos, vPos + vDir * 0.1, Ogre::ColourValue::Blue);
createDamage(Ogre::Ray(vPos, vDir * 0.1), CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis()));
}
开发者ID:PaulineMitchell,项目名称:Zelda,代码行数:25,代码来源:SimpleEnemy.cpp
示例6: switch
void Game::onKeyboardKey(KeyboardCodes::Key key, bool pressed)
{
switch (key)
{
case KeyboardCodes::Key::Escape: window.postClose();
break;
case KeyboardCodes::Key::W:
if (pressed)
setAnimation(6);
else
setAnimation(-1u);
//setAnimation(pressed ? "Walk" : nullptr);
walking = pressed;
break;
case KeyboardCodes::Key::Space:
if (pressed)
{
setAnimation(5);
walking = false;
}
break;
case KeyboardCodes::Key::LShift:
cameraMode = pressed;
break;
case KeyboardCodes::Key::RShift:
camera2->getFrustum().addConvexPoint(vector3f(-1., 0., 0.));
break;
}
}
开发者ID:habanero3d,项目名称:habanero3d-current,代码行数:29,代码来源:game.cpp
示例7: ShooterEnemy_onFrame
void ShooterEnemy_onFrame( Object* e )
{
const int STATE_MOVING = 0;
const int STATE_ATTACK1 = MS_TO_FRAMES(750);
const int STATE_ATTACK2 = MS_TO_FRAMES(1000);
if (e->state <= STATE_MOVING) {
if (isVisible(e, (Object*)&player)) {
Object* shot = createObject(level, TYPE_ICESHOT, 0, 0);
shot->x = e->anim.direction > 0 ? e->x + e->type->width : e->x - e->type->width;
shot->y = e->y;
shot->vx *= e->anim.direction;
shot->anim.direction = e->anim.direction;
e->state = STATE_MOVING + 1;
} else if (move(e, e->vx, e->vy, 1)) {
e->vx = -e->vx;
e->anim.direction = -e->anim.direction;
}
setAnimation(e, 1, 2, 24);
} else if (e->state <= STATE_ATTACK1) {
setAnimation(e, 4, 4, 24);
} else if (e->state <= STATE_ATTACK2) {
setAnimation(e, 1, 1, 24);
} else {
e->state = STATE_MOVING;
}
e->state += e->state > STATE_MOVING;
}
开发者ID:artureganyan,项目名称:sdl-platformer,代码行数:32,代码来源:objects.c
示例8: setAnimation
void
Trundler::update()
{
// MOVE IT
int oldX = x;
int oldY = y;
int animMap[] = {TRUNDLER_RIGHT, TRUNDLER_LEFT};
if(inAir)
{
// Fall
field->moveCollidableRel(this, 0, yvel);
if(yvel < 4 && --yvelTimer == 0)
{
yvel++;
yvelTimer = TRUNDLER_FALL_DELAY;
}
// See if we've landed
if(oldY == y)
{
inAir = false;
setAnimation(animMap[dir]);
}
}
else
{
// Move in 'dir' direction
int dirMap[] = {1, -1};
TrundlerDir dirChangeMap[] = {TRUNDLE_LEFT, TRUNDLE_RIGHT};
field->moveCollidableRel(this, dirMap[dir], 0);
if(oldX == x)
{
dir = dirChangeMap[dir];
setAnimation(animMap[dir]);
}
}
// See if we're now suddenly in the air
if(!inAir)
{
if(field->blockEmpty((x+boxX)/32, (y+boxY+boxHeight)/32)
&& field->blockEmpty((x+boxX+boxWidth-1)/32, (y+boxY+boxHeight)/32))
{
inAir = true;
setAnimation(TRUNDLER_PAUSE);
yvel = 1;
yvelTimer = TRUNDLER_FALL_DELAY;
}
}
}
开发者ID:remar,项目名称:castle,代码行数:57,代码来源:Trundler.cpp
示例9: setAnimation
void Player::endLevel(GameProperties* gameProps)
{
pi->playerDied(this);
ending_level = 1;
end_level_anim_time = 0;
if (dir_facing & DIR_RIGHT)
setAnimation(gameProps->getAnimHolder(), ANIM_PLAYER_CUT_UP_RIGHT);
if (dir_facing & DIR_LEFT)
setAnimation(gameProps->getAnimHolder(), ANIM_PLAYER_CUT_UP_LEFT);
}
开发者ID:happypandaface,项目名称:sdl_wii,代码行数:10,代码来源:player.cpp
示例10: millis
bool AlaLedRgb::runAnimation()
{
// skip the refresh if not enough time has passed since last update
unsigned long cTime = millis();
if (cTime < lastRefreshTime + refreshMillis)
return false;
// calculate real refresh rate
refreshRate = 1000/(cTime - lastRefreshTime);
lastRefreshTime = cTime;
if (animSeqLen != 0)
{
if(animSeq[currAnim].duration == 0)
{
setAnimation(animSeq[currAnim].animation, animSeq[currAnim].speed, animSeq[currAnim].palette);
}
else
{
long c = 0;
long t = cTime % animSeqDuration;
for(int i=0; i<animSeqLen; i++)
{
if (t>=c && t<(c+animSeq[i].duration))
{
setAnimation(animSeq[i].animation, animSeq[i].speed, animSeq[i].palette);
break;
}
c = c + animSeq[i].duration;
}
}
}
if (animFunc != NULL)
{
(this->*animFunc)();
// use an 8 bit shift to divide by 256
if((driver==ALA_PWM) || (driver==ALA_BP))
{
int offset = 0;
if (driver==ALA_BP)
offset = 255;
for(int i=0; i<numLeds; i++)
{
int j = 3*i;
analogWrite(pins[j], offset - (leds[i].r*maxOut.r)>>8);
analogWrite(pins[j+1], offset - (leds[i].g*maxOut.g)>>8);
analogWrite(pins[j+2], offset - (leds[i].b*maxOut.b)>>8);
}
}
开发者ID:SnowsongWolf,项目名称:ALA,代码行数:55,代码来源:AlaLedRgb.cpp
示例11: init
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez )
{
init();
setPodIndex( aPODIndex );
SPODNode* psn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez );
//LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn));
setName( psn->pszName );
setPodContentIndex( psn->nIdx );
setPodParentIndex( psn->nIdxParent );
if ( psn->pfAnimPosition )
setLocation( *(CC3Vector*)psn->pfAnimPosition );
if ( psn->pfAnimRotation )
setQuaternion( *(CC3Quaternion*)psn->pfAnimRotation );
if ( psn->pfAnimScale )
setScale( *(CC3Vector*)psn->pfAnimScale );
if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)psn) )
setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)psn, aPODRez->getAnimationFrameCount() ) );
else if (aPODRez->shouldFreezeInanimateNodes())
setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) );
// Get the light content
if (getPodContentIndex() >= 0)
{
SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex());
//LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl));
setPodTargetIndex( psl->nIdxTarget );
setAmbientColor( kCC3DefaultLightColorAmbient );
setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) );
setSpecularColor( kCC3DefaultLightColorSpecular );
setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation,
psl->fLinearAttenuation,
psl->fQuadraticAttenuation) );
switch (psl->eType)
{
case ePODDirectional:
setIsDirectionalOnly( true );
break;
case ePODPoint:
setIsDirectionalOnly( false );
break;
case ePODSpot:
setIsDirectionalOnly( false );
setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) );
setSpotExponent( psl->fFalloffExponent );
break;
default:
break;
}
}
}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:55,代码来源:CC3PODLight.cpp
示例12: setAnimation
void Game::onMouseButton(int x, int y, MouseCodes::Button button, bool down)
{
if (down) switch (button)
{
case MouseCodes::Button::Left:
setAnimation(0);
walking = false;
break;
case MouseCodes::Button::Right:
setAnimation(2);
walking = false;
break;
}
}
开发者ID:habanero3d,项目名称:habanero3d-current,代码行数:14,代码来源:game.cpp
示例13: fwdView
void Orientation::chooseAnimation()
{
//determine the default orientation of the agent
Vec3f fwdView(Config::getParamF(Agent_Param::FwdViewX_F), Config::getParamF(Agent_Param::FwdViewY_F), Config::getParamF(Agent_Param::FwdViewZ_F));
float *rot;
if(fwdView.z > 0 || fwdView.x > 0)
rot = &m_target.y;
else if(fwdView.y > 0) //TODO: well, here we actually have 2 solutions depending on the y-axis rotation, eitehr x is the up axis or z
rot = &m_target.x;
if(*rot > 0)
setAnimation( (*m_anims)[MovementAnimTypes::ORIENT_RIGHT] );
else
setAnimation( (*m_anims)[MovementAnimTypes::ORIENT_LEFT] );
}
开发者ID:xianyinchen,项目名称:Horde3DGameEngine,代码行数:15,代码来源:Orientation.cpp
示例14: while
void Game::run()
{
while (window.processEvents())
{
float time = window.getTimeSinceLastUpdate() * animSpeed / 1000;
logic(time);
player->setParentToLocalR(matrix4f::buildScaling(0.0001f).rotated(vector3f(1, 0, 0), -M_PI / 2).rotated(vector3f(0, 1, 0), dir).translated(pos));
scene->update(time);
if (lastAnimation->weight == 0)
{
setAnimation(-1u);
scene->update(1e-7f);
}
FrameDescription * frame = scene->getFrame(*camera);
//NEWLOG("camera1: %u camera2: %u", camera, camera2);
//frame->dump();
std::vector<MemorySettingOrder> orders;
ResourceManager::getInstance().getMemoryOrders(frame, orders);
Renderer::getInstance().executeMemoryOrders(orders);
Renderer::getInstance().drawFrameToSurface(frame, camera, &window);
delete frame;
window.update();
}
window.close();
}
开发者ID:habanero3d,项目名称:habanero3d-current,代码行数:29,代码来源:game.cpp
示例15: QWidget
SiliTab::SiliTab( QWidget *parent ) : QWidget( parent )
{
p = new SiliTabPrivate;
p->preview = 0;
p->previewer_delay = 1357;
p->previewer_timer = 0;
p->layout = new QHBoxLayout();
p->layout->setContentsMargins( 0 , 0 , 0 , 0 );
p->layout->setSpacing( 1 );
p->baseLayout = new QHBoxLayout( this );
p->baseLayout->setContentsMargins( 0 , 0 , 0 , 0 );
p->baseLayout->setSpacing( 0 );
p->baseLayout->addLayout( p->layout );
p->baseLayout->addSpacerItem( new QSpacerItem( 4 , 2 , QSizePolicy::Expanding , QSizePolicy::Minimum ) );
p->default_items_size = QSize( 137 , 30 );
p->animation = 0;
p->current_item = 0;
p->at_spec_removing = false;
setPreviewer( true );
setAnimation( true );
}
开发者ID:realbardia,项目名称:silicon,代码行数:27,代码来源:silitab.cpp
示例16: getPos
void MosquitoBase::setState(MOSQUITO_STATE state)
{
bool loop = true, blend = false;
float pos[3];
getPos(pos);
if(state == eMosuqitoHit)
{
loop = false;
setBillboard("blood_billboard");
AudioSystem::getInstance()->play3D("../music/spring.wav", pos);
}
else if(state == eMosuqitoCut)
{
loop = false;
setBillboard("blood_billboard");
AudioSystem::getInstance()->play3D("../music/pop.wav", pos);
}
else if(state == eMosquitoBlood)
{
GameSystem::getInstance()->setDrinkTime();
AudioSystem::getInstance()->play3D("../music/kiss.wav", pos);
}
if(m_uiMeshID < GameSystem::getInstance()->m_vMeshData.size())
{
if(state < GameSystem::getInstance()->m_vMeshData[m_uiMeshID].m_vAniName.size())
setAnimation(GameSystem::getInstance()->m_vMeshData[m_uiMeshID].m_vAniName[state].c_str(), loop, blend);
}
m_eState = state;
m_fTimer = 0.0f;
}
开发者ID:templeblock,项目名称:ogre-application,代码行数:30,代码来源:mosquito.cpp
示例17: Item
Spawn::Spawn(uint16_t id,
int16_t x, int16_t y, int16_t z,
int16_t deltaX, int16_t deltaY, int16_t deltaZ,
int8_t heading, int8_t deltaHeading,
uint8_t animation)
: Item(tSpawn, id)
{
// apply the unknown mob values
m_name = "unknown";
setNPC(SPAWN_NPC_UNKNOWN);
// set what is known
setPos(x, y, z);
setDeltas(deltaX, deltaY, deltaZ);
setHeading(heading, deltaHeading);
setAnimation(animation);
// initialize what isn't to 0
setPetOwnerID(0);
setLight(0);
setGender(0);
setDeity(0);
setRace(0);
setClassVal(0);
setHP(0);
setMaxHP(0);
setLevel(0);
for (int i = 0; i < tNumWearSlots; i++)
setEquipment(i, 0);
setTypeflag(0);
setConsidered(false);
// turn on auto delete for the track list
m_spawnTrackList.setAutoDelete(true);
}
开发者ID:xbackupx,项目名称:showeqx,代码行数:35,代码来源:spawn.cpp
示例18: setDescriptionEnabled
void PathStrokeRenderer::mousePressEvent(QMouseEvent *e)
{
if (!m_fingerPointMapping.isEmpty())
return;
setDescriptionEnabled(false);
m_activePoint = -1;
qreal distance = -1;
for (int i=0; i<m_points.size(); ++i) {
qreal d = QLineF(e->pos(), m_points.at(i)).length();
if ((distance < 0 && d < 8 * m_pointSize) || d < distance) {
distance = d;
m_activePoint = i;
}
}
if (m_activePoint != -1) {
m_wasAnimated = m_timer.isActive();
setAnimation(false);
mouseMoveEvent(e);
}
// If we're not running in small screen mode, always assume we're dragging
m_mouseDrag = !m_smallScreen;
m_mousePress = e->pos();
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:25,代码来源:pathstroke.cpp
示例19: Entity
Character::Character(PhysicsWorld& physicsWorld)
: Entity(physicsWorld.createCircleBody(GData::r_width/2, GData::r_height/2, GData::t_size/2)),
walkingSpeed(4.0f),
runningSpeed(8.0f)
{
setAnimation(GData::assets.getAnimation("standing"));
}
开发者ID:ggtucker,项目名称:EtherealGame,代码行数:7,代码来源:Character.cpp
示例20: setFrame
void YYEnemy::updateAnimation(){
if (frameIntervalCount< actualInterval) {
frameIntervalCount ++;
}else{
frameIntervalCount = 0;
if(currentFrameIndex < getCurrentActionData()->endFrameIndex){
currentFrameIndex ++;
setFrame(currentFrameIndex,isFaceToRight());
}else{
isAnimationOver = true;
if(isRepeatAnimation){
currentFrameIndex = getCurrentActionData()->startFrameIndex;
setFrame(currentFrameIndex,isFaceToRight());
}else{
switch (_animationID) {
case ACTION_STAND:
case ACTION_WALK:
currentFrameIndex = getCurrentActionData()->startFrameIndex;
setFrame(currentFrameIndex,_isFaceToRight);
break;
case ACTION_ATTACK_0:
setAnimation(ACTION_STAND, true, isFaceToRight());
setActionState(kActionNormal);
break;
default:
currentFrameIndex = getCurrentActionData()->endFrameIndex;
break;
}
}
}
setPosition(ccpAdd(offsetPerFrame, getPosition()));
}
}
开发者ID:volontin,项目名称:XJ,代码行数:33,代码来源:YYEnemy.cpp
注:本文中的setAnimation函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论