Anyways I used the forums to get an answer to this and what I’m not too sure about is the event.other.objectName part underneath the groungTouch function. Basically all I want to do is have the crates make a (knock) sound when they hit the floor. (the locals for the ground and knock sound are already inserted before this segment).
[lua]local function trackOrbs (obj)
obj: removeSelf ()
end
local function spawncrate ()
local crate = display.newImageRect (“egg.png”, 45, 45);
physics.addBody (crate, {friction= 0.5, bounce= 0.3})
crate.x = math.random(300); crate.y = -100;
function crate: touch (e)
if (e.phase == “began”) then
trackOrbs (self);
audio.play (sound)
end
end
function groundTouch: (e)
if(e.phase == “began”) then
if (event.other.objectName == “ground”) then
audio.play (knock)
end
end
end
crate: addEventListener (“touch”, crate);
crate: addEventListener (“collision”, groundTouch);
end
timer.performWithDelay (10, spawncrate, 2);[/lua] [import]uid: 35535 topic_id: 6749 reply_id: 306749[/import]