No I’m not using director :o
It’s like this.
[lua]local background = display.newImageRect( “background.png”, display.contentWidth, display.contentHeight )
background:setReferencePoint( display.TopLeftReferencePoint )
background.x, background.y = 0, 0
local ground = display.newImage( “ground.png” )
ground:setReferencePoint( display.BottomLeftReferencePoint )
ground.x, ground.y = 0, 530
ground.name = “ground”
physics.addBody( ground, “static”, { friction=1.0, density=1.0, bounce=0 } )
local statue = display.newImageRect( “statue.png”, 74, 104 )
statue.x, statue.y = 160, 300
physics.addBody( statue, { density=1.0, friction=0.3, bounce=0.3 } )
function statue:collision(event)
print(“here”)
self.alive = false
if(event.phase == “began”)then
if(event.other.name == “ground”)then
print(“Game Over”)
event.other:setFillColor(255,0,0)
EndGame()
end
end
end
statue:addEventListener(“collision”, statue)
local crate = display.newImageRect( “cement.png”, 220, 40 )
crate.x, crate.y = 160, 380
physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } )
local crate = display.newImageRect( “wood.png”, 50, 60 )
crate.x, crate.y = 60, 430
physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } )
function crate:touch(event)
print(“Destroy”)
if (event.phase == “began”) then
timer.performWithDelay(1, function()
self:removeEventListener(“touch”,self)
self:removeSelf()
end)
end
end
crate:addEventListener(“touch”, crate)
local crate = display.newImageRect( “wood.png”, 50, 60 )
crate.x, crate.y = 260, 430
physics.addBody( crate, { density=1.0, friction=0.3, bounce=0.3 } )
function crate:touch(event)
print(“Destroy”)
if (event.phase == “began”) then
timer.performWithDelay(1, function()
self:removeEventListener(“touch”,self)
self:removeSelf()
end)
end
end
crate:addEventListener(“touch”, crate)
– all display objects must be inserted into group
group:insert( background )
group:insert( ground)
group:insert( crate)
end[/lua] [import]uid: 134147 topic_id: 24533 reply_id: 99342[/import]