local eventDispatcher = self:getEventDispatcher()
local contactListener = cc.EventListenerPhysicsContact:create()
contactListener:registerScriptHandler(function(physicsContact)
printf('>> EVENT_PHYSICS_CONTACT_BEGIN')
return true
end, cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN)
contactListener:registerScriptHandler(function(physicsContact)
printf('>> EVENT_PHYSICS_CONTACT_PRESOLVE')
end, cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE)
contactListener:registerScriptHandler(function(physicsContact)
printf('>> EVENT_PHYSICS_CONTACT_POSTSOLVE')
end, cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE)
contactListener:registerScriptHandler(function(physicsContact)
printf('>> EVENT_PHYSICS_CONTACT_SEPERATE')
end, cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE)
eventDispatcher:addEventListenerWithSceneGraphPriority(contactListener, self)
我这样写只进了begin