• 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!

Make Text Appear Over Time

T

Tenten2016

Guest
So I'm trying to make my draw text appear over time such as five seconds. The code that I used:
Create:
draw = false;
alarm[0] = 5;
textAlpha = 1;
fadeSpeed = 0.01;

Alarm 0:
Code:
draw = true;

Step:
Code:
if (!draw && text_alpha > 0) {
text_alpha -= fadeSpeed;
}

Draw:
Code:
if (textAlpha > 0)
{
draw_set_color(c_white);
draw_set_font(font0);
draw_text(32,480, "Hey world!");

}

But I'm not getting it to work; I'll try it once again just to make sure. Any suggestions just in case?
 

Roderick

Member
1: textAlpha and text_alpha are two totally different variables.
2: You have no draw_set_alpha line.
3: By checking !draw, you're checking if draw is false. Remove the !, and just check (draw && text_alpha > 0).

Worked perfectly for me once I fixed those three things.
 
T

Tenten2016

Guest
So I did as requested by adding in draw_set_alpha(1).
I took out the !
I changed textAlpha to text_alpha; the result, the text have disappear but refuse to reappear after five seconds.

1: textAlpha and text_alpha are two totally different variables.
2: You have no draw_set_alpha line.
3: By checking !draw, you're checking if draw is false. Remove the !, and just check (draw && text_alpha > 0).

Worked perfectly for me once I fixed those three things.
 

Roderick

Member
draw_set_alpha(1) makes the alpha always 1 (ie, no transparency). You need to draw_set_alpha(text_alpha)
 
T

Tenten2016

Guest
The slightly edited code:

Create:
draw = false;
alarm[0] = 5;
text_alpha = 1;
fadeSpeed = 0.01;

Alarm:
draw = true;

Step:
if (draw && text_alpha > 0)
{
text_alpha -= fadeSpeed;
}

Draw:
if (text_alpha > 0)
{
draw_set_alpha(text_alpha);
draw_set_color(c_white);
draw_set_font(font0);
draw_text(32,480, "hey world!");

}

It would seem text_alpha is what's making me so fluster. I shall be reading more into that. Do you think it could also be because it's >0 versa <0?
draw_set_alpha(1) makes the alpha always 1 (ie, no transparency). You need to draw_set_alpha(text_alpha)
 
T

Tenten2016

Guest
Nope, changing it from > 0 to < 0 didn't do anything either. Hmm
 
T

Tenten2016

Guest
Hmm, I even changed the fadeSpeed to 1. But nope. Hmmm, what could it be?
 
T

Tenten2016

Guest
So nothing happened. I will be updating this post until I figure out how to code this event correctly. I'll also see if I can get some advice from Reddit as well.
 
T

Tenten2016

Guest
I'm not trying to make it fade out. It's suppose to fade in. I don't really care if it fades in or not. But the code I'm using, the objective is to get the text to appear after five seconds.

I just tried this code and the text fades out smoothly after 5 steps. Are you trying to make it fade in or out?
 

RyanC

Member
Oh OK try this:

//create event:
draw = false;
alarm[0] = 5;
text_alpha = 0;
fadeSpeed = 0.01

// alarm[0]
draw = true;

//step
if (draw && text_alpha < 1)
{
text_alpha += fadeSpeed;
}

//draw
if (text_alpha > 0)
{
draw_set_alpha(text_alpha);
draw_set_color(c_white);
draw_set_font(font0);
draw_text(32,480, "hey world!");
}
 
T

Tenten2016

Guest
This still isn't working; it's so crazy. Thanks for the response by the way, I truly appreciate it. I'm still gonna try and nick pick at it because it seems its something small that I'm not seeing, what not. That one poster said it worked on his end, and I'm curious to see the code he used to see how different it really is from this one.

Oh OK try this:

//create event:
draw = false;
alarm[0] = 5;
text_alpha = 0;
fadeSpeed = 0.01

// alarm[0]
draw = true;

//step
if (draw && text_alpha < 1)
{
text_alpha += fadeSpeed;
}

//draw
if (text_alpha > 0)
{
draw_set_alpha(text_alpha);
draw_set_color(c_white);
draw_set_font(font0);
draw_text(32,480, "hey world!");
}
 

RyanC

Member
I did test the code I edited before posting it and it worked here absolutely fine.
You had set the text alpha to 1 already in the create event when it should start at 0. I changed the step event to < 1 and += too.

What do you see on screen when testing?
 

Tornado

Member
The code RyanC sent works. I created a new project and put his code in some new object called for example obj_Control.
The only extra thing I had to do was to create font0, because it is referred to from draw event.
Try to set
draw_set_color(c_blue);
instead of
draw_set_color(c_white);

Maybe your room background color is white and therefore you can't see the text.
 

Tornado

Member
Also don't forget to put that object (in my case obj_Control) into the room. In the properties of the object, the flag "visible" must be active.
 
T

Tenten2016

Guest
So one thing that I noticed is my object_text wasn't visible. So I checked the visible box, and now the text shows, but it doesn't fade in after 5 seconds. I don't recall turning off visible, but nonetheless, I turned it back on.

Also don't forget to put that object (in my case obj_Control) into the room.

I did test the code I edited before posting it and it worked here absolutely fine.
You had set the text alpha to 1 already in the create event when it should start at 0. I changed the step event to < 1 and += too.

What do you see on screen when testing?
 
T

Tenten2016

Guest
The reason why I had the 'visible' box unchecked because I was attempting to do an code such as an

object_text.visible;

code
 

Tornado

Member
in create event set the alarm to this:
alarm[0] = room_speed * 5;

room speed is always one second, so we multiply that by 5 to get our 5 seconds.
 
T

Tenten2016

Guest
Did it; however, I reset my object_text back to visible, so now the text appears automatically when the room starts. I'll test it again with the visible unchecked. Thanks for the responses and this tricky situation. =0

in create event set the alarm to this:
alarm[0] = room_speed * 5;

room speed is always one second, so we multiply that by 5 to get our 5 seconds.
 
T

Tenten2016

Guest
Does anyone have an download example that I can use to study?
 
T

Tenten2016

Guest
RESOLVED ( I still don't know how to edit that into an post). Here are the mistakes I've made:

1.) Visible needs to be check
2.) roomspeed needs to be included in the code
3.) spacing of variables and within lines

Thank you all for helping me. Awesome, I didn't have to go to reddit. =D
 
Top