+14
-10
@@ -12,7 +12,7 @@ export default class Player extends Entity {
|
||||
constructor(scene, spawnPoint, texture) {
|
||||
super(scene, spawnPoint.x, spawnPoint.y, texture);
|
||||
this.setData("speed", 100);
|
||||
this.setData('hp', 20);
|
||||
this.setData('hp', 10);
|
||||
this.setOrigin(0.5, 1).setScale(32 / 48);
|
||||
|
||||
this.body.setSize(48, 48, false);
|
||||
@@ -29,6 +29,9 @@ export default class Player extends Entity {
|
||||
]);
|
||||
|
||||
this.items = [];
|
||||
|
||||
this.dieAnimation = 'die';
|
||||
this.hitAnimation = 'hit';
|
||||
}
|
||||
|
||||
pickup(item) {
|
||||
@@ -45,15 +48,6 @@ export default class Player extends Entity {
|
||||
}
|
||||
|
||||
update(...args) {
|
||||
// if (this.scene.dieActive()) {
|
||||
// this.pause = true;
|
||||
// this.play('die', true)
|
||||
// .once('animationcomplete', () => {
|
||||
// this.setFrame(51);
|
||||
// this.scene.scene.pause();
|
||||
// })
|
||||
// }
|
||||
|
||||
if (this.pause)
|
||||
return;
|
||||
|
||||
@@ -112,4 +106,14 @@ export default class Player extends Entity {
|
||||
this.items.shift().die();
|
||||
}
|
||||
}
|
||||
|
||||
die() {
|
||||
this.anims.stop();
|
||||
this.pause = true;
|
||||
this.play(this.dieAnimation)
|
||||
.once('animationcomplete', () => {
|
||||
this.setFrame(51);
|
||||
this.scene.scene.pause();
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user