Juegos ⭐ 34k stars
Marco de juegos HTML5 2D/3D con WebGL, Canvas y físicas integradas.
frontend-desarrollo (regla: solo catálogo de las 66 · versiones por ERR/MEJ)
Instalación: npm i phaser (o CDN)
new Phaser.Game({ type: Phaser.AUTO, width: 400, height: 300,
scene: { create() { this.add.text(20, 20, 'Hola Phaser'); } } });
Dos casos de uso comunes implementados con esta librería.
Un sprite se mueve con las flechas.
new Phaser.Game({
type: Phaser.AUTO, width: 400, height: 300,
scene: {
create() {
this.jug = this.add.rectangle(200, 150, 30, 30, 0xff6600);
this.cursors = this.input.keyboard.createCursorKeys();
},
update() {
const p = this.jug; const c = this.cursors;
if (c.left.isDown) p.x -= 3; if (c.right.isDown) p.x += 3;
if (c.up.isDown) p.y -= 3; if (c.down.isDown) p.y += 3;
},
},
});Cuenta cuántas monedas recoge el jugador.
const game = new Phaser.Game({
type: Phaser.AUTO, width: 400, height: 300,
scene: {
create() {
this.puntos = 0;
this.jug = this.add.rectangle(20, 150, 30, 30, 0x3399ff);
this.moneda = this.add.circle(350, 150, 12, 0xffd700);
this.txt = this.add.text(10, 10, 'Puntos: 0');
},
update() {
const d = Phaser.Math.Distance.Between(this.jug.x, this.jug.y, this.moneda.x, this.moneda.y);
if (d < 30) { this.puntos++; this.txt.setText('Puntos: ' + this.puntos); this.moneda.setVisible(false); }
},
},
});| Categoría | Juegos |
|---|---|
| Stars (GitHub) | ⭐ 34k |
| Sitio oficial | https://phaser.io/ |
| GitHub | https://github.com/photonstorm/phaser |
| Instalación | npm i phaser (o CDN) |
| Relacionadas | Babylon.js · Pixi.js · CreateJS |
C:\Users\TUF\Documents\librerías\local\ antes de descargar.
Volver al índice de los 66 estudios.