Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

GMLive.gml

Livecoding for GameMaker: Studio / GameMaker Studio 2 · By YellowAfterlife

[Fixed] Doesn't work when using view variables

A topic by Tanktot Games created Apr 05, 2022 Views: 306 Replies: 2
Viewing posts 1 to 2
(2 edits)

The extension works great when I'm doing simple GML with no regards to the view but when I add view variables particularly the variables containing the height and width of the view it seems to stop working and vanishes, whenever I update it. The thing that was once displayed is no longer displayed when the function is updated.

For an example the following code in the draw_gui event:

if (live_call()) return live_result;
draw_sprite(spr_castbar_background, 0, 128, view_hview[0] - 48);
draw_sprite_part(spr_castbar_foreground, 0, 0, 0, 256 * (1 - alarm[0] / base_tilling_speed), 32, 128, view_hview[0] - 48);
draw_set_color(c_black);
draw_text(128 + (256 - string_width("Tilling"))/2, (view_hview[0] - 48) + (32 - string_height("Tilling"))/2, "Tilling");

It draws and works fine until I update it where the once drawn "cast bar" is no longer able to be seen. The code was updating fine until I added the variable view_hview[0]. After I added that variable to be relative to the screen it no longer updates correctly and just vanishes whenever I update the function after the initial compilation.

Edit:

Here's how I'm defining my camera variables in a step event:

var camera = view_get_camera(0);
camera_set_view_size(camera, view_wport[0], view_hport[0]);
view_wview[0] = camera_get_view_width(0);
view_hview[0] = camera_get_view_height(0);
view_yview[0] += (obj_player.y-(view_hview[0]/2) - view_yview[0]) * 0.1;
view_xview[0] += (obj_player.x-(view_wview[0]/2) - view_xview[0]) * 0.3;
camera_set_view_pos(camera, view_xview[0], view_yview[0]);
Developer (1 edit)

view_*view variables have been deprecated since GMS2 - trying to use them as user-defined variables can have various undefined behaviour.

Did not know this. Been a while since I've started using GMS. Thanks!