okay, so in the physics game’s level1.lua, these are some of the necessary codes:
[lua]
local physics = require “physics”
physics.start()
function Cameraview( event )
group.x = screenW/2 - object1.x
group.y = screenH/1.2 - object1.y
end
function onobject1Touch( event )
if event.phase == “began” then
print(“yo”)
display.getCurrentStage():setFocus(object1)
if a1==0 then
eventx = event.x; eventy = event.y
a1=1
end
elseif event.phase == “ended” then
object1:applyLinearImpulse(0,100,object1.x,object1.y)
print(“hello”)
display.getCurrentStage():setFocus(nil)
x=x+1
end
end
Runtime:addEventListener(“touch”, onobject1Touch)
function scene:createScene( event )
group = self.view
table1 = display.newImageRect(“table1.png”,543,755 )
table1.x = 154
table1.y = 231
table1.name = “img_1”
group:insert(table1)
object1 = display.newImageRect(“object1.png”,140,140 )
object1.x = 162
object1.y = 586
local img_2_shape = {-47,19,18,-46,57,-70,70,-59,48,-21,-17,44,-66,70,-70,63 }
physics.addBody(object1,“static”,{density = .001, friction = 0, bounce = 0, shape = img_2_shape})
object1.name = “img_2”
object1.rotation = 135
group:insert(object1)
object3 = display.newImageRect(“object3.png”,140,140 )
object3.x = 396
object3.y = 70
local img_3_shape = {-51,25,33,-58,60,-70,70,-62,60,-36,-25,51,-64,69,-68,60 }
physics.addBody(object3,“static”,{density = 1, friction = 0, bounce = 0, shape = img_3_shape})
object3.name = “img_3”
object3.rotation = 45
group:insert(object3)
object2 = display.newImageRect(“object2.png”,140,140 )
object2.x = -96
object2.y = 68
local img_4_shape = {-51,23,22,-52,57,-70,69,-58,48,-21,-21,49,-62,69,-70,62 }
physics.addBody(object2,“static”,{density = 1, friction = 0, bounce = 0, shape = img_4_shape})
object2.name = “img_4”
object2.rotation = -135
group:insert(object2)
end
[/lua]