Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

i want to animation the transition between game screens , in my game loop i have a function called getCurrentScreen() which returns a Screen object this Screen Class has a function called present() this function draw on the framebuffer , when i want to change to another screen i call setCurrentScreen(Screen) , so it will draw the screen i set , What i want is to animation the transition between these screens any suggestion , is the a book or an article that discusses this

share|improve this question

2 Answers 2

Given your current design you could create a new Screen (TransitionScreen or whatever) that takes two screens for the constructor and maybe a fade-time. Then you would do something along the lines ofsetCurrentScreen(new Screen(lastScreen, nextScreen, fadeTime)). Your TransitionScreen would have to deal with mixing both framebuffer outputs (you might have to tweak your drawing method for this if each screen is drawing to the framebuffer directly on its own) and then after the given fade time it would setCurrentScreen(nextScreen) to fix the final screen.

This is a very-simplified method and doing it exactly like this will lead to poor code and lots of coupling, but with a bit of work you can make it. E.g. TransitionScreen shouldn't set the new screen itself because it'll couple with your setScreen, but instead raise a TransitionFinished event, flag transition as finished or something like that. Then your game loop should do the setScreen and you're good to go.

share|improve this answer
    
very nice solution , can i implement a left to right transition using this method ?? that i will draw some of the current screen frame buffer with some of the future screen frame buffer ? –  Nammari Feb 17 '12 at 14:52
    
If you're not drawing directly to your framebuffer but instead to an offscreen FBO (or are able to choose), you can tell TransitionScreen to issue drawing for both screens in two different FBOs and then TransitionScreen can mix it into your final framebuffer (e.g. via a shader program), whatever the transition you want. –  kaoD Feb 17 '12 at 14:59
    
you can help me more if you give me a book that talk about animation and transitions or articles –  Nammari Feb 17 '12 at 15:02
    
Well, I know no book and probably there is not (I could Google it, but of course you could too.) Transitions aren't rocket science. You just have to think about the answer and how to implement it properly with shaders. It's just binding both temp-FBOs to the texture units and a shader to mix them (with pretty much ANY effect you'd like to do.) –  kaoD Feb 17 '12 at 15:07

I worked on something similar before. I think the best thing to do is to have a sort of stack with your current screen on the top. For each screen have a Boolean value whether it covers up the draw of the screen underneath. So when drawing you start at the top of your stack and draw screens that are not covered up by a screen above it in the stack.

The good thing about this is that when you want to transition off a screen, you can push a new screen on top with the covering boolean set as false. You can then do your transition animation (for instance fade in the new screen) whilst drawing the underneath screen and at the end you can set the covering boolean to true so you no longer draw the screen below at all.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.