lua - Objects keep colliding even though I set the groupIndex -/+ -
i have 4 objects of same kind, mines, , 1 don't want collide of other objects. i've set groupindex
of 4 objects positive , other object negative. 2 of mines works other 2 collides.
here objects:
mine=display.newimage("mine.png") mine:setreferencepoint(display.bottomleftreferencepoint) mine.y=-200 mine.x=math.random(0,280) physics.addbody(mine, "static", {density=0, bounce=0, friction=0, radius=12}) mine.isvisible=true local minecollisionfilter = { groupindex = 2 } mine2=display.newimage("mine.png") mine2:setreferencepoint(display.bottomleftreferencepoint) mine2.y=-400 mine2.x=math.random(0,280) physics.addbody(mine2, "static", {density=0, bounce=0, friction=0, radius=12}) mine2.isvisible=true local mine2collisionfilter = { groupindex = 3 } mine3=display.newimage("mine.png") mine3:setreferencepoint(display.bottomleftreferencepoint) mine3.y=-50 mine3.x=math.random(0,280) physics.addbody(mine3, "static", {density=0, bounce=0, friction=0, radius=12}) mine3.isvisible=true local mine3collisionfilter = { groupindex = 4 } mine4=display.newimage("mine.png") mine4:setreferencepoint(display.bottomleftreferencepoint) mine4.y=-400 mine4.x=math.random(0,280) physics.addbody(mine4, "static", {density=0, bounce=0, friction=0,r adius=12}) mine4.isvisible=true local mine4collisionfilter = { groupindex = 5 } function salvaref(event) salvare=display.newimage("redbutton.png") salvare.x=math.random(0,300) salvare.y=0 salvare.height=30 salvare.width=30 physics.addbody( salvare, "dynamic", {density=0, bounce=0, friction=0, radius=12} ) salvare.gravityscale=0 salvare:setlinearvelocity( 0,350 ) salvare.isvisible=true salvare.collision=evcollision local salvarecollisionfilter = { groupindex=-6 } salvare:addeventlistener("collision", salvare) end
Comments
Post a Comment