as to continue my post at : link
i am following the instruction at : link& i have updated the code to :
badc1CollisionFilter = { categoryBits = 1, maskBits = 16 } badc2CollisionFilter = { categoryBits = 2, maskBits = 16 } badc3CollisionFilter = { categoryBits = 4, maskBits = 16 } wallCollisionFilter = { categoryBits = 8, maskBits = 16 } playerCollisionFilter = { categoryBits = 16, maskBits = 15 } function getRandomStar() local temp = starTable[math.random(1, #starTable)] local randomStar = display.newImage(temp.imgpath) if ( temp.imgpath == "BCloud1.png" ) then physics.addBody( randomStar, { density=.1, bounce=0.1, friction=.2, radius=45, filter=badc1CollisionFilter } ) temp.imgpath = "BCloud"..tostring(math.random(1, 3))..".png"; end if ( temp.imgpath == "BCloud2.png" ) then temp.imgpath = "BCloud"..tostring(math.random(1, 3))..".png"; physics.addBody( randomStar, "static", { density=.1, bounce=.1, friction=.2, radius=45 } ) end if ( temp.imgpath == "BCloud3.png" ) then temp.imgpath = "BCloud"..tostring(math.random(1, 3))..".png"; physics.addBody( randomStar, "static", { density=.1, bounce=.1, friction=.2, radius=45 } ) end randomStar.myName = "star" -- Set the name of the object to star randomStar.movementSpeed = temp.movementSpeed; -- Set how fast the object will move randomStar.x = math.random(-30, \_W); randomStar.y = -35; randomStar.rotation = math.random(0,20) -- Rotate the object starMove = transition.to(randomStar, { time=randomStar.movementSpeed, y=500, onComplete = function(self) self.parent:remove(self); self = nil; end }) -- Move the star end playerSpriteSheet = sprite.newSpriteSheet("player.png", 113, 55) playerSprites = sprite.newSpriteSet(playerSpriteSheet, 1, 4) sprite.add(playerSprites, "players", 1, 4, 1000, 0) player = sprite.newSprite(playerSprites) player.x = -80 player.y = 350 player:prepare("players") player:play() player.collided = false player:setReferencePoint(display.CenterReferencePoint); physics.addBody(player, "static", {density=.1, bounce=0.1, friction=.2, radius=10, filter=playerCollisionFilter } ) player.gravityScale = 0 screenGroup:insert(player) playerIntro = transition.to(player,{time=2000, x=150, onComplete=playerReady}) local collision = function( badc1CollisionFilter ) if badc1CollisionFilter.phase == 'began' then print("Hello i am badc1CollisionFilter") end end Runtime:addEventListener("badc1CollisionFilter", collision)
so i like the ‘player’ to collide whit badc1CollisionFilter but nothing is happening, and i don’t understand what i am doing wrong
