Help, Text and rectangle keep appearing when closed

V

Vincent

Guest
Hi there! In my platformer, there's a message that displays just when you start the first room after the menu that works like this:

-Create event
text [0] = "Oh, hello!"
text [1] = "Are you lost?"
text [2] = "I'll help you "

-In Draw event
draw_self ()
draw_set_colour (c_white)
draw_set_halign (fa_middle)
draw_set_font (fnt_texto)
draw_text (x, y-20, string (texto [global.number]))

draw_set_colour (c_white)
draw_set_font (fnt_mini)
draw_text (x+50, y+30, string ("Space to continue"))

-Press space event
if global.number < 2
{
global.number+= 1
}
else
{
instance_destroy ()
}

(The number variable is set in the menu)


But when I close the message after the three texts, leave the room and return it keeps with the last message
Thanks!
 

TheouAegis

Member
Because you only destroy the instance that's showing that message when the spacebar is pressed. When you leave the room and go back, the instance is respawned.

Try making the conditional if global.number < 3 make text[3]="" so that nothing shows up.
 
V

Vincent

Guest
Because you only destroy the instance that's showing that message when the spacebar is pressed. When you leave the room and go back, the instance is respawned.

Try making the conditional if global.number < 3 make text[3]="" so that nothing shows up.
Yes, but it draws a rectangle behind the text, and doing that the rectangle keeps appearing
 

Tsa05

Member
Insert a conditional into your Draw event:
Code:
draw_self ()
if(global.number < 3){
  draw_set_colour (c_white)
  draw_set_halign (fa_middle)
  draw_set_font (fnt_texto)
  draw_text (x, y-20, string (texto [global.number]))

  draw_set_colour (c_white)
  draw_set_font (fnt_mini)
  draw_text (x+50, y+30, string ("Space to continue"))
}
The if statement ensures that the box and text will only be drawn if global.number is withon the range you wanted.
 
Top