void Game::SpawnExplosion(int x, int y) { Explosion* explosion = new Explosion(); explosion->SetPositionX(x - 10); explosion->SetPositionY(y - 10); AnimatedSprite* exploding = m_pBackBuffer->CreateAnimatedSprite("assets\\explosion.png"); exploding->SetLooping(false); exploding->SetFrameWidth(64); exploding->SetFrameSpeed(0.05); exploding->AddFrame(0); exploding->AddFrame(64); exploding->AddFrame(128); exploding->AddFrame(192); exploding->AddFrame(256); explosion->Initialise(exploding); Explosions.push_back(explosion); }
void Game::SpawnExplosion(int x, int y) { Sprite* aS = m_pBackBuffer->CreateSprite("assets\\explosion.png"); // create an explosion object Explosion* explosion = new Explosion(); // initialize the texture if (!explosion->Initialise(*aS->GetTexture())) { LogManager::GetInstance().Log("Explosion Init Fail!"); return; } // set the width and speed of the animation int fw = aS->GetWidth() / 5; explosion->SetFrameWidth(fw); // 5 frames in the animation explosion->SetFrameSpeed(0.1f); for (int i = 0; i < 5; i++) { explosion->AddFrame(i * fw); } // set the center points for visual alignment explosion->SetCenter(fw / 2, aS->GetHeight() / 2); // set the x and y explosion->SetX(x - explosion->GetCenterX() / 2); explosion->SetY(y - explosion->GetCenterY() / 2); // add to the explosion container m_explosion.push_back(explosion); }