Files
MI2Mario/src/entities/Attacks/Hitbox.js
T
Pascal e3b9eff67d added a whole lot of crap
Signed-off-by: Pascal Syma <pascal@syma.dev>
2020-07-15 23:47:44 +02:00

34 lines
761 B
JavaScript

/*
* Copyright (c) 2020. Antonio Martinez Casadesus and Pascal Syma.
* All rights reserved.
*/
import Entity from "../Entity";
export default class Hitbox extends Entity {
constructor(player, dmg) {
super(player.scene, player.body.x, player.body.y, null);
this.setData('dmg', dmg);
this.player = player;
this.setSize(0, 0);
this.setOrigin(0, 0);
this.alpha = 0;
this.body.setAllowGravity(false);
this.setData('active', false);
this.body.setSize(0, 0);
}
update(...args) {
this.setPosition(this.player.body.x, this.player.body.y);
}
start() {
}
overlap(obj) {
this.setData('active', false);
obj.hit(this.getData('dmg'));
}
}