How do you use the "round" command?
Develop games in your browser. Powerful, performant & highly capable.
The 'round' expression? It just rounds a floating point number to the nearest whole number. Eg. round(0.7) = 1, round(6.3) = 6. It was missing from System Expressions on the wiki, so I added it.
oh... I thought it could be used for grids. Like round 29 to closest 32.
You can also use it for that, to round x to the nearest multiple of 32 is something like:
round(x / 32) * 32
If the alignment is wrong try floor(x / 32) * 32.
Ok thanks! Since mmf didn't use decimals i was used to do just X/32*32.
It's worth noting that division defaults to floating point calculation in Construct - you have to explicitly use Round or Int to specify integer operations (which is opposite to MMF where you explicitly specify when you want to use float operations).