Powered by Invision Power Board

 
    Reply to this topicStart new topicStart Poll

> How do you get text that types itself out in GM?, Like in Cave Story or The Underside.
United Kingdom
Thingy
Posted: Oct 18 2009, 08:51 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


I want to get text that types itself out for a game I'm making, but I'm not sure how to do that.

Any suggestions?


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
United States
Yoshi340
Posted: Oct 18 2009, 09:15 AM
Quote Post


Regular


Group Icon
Group: Members
Posts: 148
Member No.: 5562
Joined: 25-July 08

Status: (0d) [--]


What do you mean by "types itself out"?
PMEmail Poster
Top
Unspecified
Miaxis
Posted: Oct 18 2009, 09:16 AM
Quote Post


hagan bromas
[*]

Group Icon
Group: Members
Posts: 1799
Member No.: 2793
Joined: 12-October 06

Status: (0d) [--]


I guess he means like a typewriter.

Try looking at the GMC - there's alot of textbox scripts, one being a rather advanced example called Textbox Engine by J-Factor if you don't want to code it all by yourself.

The main thing is adding one character at a time to a variable, then drawing it. Say like, you set an alarm (my method, you can also use a script that uses sleep() and restarts itself after a character has been added but be aware that this stops all movement on screen) and if its value is 0, you take the next character from stringA and add it to stringB and reset the alarm. I know it sounds a bit complicated but maybe this little example helps you:
CODE
//create event
msg = "";
position = 0;
message = insert your message (you may want to set this either by using a script and an argument or the instance creation code)

//alarm 0 event

msg += string_char_at(message,position);
position += 1;
alarm[0] = 4;

//draw event
draw_text(x,y,msg)


--------------------
user posted image

user posted imageuser posted imageuser posted imageuser posted image
PMEmail PosterUsers WebsiteMSN
Top
United Kingdom
Thingy
Posted: Oct 18 2009, 09:47 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


Wait, I get it.

I can't get it to work right.
I'm using this:
CODE
Create Event:
execute code:

msg = "";
position = 0;
message = "Press SHIFT to jump"

Alarm Event for alarm 0:
execute code:

msg += string_char_at(message,position);
position += 1;
alarm[0] = 4;


Step Event:
if position is larger than 20
     for all object36: set variable allow to 1

Draw Event:
set the font for drawing text to font0 and align left
set the drawing color to 16777215
execute code:

draw_text(view_xview + 4,view_yview + 72,msg)


but nothing comes up on my box.

My old code had the text come up all at once, but did not require a secondary object to be made.

This post has been edited by Thingy on Oct 18 2009, 10:30 AM


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
United States
RetroXYZ
Posted: Oct 18 2009, 10:50 AM
Quote Post


Standard Member
[*][*]

Group Icon
Group: Members
Posts: 2714
Member No.: 4325
Joined: 27-August 07

Status: (0d) [--]


Guys, stop giving way more complex code than you need.

CODE
// Create
string_to_draw="Hello, World!";
string_draw="";
delay=1; // change this value depending on the delay of each letter you want
alarm[0]=delay;

// Alarm 0
string_draw=string_copy(string_to_draw,1,string_length(string_draw)+1);
alarm[0]=delay;

Very easy to do; stop over-complicating things.

In the draw event, just draw the string however you want. Use any font you want, including fonts you can make with font_add_sprite() (you can see how to use it in the GM manual).

This post has been edited by RetroXYZ on Oct 18 2009, 10:52 AM
PMEmail PosterMSN
Top
United States
Mike Shinoda
Posted: Oct 18 2009, 10:58 AM
Quote Post


Aka Artic
[*][*]

Group Icon
Group: Members
Posts: 802
Member No.: 3598
Joined: 12-April 07

Status: (0d) [--]


QUOTE (RetroXYZ @ Oct 18 2009, 10:50 AM)
Guys, stop giving way more complex code than you need.

CODE
// Create
string_to_draw="Hello, World!";
string_draw="";
delay=1; // change this value depending on the delay of each letter you want
alarm[0]=delay;

// Alarm 0
string_draw=string_copy(string_to_draw,1,string_length(string_draw)+1);
alarm[0]=delay;

Very easy to do; stop over-complicating things.

In the draw event, just draw the string however you want. Use any font you want, including fonts you can make with font_add_sprite() (you can see how to use it in the GM manual).

Is there a way to change the delay in the middle of a string? Like, when someone talks at normal speed and then 3 dots (...) appear, but they apear really slow?


--------------------
rain.

AKA Artic

I'm gonna miss you ol' pal. See you guys in the 3.0.
PMEmail PosterUsers WebsiteIntegrity Messenger IMAOLYahooMSN
Top
United States
RetroXYZ
Posted: Oct 18 2009, 11:01 AM
Quote Post


Standard Member
[*][*]

Group Icon
Group: Members
Posts: 2714
Member No.: 4325
Joined: 27-August 07

Status: (0d) [--]


QUOTE (Mike Shinoda @ Oct 18 2009, 11:58 AM)
Is there a way to change the delay in the middle of a string? Like, when someone talks at normal speed and then 3 dots (...) appear, but they apear really slow?

Well, it would have to be checked for in the alarm, and change the time that the alarm sets. It would be very-specific.
PMEmail PosterMSN
Top
Sweden
Alex
Posted: Oct 18 2009, 11:24 AM
Quote Post


In Donaldismo Veritas
[*][*][*][*][*]
[*][*]

Group Icon
Group: Members
Posts: 1678
Member No.: 5509
Joined: 9-July 08

Status: (0d) [--]


Thank you very much RetroX, I needed this!


--------------------
user posted image
--------------------
My character has been drawn by:
NICKtendo DS
Jazz
Tek
PM
Top
United States
YoManRuLz
Posted: Oct 18 2009, 11:30 AM
Quote Post


sit down, it's just me


Group Icon
Group: Members
Posts: 152
Member No.: 6502
Joined: 6-September 09

Status: (0d) [--]


QUOTE (RetroXYZ @ Oct 18 2009, 10:50 AM)
CODE
// Create
string_to_draw="Hello, World!";
string_draw="";
delay=1; // change this value depending on the delay of each letter you want
alarm[0]=delay;

// Alarm 0
string_draw=string_copy(string_to_draw,1,string_length(string_draw)+1);
alarm[0]=delay;

nice.
how would you make it so every 50 characters it draws it down one line?

(and I think I will use this, so do you want credit?)


--------------------
PMEmail Poster
Top
United Kingdom
Thingy
Posted: Oct 18 2009, 11:55 AM
Quote Post


So long MFGG 2.0~
[*][*][*][*]

Group Icon
Group: Members
Posts: 1824
Member No.: 4642
Joined: 30-October 07

Status: (0d) [--]


QUOTE (YoManRuLz @ Oct 18 2009, 05:30 PM)
nice.
how would you make it so every 50 characters it draws it down one line?

(and I think I will use this, so do you want credit?)

I think just putting a # in does the trick.

Also will I be able to use characters such as / + - * and .?


--------------------
user posted image
Old ref, Current ref
Click to see the rest. (opens sig on top post)

user posted image
Hey, MFGG 3.0, it's me from the past.
PMEmail PosterMSN
Top
Sweden
Alex
Posted: Oct 18 2009, 12:13 PM
Quote Post


In Donaldismo Veritas
[*][*][*][*][*]
[*][*]

Group Icon
Group: Members
Posts: 1678
Member No.: 5509
Joined: 9-July 08

Status: (0d) [--]


QUOTE (Thingy @ Oct 18 2009, 06:55 PM)
I think just putting a # in does the trick.

Also will I be able to use characters such as / + - * and .?

Yes, you can. And # makes a new line.


--------------------
user posted image
--------------------
My character has been drawn by:
NICKtendo DS
Jazz
Tek
PM
Top
United States
RetroXYZ
Posted: Oct 18 2009, 12:59 PM
Quote Post


Standard Member
[*][*]

Group Icon
Group: Members
Posts: 2714
Member No.: 4325
Joined: 27-August 07

Status: (0d) [--]


QUOTE (Thingy @ Oct 18 2009, 12:55 PM)
Also will I be able to use characters such as / + - * and .?

Any string in Game Maker will work. Use # for a new line, and use ## for a #.

QUOTE (Alex @ Oct 18 2009, 12:24 PM)
Thank you very much RetroX, I needed this!

No problem!
PMEmail PosterMSN
Top
India
Char
Posted: Oct 18 2009, 02:05 PM
Quote Post


fad was bad
[M][*][*]

Group Icon
Group: Admins
Posts: 2123
Member No.: 2856
Joined: 25-October 06

Status: (0d) [--]


QUOTE (YoManRuLz @ Oct 18 2009, 10:00 PM)
how would you make it so every 50 characters it draws it down one line?

it should be something like
if (string_length(string_draw) mod 50 == 0)
  string_draw += "#";



--------------------
aa this broke


Make your own | If a level is breaking the rules, note the ID and PM me.
Reference (thanks Frogjester!)
PMEmail PosterUsers WebsiteAOLYahooMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

  Topic Options Topic Options Reply to this topicStart new topicStart Poll

 




[ Script Execution time: 0.0657 ]   [ 13 queries used ]   [ GZIP Enabled ]   [ Server Load: 1.93 ]