Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change animation state via variable #1690

Open
SGTADMAN opened this issue Feb 10, 2025 · 7 comments
Open

Change animation state via variable #1690

SGTADMAN opened this issue Feb 10, 2025 · 7 comments
Labels
enhancement New feature or request

Comments

@SGTADMAN
Copy link

Is your feature request related to a problem? Please describe.

I'm trying to display HP, MP, and other stats on a UI. I can't use Draw Text due to limits, but I found a way to display it via actors by having animation states, each one displaying a one- or two-digit number as a sprite. I currently have 100 animation states (0 to 99).

Setting an animation state has to be done via a drop-down menu. So the only way I can set it currently is via several dozen nested if statements, which is as tedious to set up as it sounds.

Describe the solution you'd like

I would like the ability to feed it a number (0 to however many states there are). Preferably via a variable. So if the player HP variable is 37, it will display the 38th animation state (seeing as indexing starts at 0).

Describe alternatives you've considered

Another way I found to display it is via an actor per digit, but it still has to be manually set via switch or if statements.

If there's a way of doing this via GBVM script or something, that would also be fine.

@SGTADMAN SGTADMAN added the enhancement New feature or request label Feb 10, 2025
@nielsderijk
Copy link

Why not use background tiles for the UI and replace them with a variable tile index?

@maxoakland
Copy link

Why not use background tiles for the UI and replace them with a variable tile index?

That's a usable workaround most of the time, but it does have limitations. Especially if you want your UI at the top of the screen and/or you want to have parallax

I have personally done the thing where you have an actor for every character of the score and this would be a nice upgrade. I bet it would be useful for a lot of different scenarios

@SGTADMAN
Copy link
Author

Why not use background tiles for the UI and replace them with a variable tile index?

I've switched to using that for now, but it does mean I have to use up more variables.

I have personally done the thing where you have an actor for every character of the score and this would be a nice upgrade. I bet it would be useful for a lot of different scenarios

I considered using actors for each of the digits as well, but I ran into the actor limit very quickly.

@nielsderijk
Copy link

@SGTADMAN If you make a tile sheet with numbers you can display a 4 digit score with just one variable, so it should not use up much.

@SGTADMAN
Copy link
Author

If you make a tile sheet with numbers you can display a 4 digit score with just one variable, so it should not use up much.

Can you provide an example or guide on doing this?

@nielsderijk
Copy link

nielsderijk commented Feb 16, 2025

@SGTADMAN The GB Studio discord is a better place for this perhaps, but sure, here you go!
I run this script when I want to update the 4-digit score in my HUD. I've added my tileset too, so you can see which tiles are called.

Image

Image

@SGTADMAN
Copy link
Author

@nielsderijk That works perfectly, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants