Align Currency Number in constant distance to actor based on amount. How?
BigDave
Member Posts: 2,239
I'm sure some of you have a nice solution for this so here my question.
I have a currency icon and a display text behaviour next to it.
Now i want depending on the amount move the number next so they remain the same distance to the symbol even tough they go above the decimal etc.
Currency<10 = +12 pixels to the actor
Currency>100 = +24 pixel to the actor
Currency>1000= +36 pixels to the actor
Currency>10000= +48 pixel to the actor
etc.
I could do it by making separate behaviour for each with the conditions above but I would prefer an equation that will follow that behaviour endless.
Any idea?
Comments
Can you provide a sketch of what this should look like? I'm not clear on what the "actor" has to do with the position of the currency. Are you trying to display the currency amount to the left (or right) of another actor? Have you tried aligning the text left or right?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
hi @tatliang
I now do align it and this works suprisingly fine.
But still the position would need to adjust to the amount of numbers displayed here is how it is right now.
As you see the coin is centred the text aligned on the right side of it.
But the whole component is not perfectly centred anymore
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
So with this approach I basically want to keep the actor centered considering the
actor size + text length
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
-deleted, ignore
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
-
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
I see, so you want the currency symbol and value to be centered over the "stand" actor. Yes, I think you would need to add an offset pixel value as you suggested. Use a fixed width font.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Is there a way to get the digits displayed
like 100 = 3 digits
From there i could make a solid equation like
3 digits * -12 Pixel (font size)
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de
Yes, just do textLength(number.attribute). That'll give you the number of digits.
I'll see if I can dig out my left aligned custom font demo though, the easiest way is to just bake it all in to the custom font display.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
@Armelline @tatiang perfect thanks guys!
My Apps
https://itunes.apple.com/de/artist/david-zobrist/id733552276
https://play.google.com/store/apps/developer?id=David+Zobrist&hl=de