Hey everyone. I wrote this demo code to better demonstrate my challenge. I’m trying to “hit” a physics body with my finger. Not slide it by dragging it. So ideally it would simulate a tennis racquet hitting a ball. The code is simply a container where you could hit the ball using the drawBody function pulled from Codea. Thanks!
function setup()
    supportedOrientations(PORTRAIT)
    j = physics.body(CIRCLE,WIDTH/20)
    j.type = DYNAMIC
    j.x = WIDTH/2
    j.y = HEIGHT/2
    left = physics.body(EDGE,vec2(0,HEIGHT),vec2(0,0))
    left.type = STATIC
    center = physics.body(EDGE,vec2(0,0),vec2(WIDTH,0))
    center.type = STATIC
    right = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
    right.type = STATIC
end
function draw()
    background(0, 0, 0, 255)
    drawBody(left)
    drawBody(center)
    drawBody(right)
    drawBody(j)
end
function drawBody(body)
    pushStyle()
    pushMatrix()
        stroke(255, 255, 255, 255)
        strokeWidth(3.0)
        translate(body.x, body.y)
        if body.shapeType == POLYGON then
            local points = body.points
            for j = 1,#points do
                a = points[j]
                b = points[(j % #points)+1]
                line(a.x, a.y, b.x, b.y)
            end
        elseif body.shapeType == CHAIN or body.shapeType == EDGE then
            local points = body.points
            for j = 1,#points-1 do
                a = points[j]
                b = points[j+1]
                line(a.x, a.y, b.x, b.y)
            end
        elseif body.shapeType == CIRCLE then
            fill(255, 255, 255, 255)
            ellipse(0,0,body.radius*2)
        end
    popMatrix()
    popStyle()
end