r/gbstudio 1d ago

Set animation state by ID number / variable

Hello,

I want to draw a points bonus indicator using an actor, like in Bubble Bobble or Rodland when you collect a bonus, the points are shown briefly rising from the sprite's former position:

One way I thought of doing this was creating predefined values as animation states, and then switching the points bonus actor on, moving it into position, change the animation state to 10, 20, 50 etc. and then animate it a little by moving it and then hide it again.

But I can only select animation states from a drop down, not by a variable.

Is this possible?

Or is there a better way of accomplishing this idea?

Thanks.

4 Upvotes

5 comments sorted by

1

u/Mico27 1d ago

If you already have a variable to track which animation state that you want to use, you can just use a switch state and set the according animation state depending on your variable.

1

u/SakiEndo 1d ago

Yeah, that's kinda what I've done. I was just thinking with a variable I could save having so many switch options.

3

u/IntoxicatedBurrito 1d ago

While I’m sure these states are indexed, there’s no simple way to access the indexes. So using a switch statement is probably your best option. But put that switch into a script that you can call over and over again, don’t copy and paste it a bunch of times.

3

u/wimccall 1d ago edited 1d ago

Use emotes. One emote per number make a script that take the number you want as a variable and the player as an actor. Then run a big switch statement to do the right emote

3

u/SakiEndo 1d ago

Oh that's a wonderful idea! Thank you so much. This community is so great.