GameSalad

how can I calculate distance in % ???

Simple+Gamer+ArtsSimple Gamer Arts Posts: 96Member, PRO
edited December 1 in Working with GS (Mac)

Is there an easy way to calculate how far I got in my runner but in % ?

So, in other words, I'd like to display the % of the total distance I accomplished in the level.... so to say, "user got 33% of the way" for example).

(my runner is from left to right)

My intuition tells me to make an invisible platform the length of the level and to record the amount of pixels from start to finish (death) somehow and then turn it into a % somehow... I just don't know how to do it.

Thank you

Comments

  • IceboxIcebox Posts: 1,445Member, PRO

    (self.positionX / scene width) * 100 , or you can replace the scene width to the final goal's position. You can also round the number to display as an integer if you want.

    Display text round((self.position.X / scene.width)*100)

  • Simple+Gamer+ArtsSimple Gamer Arts Posts: 96Member, PRO

    @Icebox YOU DA MAN, thanks Icebox, that worked beautifully.

Sign In or Register to comment.