All I have in my game is a player, which is this:
local player = display.newRect(30, centerY - 20, 20, 20) player:setFillColor(0.5)
Movement buttons, which are these:
local upArrow = display.newImage("arrows/up.png", 50, centerY + 30) local downArrow = display.newImage("arrows/down.png", 50, centerY + 130) local rightArrow = display.newImage("arrows/right.png", 100, centerY + 80) local leftArrow = display.newImage("arrows/left.png", 0, centerY + 80)
They work like this:
function moveUp( event ) player.y = player.y - 5 end upArrow:addEventListener("tap", moveUp)
And I have objects that I named blocks(which are these white “walls”):
local block1 = display.newRect(centerX, centerY - 50, 100, 220) local block2 = display.newRect(centerX + 125, centerY + 135, 350, 80) local block3 = display.newRect(centerX + 188, centerY + 45, 200, 100) local block4 = display.newRect(centerX + 100, centerY - 100, 100, 125) local block5 = display.newRect(centerX + 240, centerY - 50, 100, 100) local block6 = display.newRect(centerX + 230, centerY - 160, 160, 50)
How could I detect the player hitting one of these blocks?