I ran into this before and after experimenting... it seems to be the default sprite colliders are one additional pixel wide. So if the image is 64 pixels wide the collider space covers the sprite area from x=0 to x=64
However, if you add your own collider running from x=0 to x=63 which is the actual space of the sprite you will get the expected behavior.
I updated your sample to show what I mean.
The top 4 sprites in shades of red use the default sprite collider.
The collision function reports a collision for sprites 1 and 2 before they are even moved and the distance between these two sprites is reported as 0 instead of 1.
The distance should be reported as 1 because the space of sprite 1 is from x=300 to x=363 and the space of sprite 2 is from x=364 to x=427... 364-363 = 1.
The bottom sprites in shades of green use custom colliders covering the space from x=0 to x=63 and the distance and the collision are reported correctly both before and after moving expect distance actually shows about 1.9 / 0.9 pixels of space. That is reasonable considering floating point.
But basically my "take away" is always create your own colliders if you want it to be more precise.
SetVirtualResolution( 640,480 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
Spr1 = CreateSprite(0)
SetSpriteColor(Spr1, 192,0,0,255)
SetSpritePosition(Spr1,300,0)
SetSpriteSize(Spr1,64,64)
Spr2 = CreateSprite(0)
SetSpriteColor(Spr2, 255,0,0,255)
SetSpriteSize(Spr2,64,64)
Spr3 = CreateSprite(0)
SetSpriteColor(Spr3, 192,0,0,255)
SetSpritePosition(Spr3,450,0)
SetSpriteSize(Spr3,64,64)
Spr4 = CreateSprite(0)
SetSpriteColor(Spr4, 255,0,0,255)
SetSpriteSize(Spr4,64,64)
Spr5 = CreateSprite(0)
SetSpriteColor(Spr5, 0,192,0,255)
SetSpritePosition(Spr5,300,150)
SetSpriteSize(Spr5,64,64)
SetSpriteShapeBox(Spr5,0,0, 63,63, 0)
Spr6 = CreateSprite(0)
SetSpriteColor(Spr6, 0,255,0,255)
SetSpriteSize(Spr6,64,64)
SetSpriteShapeBox(Spr6,0,0, 63,63, 0)
Spr7 = CreateSprite(0)
SetSpriteColor(Spr7, 0,192,0,255)
SetSpritePosition(Spr7,450,150)
SetSpriteSize(Spr7,64,64)
SetSpriteShapeBox(Spr7,0,0, 63,63, 0)
Spr8 = CreateSprite(0)
SetSpriteColor(Spr8, 0,255,0,255)
SetSpriteSize(Spr8,64,64)
SetSpriteShapeBox(Spr8,0,0, 63,63, 0)
do
If GetRawKeyState(37) `[LeftKey]
SetSpritePosition(Spr2,363,32)
SetSpritePosition(Spr4,514,32)
SetSpritePosition(Spr6,363,182)
SetSpritePosition(Spr8,514,182)
Else
SetSpritePosition(Spr2,364,32)
SetSpritePosition(Spr4,515,32)
SetSpritePosition(Spr6,364,182)
SetSpritePosition(Spr8,515,182)
Endif
print("default colliders")
Print("Sprite 1 to 2 Collision:" + str(GetSpriteCollision(Spr1,Spr2)))
print("Sprite 1 to 2 Distance:" + str(GetSpriteDistance(Spr1,Spr2)))
Print("Sprite 3 to 4 Collision:" + str(GetSpriteCollision(Spr3,Spr4)))
print("Sprite 3 to 4 Distance:" + str(GetSpriteDistance(Spr3,Spr4)))
print("")
print("")
print("custom colliders of 64x64 area")
Print("Sprite 5 to 6 Collision:" + str(GetSpriteCollision(Spr3,Spr4)))
print("Sprite 5 to 6 Distance:" + str(GetSpriteDistance(Spr3,Spr4)))
Print("Sprite 7 to 8 Collision:" + str(GetSpriteCollision(Spr7,Spr8)))
print("Sprite 7 to 8 Distance:" + str(GetSpriteDistance(Spr7,Spr8)))
Sync()
loop
This is the display BEFORE moving...
This is the display AFTER sprites 2,4,6 and 8 have been moved 1 pixel to the left.