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.


Messages - Legacy

Pages: [1]
1
Graphics / [Solved] Sprite Fade Out?
« on: September 29, 2011, 11:51:40 pm »
Ah thankyou for that. Ill see what i can do to get the same effect. :)

2
Graphics / [Solved] Sprite Fade Out?
« on: September 29, 2011, 10:37:28 pm »
Ah, i see, could you post a little example of what you mean. If im not using a for statement.

EDIT:

i was having a weird day yesterday. Just took another go at it, but this time instead of using a for statement, i switched it to an if, using a variable to control the alpha.

Code: [Select]
bool fadeComplete = false;
if(GetElapsedTime() > 1.5f)
{
if(mAlpha < 250)
{
mAlpha += 10;
mSplashSprite->SetColor(sf::Color(255,255,255, mAlpha));
if( mAlpha == 250)
{
fadeComplete = true;
}
}
}


thank you for your help, much appreciated.

But now i have another question related to fade in/out, how would i fade in or out, the entire contents of the screen?

3
Graphics / [Solved] Sprite Fade Out?
« on: September 29, 2011, 10:17:22 pm »
Quote from: "DevilWithin"
Im not sure you 're doing it the right way. The first snippet, unless running in a thread, shouldn't do an animation at all.

You're trying to evolve the alpha channel of the sprite in a single pass, while that won't allow anything to be displayed in-between the begining and ending state of the alpha animation. You need to do the alpha change over time.

That meaning each frame, before you render everything, you should call the update, and pass it the elapsed time since the last frame, and update only by that fraction of time.

The fade in and fade out are exactly the same thing, but inverted. Try to solve it on your own with this information :)


the scene->update() method is called each frame, the scene object holds the Splash Screen inside it, and when it is droped, it goes to the next in the list, which is the Title Screen.

I tried to invert the for statement, but it only displayed a black screen. I will look further into it, but thank you for your help anyway. :)

4
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]