Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
FogNetwork
GitHub Repository: FogNetwork/Tsunami
Path: blob/main/public/games/files/asteroids/ipad.js
1036 views
1
var ipad = navigator.userAgent.match(/iPad/i) != null;
2
3
if (ipad) {
4
$(function () {
5
$('#left-controls, #right-controls').show();
6
$('body > *').hide();
7
$('body').css('margin', '0px').css('background', 'black').prepend($('#game-container').remove());
8
$('#game-container').width(1024).css('margin-top', 26).show();
9
$('#canvas').attr('width', 1020).attr('height', 660).css('background', 'white').css('margin', '0 1');
10
11
$('head').prepend($('<meta/>').attr('name', 'viewport').attr('content', 'width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'));
12
13
$('#left-controls, #right-controls').bind('touchstart touchmove touchend', function (e) {
14
if (e.type != 'touchend') {
15
for (k in KEY_STATUS) {
16
KEY_STATUS[k] = false;
17
}
18
}
19
var touches = e.type == 'touchend' ? e.originalEvent.changedTouches : e.originalEvent.touches
20
for (var i = 0; i < touches.length; i++) {
21
var ele = document.elementFromPoint(touches[i].pageX, touches[i].pageY);
22
KEY_STATUS[ele.id] = (e.type != 'touchend');
23
}
24
});
25
26
$(document).bind('touchstart', function (e) {
27
window.gameStart = true;
28
});
29
30
$(document).bind('gesturestart gesturechange gestureend touchstart touchmove touchend', function (e) {
31
e.preventDefault();
32
});
33
});
34
}
35
36
37