Hey There,
im testing different features of corona and was doing some useless examples :), and i came across this weird behavior.
My example:
I have two rectangles (say pillar1, pillar2) , pillar1 transitions from bottom of the screen to some height, where as pillar 2 transitions from some height to bottom of the screen. there are two objects right on top of these (say hero1, hero2) hero1 is free falling onto the pillar1 and hero2 is going to the bottom along with pillar2.
Weird behavior:
Though i had set bounce=0 for all the objects the hero2 still bounces while pillar2 goes down, how can we make hero2 to not bounce of and just stay on pillar2 while both go down.
In case of hero1, when hero1 freefalls on pillar1 some part of hero1 intersects with the pillar1, why does it intersect with the pillar1, since both of them have solid bodies i expect hero1 to not intersect and fall on pillar2.
where am i going wrong.
below is the code
main.lua
display.setStatusBar( display.HiddenStatusBar ) local physics = require( "physics" ) physics.start() physics.setDrawMode( "debug" ) ------------------------------------------------------------ local pillar1 = display.newRect(40,display.contentHeight,70,display.contentHeight/2) pillar1.anchorY = 0 pillar1.y = display.contentHeight -10 pillar1:setFillColor( .3, 0.5, 0.9 ) pillar1.name = "pillar2" pillar1.isGoingUp = true physics.addBody( pillar1 ,"kinematic", {friction=1,bounce = 0, density = 1} ) -------------------------------------------------------------------------------- local pillar2 = display.newRect(display.contentWidth/2,display.contentHeight,70,display.contentHeight/2) pillar2.anchorY = 0 pillar2.y = display.contentHeight/2 pillar2:setFillColor( .3, 0.5, 0.9 ) pillar2.name = "pillar1" pillar2.isGoingUp = false physics.addBody( pillar2, "kinematic", { friction=1,bounce = 0, density = 1 } ) --------------------------------------------------------------- local hero1 = display.newRect(40,display.contentHeight/2,40,40) hero1:setFillColor( .5, 0.3, 0.1 ) hero1.anchorY = 1 physics.addBody( hero1, "dynamic", { friction=1,bounce = 0, density = 1 } ) hero1.isFixedRotation = true ----------------------------------------------------------------------------------------------------- local hero2 = display.newRect(display.contentWidth/2,display.contentHeight/2,40,40) hero2:setFillColor( .5, 0.3, 0.1 ) hero2.anchorY = 1 physics.addBody( hero2, "dynamic", { friction=1,bounce = 0, density = 1 } ) hero2.isFixedRotation = true ------------------------------------------------------------------------------------------ transition.moveTo(pillar2,{y = (display.contentHeight), time = 2500, onStart=transitionStart,onComplete=transitionComplete}) transition.moveTo(pillar1,{y = (display.contentHeight \* 0.5), time = 2500, onStart=transitionStart,onComplete=transitionComplete})
config.lua
--calculate the aspect ratio of the device local aspectRatio = display.pixelHeight / display.pixelWidth application = { content = { width = aspectRatio \> 1.5 and 800 or math.ceil( 1200 / aspectRatio ), height = aspectRatio \< 1.5 and 1200 or math.ceil( 800 \* aspectRatio ), scale = "letterBox", fps = 30, }, }
Thanks,
Nischal Y
