/
work13.html
69 lines (60 loc) · 1.5 KB
/
work13.html
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
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<script src="//cdn.jsdelivr.net/npm/phaser@3.18.0/dist/phaser.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
overflow: hidden;
}
</style>
<script>
const mainScene = new Phaser.Scene('MainScene');
mainScene.preload = function() {
// スプライト画像の読み込み
this.load.spritesheet('jets', 'assets/images/jets.png', {frameWidth: 64, frameHeight: 64});
};
mainScene.create = function() {
// 画面中央のX座標
this.centerX = this.game.config.width / 2;
// 画面中央のY座標
this.centerY = this.game.config.height / 2;
// ジェット機の作成
this.createJets();
};
mainScene.update = function() {
this.rotateJets();
};
mainScene.createJets = function() {
// ジェット機の作成
this.jets = this.add.sprite(this.centerX, this.centerY, 'jets');
this.jets.setDisplaySize(50,50);
this.jets.setFrame(1);
this.jets.angle = 0;
};
mainScene.rotateJets = function() {
// ジェット機が時計回りに回転する
this.jets.angle++;
this.jets.setAngle(this.jets.angle);
};
const config = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
backgroundColor: '#c1c1c1',
scene: [mainScene],
};
const game = new Phaser.Game(config);
window.addEventListener("resize", (event) => {
game.scale.resize(window.innerWidth, window.innerHeight);
},false);
</script>
</head>
<body>
</body>
</html>