Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Events::PhysicsContact object in Scene#on_contact_begin callback #75

Open
andrewhavens opened this issue Mar 8, 2017 · 2 comments

Comments

@andrewhavens
Copy link
Contributor

I noticed that the on_contact_begin method is documented as yielding an Events::PhysicsContact object. However, the code actually returns NULL. I am curious if this event object could provide some helpful information when determining collision behavior.

I'm working on finding efficient ways to detect whether or not my "player" sprite is colliding with something bad or something good. Right now my code looks like this:

on_contact_begin do |contact_event|
  puts "Bad: #{@hero.intersects?(@bad_guy)}"
  puts "Good: #{@hero.intersects?(@other_guy)}"
end

I'm assuming that checking the intersection of @hero on every collision is not the right approach. I wonder if cocos2d::PhysicsContact is intended to provide this information. Here is the documentation for that: http://cocos2d-x.org/docs/api-ref/cplusplus/v3x/d5/d22/classcocos2d_1_1_physics_contact.html

@eichert12
Copy link
Contributor

Agreed, I ran into the same and think having the PhysicsContact object would be beneficial.

@lrz
Copy link
Member

lrz commented Mar 8, 2017

Looks like I forgot to wrap this one :( It shouldn't be hard to do this, you can add PhysicsContact to https://github.com/HipByte/motion-game/blob/master/src/events.cpp then change the #on_contact_begin callback to create and pass it (you can look at similar methods that create these event objects for an example of use).

I'm not sure what methods the PhysicsContact Ruby class should have. It looks like the interesting C++ methods are returning a PhysicsShape class (http://cocos2d-x.org/reference/native-cpp/V3.2/df/d56/classcocos2d_1_1_physics_shape.html).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants