diff --git a/src/play_clj/core_physics.clj b/src/play_clj/core_physics.clj index 1e4bdaf..c9d81f7 100644 --- a/src/play_clj/core_physics.clj +++ b/src/play_clj/core_physics.clj @@ -11,6 +11,11 @@ `basic-body` or a `rigid-body`." (fn [screen body] (-> screen (u/get-obj :world) class))) +(defmulti add-joint! + "Adds the `joint` to the `screen` for physics simulations and returns it. For +2D physics, `joint` should be a `joint-def`." + (fn [screen joint] (-> screen (u/get-obj :world) class))) + (defmulti body-position! "Changes the position of the body in `entity`. For 2D physics, the arguments should be x, y, and angle, whereas for 3D physics they should be x, y, and z." diff --git a/src/play_clj/g2d_physics.clj b/src/play_clj/g2d_physics.clj index f0fbd68..a935aec 100644 --- a/src/play_clj/g2d_physics.clj +++ b/src/play_clj/g2d_physics.clj @@ -103,16 +103,6 @@ [object k & options] `(u/call! ^Joint ~object ~k ~@options)) -(defn create-joint!* - [screen j-def] - (box-2d! screen :create-joint j-def)) - -(defmacro create-joint! - "Returns a [Joint](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/physics/box2d/Joint.html)." - [screen j-def & options] - `(let [object# (create-joint!* ~screen ~j-def)] - (u/calls! object# ~@options))) - ; fixtures (defmacro fixture-def @@ -220,6 +210,11 @@ [screen b-def] (box-2d! screen :create-body b-def)) +(defmethod c/add-joint! + World + [screen j-def] + (box-2d! screen :create-joint j-def)) + (defmethod c/physics-listeners World [screen