I’m wondering why I’m seeing inconsistent behaviour between circle and edge bodies …
Let’s say we create a circle body, and an edge body, and give them linear velocities in setup()
And then in draw() we draw a rect (for the circle) and line (for the paddle) … What happens is
that the ball will start moving but the paddle does not … Any ideas?
ball = physics.body(CIRCLE, 20)
ball.position = vec2(100, 100)
ball.linearVelocity = vec2(50,10)
rect(ball.x-20, ball.y-20, 40, 40)
paddle = physics.body(EDGE, vec2(60,20), vec2(160,20))
paddle.linearVelocity = vec2(50,10)
line(paddle.points[1].x, paddle.points[1].y, paddle.points[2].x, paddle.points[2].y)
Thanks!
Ignatz
February 21, 2014, 10:44pm
2
@escape75 - an edge body doesn’t move - it’s static
Ok, but I also get the same results using a Polygon body,
and I set them both to type Dynamic …
When using polygon I adjust the line …
line(paddle.points[1].x, paddle.points[1].y, paddle.points[4].x, paddle.points[4].y)
@escape75 See this link for an example of a ball and paddle that uses CIRCLE and EDGE. Slide your finger right or left to move the paddle.
http://twolivesleft.com/Codea/Talk/discussion/4576/simple-ball-paddle-example/p1
Thanks, based on the example I was able to fix my issue.
paddle = physics.body(POLYGON, vec2(-60,10), vec2(60,10), vec2(60,-10), vec2(-60,-10))
paddle.position = vec2(WIDTH/2,60)
paddle.type = STATIC
rect(paddle.x, paddle.y, 120, 20)