@dill-pixel/plugin-crunch-physics
Version:
Crunch Physics
110 lines • 3.53 kB
TypeScript
import { Application } from 'dill-pixel';
import { Actor } from './Actor';
import { Entity } from './Entity';
import { Sensor } from './Sensor';
import { EntityData, PhysicsEntityConfig, PhysicsEntityType } from './types';
/**
* Static or moving solid object that other entities can collide with.
* Solids are typically used for platforms, walls, and other obstacles.
*
* Features:
* - Static collision boundaries
* - Support for moving platforms
* - Carries actors and sensors that are riding it
* - Pushes overlapping entities out of the way
*
* @typeParam T - Application type, defaults to base Application
*
* @example
* ```typescript
* // Create a static platform
* const platform = physics.createSolid({
* type: 'Platform',
* position: [0, 500],
* size: [800, 32],
* view: platformSprite
* });
*
* // Create a moving platform
* const movingPlatform = physics.createSolid({
* type: 'Platform',
* position: [100, 300],
* size: [200, 32],
* view: platformSprite
* });
*
* // Move the platform back and forth
* gsap.to(movingPlatform, {
* x: 500,
* duration: 2,
* yoyo: true,
* repeat: -1
* });
* ```
*/
export declare class Solid<T extends Application = Application, D extends EntityData = EntityData> extends Entity<T, D> {
readonly entityType: PhysicsEntityType;
/** Whether this solid should be removed when culled (typically false) */
shouldRemoveOnCull: boolean;
/** Whether this solid can be collided with */
private _canCollide;
get canCollide(): boolean;
/** Whether this solid has collisions enabled */
collideable: boolean;
/** Whether this solid is currently moving */
moving: boolean;
private _nextX;
private _nextY;
setPosition(x: number, y: number): void;
/**
* Sets the solid's X position.
* For moving solids, this queues the movement to be applied on next update.
*/
set x(value: number);
get x(): number;
/**
* Sets the solid's Y position.
* For moving solids, this queues the movement to be applied on next update.
*/
set y(value: number);
get y(): number;
/**
* Initializes or reinitializes the solid with new configuration.
*
* @param config - Configuration for the solid
*/
init(config: PhysicsEntityConfig<D>): void;
/** Right edge X coordinate */
get right(): number;
/** Left edge X coordinate */
get left(): number;
/** Top edge Y coordinate */
get top(): number;
/** Bottom edge Y coordinate */
get bottom(): number;
/**
* Checks if this solid can collide with the given entity type.
* This method is kept for backward compatibility.
*
* @returns Always returns true as we're now using only collision layers/masks
*/
canCollideWith(): boolean;
/**
* Moves the solid by the specified amount, carrying any riding entities.
* Also pushes any overlapping entities out of the way.
*
* @param x - X distance to move
* @param y - Y distance to move
* @param actors - Set of actors to check for riding/pushing
* @param sensors - Set of sensors to check for riding/pushing
*/
move(x: number, y: number, actors?: Set<Actor>, sensors?: Set<Sensor>, force?: boolean): void;
/**
* Checks if this solid overlaps with the given entity.
*
* @param entity - Entity to check for overlap
* @returns True if overlapping
*/
private overlaps;
}
//# sourceMappingURL=Solid.d.ts.map