added entitys, enemys, bats and custom attack hitboxes for players
added map loading and one-way collision (needs to move to tiled attribute tho) Signed-off-by: Pascal Syma <pascal@syma.dev>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2020. Pascal Syma <pascal@syma.dev>
|
||||
* 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.setData('hp', obj.getData('hp') - this.getData('dmg'));
|
||||
obj.hit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user