Skip to content

Instantly share code, notes, and snippets.

Richard Davey photonstorm

Block or report user

Report or block photonstorm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PointerMonitor.js
class PointerMonitor
constructor (scene, pointer, swipeThreshold = 100, swipeDuration = 500)
// The current Scene
this.scene = scene;
// The Pointer we're monitoring for swipes
this.pointer = pointer;
View PlatformerAttempt1.js
<!doctype html>
<html lang="en">
<meta charset="UTF-8" />
<title>Basic Platofrmer Idea</title>
<script src="//"></script>
<style type="text/css">
body {
margin: 0;
View phaser3-example.html
<!DOCTYPE html>
<script src=""></script>
var config = {
type: Phaser.AUTO,
photonstorm / chiptune2-iOS.js
Created Nov 8, 2017
iOS fixed version of chiptune2.js
View chiptune2-iOS.js
// audio context
var ChiptuneAudioContext = window['AudioContext'] || window['webkitAudioContext'];
// config
var ChiptuneJsConfig = function (repeatCount, context)
this.repeatCount = repeatCount;
this.context = context;
photonstorm / gameframeworkterms.txt
Last active Jul 18, 2017
A list of the terms that game frameworks use to describe a 'scene' or 'state', i.e. such as a composition of objects in a level
View gameframeworkterms.txt
Cocos2D - Scenes (and nodes)
Godot Engine - Scenes (and nodes)
CryEngine - Level
Torque3D - World and Level
Starling - nothing that I could find! In their tutorial 'Game' extends 'Sprite' :)
Urho3D - Scene (and Objects)
Atomic Game Engine - Scene (and nodes)
Monkey Engine - AppStates (short for Application States)
Banshee Engine - Level
Superpowers - Scenes (State is used too, to define entities changing states, Actors = Sprites)
photonstorm / game.js
Created May 10, 2017
Phaser Game Config Object
View game.js
var conf = {
width: 800,
height: 600,
renderer: Phaser.AUTO,
parent: 'phaser-example',
transparent: false,
antialias: false,
state: this,
scaleMode: Phaser.ScaleManager.EXACT_FIT
photonstorm / compressed-textures.js
Last active Apr 15, 2018
Phaser Compressed Texture Support
View compressed-textures.js
// Phaser 3 has the new Loader method, texture:
load.texture('factory', {
etc1: 'assets/factory_etc1.pkm',
s3tc: 'assets/factory_dxt1.pvr',
pvrtc: 'assets/factory_pvrtc.pvr',
truecolor: 'assets/factory.png'
// You can also use load.image:
View phaser-multi-texture-example.js
var game = new Phaser.Game(800, 600, Phaser.WEBGL_MULTI, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
game.load.image('clown', 'assets/sprites/clown.png');
game.load.image('beball', 'assets/sprites/beball1.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('asuna', 'assets/sprites/asuna_by_vali233.png');
photonstorm / state-swap.js
Created Mar 3, 2016
How to keep the same Phaser Sprite through a change in State
View state-swap.js
var PewPew = {
// Our global Sprite, shared between States
spaceship: null
PewPew.Preloader = function () {};
PewPew.Preloader.prototype = {
photonstorm / stopSidewaysVelocity.js
Created Feb 24, 2016 — forked from ShimShamSam/stopSidewaysVelocity.js
Phaser Physics - Stop sideways velocity
View stopSidewaysVelocity.js
* Negate sideways velocity on an object being acted upon by a Phaser physics engine.
* The primary use for this is to simulate vehicle movement by negating "drift" when the vehicle turns.
* @param {Phaser.Sprite} sprite The sprite whose sideways velocity you want to negate
function stopSidewaysVelocity(sprite) {
// Recycle the same object to conserve memory
if(!stopSidewaysVelocity.sideways) {
stopSidewaysVelocity.sideways = {};
You can’t perform that action at this time.