X position variable is rounded

That reminds me — Hopscotch’s grid size is based on points. Different screens can have different number of pixels for each point (some have 1x1 pixel for each point, some screens have 2x2, some high-definition might have 3x3). So I think the X position variable may round to the nearest point, regardless of whichever pixel - point ratio it is.


source: iPad & iPhone Graphics points vs pixels


source: Ultimate Guide to iPhone resolutions

4 Likes

so you’re saying that this is because of my device, and not a hopscotch bug?

2 Likes

ah ok, never mind then @/Friday! :sweat_smile:

4 Likes

So it’s not dependent on your device — using points means it will be the same number regardless of whichever device you’re on.

In the second graphic, for the last 2 pictures for example — you can see in points that they both have the same coordinates 320x480. This means that they can use that coordinate system even if the actual screen resolution for one of them is 640x960 and the other one is 320x480.

But I will have to confirm whether it’s meant to be rounded.

3 Likes

ah i see, i misunderstood :sweat_smile:

okay, tysm!

2 Likes

@t1_hopscotch - any updates?

2 Likes

Sorry for the delay in getting back, I appreciate the reminder.

I checked the player code for traits (the built-in object variables), and the X position trait is indeed deliberately rounded at the moment. (Same for Y position, origin X and origin Y.)

I suspect it might be optimised for newer users (e.g. if you want to display the X position of an object, all the extra decimals is probably a bit overwhelming at first). But for projects where you need accuracy, it becomes problematic.

We can leave this topic open, so we can decide to revisit that design decision if we would like.

For now, I think a way to get accuracy would be to use other variables (In the second Set Position in the original post, you would have to use the same math operators as in the first, or put the math operators in a custom variable and use that, rather than use the X position trait)

3 Likes

okay thank you!

1 Like