I want it that when the player hits/collides/touches/etc with flag then have it display text in center of screen. I couldn’t find an answer for collision for this or I’m not doing it right. Please help, thanks!!!
–
– main.lua
–
display.setStatusBar( display.HiddenStatusBar )
local physics = require “physics”
physics.start()
local background = display.newImage( “background.jpg” )
background.x, background.y = 160, 240
local ground = display.newImage( “ground.png” )
ground.x, ground.y = 160, 700
physics.addBody( ground, “static”, { friction=1.0, density=1.0, bounce=0 } )
local flag = display.newImage( “flag.png” )
flag.x, flag.y = 160, 50
physics.addBody( flag, “static”, { density = 1.0, friction = 0.3, bounce = 0.2 } )
flag.myName = “flag”
local player = display.newImage( “player.png” )
player.x = 160
player.y = 230
player.myName = “player”
physics.addBody( player, { friction=0.3, bounce = 0.3, density = 1.0, radius = 35 } )
local function onScreenTouch( event )
if event.phase == “began” then
– make player jump forward
player:applyForce( 0, -500, player.x, player.y )
end
end
Runtime:addEventListener(“touch”, onScreenTouch )