Просмотр исходного кода

fixed player bounding box

master
mortie 6 лет назад
Родитель
Сommit
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);
}
}

Загрузка…
Отмена
Сохранить