I am trying to move the self.title_top CardArea on the main menu from center to left, so it fits with another title text image I want to display. I managed to write a mod which replaces the main_menu function of game.lua and, for example, changes the version text or move the "balatro" text through its offset parameters. So I know that my code gets recognized. However, when I change the first two parameters (X and Y) that CardArea takes, it does not have any effect...
Through trial and error, I managed to move the area by multiplying the given height parameter by 5, but that seems like somewhat of a band-aid fix. Is there anything I don't see here?
#Issue Moving Card Area On Main Menu
13 messages · Page 1 of 1 (latest)
I think the height and width parameters are in the "correct" scale, which is the scale of the monitor the game is being rendered on.
But I don't know anything about UI.
Yes, I think so too, so I think moving the CardArea on the X axis by "increasing the height" is the wrong approach. Usually in 2D games, you change an object's position through X and Y parameters, and, for example, the offset on the title sprite also works this way. But for some reason I don't understand yet, changing the X and Y on this particular CardArea does not change anything 🤔
How are you changing it?
in the "main_menu" function right before "G.SPLASH_LOGO" gets set I try to edit ```self.title_top = CardArea(
0, 0,
CAI.TITLE_TOP_W,CAI.TITLE_TOP_H,
{card_limit = 1, type = 'title'})
So in the first step I only try to set the X value to something other than 0. 1 or 50 or -50, doesn't matter, the CardArea doesnt move 🤔
just something like
```self.title_top = CardArea(
50, 0,
CAI.TITLE_TOP_W,CAI.TITLE_TOP_H,
{card_limit = 1, type = 'title'})
```you know?
I think the scale of the screen is sufficiently large that 1 and 50 is very small compare to it, or those values serve as the origin. From what you've said, I'm guessing it's the former.
If you're using Steamodded, you can sendDebugMessage and use the Python debugger to see how large the width and height values are. But keep in mind you're going to want to use them anyways
You're right. Eventually I should make the positioning window dependent, but for now I only try to move it at all 😅
So I tried that and first logged CAI.TITLE_TOP_W which is on my screen 2.048780487049 but when I put that in the X it still doesn't move...
Even if I set the value for debug purposes to 10000 it doesn't move at all.
I tried looking further into cardarea.lua and found that the config parameter can also hold an offset, but that appears to only apply to the objects within the card area.
I am not too familiar with LÖVE, because I mostly develop in Unity, but is there any childing or anchoring happening which might lead to the card area staying centered on the window?
Hi! Didn't work with cardareas, but tried to make a couple of custom UI elements in-game. Here are a few things:
- Offsetting an object by 50 units should put it offscreen if your method works, as those units are in "game space" and are size-agnostic from actual window size in pixels.
- Movable objects have a
rolefield that may describe their "bond" with another object if itsrole.role_typeis set toMinor. You can check if that exists and if so, possibly edit the bond or offset found there. - Movable objects also have an
alignmentfield that stores another position offset - you could try editing that to see if the cardarea moves.
Ah now that you say it I see that cardarea inherits from moveable. I'm quite new to Lua 😅
I can see that the title_top is the Major of the title text spirte. So I dont think its role is the issue here 🤔
I tried applying an offset to the alignment like this self.title_top.alignment.offset = {x = 2, y = 0}, which also had no success...
Interestingly I looked into how other card areas are created and none of them ever use the X and Y paramters, they are always 0 🤔
Maybe instead of moving the whole card area I only need to move the card within the are? Hmm
I also found that the buttons of the main menu are actually created in the UI_definitions.lua, so maybe I've been searching at the completely wrong place to begin with? Couldn't find any reference to the CardArea there yet tho