Skip to content

Instantly share code, notes, and snippets.

View lardratboy's full-sized avatar

Brad P. Taylor lardratboy

View GitHub Profile
@lardratboy
lardratboy / bpt_flickrsprite.ts
Created August 28, 2014 18:38
Phaser flickr sprite helpers (work in progress)
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="./prefab.ts"/>
///<reference path="./basic.ts"/>
///<reference path="../libs/collections.ts"/>
///<reference path="../../DefinitelyTyped/async/async.d.ts"/>
///<reference path="../../DefinitelyTyped/lodash/lodash.d.ts"/>
module bpt {
@lardratboy
lardratboy / bpt_prefab_extras.ts
Created August 28, 2014 18:35
Phaser bpt.Prefab breadthfirst/depthfirst children searching (work in progress)
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="../../DefinitelyTyped/lodash/lodash.d.ts"/>
///<reference path="./prefab.ts"/>
///<reference path="./basic.ts"/>
// this really should just be a collection of utils
module bpt.prefab {
@lardratboy
lardratboy / extendedgroup.ts
Created August 28, 2014 18:33
Phaser group supports visual and input clipping (work in progress)
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="../../DefinitelyTyped/lodash/lodash.d.ts"/>
///<reference path="./prefab.ts"/>
///<reference path="./prefab_extras.ts"/>
module bpt.prefab {
// ------------------------------------------------------------------------
@lardratboy
lardratboy / hvlayoutgroup.ts
Created August 28, 2014 18:31
Phaser group to layout children in rows or columns (work in progress)
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="./extendedgroup.ts"/>
module bpt {
export interface ILayoutController {
onlayoutChange:Phaser.Signal;
requestLayout();
handleLayout();
@lardratboy
lardratboy / scrolling.ts
Created August 28, 2014 18:20
Phaser scrolling group (work in progress)
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="../../DefinitelyTyped/scroller/scroller.d.ts"/>
///<reference path="./hvlayoutgroup.ts"/>
module bpt {
// ------------------------------------------------------------------------
export class DragScrollerHelperSprite extends bpt.SpritePrefab {
@lardratboy
lardratboy / phaser_Input_setCapture.ts
Last active August 29, 2015 14:05
setcapture_phaser_input.js
(function(property) {
Phaser.Input.prototype.getCapture = function() {
return this[property] && this[property].captor;
}
Phaser.Input.prototype.setCapture = function( inputHandlers ) {
this[property] = this[property] || {captor:undefined,inputStack:[]};
if ( 0 !== this[property].inputStack.length ) {this.releaseCapture();}
this[property].inputStack.push( this.interactiveItems );
(function(property) {
var local = new Phaser.Point();
function askAncestors( child, pointer ) {
for ( var parent = child.parent; parent; parent = parent.parent ) {
var clip = parent[property];
if ( !clip ) continue;
parent.game.input.getLocalPosition( parent, pointer, local);
var cx = local.x - clip.x, cy = local.y - clip.y;
@lardratboy
lardratboy / bpt.scale9.ts
Last active September 30, 2015 18:59
Phaser Scale9 sprite supports tiled or basic scaling
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
///<reference path="./prefab.ts"/>
// TODO - support PIXI.Texture/BaseTexture/Atlas (if texture then use inner texture)
// TODO - error checking ? possibly correct bad snap requests (not multiple)
module bpt {
export class Scale9 extends Phaser.Group {
@lardratboy
lardratboy / bpt.prefab.ts
Last active August 29, 2015 14:03
Phaser.io Prefab/Scene Layout Factory - early pass
// Author Brad P. Taylor (bradptaylor+github@gmail.com) license MIT
///<reference path="../../../../bower_components/phaser-official/build/phaser.d.ts"/>
/*
Pefab JSON configuration / layout format details
Every Prefab registered is automatically associated with an [OPTIONAL] .json file, the
members of this .json data blob if present are currently processed as follows.