Login | Register

Changing the caption

July 25, 2006, 14:58 by Calle
[loading]
-->
There are a lot of things you could do with the caption. Basically, for an example, you could write anything in it. First of all you could enter a text in the room menu, under the settings tab, but then there are also a bunch of variables and one function to work with the caption in the game:

window_set_caption(caption)
room_caption
show_score Whether to show the score in the window caption.
show_lives Whether to show the number of lives in the window caption.
show_health Whether to show the health in the window caption.
caption_score The caption used for the score.
caption_lives The caption used for the number of lives.
caption_health The caption used for the health.


As it says (I copied it over from the manual) the three first variables show_ defines whether to show a specific value or not, while caption_ sets the value that should be drawn. This is useful, as the names indicates they are meant to show the status of things in game such as how many lives the player got left and more. Even more interesting and useful though, is the function which can set the caption to anything, any text. But even better is the variable room_caption which does the same.

At the beginning of my Game Maker career there was a global moderator who was very famous. He sure is even today, but he was even more admired then. He sure is really great still and you might’ve heard of him as the creator of Xtreme3D, and his username is Xception. I am pretty sure he created an example of how to make scrolling text and put it in the caption. That’s cool, and I’ll try to create something similar.

caption = window_get_caption();
caption_e = string_copy(caption,2,string_length(caption)-1)
caption_e += string_char_at(caption,1);
caption = caption_e;
room_caption = caption;


Putting that code in step event works. But it goes fast. You might want it to scroll slower and then I would suggest that you would use an alarm event or something. Don’t forget to set the caption to something either, of course, you won’t be able to see anything otherwise!

Example:
http://gmtutorials.com/files/captionex.gm6

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games