-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
58 lines (47 loc) · 1.26 KB
/
Copy pathexample.js
File metadata and controls
58 lines (47 loc) · 1.26 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
var PIXI = require('pixi.js');
var Connector = require('./index.js');
var app = new PIXI.Application(320, 400, {
backgroundColor: 0x1099bb
});
document.body.appendChild(app.view);
var world = new PIXI.Graphics();
world.beginFill(0xFF3300);
world.drawRect(0, 0, 1000, 1000);
app.stage.addChild(world);
var rect = new PIXI.Graphics();
rect.beginFill(0x000000);
rect.drawRect(100, 100, 100, 100);
rect.priority = 1;
app.stage.addChild(rect);
var rect2 = new PIXI.Graphics();
rect2.beginFill(0x0000FF);
rect2.drawRect(150, 50, 100, 100);
rect2.priority = 2;
app.stage.addChild(rect2);
/**
* connect events
*/
var c = new Connector(app);
c.listen(world, 'hammer.input', function(e) {
if (e.isFirst) {
console.log('this is first touch!');
} else if (e.isFinal) {
console.log('this is final touch!')
}
});
c.listen(world, 'pan', function(e) {
console.log('panning on the world!');
});
c.listen(rect2, 'double-tap', {
taps: 2
}, function(e) {
console.log('double tap on the rect2!');
});
c.listen(rect, 'tap', function(e) {
console.log('tapping on the rect1!');
});
c.listen(rect2, 'tap', function(e) {
console.log('tapping on the rect2!');
});
c.setDependency('recognizeWith', 'tap', 'double-tap');
c.setDependency('requireFailure', 'tap', 'double-tap');