Need help with variables / text

For questions about using Classic.

Post » Mon Aug 31, 2009 2:58 pm

I want to make distance meter. Now what I have is: reading x position of an object and placing this data into global variable. As a result I got distance in pixels. My problem is that construct shows massive number (example 404.3089748374) so it's 404 px and so much more.
Question: How to reduce that just to whole numbers (main part) and how to divide that by 5 for example.

Always(every tick):
System: Set global variable 'dis' to Sprite2.X
Text: Set text to global('dist')

Thanks
B
4
S
1
G
3
Posts: 85
Reputation: 1,234

Post » Mon Aug 31, 2009 3:36 pm

If you want a whole number, use round(number), such as round(global('dist') / 5)

http://sourceforge.net/apps/mediawiki/c ... xpressions has some helpful stuff on it.
Also, when doing something like: System: Set global variable to...
in that window, you should be able to double-click on the system object, and it'll give you a list of system expressions you can use.

Also of note is the expression: distance(x1,y1,x2,y2)
You can go: distance(sprite1.x,sprite1.y,sprite2.x,sprite2.y)
or round(distance(sprite1.x,sprite1.y,sprite2.x,sprite2.y))
B
3
S
1
G
3
Posts: 82
Reputation: 1,189

Post » Mon Aug 31, 2009 3:44 pm

Thank's, this is exacly what I was looking for. Many thanks!
B
4
S
1
G
3
Posts: 85
Reputation: 1,234


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests