#Title menu background displaying incorrectly

9 messages · Page 1 of 1 (latest)

civic rampart
#

So I've been working through this tutorial series: https://youtu.be/xLasKr0ekHY?si=jQElIFJBGLb_qqyT

And I have everything working EXCEPT the background for my title screen refuses to display properly. It Either does not display at all and has the text for the menu off center, or it has the text centered but with no background. It changes depending on whether I add or remove lines of code from the Draw tab, but neither is correct. Additionally, the background itself behaves oddly when tiled. The smaller the space it takes up, the larger it appears when I run the game. Attached I've included screenshots. In order, it should show the game running with the lines of code that cause the background to disappear, along with what that looks like, then it's without the code and what that looks like. The final screenshot is just an example of the tiling of the menu room. Any help would be really appreciated as I just cannot seem to identify the problem. It seems like I've followed the tutorial exactly, it just isn't working.

Support me and these videos on Patreon! https://www.patreon.com/peytonburnham

Title screens, pause menus, shop systems, whatever! This system can very easily be added to any game (including the "How to Make an RPG" series game), and is good prep for my next video on Textboxes and Branching Dialogue!

If you want to support me, subscribe and fo...

▶ Play video
coral aspen
#

Looks to me like the issue is the sprite origin

#

It seems like the sprite origin is at top right instead of top left

civic rampart
#

I checked this and unfortunately it is correctly set at the top left. Now, I did flip the sprite and that fixed the issue of it aligning with the text, but it still doesn't help me understand what went wrong with the code or fix the issue where the background size and the tile size seems to invert. There doesn't seem to be a way for me to make the background cover the entire room due to this issue.

velvet saddle
#

So, I followed this tutorial when I was just starting out.

I ended up rewriting it to use the GUI layer, and then ended up scrapping and replacing it with something entirely different.

However, the code still exists in my project, and it still works.

I've read over your code several times, and if there's a difference I am not seeing it.

This would suggest that VI backwardsN I's suggestion that there may be issues with the setup of your assets is probably correct.

I can tell you that my background sprite has its origin at top left and is configured for nine slice. Here is the code (from my reglar draw event, before I rewrote it for draw GUI) in case you want to read over it.

//dynamically get width and height of the options and font 
draw_set_font(fText);

var _new_w = 0;
for (var i = 0; i < op_length; i++)
{
    var _op_w = string_width(option[menu_level,i]);
    _new_w = max(_new_w, _op_w);
}

width = _new_w + op_border * 2;
height = op_border * 2 + string_height(option[0,0]) + (op_length - 1) * op_space;

//center menu
x = camera_get_view_x(view_camera[0]) + camera_get_view_width(view_camera[0])/2 - width/2;
y = camera_get_view_y(view_camera[0]) + camera_get_view_height(view_camera[0])/2 - height/2;

//draw menu background
draw_sprite_ext(sprite_index, image_index,x,y, width/sprite_width, height/sprite_height, 0, c_white, 1);

//draw the options

draw_set_valign(fa_top);
draw_set_halign(fa_left);

for (var i = 0; i < op_length; i++)
{
    var _color = c_white
    if (pos == i){_color = c_yellow}
    draw_text_color(x+op_border,y+op_border + op_space * i,option[menu_level, i],_color,_color,_color,_color,1);    
}
coral aspen
#

I think i did find a mistake that could be causing the issue

#

Here the second = on line 9 should be a +

#

I think game maker is interpreting it as: width = (_new_w == op_border*2);

So, comparing both values, and resulting in 0 if they are not the same, then width/sprite_width is 0/(something) which is always 0, making your image_xscale be 0, which looks like the sprite isn't being drawn at all. This also explains why the text isn't centered, since you are taking width/2 away from it to center it.