Jump to content
  • Advertisement
Sign in to follow this  
Tejwinder

corona sdk collision not working

This topic is 1130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

my  code collision is not working

 

local physics = require("physics")

physics.start()
 
display.setDefault("background", 88/255)
 
local myRect = display.newRect(100,100,100,100)
 
myRect.anchorX = 1
myRect.anchorY = 1
 
myRect.x = display.contentCenterX
myRect.y = display.contentCenterY
 
physics.addBody( myRect,{ density=4.0, friction=1, bounce=0.4})
 
local coolRect = display.newRect(20,20,500,50)
 
 
coolRect.anchorY = 1
coolRect.anchorY = 1
 
coolRect.x = 250
coolRect.y = 525
 
physics.addBody( coolRect,{ isSensor = false} )
 
coolRect.bodyType = "kinematic" 
 
local widget = require( "widget" )
 
local function handleButtonEvent( event )
 
    if ( "ended" == event.phase ) then
    transition.moveTo(myRect, { x=100 + 115, y=100 + 115, time=500 } )
        
    end
end
 
local button1 = widget.newButton
{
    width = 240,
    height = 120,
    defaultFile = "Play.png",
    overFile = "Play.png",
    label = "button",
    onEvent = handleButtonEvent
}
 
local function onCollision( event )
    if ( event.phase == "began" ) then
        print( "began: " .. event.object1.myRect .. " & " .. event.object2.coolRect )
    elseif ( event.phase == "ended" ) then
        print( "ended: " .. event.object1.myRect .. " & " .. event.object2.coolRect )
    end
end
 

Share this post


Link to post
Share on other sites
Advertisement

This topic is 1130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!