65 lines
967 B
JavaScript
65 lines
967 B
JavaScript
|
if (GameLib.Utils.UndefinedOrNull(this.entityLoaded)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var touch = data;
|
||
|
var max = Math.max(touch.left, touch.right, touch.up, touch.down);
|
||
|
|
||
|
var units = Math.floor(max / 150) + 1;
|
||
|
|
||
|
if (typeof max === 'number') {
|
||
|
|
||
|
if (max < 5) {
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.KEY_DOWN,
|
||
|
{
|
||
|
code : 'ArrowUp'
|
||
|
}
|
||
|
);
|
||
|
} else {
|
||
|
|
||
|
if (max === touch.left) {
|
||
|
for (var i = 0; i < units; i++) {
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.KEY_DOWN,
|
||
|
{
|
||
|
code : 'ArrowLeft'
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (max === touch.right) {
|
||
|
for (var i = 0; i < units; i++) {
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.KEY_DOWN,
|
||
|
{
|
||
|
code : 'ArrowRight'
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (max === touch.up) {
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.KEY_DOWN,
|
||
|
{
|
||
|
code : 'ArrowUp'
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
if (max === touch.down) {
|
||
|
GameLib.Event.Emit(
|
||
|
GameLib.Event.KEY_DOWN,
|
||
|
{
|
||
|
code : 'Space'
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
//# sourceURL=touchEnd.js
|