added simple test to isolate button click issues
This commit is contained in:
86
pacman.html
86
pacman.html
@@ -904,69 +904,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize game for Chrome Android
|
// Ultra-simple test for Chrome Android
|
||||||
function initializeGame() {
|
function simpleTest() {
|
||||||
console.log('Initializing game for Chrome Android...');
|
console.log('=== SIMPLE TEST START ===');
|
||||||
|
|
||||||
// Force show mobile controls
|
// Test 1: Check if elements exist
|
||||||
mobileControlsElement.classList.add('active');
|
|
||||||
mobileSpaceBtnElement.style.display = 'block';
|
|
||||||
|
|
||||||
// Show start screen
|
|
||||||
startScreenElement.style.display = 'block';
|
|
||||||
|
|
||||||
// Set initial game state
|
|
||||||
gameState = 'START';
|
|
||||||
attractModeTimer = 0;
|
|
||||||
|
|
||||||
// Update debug info
|
|
||||||
updateDebugInfo();
|
|
||||||
|
|
||||||
// Setup mobile controls
|
|
||||||
if (isMobile || window.innerWidth <= 768) {
|
|
||||||
setupMobileControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Game initialized successfully');
|
|
||||||
console.log('Game state:', gameState);
|
|
||||||
console.log('Mobile controls visible:', mobileControlsElement.classList.contains('active'));
|
|
||||||
console.log('Start screen visible:', startScreenElement.style.display);
|
|
||||||
|
|
||||||
// Start game loop
|
|
||||||
gameLoop();
|
|
||||||
gameLoopStarted = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test function for mobile controls
|
|
||||||
window.testMobileControls = function() {
|
|
||||||
console.log('Testing mobile controls...');
|
|
||||||
console.log('Space button element:', mobileSpaceBtnElement);
|
console.log('Space button element:', mobileSpaceBtnElement);
|
||||||
console.log('Space button visible:', mobileSpaceBtnElement.style.display !== 'none');
|
console.log('Start screen element:', startScreenElement);
|
||||||
console.log('Mobile controls element:', mobileControlsElement);
|
console.log('Canvas element:', canvas);
|
||||||
console.log('Mobile controls visible:', mobileControlsElement.classList.contains('active'));
|
|
||||||
|
|
||||||
// Test space button
|
// Test 2: Add a simple click handler
|
||||||
handleSpaceButton();
|
mobileSpaceBtnElement.addEventListener('click', function(e) {
|
||||||
};
|
console.log('CLICK DETECTED!');
|
||||||
|
alert('Space button clicked! Game should start now.');
|
||||||
let gameLoopStarted = false;
|
|
||||||
|
// Hide start screen
|
||||||
// Initialize on page load with fallback for Chrome Android
|
startScreenElement.style.display = 'none';
|
||||||
if (document.readyState === 'loading') {
|
|
||||||
document.addEventListener('DOMContentLoaded', initializeGame);
|
// Change background to show something happened
|
||||||
} else {
|
document.body.style.backgroundColor = '#ff0000';
|
||||||
// DOM already loaded
|
|
||||||
initializeGame();
|
console.log('Game started!');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test 3: Add visual feedback
|
||||||
|
mobileSpaceBtnElement.style.backgroundColor = '#00ff00';
|
||||||
|
mobileSpaceBtnElement.style.color = '#000000';
|
||||||
|
mobileSpaceBtnElement.textContent = 'CLICK ME!';
|
||||||
|
|
||||||
|
console.log('=== SIMPLE TEST SETUP COMPLETE ===');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additional fallback for Chrome Android
|
// Run simple test immediately
|
||||||
window.addEventListener('load', function() {
|
simpleTest();
|
||||||
console.log('Page fully loaded');
|
|
||||||
if (!gameLoopStarted) {
|
|
||||||
console.log('Fallback initialization');
|
|
||||||
initializeGame();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user