S
SlaggyWolfie
Guest
EDIT: I could try and provide a video of it if that would help. EDIT2: How do I format code in this forum?
Sorry for bugging you guys...
Also I'm using (according to the title of the app) - GameMaker: Studio Standard Edition (v1.4.1757).
Also the code is in the GML.
But I'm doing some text boxes - problem is I'm using views and I can't for the life of me figure out how to destroy the old text boxes without destroying the new one. The text box has to be destroyed after 3.5 seconds (like any normal text box).
The basic premise is this (without me trying to destroy the old text boxes): I create the text box from some condition being checked. It's created but it's created at specific coordinates relative to the view. I then continue meeting the check and it spams text boxes for days...
I am using Shaun Spalding's tutorial on text boxes with the addition of a Step Event in obj_text. The instance destroys itself after 3.5s. Those comments are my attempts at doing it myself:
//if (time < text_length + 3.5 && global.text_move_check != 0 && (x < view_xview[0] - 5 || x > view_xview[0] + 5)) instance_destroy();
//if (instance_find(obj_text, id) < instance_find(obj_text, id + 1)) with(obj_text) instance_destroy();
if (time > text_length + 3.5)
{
instance_destroy();
time = 0;
}
time += 1/room_speed;
Sorry if the comments are spaghetti code.
Here's the entire object:
Information about object: obj_text
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
alpha = 0;
print = "";
time = 0;
depth = depth - instance_number(obj_text) - 2;
//if(instance_number(obj_text) > 2);
/*var i;
for (i = 0; i < instance_number(obj_text); i += 1)
{
text = instance_find(obj_text,i);
}
if (instance_find(obj_text, i) > instance_find(obj_text, i - 1) with(obj_text) instance_destroy();
//instance_destroy(obj_text)
Step Event:
execute code:
//if (time < text_length + 3.5 && global.text_move_check != 0 && (x < view_xview[0] - 5 || x > view_xview[0] + 5)) instance_destroy();
//if (instance_find(obj_text, id) < instance_find(obj_text, id + 1)) with(obj_text) instance_destroy();
if (time > text_length + 3.5)
{
instance_destroy();
time = 0;
}
time += 1/room_speed;
Draw Event:
execute code:
///Add letters over time
if (time < text_length)
{
time += spd;
print = string_copy(text,0,time)
}
execute code:
///Render textbox & text
draw_set_alpha(alpha);
if (alpha < 0.6) alpha += spd/10; else alpha = 0.6;
draw_set_font(font);
draw_set_color(c_gray);
draw_rectangle(x,y,x+boxwidth,y+boxheight,0);
draw_set_color(c_black);
draw_rectangle(x,y,x+boxwidth,y+boxheight,1);
draw_set_color(c_white);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
//while (time < text_length + 3.5)
draw_text_ext
(
x + padding,
y + padding,
print,
font_size+(font_size/2),
maxlength
);
draw_set_alpha(1);
Here's the script:
//scr_text("Text",speed,x,y);
txt = instance_create(argument2,argument3,obj_text);
with (txt)
{
padding = 16;
maxlength = view_wview[0];
text = argument0;
spd = argument1;
font = fnt_text;
text_length = string_length(text);
font_size = font_get_size(font);
draw_set_font(font);
text_width = string_width_ext(text,font_size+(font_size/2), maxlength);
text_height = string_height_ext(text,font_size+(font_size/2), maxlength);
boxwidth = text_width + (padding*2);
boxheight = text_height + (padding*2);
}
P.S. Duck
Sorry for bugging you guys...
Also I'm using (according to the title of the app) - GameMaker: Studio Standard Edition (v1.4.1757).
Also the code is in the GML.
But I'm doing some text boxes - problem is I'm using views and I can't for the life of me figure out how to destroy the old text boxes without destroying the new one. The text box has to be destroyed after 3.5 seconds (like any normal text box).
The basic premise is this (without me trying to destroy the old text boxes): I create the text box from some condition being checked. It's created but it's created at specific coordinates relative to the view. I then continue meeting the check and it spams text boxes for days...
I am using Shaun Spalding's tutorial on text boxes with the addition of a Step Event in obj_text. The instance destroys itself after 3.5s. Those comments are my attempts at doing it myself:
//if (time < text_length + 3.5 && global.text_move_check != 0 && (x < view_xview[0] - 5 || x > view_xview[0] + 5)) instance_destroy();
//if (instance_find(obj_text, id) < instance_find(obj_text, id + 1)) with(obj_text) instance_destroy();
if (time > text_length + 3.5)
{
instance_destroy();
time = 0;
}
time += 1/room_speed;
Sorry if the comments are spaghetti code.
Here's the entire object:
Information about object: obj_text
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
alpha = 0;
print = "";
time = 0;
depth = depth - instance_number(obj_text) - 2;
//if(instance_number(obj_text) > 2);
/*var i;
for (i = 0; i < instance_number(obj_text); i += 1)
{
text = instance_find(obj_text,i);
}
if (instance_find(obj_text, i) > instance_find(obj_text, i - 1) with(obj_text) instance_destroy();
//instance_destroy(obj_text)
Step Event:
execute code:
//if (time < text_length + 3.5 && global.text_move_check != 0 && (x < view_xview[0] - 5 || x > view_xview[0] + 5)) instance_destroy();
//if (instance_find(obj_text, id) < instance_find(obj_text, id + 1)) with(obj_text) instance_destroy();
if (time > text_length + 3.5)
{
instance_destroy();
time = 0;
}
time += 1/room_speed;
Draw Event:
execute code:
///Add letters over time
if (time < text_length)
{
time += spd;
print = string_copy(text,0,time)
}
execute code:
///Render textbox & text
draw_set_alpha(alpha);
if (alpha < 0.6) alpha += spd/10; else alpha = 0.6;
draw_set_font(font);
draw_set_color(c_gray);
draw_rectangle(x,y,x+boxwidth,y+boxheight,0);
draw_set_color(c_black);
draw_rectangle(x,y,x+boxwidth,y+boxheight,1);
draw_set_color(c_white);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
//while (time < text_length + 3.5)
draw_text_ext
(
x + padding,
y + padding,
print,
font_size+(font_size/2),
maxlength
);
draw_set_alpha(1);
Here's the script:
//scr_text("Text",speed,x,y);
txt = instance_create(argument2,argument3,obj_text);
with (txt)
{
padding = 16;
maxlength = view_wview[0];
text = argument0;
spd = argument1;
font = fnt_text;
text_length = string_length(text);
font_size = font_get_size(font);
draw_set_font(font);
text_width = string_width_ext(text,font_size+(font_size/2), maxlength);
text_height = string_height_ext(text,font_size+(font_size/2), maxlength);
boxwidth = text_width + (padding*2);
boxheight = text_height + (padding*2);
}
P.S. Duck
Last edited by a moderator: