如何隐藏打中猴子的食物?

好的,我想让每次特定食物击中猴子时,特定食物都会消失

local objects = {
"banana",
"grape",
"pineapple",
"strawberry",
"watermelon",

}
 local function spawnObject()
    local objIdx = mRandom(#objects)
    local objName = objects[objIdx]
    local object = display.newImage( "images/fruit_" .. objName .. "_100.png" )
    object.x = mRandom(screenLeft+30, screenRight-30)
    object.y = screenTop
    object.rotation = mRandom(-15, 15)
    if objIdx < 4 then
        object.type = "food"
    else it
        object.type = "other"
    end
    physics.addBody(object, "dynamic")
    grassfront320w:toFront()

我尝试添加这行代码,但会出现错误

 local function monkeyCollision( self, event )
    if event.phase == "began" then
        if event.target.type == "monkey" and event.other.type == "food" then
            print( "chomp!" )
            Objects.alpha = 0
点赞
用户2307264
用户2307264
local function monkeyCollision( self, event )
    if event.phase == "began" then
        if event.target.type == "monkey" and event.other.type == "food" then
            print( "chomp!" )
            event.other.alpha = 0
local function monkeyCollision( self, event )
    if event.phase == "began" then
        if event.target.type == "monkey" and event.other.type == "food" then
            print( "啃!" )
            event.other.alpha = 0
2014-09-03 14:00:45