categoryBits

Im still trying to figure out why I am using category bits, I went to http://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart but the image was down.

this is the file im working on, and it seems if I erase categoryBits from the filter table it runs the same. Any ideas on how I can understand categoryBits better? I went to the red baloon, blue baloon doc but im still confused. P.S. which language should i choose in the drop down when I attach code as there is no Lua?

edit: upon further research I found the asteroids image at http://docs.coronalabs.com/daily/guide/physics/collisionDetection/index.html and I think that helps me a little, this sample code was confusing by naming the images the same as the sums.

-- Declare the visible width and height of the screen as constants \_W = display.viewableContentWidth \_H = display.viewableContentHeight -- Call the physics library local physics = require("physics"); -- Start the physics engine -- THIS IS IMPORTANT!! physics.start(); --physics.setDrawMode("hybrid");--You can also use "debug" --Create a white rectangle for the background local background = display.newRect(\_W / 2, \_H / 2, \_W, \_H) background:setFillColor(1,1,1) local leftWall = display.newRect(0,0,10,\_H); leftWall:setFillColor(255,156,0); leftWall.x = -5; leftWall.y = \_H \* 0.5; local rightWall = display.newRect(0,0,10,\_H); rightWall:setFillColor(255,156,0); rightWall.x = \_W + 5; rightWall.y = \_H \* 0.5; physics.addBody(leftWall,"static",{friction = 0.5, bounce = 0.5}); physics.addBody(rightWall,"static",{friction = 0.5, bounce = 0.5}); --For convenience, create a table of strings that refer to images to be loaded local imgTable = {256, 128, 64, 32, 16, 8, 4, 2, 1}; --Create a table to hold our image objects local blocks = {}; --Use a loop to quickly create image objects for i = 1, #imgTable do local img = "images/" .. imgTable[i] .. ".png"; blocks[i] = display.newImageRect(img,321,25); blocks[i].x = \_W \* 0.5; blocks[i].y = (\_H - (blocks[i].height \* 0.5)) - (blocks[i].height \* (i-1)\*1.5); physics.addBody(blocks[i],"static",{ filter = { categoryBits = imgTable[i], maskBits = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 } }); end local foo = display.newImageRect("images/foo.png",100,100); foo.x = 50; foo.y = 50; local bar = display.newImageRect("images/bar.png",100,100); bar.x = \_W - 50; bar.y = 50; physics.addBody(foo,{ bounce = 0.5, friction = 0.5, radius = 50, filter = { categoryBits = 1, maskBits = 128 } }); physics.addBody(bar,{ bounce = 0.5, friction = 0.5, radius = 50, filter = { categoryBits = 2, maskBits = 8 } }); local oddBlock01 = display.newImageRect("images/oddBlock01.png",62,60); oddBlock01.x = 135; oddBlock01.y = 50; local oddBlock02 = display.newImageRect("images/oddBlock02.png",60,52); oddBlock02.x = 200; oddBlock02.y = 50; local pBody = {}; --Create a table of physics body shapes for the two oddBlock objects pBody.oddBlock01 = { { friction = 0.2, bounce = 0.6, filter = { categoryBits = 4, maskBits = 256 }, shape = {-14,-29, 21,-25, 30,16, 11,29, -22,21, -30,4}--Collection of x/y coordinates, arranged clockwise, based on the center of the object at 0,0 } } pBody.oddBlock02 = { {--shape 1 friction = 0.2, filter = { categoryBits = 16, maskBits = 16 }, shape = {-17,-12, -13,-25, 9,-25, 30,15} }, {--shape 2 friction = 0.2, filter = { categoryBits = 16, maskBits = 16 }, shape = {-17,-12, 30,15, -16,25} }, {--shape 3 friction = 0.2, filter = { categoryBits = 16, maskBits = 16 }, shape = {-28,-2, -17,-12, -16,25, -26,14} } } --Use "unpack" to serialize a table physics.addBody(oddBlock01, unpack(pBody.oddBlock01)); physics.addBody(oddBlock02, unpack(pBody.oddBlock02));