-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·179 lines (128 loc) · 4.9 KB
/
index.html
File metadata and controls
executable file
·179 lines (128 loc) · 4.9 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
<title>Pixi Accessibility</title>
<style>
html, body { margin:0; padding: 0 }
</style>
</head>
<body>
<script src="//rawgit.com/mrdoob/stats.js/master/build/stats.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.11/pixi.js"></script>
<script src="bin/pixi-accessibility.js"></script>
<script>
// create an new instance of a pixi stage
// the second parameter is interactivity...
var interactive = true;
var stage = new PIXI.Stage(0x000000, {resolution:2});
// create a renderer instance.
var renderer = PIXI.autoDetectRenderer(620, 400);
// add the renderer view element to the DOM
document.body.appendChild(renderer.view);
requestAnimationFrame( animate );
// create a background..
var background = PIXI.Sprite.fromImage("test/button_test_BG.jpg");
// add background to stage..
stage.addChild(background);
// create some textures from an image path
var textureButton = PIXI.Texture.fromImage("test/button.png");
var textureButtonDown = PIXI.Texture.fromImage("test/buttonDown.png");
var textureButtonOver = PIXI.Texture.fromImage("test/buttonOver.png");
var buttons = [];
var buttonPositions = [175,75,
600-145, 75,
600/2 - 20, 400/2 + 10,
175, 400-75,
600-115, 400-95];
for (var i=0; i < 5; i++)
{
var button = new PIXI.Sprite(textureButton);
button.anchor.x = 0.5;
button.anchor.y = 0.5;
button.position.x = buttonPositions[i*2];
button.position.y = buttonPositions[i*2 + 1];
// make the button interactive..
button.interactive = true;
button.accessible = true;
// set the mousedown and touchstart callback..
button.mousedown = button.touchstart = function(data){
this.isdown = true;
this.texture = textureButtonDown;
this.alpha = 1;
}
// set the mouseup and touchend callback..
button.mouseup = button.touchend = function(data){
this.isdown = false;
if(this.isOver)
{
this.texture = textureButtonOver;
}
else
{
this.texture = textureButton;
}
}
// set the mouseover callback..
button.mouseover = function(data){
this.isOver = true;
if(this.isdown)return
this.texture = textureButtonOver
}
// set the mouseout callback..
button.mouseout = function(data){
this.isOver = false;
if(this.isdown)return
this.texture = textureButton
}
button.click = function(data){
// click!
//console.log("CLICK!");
alert("CLICK!")
}
button.tap = function(data){
// click!
console.log("TAP!!");
//this.alpha = 0.5;
}
// add it to the stage
stage.addChild(button);
// add button to array
buttons.push(button);
};
// set some silly values..
buttons[0].scale.x = 1.2;
buttons[1].scale.y = 1.2;
buttons[2].rotation = Math.PI/10;
buttons[3].scale.x = 0.8;
buttons[3].scale.y = 0.8;
buttons[4].scale.x = 0.8;
buttons[4].scale.y = 1.2;
buttons[4].rotation = Math.PI;
buttons[0].tabIndex = 1;
buttons[1].tabIndex = 2;
buttons[2].tabIndex = 3;
buttons[3].tabIndex = 4;
buttons[4].tabIndex = 5;
// var button1 =
function animate() {
requestAnimationFrame( animate );
// render the stage
// do a test..
buttons[2].rotation += 0.03;
renderer.render(stage);
}
// add a logo!
var pixiLogo = PIXI.Sprite.fromImage("pixi.png");
stage.addChild(pixiLogo);
pixiLogo.position.x = 620 - 56;
pixiLogo.position.y = 400- 32;
pixiLogo.interactive = true;
pixiLogo.click = pixiLogo.tap = function(){
var win=window.open("https://github.com/GoodBoyDigital/pixi.js", '_blank');
}
</script>
</body>
</html>