Skip to content

Commit

Permalink
🐛 fix collision box for scaled emotes
Browse files Browse the repository at this point in the history
  • Loading branch information
haliphax committed Oct 3, 2023
1 parent 7c1def1 commit 3db185c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ export default class Avatar {
this.active = true;
this.container = game.add.container();
this.container.setData("avatar", this);
this.container.setSize(this.sprite.displayWidth, this.sprite.displayHeight);
game.physics.world.enableBody(this.container);

if (hs.debug)
if (hs.debug) {
this.rect = game.add
.rectangle(0, 0, 0, 0)
.setStrokeStyle(2, 0xff00ff)
.setOrigin(0.5, 0.5)
.setOrigin(0, 0)
.setDepth(1);
}

setTimeout(this.ready.bind(this), 100);
}
Expand All @@ -83,10 +85,8 @@ export default class Avatar {

body.pushable = true;
body.velocity.x = velocity;
body.setSize(this.sprite.width, this.sprite.height, true);
this.container.setSize(this.sprite.width, this.sprite.height);

if (hs.debug) this.rect?.setSize(body.width, body.height);
body.setSize(this.sprite.displayWidth, this.sprite.displayHeight, true);
this.rect?.setSize(body.width, body.height);

this.container.x = Math.floor(
this.sprite.width / 2 +
Expand All @@ -107,9 +107,11 @@ export default class Avatar {

const body = this.container.body as Phaser.Physics.Arcade.Body;

this.container.angle = 0;
body.angle = 0;

if (hs.debug && this.rect) {
this.rect.setPosition(body.x, body.y);
this.rect.angle = body.angle;
}

if (
Expand Down Expand Up @@ -143,6 +145,5 @@ export default class Avatar {
}

this.sprite.angle = this.chute.angle;
this.container.angle = 0;
}
}

0 comments on commit 3db185c

Please sign in to comment.