Point utilities provide a comprehensive set of functions for manipulating and working with 2D points in your game. These utilities are designed to work seamlessly with Pixi.js’s Point system while providing additional flexibility through the PointLike type.
Point Types
The framework provides flexible point types to handle different coordinate representations:
This allows you to work with points in various formats:
Basic Operations
Adding Points
Subtracting Points
Scaling Points
Distance Calculations
Linear Distance
Point Magnitude
Interpolation
Linear Interpolation
Point Resolution
The resolvePointLike function is a powerful utility for converting various coordinate formats into a consistent point representation:
Common Use Cases
Movement and Position
Distance Checking
Smooth Movement
Best Practices
Use PointLike type for flexible input parameters
Prefer distanceSq over distance for performance when comparing distances
Use resolvePointLike to handle different coordinate formats consistently
Consider using addToPoint and subtractFromPoint to avoid object creation