Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Legacy

Pages: [1]
1
Graphics / [Solved] Sprite Fade Out?
« on: September 28, 2011, 09:42:00 pm »
Hey, i'm kinda new to these forums, although i have been reading up a few threads here and there. But i couldn't quite find a thread to my problem that fixes it. So im sorry if you have read topics like this before.

Now, i have the Fade in working alright as it is, but i cant figure out how to get it to fade out. I am currently using SFML 1.6

heres my code from the splash scene's update method.

Code: [Select]
void SplashScene::Update(void)
{
// Check our App pointer
assert(NULL != engine && "SplashScene::Update() bad app pointer, init must be called first");

bool fadeComplete = false;

for(int a = 250; a > 0; a -= 5)
{
         mSplashSprite->SetColor(sf::Color(255,255,255, a));
if( a == 250)
{
fadeComplete = true;
}
}  

// Drop our state after 10 seconds have elapsed
if(fadeComplete == true && false == IsPaused() && GetElapsedTime() > 4.0f){

engine->mSceneManager.RemoveActiveState();
}
}


and my main loop looks like this.

Code: [Select]
// Loop while IsRunning returns true
while(IsRunning() && mWindow.IsOpened() && !mSceneManager.IsEmpty())
{
// Get the currently active state
IState* scene = mSceneManager.GetActiveState();

// Check for corrupt state returned by our StateManager
assert(NULL != scene && "App::Loop() received a bad pointer");

// Create a fixed rate Update loop
while(anUpdateClock.GetElapsedTime() > anUpdateNext)
{
// Handle some events and let the current active state handle the rest
sf::Event anEvent;
while(mWindow.GetEvent(anEvent))
{
// Switch on Event Type
switch(anEvent.Type)
{
case sf::Event::Closed:       // Window closed
Quit(StatusAppOK);
break;
case sf::Event::GainedFocus:  // Window gained focus
scene->Resume();
break;
case sf::Event::LostFocus:    // Window lost focus
scene->Pause();
break;
case sf::Event::Resized:      // Window resized
break;
default:                      // Current active state will handle
scene->HandleEvents(anEvent);
} // switch(anEvent.Type)
} // while(mWindow.GetEvent(anEvent))

// Let the current active state perform updates next
scene->Update();


// Update our update next time
anUpdateNext += mUpdateRate;
} // while(anUpdateClock.GetElapsedTime() > anUpdateNext)

// Let the current active state draw stuff
scene->Draw();

// Display Render window to the screen
mWindow.Display();

// Handle Cleanup of any recently removed states at this point as needed
mSceneManager.HandleCleanup();
}


I appreciate any support/help that i can get, and im sorry if its just me being stupid.

Pages: [1]