COLLISION HELP!

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 )

Look at the collisions information in the documentation. You haven’t even attached a collision listener.

I’ve tried that over 25 times it’s now been weeks I’d literally pay to have someone get the collision working and that way I’d see what I was doing wrong those 25 or more times. PLEASE HELP!

Did you try what horacebury suggested and attach a collision listener?  There are plenty of samples that have this working…

I’d always get errors like table assertion failed get table failed along with other errors. I erased the code that didn’t work after trying for weeks. This is one of the first times I have had to ask a question online. Please help, if you can be so kind to send the code that way I can see what I did wrong and I’ll probably be like, oh yeah, that’s what I did wrong. Please, if you know how please send the code. I have even tried using sublime corona snippets. I did add the event listeners and all that I’ve been searching for working answer for weeks. Please help. Please, it’s driving me nuts

Post the code that doesn’t work and then we’ll have something to look at and debug.

Also, can you use the code button in the editor when you post code so we get line numbers in the forum thread?

I’ll have to do this tonight. I’ll be at my computer hopefully by 9pm eastern time

Look at the collisions information in the documentation. You haven’t even attached a collision listener.

I’ve tried that over 25 times it’s now been weeks I’d literally pay to have someone get the collision working and that way I’d see what I was doing wrong those 25 or more times. PLEASE HELP!

Did you try what horacebury suggested and attach a collision listener?  There are plenty of samples that have this working…

I’d always get errors like table assertion failed get table failed along with other errors. I erased the code that didn’t work after trying for weeks. This is one of the first times I have had to ask a question online. Please help, if you can be so kind to send the code that way I can see what I did wrong and I’ll probably be like, oh yeah, that’s what I did wrong. Please, if you know how please send the code. I have even tried using sublime corona snippets. I did add the event listeners and all that I’ve been searching for working answer for weeks. Please help. Please, it’s driving me nuts

Post the code that doesn’t work and then we’ll have something to look at and debug.

Also, can you use the code button in the editor when you post code so we get line numbers in the forum thread?

I’ll have to do this tonight. I’ll be at my computer hopefully by 9pm eastern time