I'm using P2 physics, and I'm creating a relatively intricate border around the screen that I want balls to bounce against. I am scaling all assets on the screen for 3 different aspect ratios, depending on the user's screen size.
I create the border like this:
bgOverlay = otherSpriteGroup.create(gameWidth / 2, gameHeight / 2, "bgOverlay");
bgOverlay.anchor.setTo(0.5, 0.5);
bgOverlay.scale.setTo(scale.x, scale.y);
bgOverlay.body.clearShapes();
bgOverlay.body.loadPolygon("physicsData", "b
Hi, I have solution, that is pretty complex - once you created body with collider, you cannot scale it, but you can scale it while crating it. My solution is in TypeScript. It can handle objects with compound colliders too - for eaxample: one sprite with two circle colliders and one polygon collider. Objects in game I was working on were obstacles, so this is reason, why I use Obstacle in code below.
First I define a few interfaces:
export interface IPoint {
x: number;