Physics Collisions.... yea, I'm asking a n00B question

I’m building a basic side scroller and I was NOT planning on using physics.

I have a Runtime “enterFrame” listener that moves a big group that has my background and all of the things I can collide with in a right to left manner. My player avatar is currently a touch and drag to move up, down, left and right avoiding the things that need avoided, running into the things that need run into. Due to the nature of the game I really can’t just test for collisions using the image rectangles as I want the target of the collisions to be a bit smaller.

So I’m implementing physics.

Here’s my relevant code:

local physics = require("physics")  
...  
 physics.start()  
 physics.setDrawMode( "hybrid" )  
 physics.setGravity( 0, 0 )  
 local staticCollisionFilter = { categoryBits = 1, maskBits = 2 }  
 local playerCollisionFilter = { categoryBits = 2, maskBits = 1 }   
...  
 local blockerBaseShape = { -25,40, 25,40, 25,0, -25,0 }  
 local blockerPhysics = { density = 10.0, friction = 1.0, bounce = 0.2, shape=blockerBaseShape }  
 -- blockers are objects that stop your progression.  
...  
-- this is the level boss in slot 0. All of the object setup stuff is omitted -- and working...  
physics.addBody( objects[1], "kinematic", { density=1.5, friction=0.5, bounce=0.8 } )  
...  
for i=1,numBlockers do  
 ... -- create the objects  
 physics.addBody( objects[i], "static", blockerPhysics )  
end  
for i=numBlockers+1, numPickups + numBlockers + 1 do -- add the pick up items after the blockers  
 ... -- create the objects  
 physics.addBody( objects[i], "kinematic", { density=1.0, friction=0.5, bounce=0.3})  
 objects[i].isSensor = true  
end  
  
...  
-- code to create the player  
...  
physics.addBody(player, "kinematic", { density=1.0, friction=0.5, bounce=0.3})  
  
local function onCollision(event)  
 print(event.phase .. " " .. event.object1.name .. " is colliding with " .. event.object2.name)  
end  
  
Runtime:addEventListener( "collision", onCollision )  

So all my objects create properly. I see the debug boxes. The things that are kinematic are purple, the static green. The boxes are where I expect them. But when I run into things, nothing happens. Of course I’ve not programmed any behavior for the collisions yet, but I would expect my print statement to print.

I was using collision Filters, which I will need to implement because it is possible for pickup’s to collide with other blocker and pickup items, and I don’t want those to trigger.

I had also tried making the collision detection only on the player object and that didn’t work either.

What am I missing???
I should add, this is a Storyboard based application, and there is a physics.stop() call in the exitScene event handler.

Help!!!

Thanks
Rob [import]uid: 19626 topic_id: 18387 reply_id: 318387[/import]

I want to add, that I changed the player to static, and while I’m touch-and-dragging, its yellow, when I stop, it turns grey.

The player has the ability to fire a bullet, and when I added it as a physics body, dynamic it stayed yellow and I got collisions with the player, but not anything else.

I’m at a loss. [import]uid: 19626 topic_id: 18387 reply_id: 70504[/import]

Okay this is the “all objects have to be in the same display group” problem.

My player was not in the “backgroundGroup” where all the board elements were placed.

I added my player to the backgroundGroup and now I’m getting collisions, but because the backgroundGroup.x is changing to scroll the background, as soon as I touch the player, it blinks away (I’m assuming it’s because player.x is getting set to event.x as part of the drag operation. But the event.x is in screen coordinate space, which I suspect is jumping my player back to the begging of the level.

I tried adding the backgroundGroup.x to my player’s .x but it just zoomed off the screen too.

ARGGGHHHHHHHHHH!
[import]uid: 19626 topic_id: 18387 reply_id: 70520[/import]