forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay music.js
More file actions
51 lines (33 loc) · 1.02 KB
/
Copy pathplay music.js
File metadata and controls
51 lines (33 loc) · 1.02 KB
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
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
music.play();
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changeVolume, this);
}
function changeVolume(pointer) {
if (pointer.y < 300)
{
music.volume += 0.1;
}
else
{
music.volume -= 0.1;
}
}
function update() {
s.rotation += 0.01;
}
function render() {
game.debug.soundInfo(music, 20, 32);
}