-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
example.html
70 lines (58 loc) · 1.68 KB
/
example.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
70
<!DOCTYPE html>
<html>
<head>
<style>
:root, html, body {
margin: 0;
padding: 0;
display: block;
}
</style>
</head>
<body>
<script src="https://unpkg.com/[email protected]/build/phaser.js"></script>
<script src="dist/phaser-state-transition.umd.js"></script>
<script>
const SlideLeftIn = {
ease: Phaser.Easing.Exponential.InOut,
duration: 2e3,
intro: true,
props: {
x: function(game) {
return game.width
}
}
};
const SlideLeftOut = {
ease: Phaser.Easing.Exponential.InOut,
duration: 2e3,
intro: false,
props: {
x: function(game) {
return -game.width
}
}
};
var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, document.body, {
create: function() {
var self = this;
this.stage.backgroundColor = Phaser.Color.getRandomColor();
var circle = this.game.add.graphics(0, 0);
circle.beginFill(Phaser.Color.getRandomColor(), 1);
circle.drawCircle(this.game.width / 2, this.game.height / 2, this.game.width / 2);
this.game.input.onTap.addOnce(function () {
const slideIn = SlideLeftIn;
const slideOut = SlideLeftOut;
if (slideIn) slideIn.duration = 2e3;
if (slideOut) slideOut.duration = 2e3;
this.game.state.start(
this.game.state.current,
slideOut,
slideIn
);
});
}
});
</script>
</body>
</html>