Collsion is not firing between object

Hi . i worked with corona for some time now . but i dont know what is happening .

since i start working with the GUI and things getting messy . sometimes things works sometimes not :).

so i have this simple code and i am not be able to make the collision work . the ImpactF function is not working.

this is a simple scene with 2 images and i need to stop the image transition once the collision occur . and also print the event.target .name and event.other.name

but it is not working .

the simulator is 2016.2904 windows

MAC OSX is 2016.2912

any help ?

--------------------------------------------------------------------------------- -- -- scene.lua -- --------------------------------------------------------------------------------- local composer = require( "composer" ) local physics = require("physics") -- Load scene with same root filename as this file local scene = composer.newScene( sceneName ) --------------------------------------------------------------------------------- function scene:create( event ) local sceneGroup = self.view -- Called when the scene's view does not exist -- -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc physics.start() physics.setGravity(0,0) local SettingsButton = display.newImage (sceneGroup,"Settings32.png") SettingsButton.x = 114 SettingsButton.y = 60 physics.addBody( SettingsButton, "dynamic" ,{radius = 0, isSensor = true }) SettingsButton.name="SettingNames" SettingsButton.myName="SettingNames" local Base = display.newImage (sceneGroup,"Settings32.png",200,200) Base:scale( 4, 1) Base.x = 114 Base.y = 0 Base:toFront() physics.addBody( Base, "static" ,{radius = 0, isSensor = true }) Base.name="BaseName" local LEFT = 50 local CENTER = display.contentCenterX local RIGHT = display.contentWidth - 50 local UpMove = 50 local CENTERY = display.contentCenterY local DownMove = display.contentHeight - 50 local function handleSwipeX( event ) if event.phase == "moved" then -- display.getCurrentStage():setFocus(event.target) local dX = event.x - event.xStart --if pl2.isMoving==false then if dX \>= 15 then -- swipe right local spot = RIGHT if event.target.x == LEFT then spot = CENTER end MoveRight = transition.to(event.target, { x = event.target.x + 500, time = 1000}) elseif dX \<= -15 then -- swipe left local spot = LEFT if event.target.x == RIGHT then spot = CENTER end MoveLeft = transition.to(event.target, { x = event.target.x - 500, time = 1000}) end end return true end local function handleSwipeY( event ) if event.phase == "moved" then local dY = event.y - event.yStart --if pl2.isMoving==false then if dY \>= 15 then -- swipe right local spotY = DownMove if event.target.Y == UpMove then spot = CENTERY end MoveUp = transition.to(event.target, { y = event.target.y + 500, time = 1000}) elseif dY \<= -15 then -- swipe left local spotY = UpMove if event.target.Y == DownMove then spot = CENTERY end MoveDown = transition.to(event.target, { y = event.target.y - 500, time = 1000}) --end end end return true end ImpactF = function ( event ) if ( event.phase == "began" ) then print(event.target.name) print(event.other.name) SoundImpactName = audio.play (SoundImpact,{ channel=3}) transition.cancel(MoveDown) print("AnyThings") transition.cancel(MoveUp) transition.cancel(MoveLeft) transition.cancel(MoveRight) return true elseif ( event.phase == "ended" ) then end return true end SettingsButton:addEventListener( "touch", handleSwipeY ) SettingsButton:addEventListener( "touch", handleSwipeX ) SettingsButton:addEventListener( "collision", ImpactF) Base:addEventListener( "collision", ImpactF) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase loadsave.saveTable( myData.settings, "settings.json" ) end function scene:destroy( event ) local sceneGroup = self.view -- Called prior to the removal of scene's "view" (sceneGroup) -- -- INSERT code here to cleanup the scene -- e.g. remove display objects, remove touch listeners, save state, etc --BaseT:removeEventListener( "collision", GoToNextLevel ) end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene

any help ?

is there is any wrong with that code ?

You should use physics.hybrid mode to evaluate your code further.

https://docs.coronalabs.com/api/library/physics/setDrawMode.html

Thanks @Alex@Panc i will check

This debugging mode is helpful :slight_smile:

any help ?

is there is any wrong with that code ?

You should use physics.hybrid mode to evaluate your code further.

https://docs.coronalabs.com/api/library/physics/setDrawMode.html

Thanks @Alex@Panc i will check

This debugging mode is helpful :slight_smile: