Module hanyaeger

Interface Collided

All Superinterfaces:
Bounded, com.github.hanyaeger.core.scenes.DimensionsProvider, GameNode

public interface Collided extends Bounded
A Collided is a YaegerEntity that can be collided with by a Collider. In such a case, the Collided is the YaegerEntity that gets notified of the collision.

There are different types of collision detection. In the case of an Collided we perform a so called Axis-Aligned Bounding Box collision detection, which is based on the bounding box of the YaegerEntity.

Each Game World Update a Collided is checked against all instances ofCollider. If many instances of Collider are part of the YaegerScene, which could lead to many calculations, which could slow down the game and framerate. So make sure only those instances of YaegerEntity that really need to be part of the collision detection to implement the Collided or Collider interfaces.

  • Method Details

    • onCollision

      void onCollision(List<Collider> collidingObjects)
      This method is called if a collision has occurred.
      Parameters:
      collidingObjects - a List of all instances of Collider this Collided has collided with, during the last Game World Update.
    • checkForCollisions

      default void checkForCollisions(List<Collider> colliders)
      Perform collision detection with a Set of Collider instances. Only the first collision is detected.

      Note that all of this takes place during the same Game World update. The re-rendering takes place after this update completes, meaning the undoing will cause no jitter effect.

      Note: This method is part of the internal API, and should not be used when implementing a Yaeger game.

      Parameters:
      colliders - a Set of colliders that should be checked for collisions