#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Physics polygon type body move

edited November 2012 Posts: 65

I am having trouble with moving a polygon type physics body.
For example

``````box = physics.body(POLYGON, vec2(WIDTH/2-100,50), vec2(WIDTH/2+100,50), vec2(WIDTH/2+100,250), vec2(WIDTH/2-100,50))
box.type = STATIC
``````

I was trying to move by changing box.x and box.y value. But the polygon representation on the screen doesn't move.
Any idea??

Tagged:

• Posts: 666

 ```-- BoxMove   -- Use this function to perform your initial setup function setup()     pdb = PhysicsDebugDraw()     box = createBox(WIDTH/2,HEIGHT/2,20,20)     box.type = STATIC end   function createBox(x,y,w,h)     -- polygons are defined by a series of points in counter-clockwise order     local box = physics.body(POLYGON, vec2(-w/2,h/2), vec2(-w/2,-h/2), vec2(w/2,-h/2), vec2(w/2,h/2))     box.interpolate = true     box.x = x     box.y = y     box.restitutions = 0.25     box.sleepingAllowed = false     pdb:addBody(box)     return box end   -- This function gets called once every frame function draw()          -- This sets a dark background color      background(40, 40, 50)       -- This sets the line thickness     strokeWidth(5)       -- Do your drawing here     pdb:draw() end   function touched(touch)     if touch.tapCount == 1 then         box.x = touch.x     elseif touch.tapCount == 2 then         box.y = touch.y     end end```