Hello!
I have a problem with collisions. In LDX i made a level and has placed “stars” which player must to collect.
Main player has been created manually.
There is a part of code of code:
local proj = display.newCircle( 150, 100, 15 ) physics.addBody( proj, { density=1.0, friction=0.3, bounce=0.2 } ) myLevel:addObject('Layer\_1', proj) local function realPlayerCollision(self, event ) local collisionClass = event.other.class print(collisionClass) if (string.len(collisionClass) \> 0 ) then print ('collision ' .. event.phase .. ' with object class',collisionClass,event.other.name) end if ( event.phase == "began" ) then if (collisionClass == 'stars') then myLevel:removeLayerObject("Layer\_1",event.other.name) end end end local function onCollision(self, event ) timer.performWithDelay(1, function() return realPlayerCollision( self, event) end ) end proj.collision = onCollision proj:addEventListener( "collision", proj )
This code I code from example Scroller
But in my game this method does not work. Stars dont dissapear(
Please help me!)