/
battle.js
88 lines (68 loc) · 2.14 KB
/
battle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class battleScene extends Phaser.Scene {
constructor() {
super({ key: "battleScene" });
}
init() {}
preload() {
this.load.image(
"battleground",
"assets/backgrounds/PNG/Battleground3/Bright/Battleground3.png"
);
this.load.spritesheet("character_attack1", "assets/sprite/spritesheets/attack_spritesheet.png", {
frameWidth: 204,
frameHeight: 256,
});
this.load.spritesheet("enemy", "assets/sprite/spritesheets/King/NoBkgColor/spr_KingIdle_strip_no_bkg.png", {
frameWidth: 256,
frameHeight: 256
});
this.load.spritesheet("enemy_attack", "assets/sprite/spritesheets/king_attack.png", {
frameWidth: 437.5,
frameHeight: 350
})
}
create() {
this.scene.run("gameUI");
var bg = this.add.image(540, 305, "battleground");
this.enemy = this.physics.add.sprite(750, 300, "enemy_attack", 0);
this.enemy.setCollideWorldBounds(true);
this.character = this.physics.add.sprite(250, 270, "character_attack1", 6);
this.character.setCollideWorldBounds(true);
this.anims.create({
key: "man_attack",
frames: this.anims.generateFrameNumbers("character_attack1", {
start: 6,
end: 11
}),
frameRate: 10
});
this.anims.create({
key: "enemy_attack",
frames: this.anims.generateFrameNumbers("enemy_attack", {
start: 0,
end: 57
}),
frameRate: 10
});
this.graphics = this.add.graphics();
this.graphics.lineStyle(1, 0xffffff);
this.graphics.fillStyle(0x031f4c, 1);
this.graphics.strokeRect(0, 0, 300, 200);
this.graphics.fillRect(0, 0, 300, 200);
this.graphics.strokeRect(465, 460, 150, 150);
this.graphics.fillRect(465, 460, 150, 150);
this.graphics.strokeRect(780, 0, 300, 200);
this.graphics.fillRect(780, 0, 300, 200);
this.cursors = this.input.keyboard.createCursorKeys();
this.spacebar = this.input.keyboard.addKey(
Phaser.Input.Keyboard.KeyCodes.SPACE
);
}
startBattle() {
}
transition() {
}
update() {
}
}
export default battleScene;