UNPKG

duckengine

Version:
38 lines (37 loc) 1.77 kB
import { Duck } from '../../../index'; import Game from '../../game'; import GameObject from '../../gameobjects/gameObject'; import Group from '../../group/group'; import Hitbox from './hitbox'; /** * @class Collider * @classdesc Creates a DuckEngine Collider * @description The Collider Class. Collision Handler and Resolver * @since 1.0.0-beta */ export default class Collider { hitbox: Hitbox; collidesWith: GameObject<Duck.Types.Texture.Type>[] | Group<GameObject<Duck.Types.Texture.Type>>; game: Game; /** * @constructor Collider * @description Creates a Collider instance * @param {Hitbox} hitbox Hitbox to append the collider to * @param {GameObject<Duck.Types.Texture.Type>[] | Group<GameObject<Duck.Types.Texture.Type>>} collidesWith What the PhysicsBody collides with * @param {Game} game Game instance * @since 1.0.0-beta */ constructor(hitbox: Hitbox, collidesWith: GameObject<Duck.Types.Texture.Type>[] | Group<GameObject<Duck.Types.Texture.Type>>, game: Game); /** * @memberof Collider * @description Updates the collider and checks for collisions with the updated version of the object, and collides with. * * DO NOT CALL MANUALLY! CALLED IN PHYSICS SERVER! * * @param {Hitbox} hitbox The updated hitbox that the collider is attached * @param {GameObject<Duck.Types.Texture.Type>[] | Group<GameObject<Duck.Types.Texture.Type>>} updatedCollidesWith Updated version of what the object collides with * @since 2.0.0 */ _update(hitbox: Hitbox, updatedCollidesWith: GameObject<Duck.Types.Texture.Type>[] | Group<GameObject<Duck.Types.Texture.Type>>): void; protected collideHitboxes(hitbox2: Hitbox): Duck.Types.Collider.CollisionResponseType; }