ok i guess my question bit complex so i just want share the code ;
local physics = require “physics”
physics.start()
physics.setGravity(0,0)
–setting background image center
local centerX = display.contentCenterX
local centerY = display.contentCenterY
local background = display.newImage(“background.jpg”)
background.y = centerY
background.x = centerX
–playeroneface
local happy = display.newImage(“happygirl.png”)
happy.x = 100
happy.y = 100
physics.addBody(happy, “dynamic”)
local angry = display.newImage(“angrymen1.png”)
angry.x = 880
angry.y = 600
physics.addBody(angry, “static”)
local angry2 = display.newImage(“angrymen2.png”)
angry2.x = 830
angry2.y = 520
physics.addBody(angry2, “static”)
function touchScreen(event)
if event.phase == “ended” then
--print(event.x)
transition.to(happy, {time=1000, x=event.x, y=event.y})
end
end
Runtime:addEventListener(“touch”, touchScreen)
function moveAngry()
transition.to(angry,{time=1000, x=math.random(80,880),y=math.random(60,580), onComplete=moveAngry})
transition.to(angry2,{time=1000, x=math.random(80,880),y=math.random(60,580)})
end
moveAngry()
function onCollision (event)
happy:removeSelf()
– here i want display text Restart and start gain
end
Runtime:addEventListener(“collision”, onCollision)