S
Shadowblitz16
Guest
can someone tell me why my objects and surfaces are getting created and rendered before I can offset their positions?
it should create them on screen and then move them to their correct positions before being rendered
however they are not and are rendered in the wrong place for 1 to 2 frames
you can only really tell when debugging since the screen renders afterwards when I'm playing normally
here is my code
Edit: my code has changed a lot from when I posted this 2 hours ago
however I think GMS1.4 is bugged since there is no difference between the "CO-OP" slider and the "SINGLE" slider except for the y position, delay, and text
which neither of them should effect this
it only renders that specific instance and its surface.
with the surface being rendered in the wrong place.
also note that the surface should be a size of 0,0 since I init it as that value
and only set it the in the step event if the element_rect has changed size
they should either all be rendered or none of them
here is my project
I minimized it so that it would be easier to download
it should create them on screen and then move them to their correct positions before being rendered
however they are not and are rendered in the wrong place for 1 to 2 frames
you can only really tell when debugging since the screen renders afterwards when I'm playing normally
here is my code
Code:
///Menu create
menu_changed = 1;
menu_state = 0;
menu_index = 0;
if (surface_get_width(application_surface) != view_wview[0] || surface_get_height(application_surface) != view_hview[0])
{
surface_resize(application_surface, view_wview[0], view_hview[0])
}
Code:
///Menu step
if (keyboard_check_pressed(vk_up)) { menu_index = clamp(menu_index + 1, 0, instance_number(Slider)-1); }
if (keyboard_check_pressed(vk_down)) { menu_index = clamp(menu_index - 1, 0, instance_number(Slider)-1); }
switch (menu_state)
{
case 0: scr_menu_main() break;
case 1: scr_menu_single() break;
default: show_error("Menu.menu_state is out of bounds", true);
}
var _menu = menu_state;
var _index = menu_index;
with (Slider)
{
for (var _i=0; _i<instance_count; _i++)
{
if (element_index != _i) { break; }
if (element_index == _index) { element_selected = 1; }
else { element_selected = 0; }
if (element_menu != _menu) { x = max(x - 1, element_hidden_x); }
else { x = min(x + 1, xstart); }
}
}
menu_changed = 0;
Code:
///scr_menu_main
if (menu_changed == 1)
{
var _rect = rectangle(5, 3, 88, 22, 1);
var _inst = menus_create_slider(spr_title, 0, -1, 0, "SPACE #BUSTERS", fnt_large, _rect, 0);
_inst.element_text_y = -2;
var _rect = rectangle(5, 3, 55, 6, 1);
var _inst = menus_create_slider(spr_button, 0, 0, 64, "SINGLE", fnt_small, _rect, 32);
_inst.element_text_y = 0;
}
else
{
if (keyboard_check_pressed(vk_enter))
switch (menu_index)
{
case 0 : menu_state = 1; menu_changed = 1; break;
}
}
Code:
///Slider create
element_controller = noone;
element_menu = 0;
element_index = 0;
element_selected = 0;
element_width = sprite_get_width(sprite_index);
element_hidden_x = xstart - element_width
element_surf = surface_create(0, 0);
element_rect = rectangle(0, 0, 0, 0, 1)
element_font = fnt_small;
element_text = "";
element_flicker = 0;
element_text_x = 0;
element_text_y = 0;
Code:
///Slider step
//Update hidden x when resized
if (sprite_get_width(sprite_index) != element_width)
{
element_width = sprite_get_width(sprite_index);
element_hidden_x = xstart - element_width
x = element_hidden_x;
}
if (surface_get_width(element_surf) != element_rect[2] - element_rect[0] || surface_get_height(element_surf) != element_rect[3] - element_rect[1])
{
surface_resize(element_surf, element_rect[2] - element_rect[0], element_rect[3] - element_rect[1])
}
element_flicker ++;
element_flicker = element_flicker mod 8;
if (!element_selected)
if (x = element_hidden_x)
{
instance_destroy();
}
Code:
///Slider draw
draw_self();
//Update surface and make sure it exists
if (!surface_exists(element_surf))
{
element_surf = surface_create(0, 0)
surface_resize(element_surf, element_rect[2] - element_rect[0], element_rect[3] - element_rect[1])
}
surface_set_target(element_surf);
draw_set_halign(fa_left)
draw_set_valign(fa_top)
draw_set_font(element_font)
draw_set_alpha(0.5);
draw_set_colour($FFFF00);
draw_rectangle(0, 0, element_rect[2], element_rect[3], false);
if (element_flicker mod 2 == 0)
{
draw_set_alpha(1);
draw_set_colour($FFFFFF);
draw_text(element_text_x, element_text_y, element_text);
draw_set_alpha(1);
draw_set_colour($FFFF00);
draw_text(element_text_x + 1, element_text_y, element_text);
}
if (element_selected)
if (element_flicker mod 8 == 0)
{
draw_set_alpha(1);
draw_set_colour($FFFFFF);
draw_rectangle(0, 0, element_rect[2], element_rect[3], false);
}
draw_set_alpha(1);
surface_reset_target();
draw_surface(element_surf, x + element_rect[0], y + element_rect[1]);
Edit: my code has changed a lot from when I posted this 2 hours ago
however I think GMS1.4 is bugged since there is no difference between the "CO-OP" slider and the "SINGLE" slider except for the y position, delay, and text
which neither of them should effect this
it only renders that specific instance and its surface.
with the surface being rendered in the wrong place.
also note that the surface should be a size of 0,0 since I init it as that value
and only set it the in the step event if the element_rect has changed size
they should either all be rendered or none of them
here is my project
I minimized it so that it would be easier to download
Last edited by a moderator: