Hey guys, Im having a problem thats probably very simple to solve.
So I have a large cloud PNG image that I have placed on the bottom of the device’s screen, its a hill like shape with regular bumps going up and down that allows space for player to float into. The problem is that the player and the base cloud dont interact but rather pass through each other instead. What I want to happen is to allow the player image and cloud image to collide so that whenever the player hits the base cloud it = game over.
cheers
heres my setup so far:
–player bird–
local bird = display.newImageRect("images/player1.png", 49, 39) bird.x, bird.y = 100, 140 bird.name = "bird" physics.addBody( bird, "dynamic", { friction=0.5, bounce=0 } ) group:insert(bird)
– Cloud–
local cloud1 = display.newImage("images/clouds1.png") cloud1:setReferencePoint(display.BottomLeftReferencePoint) cloud1.x = 0 cloud1.y = 325 cloud1.name = "bottom" physics.addBody( cloud1, "static", {isSensor = true } ) group:insert(cloud1)
– Collision –
function onCollision( event ) if(event.object1.name == "bird" and event.object2.name == "bottom") then print("bottom") end end