本文整理汇总了C++中CSprite类的典型用法代码示例。如果您正苦于以下问题:C++ CSprite类的具体用法?C++ CSprite怎么用?C++ CSprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Spawn
//=========================================================
// Spawn
//=========================================================
void CGargantua :: Spawn()
{
Precache( );
if (pev->model)
SET_MODEL(ENT(pev), STRING(pev->model)); //LRC
else
SET_MODEL(ENT(pev), "models/garg.mdl");
UTIL_SetSize( pev, Vector( -32, -32, 0 ), Vector( 32, 32, 64 ) );
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_GREEN;
if (!pev->health) pev->health = gSkillData.gargantuaHealth;
//pev->view_ofs = Vector ( 0, 0, 96 );// taken from mdl file
m_flFieldOfView = -0.2;// width of forward view cone ( as a dotproduct result )
m_MonsterState = MONSTERSTATE_NONE;
MonsterInit();
m_pEyeGlow = CSprite::SpriteCreate( GARG_EYE_SPRITE_NAME, GetAbsOrigin(), FALSE );
m_pEyeGlow->SetTransparency( kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation );
m_pEyeGlow->SetAttachment( edict(), 1 );
EyeOff();
m_seeTime = gpGlobals->time + 5;
m_flameTime = gpGlobals->time + 2;
}
示例2: Precache
void CNPC_ControllerZapBall::Spawn( void )
{
Precache( );
// motor
SetMoveType( MOVETYPE_FLY );
// SetSolid( SOLID_CUSTOM );
SetSolid( SOLID_BBOX );
SetSize( vec3_origin, vec3_origin );
m_pSprite = CSprite::SpriteCreate( "sprites/xspark4.vmt", GetAbsOrigin(), FALSE );
m_pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 255, kRenderFxNoDissipation );
m_pSprite->SetAttachment( this, 0 );
m_pSprite->SetScale( 0.5 );
UTIL_SetSize( this, Vector( 0, 0, 0), Vector(0, 0, 0) );
UTIL_SetOrigin( this, GetAbsOrigin() );
SetThink( &CNPC_ControllerZapBall::AnimateThink );
SetTouch( &CNPC_ControllerZapBall::ExplodeTouch );
m_hOwner = GetOwnerEntity();
m_flSpawnTime = gpGlobals->curtime; // keep track of when ball spawned
SetNextThink( gpGlobals->curtime + 0.1 );
}
示例3: setY
void CPosition::setY(int _y) {
y = _y;
CSprite * sprite = (CSprite *) parent->getComponent("Sprite");
if ( sprite != NULL ) {
sprite->updatePosition();
}
}
示例4: setX
void CPosition::setX(int _x) {
x = _x;
CSprite * sprite = (CSprite *) parent->getComponent("Sprite");
if ( sprite != NULL ) {
sprite->updatePosition();
}
}
示例5: Hadoken
void Game::InitialiseHadoken(CSprite* previous, bool isAI)
{
Hadoken* temp = new Hadoken();
temp->m_X = previous->m_X;
temp->m_Y = previous->m_Y;
temp->SetImage(g_pResources->getSettingsButton());
temp->m_AnchorX = previous->m_AnchorX;
temp->m_AnchorY = previous->m_AnchorY;
// Fit player to Device size
temp->m_ScaleX = (float)(ScreenWidth / 8) / temp->GetImage()->GetWidth();
temp->m_ScaleY = temp->m_ScaleX;
temp->setWidth(ScreenWidth / 8);
projectiles[isAI].push_back(temp);
CSprite* tempLine = new CSprite();
tempLine->m_X = player[isAI]->m_X + (temp->getWidth() / 2);
tempLine->m_Y = player[isAI]->m_Y;
tempLine->m_AnchorX = 0.5;
tempLine->m_AnchorY = (float)(isAI); /*1.0 for AI, 0.0 fir player*/
tempLine->SetImage(g_pResources->getGreenImage());
tempLine->m_ScaleX = (float)(ScreenWidth / 50) / lifeBars[isAI]->GetImage()->GetWidth();
projectileLines[isAI].push_back(tempLine);
AddChild(projectileLines[isAI].back());
ResizeLine(tempLine, isAI, projectiles[isAI].back()->m_Y);
//we add teh hadoken after to remove overlap
AddChild(projectiles[isAI].back());
}
示例6: CImage
void PlayState::init()
{
vertical = 1;
count = 0;
background = new CImage();
background->loadImage("data/maps/black.png");
while(count != 7){
CSprite* enemy = new CSprite();
enemy->loadSpriteSparrowXML("data/img/bug.xml");
if(count > 2) vertical = 3;
enemy->setPosition((count%3)*125,50*vertical);
enemy->setAnimRate(0);
enemies[count] = enemy;
count++;
}
player = new CSprite();
player->loadSpriteSparrowXML("data/img/spaceship.xml");
player->setPosition(172,550);
player->setAnimRate(0);
dirx = 0; // direção do personagem: para a direita (5), esquerda (-5)
diry = 0; // direção do personagem: para cima (5), baixo (-5)
keyState = SDL_GetKeyState(0); // get key state array
cout << "PlayState Init Successful" << endl;
}
示例7: CREATE_ENTITY
void CSquidSpit::Shoot( CBaseEntity *pOwner, Vector vecStart, Vector vecVelocity )
{
CSquidSpit *pSpit = CREATE_ENTITY( CSquidSpit, "squidspit" );
pSpit->Spawn();
UTIL_SetOrigin( pSpit, vecStart );
pSpit->SetAbsVelocity( vecVelocity );
pSpit->SetOwnerEntity( pOwner );
CSprite *pSprite = (CSprite*)pSpit->GetSprite();
if ( pSprite )
{
pSprite->SetAttachment( pSpit, 0 );
pSprite->SetOwnerEntity( pSpit );
pSprite->SetScale( 0.5 );
pSprite->SetTransparency( pSpit->m_nRenderMode, pSpit->m_clrRender->r, pSpit->m_clrRender->g, pSpit->m_clrRender->b, pSpit->m_clrRender->a, pSpit->m_nRenderFX );
}
CPVSFilter filter( vecStart );
VectorNormalize( vecVelocity );
te->SpriteSpray( filter, 0.0, &vecStart , &vecVelocity, pSpit->m_nSquidSpitSprite, 210, 25, 15 );
}
示例8: RectBody
bool LevelScene::onTouchBegan(Touch* touch, Event* event) {
Point point = this->convertTouchToNodeSpace(touch);
this->isMoved = false;
this->isTouched = false;
RectBody* chapterLayerBody = new RectBody(this->levelLayer->getContentSize().width, this->levelLayer->getContentSize().height);
chapterLayerBody->setPosition(this->levelLayer->getPosition() + Point(chapterLayerBody->getWidth() / 2, chapterLayerBody->getHeight() / 2));
if (chapterLayerBody->contains(point)) {
this->isTouched = true;
this->firstPoint = point;
// update flash
{
Point point = this->convertTouchToNodeSpace(touch);
point = point - this->levelLayer->getPosition();
for (int i = 0; i < this->levelLayer->getChildren().size(); i++) {
CSprite* levelFace = dynamic_cast<CSprite*>(this->levelLayer->getChildren().at(i));
if (levelFace != NULL) {
RectBody* levelBody = new RectBody(levelFace->getContentSize().width, levelFace->getContentSize().height);
levelBody->setPosition(levelFace->getPosition());
}
}
}
return true;
}
return false;
}
示例9: Spawn
// UNDONE: right now this is pretty much a copy of the squid spit with minor changes to the way it does damage
void CBMortar:: Spawn( void )
{
SetMoveType( MOVETYPE_FLYGRAVITY );
SetClassname( "bmortar" );
SetSolid( SOLID_BBOX );
pSprite = CSprite::SpriteCreate( "sprites/mommaspit.vmt", GetAbsOrigin(), true );
if ( pSprite )
{
pSprite->SetAttachment( this, 0 );
pSprite->m_flSpriteFramerate = 5;
pSprite->m_nRenderMode = kRenderTransAlpha;
pSprite->SetBrightness( 255 );
m_iFrame = 0;
pSprite->SetScale( 2.5f );
}
UTIL_SetSize( this, Vector( 0, 0, 0), Vector(0, 0, 0) );
m_maxFrame = (float)modelinfo->GetModelFrameCount( GetModel() ) - 1;
m_flDmgTime = gpGlobals->curtime + 0.4;
}
示例10: CreateCombination
// This is where the bones of the project are forged
// (loading sprites, for example)
BOOL CGameLogic::Init(CGame *game)
{
// Initialize the combination
m_combo = CreateCombination();
m_nodes = m_combo;
for (unsigned i = 0; i < m_nodes.size(); i++)
m_nodes[i] = i;
// Load sprites
auto path = game->GetExecutablePath();
// Slider (Mid-section)
CSprite *spr = nullptr;
if (!LoadSprite(path, L"sliderMid.png", game->GetRenderer(), &spr))
return FALSE;
m_sprites.push_back(spr);
spr->SetPosition(0, 0);
// Slider (nodes)
for (auto i = 0; i < 5; i++) {
spr = nullptr;
if (!LoadSprite(path, L"sliderNode.png", game->GetRenderer(), &spr))
return FALSE;
m_sprites.push_back(spr);
}
return TRUE;
}
示例11: GetSprite
void CGib::DieThink ( void )
{
if ( GetSprite() )
{
CSprite *pSprite = dynamic_cast<CSprite*>( GetSprite() );
if ( pSprite )
{
pSprite->FadeAndDie( 0.0 );
}
}
if ( GetFlame() )
{
CEntityFlame *pFlame = dynamic_cast< CEntityFlame*>( GetFlame() );
if ( pFlame )
{
pFlame->SetLifetime( 1.0f );
}
}
if ( g_pGameRules->IsMultiplayer() )
{
UTIL_Remove( this );
}
else
{
SetThink ( &CGib::SUB_FadeOut );
SetNextThink( gpGlobals->curtime );
}
}
示例12: glTexEnvi
void CEntity::RenderRallyPoint()
{
if( !m_visible )
return;
/*
if ( !entf_get(ENTF_HAS_RALLY_POINT) ||
g_Selection.m_unitUITextures.find(m_base->m_rallyName) == g_Selection.m_unitUITextures.end() )
{
return;
}
*/
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, g_Renderer.m_Options.m_LodBias);
CSprite sprite;
CTexture tex;
// tex.SetHandle( g_Selection.m_unitUITextures[m_base->m_rallyName] );
sprite.SetTexture(&tex);
// Place the sprite slightly above ground/water level.
float terrainHeight = g_Game->GetWorld()->GetTerrain()->GetExactGroundLevel(m_rallyPoint);
float height = std::max(terrainHeight, g_Renderer.GetWaterManager()->m_WaterHeight) + 0.5f;
CVector3D rally(m_rallyPoint.x, height, m_rallyPoint.y);
sprite.SetTranslation(rally);
sprite.Render();
}
示例13: onTouchMoved
void LevelScene::onTouchMoved(Touch* touch, Event* event) {
Point point = this->convertTouchToNodeSpace(touch);
Point vectorMove = Point::ZERO;
if (!this->isMoved) {
vectorMove = point - this->firstPoint;
} else {
vectorMove = point - this->movePoint;
}
this->updateLevelLayer(vectorMove);
this->movePoint = point;
this->isMoved = true;
// update flash
{
Point point = this->convertTouchToNodeSpace(touch);
point = point - this->levelLayer->getPosition();
for (int i = 0; i < this->levelLayer->getChildren().size(); i++) {
CSprite* levelFace = dynamic_cast<CSprite*>(this->levelLayer->getChildren().at(i));
if (levelFace != NULL) {
RectBody* levelBody = new RectBody(levelFace->getContentSize().width, levelFace->getContentSize().height);
levelBody->setPosition(levelFace->getPosition());
}
}
}
}
示例14: Render
void CBoard::Render()
{
if (m_pBoard)
{
m_pBoard->Render();
}
for (int i = 0; i < 9; i++)
{
int x = i / 3;
int y = i % 3;
if ( IsTileFree( x, y ) )
{
continue;
}
CSprite *pIcon = m_iMatrix[x][y] == PLAYER_X ? m_pX : m_pO;
if (!pIcon)
{
continue;
}
pIcon->SetPosition( (x-1)*DELTA_WIDTH, (y-1)*DELTA_HEIGHT );
pIcon->SetScale( SCALE );
pIcon->Render();
}
}
示例15: UTIL_Remove
//=========================================================
// WaitTillLand - in order to emit their meaty scent from
// the proper location, gibs should wait until they stop
// bouncing to emit their scent. That's what this function
// does.
//=========================================================
void CGib::WaitTillLand ( void )
{
if (!IsInWorld())
{
UTIL_Remove( this );
return;
}
if ( GetAbsVelocity() == vec3_origin )
{
SetRenderAlpha( 255 );
m_nRenderMode = kRenderTransTexture;
if ( GetMoveType() != MOVETYPE_VPHYSICS )
{
AddSolidFlags( FSOLID_NOT_SOLID );
}
SetLocalAngularVelocity( vec3_angle );
SetNextThink( gpGlobals->curtime + m_lifeTime );
SetThink ( &CGib::SUB_FadeOut );
if ( GetSprite() )
{
CSprite *pSprite = dynamic_cast<CSprite*>( GetSprite() );
if ( pSprite )
{
//Adrian - Why am I doing this? Check InitPointGib for the answer!
if ( m_lifeTime == 0 )
m_lifeTime = random->RandomFloat( 1, 3 );
pSprite->FadeAndDie( m_lifeTime );
}
}
if ( GetFlame() )
{
CEntityFlame *pFlame = dynamic_cast< CEntityFlame*>( GetFlame() );
if ( pFlame )
{
pFlame->SetLifetime( 1.0f );
}
}
// If you bleed, you stink!
if ( m_bloodColor != DONT_BLEED )
{
// ok, start stinkin!
// FIXME: It's too easy to fill up the sound queue with all these meat sounds
// CSoundEnt::InsertSound ( SOUND_MEAT, GetAbsOrigin(), 384, 25 );
}
}
else
{
// wait and check again in another half second.
SetNextThink( gpGlobals->curtime + 0.5f );
}
}