瀏覽代碼

fixed player bounding box

master
mortie 6 年之前
父節點
當前提交
dfe7adb0d3
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7
    4
      js/entities/Player.js

+ 7
- 4
js/entities/Player.js 查看文件

@@ -11,7 +11,7 @@ export default class Player extends Entity {
constructor(level) {
super(level, "player");

this.bounds.size.set(1, 2);
this.bounds.size.set(0.5, 2);
this.addTrait(new TCollider(this));
this.addTrait(new TKeyboardController(this));
this.addTrait(new TPhysics(this));
@@ -22,8 +22,11 @@ export default class Player extends Entity {
}

draw(ctx) {
this.texture.draw(ctx,
this.bounds.pos.pixelX - assets.entities.scale * 1.5,
this.bounds.pos.pixelY);
let x =
this.bounds.pos.pixelX -
assets.entities.scale * 1.5 -
this.bounds.size.pixelX / 2

this.texture.draw(ctx, x, this.bounds.pos.pixelY);
}
}

Loading…
取消
儲存