Here is some part of the code; I have two object below, canavar is the static object and kure is randomly produced with different images. I want to remove the kure object when it has collosion with canavar object. But I can not figure it how to do, I get error all the time. Any help will be highly appreciated
local canavar = display.newImage (“canavar.png”);
canavar.xScale = 0.5
canavar.yScale = 0.5
canavar.alpha = 0.8
canavar:setReferencePoint(display.CenterReferencePoint);
canavar.x = _GE * 0.5
canavar.y = _Y-60
canavar.myName = “canavar”
kareShape = { 50,-40, 50,-20, -50,-20, -50,-40 }
physics.addBody( canavar, “static”, { friction=0.5, bounce=0.3,shape=kareShape})
canavar:addEventListener( “touch”, dokun)
–obje
t = function()
local kure = {}
kure[1] = “kure1.png”
kure[2] = “kure2.png”
kure[3] = “kure3.png”
kure[4] = “kure4.png”
kure[5] = “kure5.png”
kure[6] = “kure6.png”
kure[7] = “kure7.png”
kure[8] = “kure8.png”
local sira = mran(1,#kure)
local yol = kure[sira]
local kure = display.newImage( yol )
kure:setReferencePoint(display.CenterReferencePoint);
kure.xScale = 0.5
kure.yScale = 0.5
kure.x = mran(50,_GE)
kure.y = 30
physics.addBody( kure, { friction=0.5, bounce=0.3,radius=30 } )
end
–Gruplar
–Zamanlay?c?lar
timer.performWithDelay( 1000, t, -1 )
–Olaylar
local function onLocalCollision( self, event )
if ( event.phase == “began” ) then
kure:removeSelf()
elseif ( event.phase == “ended” ) then
end
end
canavar.collision = onLocalCollision
canavar:addEventListener( “collision”, canavar )
kure.collision = onLocalCollision
kure:addEventListener( “collision”, kure ) [import]uid: 74718 topic_id: 12344 reply_id: 312344[/import]