Skip to content

Instantly share code, notes, and snippets.

@samme
samme / readme.md
Last active January 23, 2020 01:24
Phaser.Display.Color conversions
input / output ColorObject Color† HSVColorObject number† string
(h: number, s: number, l: number) HSLToColor
(h: number, s: number, v: number) HSVToRGB HSVToRGB
(r: number, g: number, b: number, a: number) GetColor32
(r: number, g: number, b: number) RGBToHSV RGBToHSV GetColor RGBToString
ColorObject ObjectToColor, ValueToColor
string '#RGB' '#RRGGBB'
@samme
samme / phaser-test.js
Created February 1, 2019 22:06
Phaser CE test #617
This file has been truncated, but you can view the full file.
/**
* @author Richard Davey <[email protected]>
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*
* @overview
*
* Phaser - http://phaser.io
*
* v2.11.1 "2018-10-02" - Built: Fri Feb 01 2019 14:02:33
@samme
samme / index.js
Created July 11, 2018 17:57
GameScalePlugin in phaser3-project-template (webpack)
import 'phaser';
import GameScalePlugin from 'phaser-plugin-game-scale';
console.assert(GameScalePlugin, 'GameScalePlugin');
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
@samme
samme / phaser-scenes-summary.md
Last active August 2, 2023 16:26
Phaser 3 Scenes Summary

Scene control

Calls without a key argument

These affect the calling scene only.

Example:

this.scene.start()

@samme
samme / app.js
Last active June 27, 2019 08:17
Minimal Phaser 3 setup
new Phaser.Game(/* ... */);
@samme
samme / phaser.d.ts
Created May 17, 2018 02:26
Phaser v3.8.0 TypeScript definitions, corrected
This file has been truncated, but you can view the full file.
declare type CallCallback = (item: Phaser.GameObjects.GameObject)=>void;
declare type GridAlignConfig = {
/**
* The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity.
* If both this value and height are set to -1 then this value overrides it and the `height` value is ignored.
*/
width?: integer;
/**
* The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity.
/**
* Renders the content and empties the current batch.
*
* Modified for {@link https://github.com/photonstorm/phaser-ce/issues/194 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range (Ubuntu)}.
*
* @method PIXI.WebGLSpriteBatch#flush
*/
PIXI.WebGLSpriteBatch.prototype.flush = function () {
// If the batch is length 0 then return as there is nothing to draw
if (this.currentBatchSize === 0) {
@samme
samme / phaser-sprite-vs-sprite-collision.md
Last active August 31, 2017 20:26
Phaser sprite vs. sprite collision

Results of collide(sprite1, sprite2) or overlap(sprite1, sprite2).

Body 1 Body 2 collide overlap embedded touching.none overlapX/Y separation¹ acceleration¹
sprite.exists=false false false
enable=false false false
checkCollision.none=true false false
immovable=true true true false ≠ 0 no no
moves=false true true false ≠ 0 yes no²
bounce³ is 0
@samme
samme / html-attributes.md
Last active April 6, 2019 18:50
Boolean and boolean-like attributes in HTML

Boolean attributes

The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace. The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

  • allowfullscreen
  • async
  • autofocus
  • autoplay
  • checked
@samme
samme / phaser-sprite-lifecycle.md
Last active September 2, 2017 10:30
Phaser Sprite Lifecycle
alive exists fresh health renderable visible
sprite.exists = false
sprite.exists = true ✔️ ✔️
sprite.kill()
sprite.revive(…) ✔️ ✔️ 1* ✔️
sprite.reset(…) ✔️ ✔️ ✔️ 1* ✔️ ✔️
group.create(…) ✔️* ✔️* ✔️*
group.createMultiple(…) ❌* ❌* ❌*
group.resetChild(…, x, y) ✔️ ✔️ ✔️ 1 ✔️ ✔️