Skip to content

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

@andrewhavens

Description

@andrewhavens

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions