本文整理汇总了C++中SpriteManager类的典型用法代码示例。如果您正苦于以下问题:C++ SpriteManager类的具体用法?C++ SpriteManager怎么用?C++ SpriteManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpriteManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processPunchSound
void GameAudio::processPunchSound()
{
if (soundEffectRegistrationMap[ENUM_SOUND_EFFECT_PUNCH] == true)
{
Game *game = Game::getSingleton();
GameStateManager *gsm = game->getGSM();
SpriteManager *spriteMgr = gsm->getSpriteManager();
PlayerSprite *player = spriteMgr->getPlayer();
wstring playerState = player->getCurrentState();
if (playerState.compare(L"PUNCH_LEFT") == 0 || playerState.compare(L"PUNCH_RIGHT") == 0
|| playerState.compare(L"PUNCH_BACK") == 0 || playerState.compare(L"PUNCH_FRONT") == 0)
{
IXAudio2SourceVoice *punchSound = soundEffectMap[ENUM_SOUND_EFFECT_PUNCH];
XAUDIO2_VOICE_STATE voiceState;
punchSound->GetState(&voiceState);
//// [voiceState.BuffersQueued <= 0] means there are nothing in the buffer
//// so let's make a new buffer to queue the sound
if (voiceState.BuffersQueued <= 0)
{
XAUDIO2_BUFFER *proto = audioBufferPrototypeMap[ENUM_SOUND_EFFECT_PUNCH];
bool ssbSuccess = SUCCEEDED(punchSound->SubmitSourceBuffer(proto));
punchSound->Start();
}
//// if there is something in the buffer
else
{
/// do nothing
}
}
}
}
示例2: GetMomentum
/**\brief Update function on every frame.
*/
void Ship::Update( lua_State *L ) {
Sprite::Update( L ); // update momentum and other generic sprite attributes
if( status.isAccelerating == false
&& status.isRotatingLeft == false
&& status.isRotatingRight == false) {
flareAnimation->Reset();
}
flareAnimation->Update();
Coordinate momentum = GetMomentum();
momentum.EnforceMagnitude( shipStats.GetMaxSpeed()*engineBooster );
// Show the hits taken as part of the radar color
if(IsDisabled()) SetRadarColor( GREY );
else SetRadarColor( RED * GetHullIntegrityPct() );
// Ship has taken as much damage as possible...
// It Explodes!
if( status.hullDamage >= (float)shipStats.GetHullStrength() ) {
SpriteManager *sprites = Simulation_Lua::GetSimulation(L)->GetSpriteManager();
Camera* camera = Simulation_Lua::GetSimulation(L)->GetCamera();
// Play explode sound
if(OPTION(int, "options/sound/explosions")) {
Sound *explodesnd = Sound::Get("Resources/Audio/Effects/18384__inferno__largex.wav.ogg");
explodesnd->Play( GetWorldPosition() - camera->GetFocusCoordinate());
}
// Create Explosion
sprites->Add( new Effect( GetWorldPosition(), "Resources/Animations/explosion1.ani", 0) );
// Remove this Sprite from the SpriteManager
sprites->Delete( (Sprite*)this );
}
示例3: move
void SmartEnemySprite::move()
{
//offscreen
if (offset.x == 0)
{
state = DEAD;
GameWorld::Instance()->activateSmartEnemies();
}
offset.x -= xVel;
if (state == ALIVE)
{
//Consult strategy
if(currentStrategy->shoot())
{
SpriteManager* spriteManager = SpriteManager::Instance();
spriteManager->newEnemyBullet(&offset);
}
}
//If we have finished imploding
if (animation->getCurrentFrame()==5)
{
state = DEAD;
delete animation;
//This will ensure the strategy memory is deallocated
changeStrategy((Strategy*)0);
GameWorld::Instance()->activateSmartEnemies();
GameWorld::Instance()->increaseScore(2500);
}
}
示例4: processHealSound
void GameAudio::processHealSound()
{
if (soundEffectRegistrationMap[ENUM_SOUND_EFFECT_HEAL] == true)
{
Game *game = Game::getSingleton();
GameStateManager *gsm = game->getGSM();
SpriteManager *spriteMgr = gsm->getSpriteManager();
PlayerSprite *player = spriteMgr->getPlayer();
bool isHealing = player->getIshealing();
if (isHealing == true)
{
IXAudio2SourceVoice *healSound = soundEffectMap[ENUM_SOUND_EFFECT_HEAL];
XAUDIO2_VOICE_STATE voiceState;
healSound->GetState(&voiceState);
//// [voiceState.BuffersQueued <= 0] means there are nothing in the buffer
//// so let's make a new buffer to queue the sound
if (voiceState.BuffersQueued <= 0)
{
XAUDIO2_BUFFER *proto = audioBufferPrototypeMap[ENUM_SOUND_EFFECT_HEAL];
bool ssbSuccess = SUCCEEDED(healSound->SubmitSourceBuffer(proto));
healSound->Start();
//// After all, there will be only one buffer node in the queue always ...
}
//// if there is something in the buffer
else
{
/// do nothing
}
}
}
}
示例5: handleMousePressEvent
void WalkaboutMouseEventHandler::handleMousePressEvent(Game *game, int mouseX, int mouseY)
{
if (game->getGSM()->isGameInProgress())
{
Viewport *viewport = game->getGUI()->getViewport();
// DETERMINE WHERE ON THE MAP WE HAVE CLICKED
int worldCoordinateX = mouseX + viewport->getViewportX();
int worldCoordinateY = mouseY + viewport->getViewportY();
SpriteManager *spriteManager = game->getGSM()->getSpriteManager();
Player* player = static_cast<Player*>(spriteManager->getPlayer());
PhysicalProperties* playerPP = spriteManager->getPlayer()->getPhysicalProperties();
if(!player->getIsDead() && !player->getIsDying() && player->getAmmo() != 0)
{
float dx = worldCoordinateX - playerPP->getX();
float dy = worldCoordinateY - playerPP->getY();
float distanceToMouse = sqrtf(dx*dx + dy*dy);
dx /= distanceToMouse;
dy /= distanceToMouse;
float bulletOffset = 60;
float bulletSpeed = 50;
//Fire projectile
spriteManager->createProjectile(playerPP->getX() + bulletOffset*dx, playerPP->getY() + bulletOffset*dy,
bulletSpeed*dx,bulletSpeed*dy);
player->decrementAmmo();
}
}
}
示例6: loadTexture
Sprite::Sprite(const Sprite& _other) {
mRect.x = _other.mRect.x;
mRect.y = _other.mRect.y;
mElevation = _other.mElevation;
mFile = _other.mFile;
loadTexture(*mFile);
SpriteManager* manager = SpriteManager::getInstance();
manager->addSprite(*this);
}
示例7: RenderScene
void RenderScene(void)
{
static clock_t lastTime = 0;
clock_t now;
now = clock();
SpriteManager* sprites = SpriteManager::instance();
if (!isPaused && now -lastTime > CLOCKS_PER_SEC/60) {
sprites->update();
}
lastTime = now;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
Matrix4f ViewProjectionMatrix;
if (!cameraLock) {
ViewProjectionMatrix = projectionMatrix * camera;
}else{
ViewProjectionMatrix = projectionMatrix * player->getCamera();
}
/*
GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f };
glUseProgram( shader.program );
glUniform4f( shader.uniforms.colour, vRed[0], vRed[1], vRed[2], vRed[3] );
Matrix4f modelView;
//modelView.rotate( [0], rotation[1], rotation[2]);
modelView.translate( 0, 0, 5 );
Matrix4f modelViewProjectionMatrix =ViewProjectionMatrix * modelView;
modelViewProjectionMatrix.loadUniform( shader.uniforms.modelViewProjectionMatrix);
test->draw( shader.attributes.pos );
*/
sprites->draw( ViewProjectionMatrix, shader);
// Perform the buffer swap to display back buffer
glutSwapBuffers();
glutPostRedisplay();
}
示例8: LogMsg
/**\brief The last function call to the ship before it get's deleted
*
* At this point, the ship still exists. It has not been removed from the Universe
*
* \note We don't want to make this a destructor call because we want the rest
* of the system to still treat the ship normally.
*/
void AI::Killed( lua_State *L ) {
LogMsg( WARN, "AI %s has been killed\n", GetName().c_str() );
SpriteManager *sprites = Simulation_Lua::GetSimulation(L)->GetSpriteManager();
Sprite* killer = sprites->GetSpriteByID( target );
if(killer != NULL) {
if( killer->GetDrawOrder() == DRAW_ORDER_PLAYER ) {
((Player*)killer)->UpdateFavor( this->GetAlliance()->GetName(), -1 );
}
}
}
示例9:
Sprite::Sprite(int _width, int _height) {
mRect.x = 0;
mRect.y = 0;
mRect.w = _width;
mRect.h = _height;
mOriginalRect = mRect;
mElevation = 0;
mTexture = NULL;
SpriteManager* manager = SpriteManager::getInstance();
manager->addSprite(*this);
}
示例10: handleMousePressEvent
void ScienceMouseEventHandler::handleMousePressEvent(Game *game, int mouseX, int mouseY)
{
if (game->getGSM()->isGameInProgress())
{
Viewport *viewport = game->getGUI()->getViewport();
// DETERMINE WHERE ON THE MAP WE HAVE CLICKED
int worldCoordinateX = mouseX + viewport->getViewportX();
int worldCoordinateY = mouseY + viewport->getViewportY();
// NOW LET'S SEE IF THERE IS A SPRITE THERE
GameStateManager *gsm = game->getGSM();
SpriteManager *spriteManager = gsm->getSpriteManager();
// IF THERE IS NO SELECTED SPRITE LOOK FOR ONE
if (!(spriteManager->getIsSpriteSelected()))
{
// IF THIS DOES NOT RETURN NULL THEN YOU FOUND A SPRITE AT THAT LOCATION
if((spriteManager->getSpriteAt(worldCoordinateX, worldCoordinateY) != NULL))
{
AnimatedSprite *selected = spriteManager->getSpriteAt(worldCoordinateX, worldCoordinateY);
spriteManager->setIsSpriteSelected(true);
}
}
else if (spriteManager->getSelectedSprite() != NULL)
{
// MOVE A SPRITE IN A DESIRED DIRECTION
AnimatedSprite *selected = spriteManager->getSelectedSprite();
PhysicalProperties *pp = selected->getPhysicalProperties();
float spriteX = pp->getX();
float spriteY = pp->getY();
//IF A SPRITE IS WHERE YOU WANT IT THEN STOP IT
if (((spriteX > worldCoordinateX - 64) && (spriteX < worldCoordinateX + 64)) && (spriteY > worldCoordinateY - 64) && (spriteY < worldCoordinateY + 64))
{
pp->setVelocity(0, 0);
}
else
{
float deltaX = worldCoordinateX - spriteX;
float deltaY = worldCoordinateY - spriteY;
float hyp = sqrtf((deltaX * deltaX) + (deltaY * deltaY));
pp->setVelocity((deltaX / hyp) * 3, (deltaY / hyp) * 3);
}
spriteManager->setIsSpriteSelected(false);
// GridPathfinder *pathfinder = spriteManager->getPathfinder();
// pathfinder->mapPath(selected, (float)worldCoordinateX, (float)worldCoordinateY);
// gsm->setSpriteSelected(false, selected);
}
else
{
spriteManager->setIsSpriteSelected(false);
}
}
}
示例11: main
int main(int argc, char** argv){
StringHelper::init();
Log >> new ConsoleLogger();
//Set filter to include all.
Log.setLevelFilter(LogManager::ll_Verbose);
for(int i = 1; i < argc; i+=2){
Log << argv[i] << " to " << argv[i+1];
SpriteManager manager;
manager.loadRaw(argv[i]);
manager.save(argv[i+1]);
}
Log.close();
return 0;
}
示例12: Draw
void Radar::Draw( SpriteManager &sprites ) {
short int radar_mid_x = RADAR_MIDDLE_X + Video::GetWidth() - 129;
short int radar_mid_y = RADAR_MIDDLE_Y + 5;
int radarSize;
const list<Sprite*>& spriteList = sprites.GetSprites();
for( list<Sprite*>::const_iterator iter = spriteList.begin(); iter != spriteList.end(); iter++)
{
Coordinate blip( -(RADAR_HEIGHT / 2.0), (RADAR_WIDTH / 2.0), (RADAR_HEIGHT / 2.0), -(RADAR_WIDTH / 2.0) );
Sprite *sprite = *iter;
if( sprite->GetDrawOrder() == DRAW_ORDER_PLAYER ) continue;
// Calculate the blip coordinate for this sprite
Coordinate wpos = sprite->GetWorldPosition();
WorldToBlip( wpos, blip );
if( blip.ViolatesBoundary() == false ) {
/* blip is on the radar */
/* Convert to screen coords */
blip.SetX( blip.GetX() + radar_mid_x );
blip.SetY( blip.GetY() + radar_mid_y );
radarSize = int((sprite->GetRadarSize() / float(visibility)) * (RADAR_HEIGHT/4.0));
Video::DrawCircle(
blip,
(radarSize>=1) ?radarSize: 1,
1,
sprite->GetRadarColor() );
}
}
}
示例13: main
int main()
{
GameManager gm;
RenderSystem rs(gm);
SpriteManager sm;
Sprite* s = sm.loadSprite("data/sprites/HorrifyingSmiley.png");
Sprite* s2 = sm.loadSprite("data/sprites/Circle.png");
//PrintTransformSystem pts(gm);
//gm.addSystem(pts);
gm.addSystem(rs);
Entity& player = gm.createEntity("player");
TransformComponent* tc = gm.addComponentToEntity<TransformComponent>(player);
tc->position.x = 100;
tc->position.y = 100;
SpriteComponent* sc = gm.addComponentToEntity<SpriteComponent>(player);
sc->sprite = s;
Entity& test2 = gm.createEntity("test2");
//Might as well reuse these
tc = gm.addComponentToEntity<TransformComponent>(test2);
tc->position.x = 500;
tc->position.y = 150;
sc = gm.addComponentToEntity<SpriteComponent>(test2);
sc->sprite = s2;
Input::initInput();
Input::addMapping("Up", 'W');
Input::addMapping("Up", Input::Keys::UP);
Input::addMapping("Down", 'S');
Input::addMapping("Down", Input::Keys::DOWN);
Input::addMapping("Exit", 'Q');
Input::addMapping("Exit", 'P');
Input::addMapping("Exit", Input::Keys::ESC);
for(int i =0; i < 10; i++){
Entity& e = gm.createEntity("whatevs");
TransformComponent* tComp = gm.addComponentToEntity<TransformComponent>(e);
tComp->position.x = (i * 100);// % 800;
tComp->position.y = (i * 100);// % 600;
SpriteComponent* spr = gm.addComponentToEntity<SpriteComponent>(e);
if(i % 2 == 0)
spr->sprite = s2;
else
spr->sprite = s;
spr->layer = i;
}
gm.run();
}
示例14: Update
void Gate::Update() {
// The Bottom Gate doesn't do anything
if(!top) return;
SpriteManager *sprites = SpriteManager::Instance();
Sprite* ship = sprites->GetNearestSprite( (Sprite*)this, 50,DRAW_ORDER_SHIP|DRAW_ORDER_PLAYER );
if(ship!=NULL) {
if(exitID != 0) {
SendToExit(ship);
} else if(rand()&1) {
SendToRandomLocation(ship);
} else {
SendRandomDistance(ship);
}
}
}
示例15: switch
Image * Sprite::GetSpriteSheetImageNoCache()
{
SpriteManager *pSpriteManager = NULL;
switch (managerSource)
{
case ManagerSourceCaseFile:
pSpriteManager = Case::GetInstance()->GetSpriteManager();
break;
case ManagerSourceCommonResources:
pSpriteManager = CommonCaseResources::GetInstance()->GetSpriteManager();
break;
}
return pSpriteManager->GetImageFromId(spriteSheetImageId);
}