Adobe Flash (poi Animate) con ActionScript 3 era lo standard per giochi browser. Flash Player è morto (dic 2020), ma il workflow resta valido per: export HTML5/Canvas, WebGL, AIR (desktop/mobile), o studio storico.
⚠ Stato 2024: Non pubblicare nuovi progetti in .swf. Usa Animate → "Publish as HTML5 Canvas" o migra a engine moderni (Phaser, Godot, Unity WebGL, Construct, GameMaker).
Fase 1: Concept & Design
- Genere, core loop, win/lose condition
- Lista asset: sprites, tileset, UI, SFX, musica
- Classi principali: Player, Enemy, Bullet, Level, UI, GameManager
- Stati gioco: Menu → Playing → Paused → GameOver → Menu
Fase 2: Setup progetto (Flash/Animate)
- Nuovo documento: ActionScript 3.0 (o HTML5 Canvas per export moderno)
- Stage: es. 800×600, 30/60 fps
- Libreria: importa grafica (PNG trasparenti, vettoriale) o disegna dentro Animate
- Simboli: MovieClip per animazioni, Sprite per oggetti statici, Button per UI
- Linkage: clic destro simbolo → "Linkage" → "Export for ActionScript" → classe (es. `Player`)
Fase 3: Codice base (Document Class)
package {
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
public function Main() {
if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event=null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// Game setup here
addEventListener(Event.ENTER_FRAME, gameLoop);
}
private function gameLoop(e:Event):void {
// Update logic: input, physics, AI, collision, UI
// Render handled by display list automatically
}
}
}
Salva come `Main.as` → Proprietà documento → Class: `Main`
Fase 4: Sistemi chiave
- Input: `Keyboard`, `Mouse`, `Gamepad` (via `flash.ui` o librerie)
- Movimento: velocity + acceleration, clamp, deltaTime (se timer-based)
- Collisione: `hitTestObject`, `hitTestPoint`, o AABB/circle custom
- Spawning/Pooling: Object Pool per bullet/particle/enemy (evita GC lag)
- Stati: State Machine o enum: `MENU`, `PLAYING`, `PAUSED`, `GAMEOVER`
- Salvataggio: `SharedObject` (local), `LocalConnection`, o server
Fase 5: Test, Debug, Export
- Ctrl+Enter (Test Movie) → debug trace in Output panel
- Fix bug: `try/catch`, `trace()`, breakpoint (Flash Builder / VS Code + extension)
- Ottimizza: bitmap caching (`cacheAsBitmap`), pooling, atlas texture
- Publish: File → Publish Settings → HTML5 Canvas (non SWF) → JS + HTML + assets
- Host: qualsiasi web server statico (Netlify, Vercel, GitHub Pages, itch.io)
Risorse apprendimento (storiche ma valide per AS3)
- Essential ActionScript 3.0 (Colin Moock)
- Foundation Game Design with Flash (Rex van der Spuy)
- GDC Vault: "Flash Game Postmortems"
- FlashKit, ActionScript.org (archivi)
Migrazione consigliata oggi
| Da Flash | A moderno | Perché |
|---|---|---|
| AS3 + Display List | Phaser 3 (JS/TS, WebGL/Canvas) | API simile, attivo, HTML5 nativo |
| Timeline animation | Spine / DragonBones / Rive + runtime | Skeletal animation, runtime ovunque |
| Vettoriale in IDE | Godot (GDScript/C#) o Unity | Engine completo, export multi-piattaforma |
| No-code / visuale | Construct 3, GDevelop | Event sheet, browser-based, HTML5 |