Game Maker Language new line
I am writing a GML script and wanted to know how to make a message appear on the next line:
ex.
show_message("Hello" + *something* + "World")
outputs:开发者_运维百科
Hello
World
For GameMaker: Studio 2, always use \n
as new line.
show_debug_message("First Line\nSecond Line");
For earlier releases, always use #
as new line.
show_message("First Line#Second Line");
I'm not positive (never used Game Maker before) but the manual appears to state that a # will work (though that may only work for draw_string). You can also try Chr(13) + Chr(10), which are a carriage return and linefeed.
So, you could try:
show_message("Hello#World")
or
show_message("Hello" + chr(13) + chr(10) +"World")
From: http://gamemaker.info/en/manual/gmaker
Despite the other mentioned methods are more "correct", in Game Maker you can also write the new line straight in the code editor:
show_message("Hello
World");
But codes get a bit messy this way.
To create a new line use # So for example
To print this:
Hello
World
Use this:
show_message('Hello#World');
Game Maker 1.4 can use the pound sign for newlines, as well as the linefeed character (chr(10)
):
show_debug_message("Hello#World");
show_debug_message("Hello" + chr(10) + "World");
Since GameMakerStudio 2 you can now use escaped characters;
show_debug_message("Hello\nWorld");
show_debug_message("Hello#World"); //Will not work, the pound sign is now literal!
show_debug_message("Hello" + chr(10) + "World");
Use #
to start a new line:
show_message("Hello World!")
Would come out like this:
Hello World!
However,
show_message("Hello#World!")
Would come out like this:
Hello
World!
As others have stated you can use "string#this is in a new line"
If you want to use a hashtag as text and not newline use \#
You can look up more information about strings here.
Here's another example. Instead of having a message box come up, you could use the function draw_text(x,y,string)
An example of this would be: draw_text(320,320,"Hello World");
Hope this helps
精彩评论