本文整理汇总了C++中CSprite::SetThink方法的典型用法代码示例。如果您正苦于以下问题:C++ CSprite::SetThink方法的具体用法?C++ CSprite::SetThink怎么用?C++ CSprite::SetThink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSprite
的用法示例。
在下文中一共展示了CSprite::SetThink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Think
void CStomp::Think( void )
{
TraceResult tr;
pev->nextthink = gpGlobals->time + 0.1;
// Do damage for this frame
Vector vecStart = GetAbsOrigin();
vecStart.z += 30;
Vector vecEnd = vecStart + (pev->movedir * pev->speed * STOMP_FRAMETIME);
UTIL_TraceHull( vecStart, vecEnd, dont_ignore_monsters, head_hull, ENT(pev), &tr );
if ( tr.pHit && tr.pHit != pev->owner )
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
entvars_t *pevOwner = pev;
if ( pev->owner )
pevOwner = VARS(pev->owner);
if ( pEntity )
pEntity->TakeDamage( pev, pevOwner, gSkillData.gargantuaDmgStomp, DMG_SONIC );
}
// Accelerate the effect
pev->speed = pev->speed + (STOMP_FRAMETIME) * pev->framerate;
pev->framerate = pev->framerate + (STOMP_FRAMETIME) * 1500;
// Move and spawn trails
while ( gpGlobals->time - pev->dmgtime > STOMP_INTERVAL )
{
SetAbsOrigin( GetAbsOrigin() + pev->movedir * pev->speed * STOMP_INTERVAL );
for ( int i = 0; i < 2; i++ )
{
CSprite *pSprite = CSprite::SpriteCreate( GARG_STOMP_SPRITE_NAME, GetAbsOrigin(), TRUE );
if ( pSprite )
{
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector( 0, 0, 500 ), ignore_monsters, edict(), &tr );
pSprite->SetAbsOrigin( tr.vecEndPos );
pSprite->SetAbsVelocity( Vector(RANDOM_FLOAT(-200,200),RANDOM_FLOAT(-200,200),175));
// pSprite->AnimateAndDie( RANDOM_FLOAT( 8.0, 12.0 ) );
pSprite->pev->nextthink = gpGlobals->time + 0.3;
pSprite->SetThink( SUB_Remove );
pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxFadeFast );
}
}
pev->dmgtime += STOMP_INTERVAL;
// Scale has the "life" of this effect
pev->scale -= STOMP_INTERVAL * pev->speed;
if ( pev->scale <= 0 )
{
// Life has run out
UTIL_Remove(this);
STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND );
}
}
}
示例2: Think
void CStomp::Think( void )
{
trace_t tr;
SetNextThink( gpGlobals->curtime + 0.1 );
// Do damage for this frame
Vector vecStart = GetAbsOrigin();
vecStart.z += 30;
Vector vecEnd = vecStart + (m_vecMoveDir * m_flSpeed * gpGlobals->frametime);
UTIL_TraceHull( vecStart, vecEnd, Vector(-32, -32, -32), Vector(32, 32, 32), MASK_SOLID, m_pOwner, COLLISION_GROUP_NONE, &tr );
// NDebugOverlay::Line( vecStart, vecEnd, 0, 255, 0, false, 10.0f );
if ( tr.m_pEnt )
{
CBaseEntity *pEntity = tr.m_pEnt;
CTakeDamageInfo info( this, this, 50, DMG_SONIC );
CalculateMeleeDamageForce( &info, m_vecMoveDir, tr.endpos );
pEntity->TakeDamage( info );
}
// Accelerate the effect
m_flSpeed += (gpGlobals->frametime) * m_uiFramerate;
m_uiFramerate += (gpGlobals->frametime) * 2000;
// Move and spawn trails
while ( gpGlobals->curtime - m_flDmgTime > STOMP_INTERVAL )
{
SetAbsOrigin( GetAbsOrigin() + m_vecMoveDir * m_flSpeed * STOMP_INTERVAL );
for ( int i = 0; i < 2; i++ )
{
CSprite *pSprite = CSprite::SpriteCreate( GARG_STOMP_SPRITE_NAME, GetAbsOrigin(), TRUE );
if ( pSprite )
{
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector(0,0,500), MASK_SOLID, this, COLLISION_GROUP_NONE, &tr );
pSprite->SetAbsOrigin( tr.endpos );
// pSprite->pev->velocity = Vector(RandomFloat(-200,200),RandomFloat(-200,200),175);
pSprite->SetNextThink( gpGlobals->curtime + 0.3 );
pSprite->SetThink( &CSprite::SUB_Remove );
pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxFadeFast );
}
g_pEffects->EnergySplash( tr.endpos, tr.plane.normal );
}
m_flDmgTime += STOMP_INTERVAL;
// Scale has the "life" of this effect
m_flScale -= STOMP_INTERVAL * m_flSpeed;
if ( m_flScale <= 0 )
{
// Life has run out
UTIL_Remove(this);
// STOP_SOUND( edict(), CHAN_BODY, GARG_STOMP_BUZZ_SOUND );
CPASAttenuationFilter filter( this );
StopSound( entindex(), CHAN_STATIC, GARG_STOMP_BUZZ_SOUND );
}
}
}
示例3: RemoveGrenade
void CTFWeaponBaseGrenadeProj::RemoveGrenade( bool bBlinkOut )
{
// Kill it
SetThink( &BaseClass::SUB_Remove );
SetNextThink( gpGlobals->curtime );
SetTouch( NULL );
AddEffects( EF_NODRAW );
if ( bBlinkOut )
{
// Sprite flash
CSprite *pGlowSprite = CSprite::SpriteCreate( NOGRENADE_SPRITE, GetAbsOrigin(), false );
if ( pGlowSprite )
{
pGlowSprite->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxFadeFast );
pGlowSprite->SetThink( &CSprite::SUB_Remove );
pGlowSprite->SetNextThink( gpGlobals->curtime + 1.0 );
}
}
}