Package com.csse3200.game.physics
Class ObjectContactListener
java.lang.Object
com.csse3200.game.physics.ObjectContactListener
- All Implemented Interfaces:
com.badlogic.gdx.physics.box2d.ContactListener
public class ObjectContactListener
extends Object
implements com.badlogic.gdx.physics.box2d.ContactListener
Combined contact listener that handles both general collision events (for tooltips, collectables, etc.)
and specific object collision logic.
This listener:
1. Triggers general "collisionStart" and "collisionEnd" events on all entities (for tooltip system)
2. Handles object-specific collision logic (for button interactions)
ContactListener for detecting collisions between the player entity and specified objects in the
game such as buttons, boxes etc.
Triggers the push event when contact is made
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
beginContact
(com.badlogic.gdx.physics.box2d.Contact contact) Called when two features begin to touch and checks if a player has collided with an object If so, the game object keeps track that player is in range Also triggers general collision events for tooltips and other systemsvoid
endContact
(com.badlogic.gdx.physics.box2d.Contact contact) Called when two features end contact If player moves away from an object (i.e.void
postSolve
(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse contactImpulse) void
preSolve
(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.Manifold manifold)
-
Constructor Details
-
ObjectContactListener
public ObjectContactListener()
-
-
Method Details
-
beginContact
public void beginContact(com.badlogic.gdx.physics.box2d.Contact contact) Called when two features begin to touch and checks if a player has collided with an object If so, the game object keeps track that player is in range Also triggers general collision events for tooltips and other systems- Specified by:
beginContact
in interfacecom.badlogic.gdx.physics.box2d.ContactListener
- Parameters:
contact
- object representing the collision
-
endContact
public void endContact(com.badlogic.gdx.physics.box2d.Contact contact) Called when two features end contact If player moves away from an object (i.e. no longer colliding), object stops tracking the player as being in range for an interaction- Specified by:
endContact
in interfacecom.badlogic.gdx.physics.box2d.ContactListener
- Parameters:
contact
- object representing the collision
-
preSolve
public void preSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.Manifold manifold) - Specified by:
preSolve
in interfacecom.badlogic.gdx.physics.box2d.ContactListener
-
postSolve
public void postSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse contactImpulse) - Specified by:
postSolve
in interfacecom.badlogic.gdx.physics.box2d.ContactListener
-