This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
65 lines (57 loc) · 1.61 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pixi.js Test</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.8/pixi.js"></script>
<script src="build/pixi-audio.js"></script>
<style>
html, body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<script>
var renderer = new PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.view);
var stage = new PIXI.Container();
function animate(){
window.requestAnimationFrame(animate);
renderer.render(stage);
}
var playTexture = new PIXI.Graphics()
.beginFill(0xffffff)
.drawRect(0, 0, 100, 100)
.endFill()
.generateTexture();
var scale = Math.min(renderer.width/800, renderer.height/600);
PIXI.loader.add([
{name:"AlphaDance", url: ["./assets/AlphaDance.mp3", "./assets/AlphaDance.ogg"]}
]).load(function(){
var playButton = new PIXI.Sprite(playTexture);
playButton.anchor.set(0.5);
playButton.scale.set(scale);
playButton.position.set(renderer.width/2, renderer.height/2);
playButton.interactive = true;
stage.addChild(playButton);
var music = PIXI.audioManager.getAudio("AlphaDance");
music.loop = true;
function _onClick(evt){
if(!music.playing){
music.play();
}else{
music.paused = !music.paused;
}
}
playButton.on('click', _onClick)
.on('tap', _onClick);
});
animate();
</script>
</body>
</html>