Книги:
- Start Developing HTML5 games in Phaser using TypeScript
- Turn Based Battle using Phaser
- What Do You Need To Know When Converting A Flash Game Into HTML5 by Tomasz Grajewski
- Phaser 2, Custom Build - phaser 2 custom build with grunt.
- Phaser 2, последний официальный релиз, репозиторий
- Создание вашей первой игры на Phaser. Часть 0 — Подготовка к работе - phaser 2 и typescript.
- Phaser Progressive Web Apps Tutorial – How to Create Offline-First Games
- Phaser CE - документация по более новым версиям phaser 2, поддерживаемая сообществом.
- Phaser 3 Dev Logs
- Phaser 3 docs
- Phaser 3 Examples - rep with examples for Phaser 3 by photonstorm.
- Phaser 3 Notes
- Об отличиях phaser 3 от phaser 2
- Phaser 3 Custom Build - статья о том, как собирать кастомный билд для phaser 3.
- How Scenes Work - article about Scene Manager in Phaser 3 by photonstorm.
- The second part of the huge Scenes tutorial and the new 3.7 Loader updates
- Part 1 of a huge guide to Phaser Scenes - Phaser 3 Dev Log #119, article about new scenes by photonstorm.
- Scenes example by photonstorm - динамическое переключение и управление сценами и анимацией с помощью кнопок пользовательского интерфейса.
- multi scenes demo rep
- Scene manager - scene manager methods and attributes.
- Devlog about registry
- Getting Started in Phaser 3 (ES6) – Create a Boomdots game
- Running Phaser 3 on the server - запуск phaser на серверной стороне.
- A REAL PERSON’S GUIDE TO PHASER 3: OR, HOW I LEARNED TO STOP WORRYING AND LOVE THE GUN
- Multi demo - phaser 3 with multi scene demo, несколько активных окон с имитацией рабочего стола.
- How to Make a Mario-style Platformer with Phaser 3
- Buttons In Phaser 3 - buttons in phaser 3, extends texts class.
- Creating A Simple Flappy Bird Clone In Phaser 3 Beta!
- Modular Game Worlds in Phaser 3 - article about tilemaps.
- Tileset documentation
- Dynamic Tilemaps are added along with ScrollFactor. - dynamic and static layers, article in devlog.
Disable visibility change for phaser 3:
this.game.events.off("hidden", this.game.onHidden, this.game, false);
this.game.events.off("visible", this.game.onVisible, this.game, false)
Tween with callbacks
var tween = this.tweens.add({
targets: image,
x: 600,
ease: 'Power1',
duration: 3000,
yoyo: true,
repeat: 1,
onStart: function () { console.log('onStart'); console.log(arguments); },
onComplete: function () { console.log('onComplete'); console.log(arguments); },
onYoyo: function () { console.log('onYoyo'); console.log(arguments); },
onRepeat: function () { console.log('onRepeat'); console.log(arguments); },
});
Current animation frame:
Phaser.Utils.Array.FindClosestInSorted(0.82, gem.anims.currentAnim.frames, 'progress')
Инструменты
- Декларация типов для Phaser 3 от самих разработчиков
- http://kvazars.com/littera/ - Онлайн-редактор для создания spritefont из обычных шрифтов.
Ресурсы
- Сайт создателей - постоянно публикуют полезные материалы о фреймворке.
- Phaser 3, документация - документация и примеры по phaser 3 на сайте photonstorm.
- Phaser 2 CE - документация по community edition phaser 2 (для версий после официальной 2.6.2).
- Very simple Phaser with ES6 boilerplate
- phaser3 project template by photonstorm
- Community Manual for Phaser 2
- Emanuele Feronato - сайт Emanuele Feronato, разработчика html5 игр, автор статей и книг о PhaserJS.
- John Pfister blog - блог о js, много полезного о phaser.
- Phaser 3 Custom Build Template - This project can be used as the basis for a custom build of Phaser 3, photonstorm rep.
- Tweaking the Custom Build
- Game Tutorials - articles on http://codetuto.com
- phaser3-typescript-webpack - rep by ampled, a Super Crate Box clone programmed using TypeScript and the Phaser 3 framework.
- sprite-storm.com - website about html5 game development, usefool articles about phaser, pixi and typescript.
- WILLIAM CLARKSON - разработчик, который пишет игры на phaser. Есть курсы о phaser 2 и 3.
Build a flappy bird copy with TypeScript & Pixi.js
- TYPESCRIPT GAMES - сайт об html5 играх на typescript. Есть ещё видеоканал.
- Phaser 3 Game Examples written in TypeScript
- phaser3-es6-webpack - Generic platformer and Phaser 3 bootstrap project. Mario example on Phaser.
- Build a wheel of fortune for your HTML5 games with Phaser 3 in only a few lines - Emanuele Feronato, manual.
- Build a HTML5 game like “Knife Hit” with Phaser 3 using only tweens and trigonometry
- Create-Phaser-App - Phaser 3, Webpack 4, Babel 7+boilerplate and a scaffold. Quickly prototype and build the Phaser game you want to make! Develop in Phaser faster than before.
Advanced Game Design with HTML5 and JavaScript - Rex van der Spuy rep with example from book.
Создание игры с правильным соотношением сторон:
game = new Phaser.Game(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio, Phaser.AUTO);
Метод resize внутри state:
resize() {
// pure javascript to scale the game
let canvas = document.getElementById("myCanva");
let windowWidth = window.innerWidth;
let windowHeight = window.innerHeight;
let windowRatio = windowWidth / windowHeight;
let gameRatio = this.config.width / this.config.height;
if (windowRatio < gameRatio) {
canvas.style.width = windowWidth + "px";
canvas.style.height = (windowWidth / gameRatio) + "px";
}
else {
canvas.style.width = (windowHeight * gameRatio) + "px";
canvas.style.height = windowHeight + "px";
}
}
-
Кастомный ресайз и стили для центрирования игры - полный пример в блоге Emanuele Feronato.
-
Scale Phaser games to fit screen - ScaleManager different modes configuration.
-
Using the Fullscreen API in web browsers - перевод игры в полноэкранный режим для мобильных устройств.
-
Using fullscreen mode - спецификация Mozilla.
-
Let Your Content Do the Talking: Fullscreen AP
# Usefool function with all existing prefixes function toggleFullScreen() { const doc = window.document; const docEl = doc.documentElement; const requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen; const cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen; if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) { requestFullScreen.call(docEl); } else { cancelFullScreen.call(doc); } }
-
Starting and stopping full screen in phaser - about scale.fullScreenScaleMode for Phaser 2.
Для расчёта расстояния между точками удобно использовать Phaser.Math.distance. Статья на тему: Finding the distance between two points in Phaser В самом js эту функция будет выглядеть так:
function (x1, y1, x2, y2) {
var dx = x1 - x2;
var dy = y1 - y2;
return Math.sqrt(dx * dx + dy * dy);
}
У Phaser 2 периодически в некоторых браузерах отображается ошибка WebGL. Чтобы исправить, нужно в исходниках Pixi найти файл src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js. Вместо gl.vertexAttribPointer(shader.aTextureIndex, 1, gl.FLOAT, false, stride, 20);
поставить:
if (shader.aTextureIndex !== -1) {
gl.vertexAttribPointer(shader.aTextureIndex, 1, gl.FLOAT, false, stride, 20);
}
Описание ошибки: phaserjs/phaser-ce#194
Метод Phaser.Math.between - returns a number between the min and max values. Ccылка на описание
Проблема - Canvas оказывается быстрее webgl.
Ссылки по теме
- Tuning PhaserJS Performance - article Mar 4, 2015 • Burak Kanber.
- Discussion on forum
- Creating spritesheets for Phaser 2 with TexturePacker - article by Andreas Loew.
Using a Texture Atlas to Optimize Your Game
Настройка событий по таймеру, forceSetTimeOut
- Tweening in Phaser 2 - chained tweens.
- Основы изменения скорости - полезная статья про различные типы изменения скорости (easing) при анимации.
- Шпаргалка функций плавности
Configure on-device developer options - справка google по дебаггингу на андроид-устройствах.
- Тестирование приложений на Canvas: рецепты на примере тестирования API Яндекс.Карт
- Testing with Jest in WebStorm
- Karma Setup with Chrome Headless + Jasmine + Webpack
-
HTML5 Canvas Rounded Corners Tutorial - draw rounded box with arcTo() and lines.
// Drow ellipse by pure canvas function drawEllipse(ctx, x, y, a, b) { // Запоминаем положение системы координат (CК) и масштаб ctx.save(); ctx.beginPath(); // Переносим СК в центр будущего эллипса ctx.translate(x, y); /* * Масштабируем по х. * Теперь нарисованная окружность вытянется в a / b раз * и станет эллипсом */ ctx.scale(a / b, 1); // Рисуем окружность, которая благодаря масштабированию станет эллипсом ctx.arc(0, 0, b, 0, Math.PI * 2, true); // Восстанавливаем СК и масштаб ctx.restore(); ctx.closePath(); ctx.stroke(); }