How can I Display Text of distance actor travels? (like on Doodle Jump)
Simple Gamer Arts
Member, PRO Posts: 305
So I am making a jumper game similar to Doodle Jump and can't decipher how to Display Text of distance that my actor travels upward.
So, the scene dimensions are 800 width by 50,000 height. If anyone has a trick up their sleeve about this one please let me know. THANK YOU
Comments
If the actor is moving through the scene. You can just use the actors Y position minus the starting position. Then multiply or divide that value to determine how much the "distance" changes.
Best
Two.E
GSLearn.com | Templates | Free Demos | Udemy Course
@Two.E Thank you first of all. Could you write the formula down for me please?... I know most of it but when it gets to the multiply or divide this value... I get lost.
In the player actor:
Change attribute self.StartingY to self.Position.Y
Constrain attribute game.distanceTraveled to self.Position.Y - self.StartingY
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank you @tatiang , that worked out wonderfully!
You multiply or divide it depending on how you want it to show. For example, if in your game 128 points of resolution = 1 km, and you want to show the distance traveled in km, then you need to divide the result by 128, etc.
Thanks again @pHghost
So my game is like Doodle Jump, where my actor jumps and gains distance as it goes up; the distance-reader is reading the pixels gained on screen, it's fine... but, it reads with decimal (0.000) and it's already set on integer... I'm guessing it's the nature of reading screen pixels that forces there to be a decimal system...?
Is there a way/formula to eliminate the decimal system in this situation?
If your attribute is an integer then the value that appears will be an integer. If you used a real attribute, you will need to convert it to an integer by using the math function round as in round(game.distance).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
/merged threads
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks a million @tatiang , very helpful!