MCPcopy
hub / github.com/arcxingye/EatKano / gameTapEvent

Function gameTapEvent

static/index.js:349–390  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

347 }
348
349 function gameTapEvent(e) {
350 if (_gameOver) {
351 return false;
352 }
353 let tar = e.target;
354 let y = e.clientY || e.targetTouches[0].clientY,
355 x = (e.clientX || e.targetTouches[0].clientX) - body.offsetLeft,
356 p = _gameBBList[_gameBBListIndex];
357 if (y > touchArea[0] || y < touchArea[1]) {
358 return false;
359 }
360 if ((p.id === tar.id && tar.notEmpty) || (p.cell === 0 && x < blockSize) || (p.cell === 1 && x > blockSize && x < 2 *
361 blockSize) || (p.cell === 2 && x > 2 * blockSize && x < 3 * blockSize) || (p.cell === 3 && x > 3 * blockSize)) {
362 if (!_gameStart) {
363 gameStart();
364 }
365 if (soundMode === 'on') {
366 createjs.Sound.play("tap");
367 }
368 tar = document.getElementById(p.id);
369 tar.className = tar.className.replace(_ttreg, ' tt$1');
370 _gameBBListIndex++;
371 _gameScore++;
372
373 updatePanel();
374
375 gameLayerMoveNextRow();
376 } else if (_gameStart && !tar.notEmpty) {
377 if (soundMode === 'on') {
378 createjs.Sound.play("err");
379 }
380 tar.classList.add('bad');
381 if (mode === MODE_PRACTICE) {
382 setTimeout(() => {
383 tar.classList.remove('bad');
384 }, 500);
385 } else {
386 gameOver();
387 }
388 }
389 return false;
390 }
391
392 function createGameLayer() {
393 let html = '<div id="GameLayerBG">';

Callers 1

clickFunction · 0.85

Calls 4

gameStartFunction · 0.85
updatePanelFunction · 0.85
gameLayerMoveNextRowFunction · 0.85
gameOverFunction · 0.85

Tested by

no test coverage detected