Posted By: 4gottenname
How to make pulsating text? - 06/07/09 14:17
Hey, I'm trying to recreate a old game and thougt I was starting out easy with making the start menu. On the first page there are 5 options (buttons): New Game, Load Game, Configuration, Credits and Exit Game. Problem is that the text on these buttons need to "pulsate" (grow bigger and then smaller over and over again). I've search the forums on how to animate buttons but didn't find any good anwser to that. Also it would requier too many bmaps so next I searched for a way to change the font size and came up with a very clumsy code. I'm using a TEXT* object called newgame_txt over a background panel with a trancparent button under the text. When you mouse over the button it calls a function that changes the font size in a while loop like this:
The brake line don't work btw. It's suposed to stop pulsating when you move the pointer away from the button... (should do so without the brake line too...)
This code looks a bit uggly and long and I need to call it for every one of my buttons (there will be a lot of them on other "pages" and later in the game). So my questions is:
1. How do i make all the diffrent buttons to call a function that makes the text (for only the button that made the call) pulsate in a efficent way? I figured they need separate functions that hold a pointer to the right text and calls an other function that holds the pulsating code, but I don't know how to do that.
2. And how do I stop the loop when pointer no longer is over the button? If I change my code it will either pulsate forever or only one time. What am I missing?
Hope I explained it in a understandable way and that it has an easy solution
Code:
function pulsate () { while(1) { newgame_txt.font = size44_font; wait (-0.2); newgame_txt.font = size50_font; wait (-0.2); newgame_txt.font = size44_font; wait (-0.2); newgame_txt.font = size38_font; wait (-0.2); if (event_type == EVENT_RELEASE) { break; } } }
The brake line don't work btw. It's suposed to stop pulsating when you move the pointer away from the button... (should do so without the brake line too...)
This code looks a bit uggly and long and I need to call it for every one of my buttons (there will be a lot of them on other "pages" and later in the game). So my questions is:
1. How do i make all the diffrent buttons to call a function that makes the text (for only the button that made the call) pulsate in a efficent way? I figured they need separate functions that hold a pointer to the right text and calls an other function that holds the pulsating code, but I don't know how to do that.
2. And how do I stop the loop when pointer no longer is over the button? If I change my code it will either pulsate forever or only one time. What am I missing?
Hope I explained it in a understandable way and that it has an easy solution