Greeting gurus,
my demo is quite simple, a moving platform & a dropping box
But seems like what corona physic engine provided doesn’t make any sense in my situation
here my code, you can try run it
main.lua
[code]
local physics = require( “physics” )
physics.start()
local gGameMovement = {}
function autoMovePlatform(x1, y1, x2, y2, moveSpeed, objectRef)
local direction = 1
function reverseDirectionCallBack()
if direction == 1 then
direction = 2
xto, yto = x2, y2
else
direction = 1
xto, yto = x1, y1
end
trans = transition.to(objectRef, {time=moveSpeed, x=xto, y=yto, onComplete=reverseDirectionCallBack})
–gGroup.movement = trans
table.insert(gGameMovement, trans)
end
reverseDirectionCallBack()
end
– platform
local square = display.newRect( 0, 0, 50, 10 )
square:setFillColor( 255,255,255 )
square.x, square.y = 174, 119
autoMovePlatform(74, 119, 254, 281, 20000, square)
physics.addBody(square, ‘static’, {density=3.0, friction=0.5, bounce=0.1 } )
– dropping ball
local ball = display.newRect( 0, 0, 30, 30 )
ball:setFillColor( 255,255,0 )
ball.x, ball.y = 174, 9
physics.addBody(ball, ‘dynamic’, {density=3.0, friction=0.5, bounce=0.1 } )
[/code] [import]uid: 10373 topic_id: 4698 reply_id: 304698[/import]