Simple & Quick Text Dialogue System [Game Maker: Studio]

This article will guide you through the steps required to create a simple & quick text dialogue system in Game Maker: Studio.

In the end, desired text will show up when the player reaches desired trigger positions. It will keep scrolling upwards until it disappears. It may not be useful for one kind of game (like RPGs) but may be useful for the other. I have used this effect in a game I developed for Ludum Dare 36.

I have created a simple example for demonstrating this effect, where the player can be moved using the mouse.



It has a player object, a block object, and a text base object which is the black bar you see on the top. That’s where our text will be drawn!

Step 1

Let’s create the object that will draw the text. We’ll name it obj_drawtext. Change its depth to a really low value like -10000, so that it stays on the top.

Here’s how we’ll program it:

Create event:

messageDraw = “”;
char = 0;

Yless = 0;

Here, we’re just declaring the variables. messageDraw will store the text that has to be drawn, which will be derived from the message variable. We’re not declaring the message variable here because it will be declared in another script.

char will contain the number of characters that have to be printed from the message string. Yless will store the change in the y coordinate of the text.

Step event:

Yless -= 0.3;

//Text Effect
char += 0.6;

messageDraw = string_copy(message, 0, char);

The first line of code (not the comment starting with //) will decrease the Yless variable, which will affect the y position of the text.

The second line will increase the number of characters that have to be displayed.

The third line will assign a substring of the message variable to the messageDraw variable, with char being the number of characters to be assigned.

Draw event:

draw_text_ext(view_xview + 10, view_yview + 20 + Yless, messageDraw, -1, view_wview – 20);

This draws the messageDraw text at a position relative to the view, and the text will wrap when it reaches a certain length (in pixels), here, view_wview – 20.

If you’re not using views, you can just remove view_xview & view_yview and replace view_wview with room_width.

Step 2

Create a script named say, with the following code:

textObj = instance_create(0, 0, obj_drawtext);
textObj.message = argument0;

According to the code, an instance of obj_drawtext will be created. The instance will be assigned to the textObj variable, using which, we will attach the variable message to the instance (the one we didn’t declare in the object). The value which will be assigned is an argument here, which means the value will be assigned when the script is executed from some other piece of code.

Step 3

Now we’ll create the trigger object, which will contain the actual message to be drawn when the player enters the trigger. We’ll name it obj_trigger.

Create the object, assign any sprite you want to associate with the trigger, but uncheck the visible option. This way, we’ll be able to see the trigger in the room editor but not in the actual game. The programming here is simple:

Collision event with obj_player:



This will execute the say script we just created, with argument0 being the msg variable. Right, we didn’t declare any msg variable. That’s because every instance of the trigger needs to have a different message. For that, we’ll declare the variable inside the room editor.

According to the second line, the trigger instance will be destroyed, so that the message doesn’t appear again.

Step 4

Now, place the trigger objects inside the room. You may resize the instance to fit the trigger zone.

Go to the instance you want to assign a message to, right click on it and select Creation Code.

msg = “What am I doing here?”;


In the code editor window that opens, declare the msg variable and assign any string to it. Close the code editor window, and do the same for every trigger instance you added. As the player reaches that trigger and touches it, the corresponding message will be drawn.


You can change the text speed and scroll speed to your liking inside obj_drawtext‘s Step event. You can use the say() command anytime to draw some text.


It’s done! Play your game and test it. The text should appear when you enter the trigger. If it doesn’t, recheck with the steps above, or comment below, with your project attached.

–> Download this example <–

If this tutorial helped you, do not hesitate to share it with others!

Have a great day!




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s