Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
No collision detected — Gideros Forum

No collision detected

AhBadianeAhBadiane Member
edited March 2013 in General questions
Hello,

In this project I'm working on collions
The test : a ball that moves on the screen and a snake moves on each touch screen
I watched the example "collision Detection" and incluted the four physics events

In my project (in the attached file), no collision occurs between the snake and the ball :-S

I ask a lot, but you have an idea ?
zip
zip
SnakeBreakout.zip
20K
AhBadiane
Tagged:

Comments

  • ScouserScouser Guru
    edited March 2013
    @AhBadiane: After looking at your code, I see a few problems.
    You have no collision filters set up for your snake or ball
    -- Add this line above where you create the snake fixture
    -- Snake is object 0x10 & accepts collisions from object 1 (ball)
    local filter = {categoryBits = 0x10, maskBits = 1}
    -- Now add filter=filter to the end of your createFixture line like so
    Self.body[ind]:createFixture{shape = Self.shape, density = 1, restitution = 0.2, friction = 0.3, filter=filter}
     
    -- Add this line above where you create the ball fixture
    -- Ball is object 1 & accepts collisions from object 0x10 (snake)
    local filter = {categoryBits = 1, maskBits = 0x10}
    -- Now add filter=filter to the end of your createFixture line like so
    self.body:createFixture{shape = self.shape, density = 1, restitution = 0.2, friction = 0.3, filter=filter}
    You are moving the ball yourself, you should apply a force to it and allow box2d to move it using world:step. Without this box2d doesn't know a collision has occurred so cannot call your collision functions

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
  • @Scouser, thank you for your help. I understand the concept of filter.
    But I do not understand the concept of force and not "move it using world: step"

    I am a true beginner, but once turn my project, I would do a little tutorial for beginners like me ;)
    AhBadiane
  • @AhBadiane, after looking more at your code, I think you're making things more complicated than they need to be with your use of Box2D.

    I would suggest using TNT Collision Engine by @GregBUG.

    I haven't used it myself but from other forum member's comments I understand it will do everything you will want (and probably more besides).
  • @Scouser, I began to look towards TNT Collision and indeed it is much simpler. I will continue with TNT
    Too bad, I wanted to finish without TNT :-((
    AhBadiane
Sign In or Register to comment.