Changing Game Score to Font Images AND centering
j75
Member, PRO Posts: 235
I have a game set up that has space for 10 score numbers allocated.
The numbers are constrained to images so that the score is displayed in a custom font as directed by a tshirtbooth video.
Since I have so many numbers for the score, I have added a feature that makes the score digits transparent if it is not in use.
So, instead of...
00000001525
it will delete the "0's" that are not in use, like so.
..............1525
My question is, is there a way to have the visible score numbers centered to the screen?
As it sits now, the score starts from the right and continues left as is grows.
Thanks!
The numbers are constrained to images so that the score is displayed in a custom font as directed by a tshirtbooth video.
Since I have so many numbers for the score, I have added a feature that makes the score digits transparent if it is not in use.
So, instead of...
00000001525
it will delete the "0's" that are not in use, like so.
..............1525
My question is, is there a way to have the visible score numbers centered to the screen?
As it sits now, the score starts from the right and continues left as is grows.
Thanks!
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
you will do this on every actor in the score.
you have an actor for each place, like zero, ten, hundred, thousand
and they all start off in the same spot.
for the zero place actor:
if game.score is > or = to 10
Position.X + 20
if game.score is > or = to 100
Position.X +40
if game.score is > or = to 1000
position.X + 60
for the other actors:
if game.score is > or = to 10
Position.X - 20
if game.score is > or = to 100
Position.X - 40
if game.score is > or = to 1000
Position.X - 60
this is off the top of my head, I didn't check it in GS so I may have forgot something...
Also, the actor I used spawned the other numbers, so you probably will have to tweak this a little bit.
I will play around with the positions and try to make it work.
Like Balls? Then click here! We've 100 coming soon
For growing numbers to the left, it's as simple as using alpha values to hide the 0s until they're in use.
For growing numbers to the right, tatiang came up with a formula that was more elegant than anything I'd come up with, but I don't think I went back and changed my code. Should probably do that. I'll see if I can dig up the thread we discussed it in.
For keeping centred, it's much more fiddly but really not very complicated. I complicated things slightly more by needing to put a + or - at the start of the number.
I'll PM you a link to a quick and dirty example of how I chose to do it. Please note though that it can be tightened up a lot. I was finishing this game in a mad rush to get it released by Christmas and in time for the Amazon promotion. Although the end user experience was what I was after, the code behind it wasn't as carefully optimised as I like. I also had a reason for using individual actors for each digit, but I expect the same result could be achieved with one actor and a bunch of extra if statements.
If I get time I'll comment and organise the code and add example buttons and things to make a real template, but what I'm sending you is the best I can manage for now, and shows you everything you need to know to translate it to your game and cut down the code a fair bit!
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support