Data Structures |
| struct | SGEBITMAPFONT |
| | a bitmap font structure More...
|
| struct | SGEFONT |
| | a font structure More...
|
| struct | SGEFONTFXFADEINFO |
| | internal, holds information about a current fade state More...
|
| struct | SGEFONTFXCOUNTDOWNINFO |
| | internal, holds information about a current count down More...
|
| struct | SGEFONTFX |
| | holds information about a font effect More...
|
| struct | SGEFONTFXFADEINOUTINFO |
| | internal, holds information about a in and out fading effect More...
|
Defines |
| #define | SGEFONT_BITMAP 1 |
| | font is a sge bitmap font
|
Enumerations |
| enum | SGEFONTFX_TYPES {
SGEFONTFX_FADE_IN,
SGEFONTFX_FADE_OUT,
SGEFONTFX_FADE_INOUT,
SGEFONTFX_MOVE_IN,
SGEFONTFX_MOVE_OUT,
SGEFONTFX_MOVE_INOUT,
SGEFONTFX_COUNTDOWN
} |
| | different font effects
More...
|
| enum | SGEFONTFX_MOVEMENT { SGEFONTFX_MOVE_LINEAR,
SGEFONTFX_MOVE_SLOWDOWN,
SGEFONTFX_MOVE_ACCELERATE,
SGEFONTFX_MOVE_BOUNCE
} |
| | different move effects
More...
|
Functions |
| SGEFONT * | sgeFontNew (int type) |
| | create a new empty font
|
| SGEFONT * | sgeFontNewFile (SGEFILE *f, int type, const char *filename) |
| | create a new font from a file
|
| void | sgeFontDestroy (SGEFONT *f) |
| | destroy a font and free its resources
|
| int | sgeFontGetLineHeight (SGEFONT *f) |
| | get the height of a line with the font
|
| int | sgeFontPrint (SGEFONT *f, SDL_Surface *dest, int x, int y, const char *text) |
| | print a text with the font
|
| int | sgeFontGetWidth (SGEFONT *f, const char *text) |
| | get the width of a text
|
| void | sgeFontIgnoreAlpha (SGEFONT *f) |
| | ignore the alpha channel of a font
|
| void | sgeFontUseAlpha (SGEFONT *f) |
| | use the alpha channel of a font (default)
|
| SGEFONTFX * | sgeFontFXNew (SGEFONT *f, Uint32 fxtype, Uint8 movement, Uint32 runtime, Uint32 charOffset, int startx, int starty, int endx, int endy, const char *text) |
| | create a new font effect
|
| void | sgeFontFXDraw (SGEFONTFX *fx) |
| | draw the effect
|
| void | sgeFontFXDestroy (SGEFONTFX *fx) |
| | destroy the effect and free its resources
|
| void | sgeFontFXCountdownSetValues (SGEFONTFX *fx, Sint32 start, Sint32 end) |
| | set the value range for a count down (or up) effect
|
| void | sgeFontFXPreDelay (SGEFONTFX *fx, Uint32 delay) |
| | set the miliseconds to wait before starting the effect
|
| void | sgeFontFXHideOnPreDelay (SGEFONTFX *fx, Uint8 yesno) |
| | hide the effect until pre delay is over
|
| void | sgeFontFXPostDelay (SGEFONTFX *fx, Uint32 delay) |
| | wait after a effect is finished until it actually is treated as finished
|
| void | sgeFontFXSetFinished (SGEFONTFX *fx) |
| | force an early finish of a effect
|
| int | sgeFontFXFinished (SGEFONTFX *fx) |
| | check if a effect is finished
|
| void | sgeFontFXSetTarget (SGEFONTFX *fx, SDL_Surface *surface) |
| | change render target (default screen) of the effect
|
Variables |
|
Uint8 | SGEFONT::alpha |
| | The alpha of the font, 0 to 255, 255 is fully opaque.
|
Bitmap font handling and effects.
Print with bitmap fonts, including animated text effects.
Bitmap fonts are wide PNG images having all characters in one row, split by a single pixel line of pink color (0xff00ff).
If the font is called myfont.png, there has to be a file called myfont.png.map which lists the characters from the image, so if your image shows the characters SGE, then your map file should read 'SGE'
Just have a look at the standard fonts to see how they are done.
| SGEFONTFX* sgeFontFXNew |
( |
SGEFONT * |
f, |
|
|
Uint32 |
fxtype, |
|
|
Uint8 |
movement, |
|
|
Uint32 |
runtime, |
|
|
Uint32 |
charOffset, |
|
|
int |
startx, |
|
|
int |
starty, |
|
|
int |
endx, |
|
|
int |
endy, |
|
|
const char * |
text |
|
) |
| |
create a new font effect
- Parameters:
-
| f | a pointer to a SGEFONT |
| fxtype | the effect type SGEFONTFX_TYPES |
| movement | the movement type SGEFONTFX_MOVEMENT |
| runtime | how long should the effect take, in miliseconds |
| charOffset | the offset of the characters in miliseconds, read detail description |
| startx | the x position to start the effect from |
| starty | the y position to start the effect from |
| endx | the x position to end the effect at |
| endy | the y position to end the effect at |
| text | the text to make the effect with |
- Returns:
- a pointer to a new SGEFONTFX
The charOffset defines how much 'behind' the single characters of the text are treated.
Setting charOffset to 0 means there is no per character treatment and the full text will only be one big image.
Setting charOffset to>0 means that each character is treated as a single image with a delay of charOffset miliseconds.
example:
Fade the text in from -100, 0 (outside the screen up left) to the bottom of the screen (1, 220), move every single character with a offset of 99 in a down slowing movement. The whole effect should take 1000 miliseconds. As we use a offset of 99, it actually takes longer then 1000 miliseconds depending on text length. It takes 1000 miliseconds for the first character and then continues until all characters are on its destination.
SGEFONTFX *fx=sgeFontFXNew(data->font, SGEFONTFX_FADE_IN, SGEFONTFX_MOVE_SLOWDOWN, 1000, 99, -100, 0, 1, 220, "Look at me, i am fancy");
Definition at line 355 of file sgefont.c.