collisionBetweenfunctionnacatamalon
collisionBetween(a: TCollisionTarget, b: TCollisionTarget) => booleanWhether two things touch right now: a bullet and a brick, the player and a door, a sword and whatever is in front of it. With no physics: just whether their rectangles share any area.
Each side can be an object, a sprite, a text, a panel, or a rectangle of the world
({ x, y, width, height }, from its top-left corner). An object is measured by its hitboxes
(useHitbox) when it has any, and by what it draws when it has none. Everything is measured
where it is drawn: turned, grown and moved with everything above it. Edges that only meet do not
count, so two tiles side by side are not touching.
For many things against many, every frame, useCollisionBetween with components or tags says it
once.
Parámetros
aTCollisionTargetOne thing.
bTCollisionTargetThe other.
Ejemplo
declare const bullet: TSprite;
declare const brick: TSprite;
useUpdate(() => {
if (collisionBetween(bullet, brick)) {
bullet.visible = false;
}
});