Hello,
I’m new here. I’m trying to build my own game in Corona SDK. I have follow some tuts and i think i’m understanding a bit of Lua. I want to show the score everytime when a happy face “destroy” a bad face. This is the code:
display.setStatusBar(display.HiddenStatusBar) local physics = require "physics" physics.start() physics.setGravity(0, 0) local background = display.newImage("background.jpg") local happy = display.newImage("happy.png") happy.x = 45 happy.y = 45 physics.addBody(happy, "dynamic") local angry = display.newImage("angry.png") angry.x = 420 angry.y = 280 physics.addBody(angry, "static") local angry2 = display.newImage("angry.png") angry2.x = 400 angry2.y = 220 physics.addBody(angry2, "static") function touchScreen(event) if event.phase == "began" then 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(10,600), y=math.random(10,250), onComplete=moveAngry}) transition.to(angry2, {time=1000, x=math.random(10,600), y=math.random(10,250)}) end moveAngry() function onCollision(event) --print("Collide!") happy:removeSelf() end Runtime:addEventListener("collision", onCollision)