• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Simple Cursor

C

CoderJoe

Guest
I remember in one of the gm tutorials there was one with text input (maybe the saving and loading tutorial?) and they made a cursor by drawing a line at the end of the text. You can do this with something like draw_line and set its position to the amount of characters times the width of the characters. Hope that helps a bit.
 
A

Aura

Guest
You can easily add a string to another string. Keep a variable for the actual text and in the draw_text() call, add the cursor to it. If you want the cursor to blink, then use a combination of string_copy() and an alarm.

Create:
Code:
blink = 1; // 1 for visible, 0 for invisible
alarm[0] = room_speed/2;
Alarm 0:
Code:
blink ^= 1; // set "blink" to 0 if it is 1 and vice versa
alarm[0] = room_speed/2;
Draw:
Code:
draw_text(x, y, keyboard_string + string_copy("|", 1, blink));
Or if you want to persistently show it, simply add the symbol to the text.

Code:
draw_text(x, y, keyboard_string + "|");
 
B

baconlovar

Guest
Ah dude, you're a genius copying the string is a great idea. Thanks for the responses! It helped a lot
 
Top