提交 b080e530 编写于 作者: G Gabriele Cirulli

add small code tweaks

上级 39ebf51c
......@@ -211,8 +211,6 @@ GameManager.prototype.tileMatchesAvailable = function () {
var cell = { x: x + vector.x, y: y + vector.y };
var other = self.grid.cellContent(cell);
if (other) {
}
if (other && other.value === tile.value) {
return true; // These two tiles can be merged
......
function HTMLActuator() {
this.tileContainer = document.querySelector(".tile-container");
this.scoreContainer = document.querySelector(".score-container");
this.bestContainer = document.querySelector(".best-container");
this.bestContainer = document.querySelector(".best-container");
this.messageContainer = document.querySelector(".game-message");
this.score = 0;
......
......@@ -59,20 +59,22 @@ KeyboardInputManager.prototype.listen = function () {
// Listen to swipe events
var touchStartClientX, touchStartClientY;
var gameContainer = document.getElementsByClassName("game-container")[0];
gameContainer.addEventListener("touchstart", function(event) {
gameContainer.addEventListener("touchstart", function (event) {
if (event.touches.length > 1) return;
touchStartClientX = event.touches[0].clientX;
touchStartClientY = event.touches[0].clientY;
event.preventDefault();
});
gameContainer.addEventListener("touchmove", function(event) {
gameContainer.addEventListener("touchmove", function (event) {
event.preventDefault();
});
gameContainer.addEventListener("touchend", function(event) {
if (event.touches.length > 0) {
return;
}
gameContainer.addEventListener("touchend", function (event) {
if (event.touches.length > 0) return;
var dx = event.changedTouches[0].clientX - touchStartClientX;
var absDx = Math.abs(dx);
......
window.fakeStorage = {
_data : {},
setItem : function (id, val) {
console.log('set');
console.log("set");
return this._data[id] = String(val);
},
getItem : function (id) {
......@@ -13,8 +13,9 @@ window.fakeStorage = {
function LocalScoreManager() {
var localSupported = !!window.localStorage;
this.key = 'bestScore';
this.storage = localSupported ? window.localStorage : window.fakeStorage;
this.key = "bestScore";
this.storage = localSupported ? window.localStorage : window.fakeStorage;
}
LocalScoreManager.prototype.get = function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册