Actually it happens with shape chains AND regular polygons.
When the last point comes in contact with another object
Check it out (Comment out the chain loop to see the polygon loop)
SetErrorMode(2)
SetWindowTitle( "chain" )
SetWindowSize(1024, 768, 0)
SetWindowAllowResize(1)
SetVirtualResolution(256, 192)
SetOrientationAllowed(1, 1, 1, 1)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
type _Point
x as float
y as float
endtype
global mypoints as _Point[]
global spr as integer
global sprW as float
global sprH as float
SetPhysicsDebugOn()
SetPhysicsGravity(0, 5)
mypoints.fromJSON('[{"x": 0.49, "y": 0.39}, {"x": -0.49, "y": 0.39}, {"x": -0.31, "y": -0.02}, {"x": -0.24, "y": -0.33}, {"x": 0.22, "y": -0.33}, {"x": 0.29, "y": -0.02}, {"x": 0.46, "y": 0.04}]')
spr = CreateSprite(0)
SetSpriteVisible(spr, 0)
SetSpriteSize(spr, 20, 20)
sprW = GetSpriteWidth(spr)
sprH = GetSpriteHeight(spr)
i as integer
l as integer
a as integer
l = mypoints.length
AddSpriteShapeChain(spr, l + 1, 0, 1, mypoints[0].x * sprW, mypoints[0].y * sprH)
for i = 1 to l
if i = 0
a = 0
else
a = 1
endif
SetSpriteShapeChain(spr, l + 1, i, 1, mypoints[i].x * sprW, mypoints[i].y * sprH, a)
next
//~l = mypoints.length
//~for i = 1 to l
//~ if i = 0
//~ a = 0
//~ else
//~ a = 1
//~ endif
//~ SetSpriteShapePolygon(spr, l + 1, i, mypoints[i].x * sprW, mypoints[i].y * sprH, a)
//~next
SetSpritePosition(spr, 100, 100)
SetSpritePhysicsOn(spr, 2)
SetSpritePhysicsAngularVelocity(spr, 1)
x as float
y as float
do
x = GetWorldXFromSprite(spr, mypoints[l].x * sprW, mypoints[l].y * sprH)
y = GetWorldYFromSprite(spr, mypoints[l].x * sprW, mypoints[l].y * sprH)
DrawEllipse(x, y, 1, 1, 0xFF00ff00, 0xff00ff00, 1)
//spr = GetSpriteHitCategory(0xFFFF, ScreenToWorldX(GetRawMouseX()), ScreenToWorldY(GetRawMouseY()))
Print("Sprite=" + str(spr))
Sync()
loop