Hi all,
Just wanted to share with you a very simple physics example, that helped me to understand the basic functions.
(An update is available later in this post, below)
--# Main
supportedOrientations(LANDSCAPE_LEFT)
saveProjectInfo("Description", "Just a simple ball to bounce around.")
-- Use this function to perform your initial setup
function setup()
parameter("GravityScale", .25, 10, 3)
ball = physics.body(CIRCLE, 50)
ball.x = WIDTH/2
ball.y = HEIGHT/2
ball.restitution = .5
wall1 = physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
wall2 = physics.body(EDGE,vec2(0,0),vec2(WIDTH,0))
wall3 = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
wall4 = physics.body(EDGE,vec2(WIDTH,HEIGHT),vec2(0,HEIGHT))
wall1.type = STATIC
wall2.type = STATIC
wall3.type = STATIC
wall4.type = STATIC
wall1.restitution = .1
wall2.restitution = .1
wall3.restitution = .1
wall4.restitution = .1
end
-- This function gets called once every frame
function draw()
physics.gravity(Gravity)
background(40, 40, 50)
strokeWidth(0)
fill(255, 255, 0, 255)
ellipse(ball.x,ball.y,ball.radius*2)
end