|
|
@@ -1,11 +1,11 @@
|
|
|
---
|
|
|
title: Collision events in Defold
|
|
|
-brief: Collision event handling can be centralized by using `physics.set_listener()` to direct all collision and interaction messages to a single specified function.
|
|
|
+brief: Collision event handling can be centralized by using `physics.set_event_listener()` to direct all collision and interaction messages to a single specified function.
|
|
|
---
|
|
|
|
|
|
# Defold Physics Event Handling
|
|
|
|
|
|
-Previously, physics interactions in Defold were handled by broadcasting messages to all components of colliding objects. However, starting with version 1.6.4, Defold offers a more centralized approach through the `physics.set_listener()` function. This function allows you to set a custom listener to handle all physics interaction events in one place, thereby streamlining your code and improving efficiency.
|
|
|
+Previously, physics interactions in Defold were handled by broadcasting messages to all components of colliding objects. However, starting with version 1.6.4, Defold offers a more centralized approach through the `physics.set_event_listener()` function. This function allows you to set a custom listener to handle all physics interaction events in one place, thereby streamlining your code and improving efficiency.
|
|
|
|
|
|
## Setting the Physics World Listener
|
|
|
|
|
|
@@ -19,7 +19,7 @@ Here is an example of how to set a physics world listener within a collection pr
|
|
|
function init(self)
|
|
|
-- Assuming this script is attached to a game object within the collection loaded by the proxy
|
|
|
-- Set the physics world listener for the physics world of this collection proxy
|
|
|
- physics.set_listener(physics_world_listener)
|
|
|
+ physics.set_event_listener(physics_world_listener)
|
|
|
end
|
|
|
```
|
|
|
|
|
|
@@ -101,7 +101,7 @@ local function physics_world_listener(self, event, data)
|
|
|
end
|
|
|
|
|
|
function init(self)
|
|
|
- physics.set_listener(physics_world_listener)
|
|
|
+ physics.set_event_listener(physics_world_listener)
|
|
|
end
|
|
|
```
|
|
|
|
|
|
@@ -132,6 +132,6 @@ function on_message(self, message_id, message)
|
|
|
end
|
|
|
|
|
|
function init(self)
|
|
|
- physics.set_listener(physics_world_listener)
|
|
|
+ physics.set_event_listener(physics_world_listener)
|
|
|
end
|
|
|
```
|