Mobile Deploy
Capacitor Setup
npm install @capacitor/core @capacitor/cli
npx cap init
npm install @capacitor/android @capacitor/ios
Config
// capacitor.config.json
{
"appId": "com.mygame.app",
"appName": "My Game",
"webDir": "dist",
"bundledWebRuntime": false
}
Build
# Build game
npm run build
# Add platforms
npx cap add android
npx cap add ios
# Sync
npx cap sync
# Open in IDE
npx cap open android
npx cap open ios
Mobile Optimizations
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
width: 1920,
height: 1080
},
render: {
pixelArt: false,
antialias: true,
powerPreference: 'high-performance'
}
};
Touch Controls
create() {
// Virtual joystick
const joystick = this.add.sprite(100, 500, 'joystick');
joystick.setInteractive();
joystick.setScrollFactor(0);
this.input.on('pointermove', (pointer) => {
if (pointer.isDown) {
const angle = Phaser.Math.Angle.Between(
joystick.x, joystick.y,
pointer.x, pointer.y
);
this.player.setVelocity(
Math.cos(angle) * 200,
Math.sin(angle) * 200
);
}
});
}
Best Practices
- Usa Capacitor per deploy nativo
- Ottimizza assets per mobile
- Test su dispositivi reali
- Virtual controls per mobile
- Gestisci orientamento schermo
