Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
self.world:addEventListener(Event.BEGIN_CONTACT, self.onBeginContact,self) — Gideros Forum

self.world:addEventListener(Event.BEGIN_CONTACT, self.onBeginContact,self)

JackoJacko Member
edited February 2015 in General questions
Hello,
Can I specify with what element will react
self.world:addEventListener(Event.BEGIN_CONTACT, self.onBeginContact,self)

Comments

  • jdbcjdbc Member
    edited February 2015
    Yes sure:
     
    local body = world:createBody{type = b2.DYNAMIC_BODY}
    body.type = "ball"
     
    local body2 = world:createBody{type = b2.DYNAMIC_BODY}
    body2.type = "paddle"
     
    ...
     
    function Scene:onBeginContact(event)
    local bodyA = event.fixtureA:getBody()
    local bodyB = event.fixtureB:getBody()
     
    if (bodyA.type == "ball" and bodyB.type == "paddle") or (bodyA.type == "paddle" and bodyB.type == "ball") then		
     
    ...
     
    end

    Likes: Jacko

    +1 -1 (+1 / -0 )Share on Facebook
  • Thank you very much;d
Sign In or Register to comment.