Sprited counter

Hello i’m actually working on a small pixel art volley game.

I have 2 counter for each team one for point one for round they work well with a text display but i wanna change it for a sprited counter is there a intelligent way to do it ?
cause i can make code for each value and it’s work but maybe someone get a smarter idea, better than making 100 fonction !

This is how it should look finish and i got all my number in sprite

Yep it’s exactly the way i use it actually but it’s a long part of code and i’m pretty sure there is a smarter way to do it
i wanna atribute only a part of the value to respond with one number : exemple

my score is 23 :

  • first number detect only the first part of the value like 00,10,20,30,etc (actual 2)
  • second number only detect the second part 0,1,2,etc (actual 3)
1 Like

Yes, you could do that, using the “text manipulation” expressions.
http://wiki.compilgames.net/doku.php/gdevelop5/all-features/expressions-reference#text_manipulation

1 Like

thx for the link i will try to make it with this :slight_smile:
it’s sometime hard to find a thing that you dont know the name ^^

EDIT : Got it !

is theyre a way to duplicate this without just basicaly copy everything 4 times

2 Likes

change the animation of “Score_Display1” set to (=) ToNumber(VariableString(T1Score)) ?

if i understand well what u say i should have 100 sprite to complete my counter or maybe theire is a way that i dont know in animation

I don’t know how many animations do you have now, but I want to say you aren’t need to do a new event for every animation change. instead of that you can use an expression.

You need to use variables, object groups, and loops:
Group your Score_DisplayX together.
Make a “for each Score_DisplayGroup / set id variable of Score_DisplayGroup = Variable(idvar) / add 1 to idvar” so each object has its own id.
Now, make a repeat 10 times: id of Score_DisplayGroup = Variable(repeatloopvar) / set animation number of Score_DisplayGroup to ToNumber(SubStr(VariableString(T1Score, 1, 1)) / add 1 to repeatloopvar.
…something like that, you get the idea :slight_smile:
For all the repeating events with just a number changing, replace it by a variable, then use a loop to cycle through the numbers.
You probably don’t need to make different score_display objects though, the id should be enough.
Good luck!

3 Likes

wow so many info thx

i will try to make something good with it

(BONUS : i made this sprite sheet for typo fell free to use it each letter is 32x64)
Typo%2032x64

1 Like

i dont really find any exemple of what u saying but i keep the information for later i will try to refocus on main thing then go for it when i got a better global undertanding of the engine :wink:

Thx anyway

2 Likes