Polygon vertices position

Hello,

I’m trying to get the position of vertices of the polygon when animating, but I can’t get there :confused:

Is there anything I’m missing? There’s no word on it in docs, only RectPath is described.

I’ve got some cool physical effects in mind, but this is blocking me, kind of, from doing it.

Thanks,

Krystian

We haven’t done anything there yet :slight_smile:

Can you give us some use cases? Better yet, some code snippets to illustrate what you’d like to do?

Walter,

I would like to simulate a bouncing ball.

I simply create a physical object which consists of a ball and some joints.

In enter frame I would assign positions of the vertices to appropriate elements of my contraption, which would allow to simulate the bounce effect.

local physics = require("physics") local verticles = {} local x, y = 300, 300 local radius = 100 local angle = 40 local circles = {} physics.start() local inner = display.newCircle(x, y, radius - 50) physics.addBody(inner) for i = 1, 360 / angle do     local radians = i \* angle \* math.pi / 180     local xa = x + radius \* math.cos(radians)     local ya = y + radius \* math.sin(radians)     table.insert(verticles, xa)     table.insert(verticles, ya)     local c = display.newCircle(xa, ya, 1)     table.insert(circles, c)     physics.addBody(c)     physics.newJoint("distance", inner, c, inner.x, inner.y, c.x, c.y)     if i \> 1 then         physics.newJoint("distance", circles[i - 1], c, circles[i - 1].x, circles[i - 1].y, c.x, c.y)         if i == 9 then             physics.newJoint("distance", circles[i], circles[1], circles[i].x, circles[i].y, circles[1].x, circles[1].y)         end     end end local poly = display.newPolygon(x, y, verticles) local line = display.newRect(512, 700, 1024, 10) physics.setDrawMode("hybrid") physics.addBody(line) line.bodyType = "static" poly.x = 100 poly.y = 100  

So I would like to map it to the polygon you see there, and put a texture on the polygon, like a beach ball for example :wink:

We haven’t done anything there yet :slight_smile:

Can you give us some use cases? Better yet, some code snippets to illustrate what you’d like to do?

Walter,

I would like to simulate a bouncing ball.

I simply create a physical object which consists of a ball and some joints.

In enter frame I would assign positions of the vertices to appropriate elements of my contraption, which would allow to simulate the bounce effect.

local physics = require("physics") local verticles = {} local x, y = 300, 300 local radius = 100 local angle = 40 local circles = {} physics.start() local inner = display.newCircle(x, y, radius - 50) physics.addBody(inner) for i = 1, 360 / angle do     local radians = i \* angle \* math.pi / 180     local xa = x + radius \* math.cos(radians)     local ya = y + radius \* math.sin(radians)     table.insert(verticles, xa)     table.insert(verticles, ya)     local c = display.newCircle(xa, ya, 1)     table.insert(circles, c)     physics.addBody(c)     physics.newJoint("distance", inner, c, inner.x, inner.y, c.x, c.y)     if i \> 1 then         physics.newJoint("distance", circles[i - 1], c, circles[i - 1].x, circles[i - 1].y, c.x, c.y)         if i == 9 then             physics.newJoint("distance", circles[i], circles[1], circles[i].x, circles[i].y, circles[1].x, circles[1].y)         end     end end local poly = display.newPolygon(x, y, verticles) local line = display.newRect(512, 700, 1024, 10) physics.setDrawMode("hybrid") physics.addBody(line) line.bodyType = "static" poly.x = 100 poly.y = 100  

So I would like to map it to the polygon you see there, and put a texture on the polygon, like a beach ball for example :wink: