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
答案 0 :(得分:0)
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