Tidying up the examples and more Tilemap work.

This commit is contained in:
photonstorm 2013-12-10 12:23:42 +00:00
parent af5847e8e4
commit 669570c701
115 changed files with 372 additions and 11768 deletions

View file

@ -55,6 +55,8 @@ Updates:
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
* Phaser.Canvas.create updated to it can be given an ID as the 3rd parameter.
* Updated display/fullscreen example to reflect new full screen change.
* Loads of updates to the TypeScript definitions files - games fully compile now and lots of missing classes added :)
* Removed 'null parent' check from Group constructor. Will parent to game.world only if parent value is undefined.
Bug Fixes:
@ -66,7 +68,7 @@ Bug Fixes:
* Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group is has no children.
* Switch Camera.setBoundsToWorld to match world.bounds instead of world (thanks cocoademon)
* Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100)
* Fixed Pixi bug (#425) incorrect width property for multi-line Bitmap (thanks jcd-as)
* Fixed Pixi bug (#425) incorrect width property for multi-line BitmapText (thanks jcd-as)
You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md
@ -81,6 +83,16 @@ We also provide a Grunt script that will build Phaser from source along with all
Run `grunt` in the phaser folder for a list of command-line options.
Bower
-----
If you use bowser you can install phaser with:
`bower install phaser`
Nice and easy :)
![Tanks](http://www.photonstorm.com/wp-content/uploads/2013/10/phaser_tanks-640x480.png)

37
bower.json Normal file
View file

@ -0,0 +1,37 @@
{
"name": "phaser",
"version": "1.1.3",
"homepage": "http://phaser.io",
"authors": [
"photonstorm <rich@photonstorm.com>"
],
"description": "A fun, free and fast 2D game framework for making HTML5 games for desktop and mobile, supporting Canvas and WebGL.",
"main": "build/phaser.min.js",
"keywords": [
"html5",
"game",
"games",
"framework",
"canvas",
"WebGL",
"tilemaps",
"physics",
"sprites",
"fonts",
"images",
"audio",
"Web",
"Audio",
"touch",
"input",
"mobile"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

226
build/phaser.d.ts vendored
View file

@ -260,7 +260,7 @@ declare module Phaser {
}
class Game {
constructor(width: number, height: number, renderer: number, parent: string, state: Object, transparent: boolean, antialias: boolean);
constructor(width: number, height: number, renderer: number, parent: string, state: Object, transparent?: boolean, antialias?: boolean);
id: number;
width: number;
height: number;
@ -655,7 +655,7 @@ declare module Phaser {
onAnimationStart: Phaser.Signal;
onAnimationComplete: Phaser.Signal;
onAnimationLoop: Phaser.Signal;
}
}
class GameObjectFactory {
constructor(game: Phaser.Game);
@ -687,7 +687,7 @@ declare module Phaser {
type: number;
renderOrderID: number;
lifespan: number;
events: Phaser.Event[];
events: Phaser.Events;
animations: Phaser.AnimationManager;
input: Phaser.InputHandler;
key: string;
@ -707,8 +707,6 @@ declare module Phaser {
bottomLeft: Phaser.Point;
bounds: Phaser.Rectangle;
body: Phaser.Physics.Arcade.Body;
velocity: number;
acceleration: number;
inWorld: boolean;
inWorldThreshold: number;
angle: number;
@ -731,6 +729,24 @@ declare module Phaser {
getBounds(rect: Phaser.Rectangle): Phaser.Rectangle;
}
class Events {
parent: Phaser.Sprite;
onAddedToGroup: Phaser.Signal;
onRemovedFromGroup: Phaser.Signal;
onKilled: Phaser.Signal;
onRevived: Phaser.Signal;
onOutOfBounds: Phaser.Signal;
onInputOver: Phaser.Signal;
onInputOut: Phaser.Signal;
onInputDown: Phaser.Signal;
onInputUp: Phaser.Signal;
onDragStart: Phaser.Signal;
onDragStop: Phaser.Signal;
onAnimationStart: Phaser.Signal;
onAnimationComplete: Phaser.Signal;
onAnimationLoop: Phaser.Signal;
}
class TileSprite {
constructor(game: Phaser.Game, x: number, y: number, width: number, height: number, key?: string, frame?: number);
texture: Phaser.RenderTexture;
@ -1166,60 +1182,68 @@ declare module Phaser {
update(time: number): boolean;
}
class Easing {
Linear: {
None: (k: number) => number;
};
Quadratic: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Cubic: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Quartic: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Quintic: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Sinusoidal: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Exponential: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Circular: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Elastic: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Back: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
Bounce: {
In: (k: number) => number;
Out: (k: number) => number;
InOut: (k: number) => number;
};
class Easing.Linear {
static None(k: number);
}
class Easing.Quadratic {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Cubic {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Quartic {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Quintic {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Sinusoidal {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Exponential {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Circular {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Elastic {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Back {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Easing.Bounce {
static In(k: number);
static Out(k: number);
static InOut(k: number);
}
class Time {
@ -1286,48 +1310,46 @@ declare module Phaser {
onComplete(): void;
}
module Animation {
class Frame {
constructor(index: number, x: number, y: number, width: number, height: number, name: string, uuid: string);
index: number;
x: number;
y: number;
width: number;
height: number;
centerX: number;
centerY: number;
distance: number;
name: string;
uuid: string;
rotated: boolean;
rotationDirection: string;
trimmed: boolean;
sourceSizeW: number;
sourceSizeH: number;
spriteSourceSizeX: number;
spriteSourceSizeY: number;
spriteSourceSizeW: number;
spriteSourcesizeH: number;
setTrim(trimmed: boolean, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): void;
}
class Frame {
constructor(index: number, x: number, y: number, width: number, height: number, name: string, uuid: string);
index: number;
x: number;
y: number;
width: number;
height: number;
centerX: number;
centerY: number;
distance: number;
name: string;
uuid: string;
rotated: boolean;
rotationDirection: string;
trimmed: boolean;
sourceSizeW: number;
sourceSizeH: number;
spriteSourceSizeX: number;
spriteSourceSizeY: number;
spriteSourceSizeW: number;
spriteSourcesizeH: number;
setTrim(trimmed: boolean, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): void;
}
class FrameData {
addFrame(frame: Frame): Frame;
getFrame(index: number): Frame;
getFrameByName(name: string): Frame;
checkFrame(name: string): boolean;
getFrameRange(start: number, end: number, output: Array<Frame>): Array<Frame>;
getFrames(frames: Array<number>, useNumericIndex?: boolean, output?: Array<Frame>): Array<Frame>;
getFrameIndexes(frames: Array<number>, useNumericIndex?: boolean, output?: Array<number>): Array<number>;
total: number;
}
class FrameData {
addFrame(frame: Frame): Frame;
getFrame(index: number): Frame;
getFrameByName(name: string): Frame;
checkFrame(name: string): boolean;
getFrameRange(start: number, end: number, output: Array<Frame>): Array<Frame>;
getFrames(frames: Array<number>, useNumericIndex?: boolean, output?: Array<Frame>): Array<Frame>;
getFrameIndexes(frames: Array<number>, useNumericIndex?: boolean, output?: Array<number>): Array<number>;
total: number;
}
class Parser {
spriteSheet(game: Phaser.Game, key: string, frameWidth: number, frameHeight: number, frameMax?: number): Phaser.Animation.FrameData;
JSONData(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
JSONDataHash(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
XMLData(game: Phaser.Game, xml: Object, cacheKey: string): Phaser.Animation.FrameData;
}
class AnimationParser {
spriteSheet(game: Phaser.Game, key: string, frameWidth: number, frameHeight: number, frameMax?: number): Phaser.Animation.FrameData;
JSONData(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
JSONDataHash(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData;
XMLData(game: Phaser.Game, xml: Object, cacheKey: string): Phaser.Animation.FrameData;
}
class Cache {
@ -1420,10 +1442,8 @@ declare module Phaser {
nextFile(previousKey: string, success: boolean): void;
}
module Loader {
class Parser {
bitmapFont(game: Phaser.Game, xml: Object, cacheKey: Phaser.Animation.FrameData): void;
}
class LoaderParser {
bitmapFont(game: Phaser.Game, xml: Object, cacheKey: Phaser.Animation.FrameData): void;
}
class Sound {

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

View file

@ -17,7 +17,7 @@ var waveDataCounter;
function create() {
// Create our BitmapData object at a size of 32x64
bmd = game.add.bitmapData('ball', 32, 64);
bmd = game.add.bitmapData(32, 64);
// And apply it to 100 randomly positioned sprites
for (var i = 0; i < 100; i++)
@ -62,7 +62,7 @@ function updateWobblyBall()
// Now all the pixel data has been redrawn we render it to the BitmapData object.
// In CANVAS mode this doesn't do anything, but on WebGL it pushes the new texture to the GPU.
// If your game is exclusively running under Canvas you ca safely ignore this step.
// If your game is exclusively running under Canvas you can safely ignore this step.
bmd.render();
// Cycle through the wave data - this is what causes the image to "undulate"

View file

@ -14,7 +14,7 @@ var bmd;
function create() {
bmd = game.add.bitmapData('ball', 32, 64);
bmd = game.add.bitmapData(32, 64);
console.log(bmd);

View file

@ -3,6 +3,9 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
function preload() {
// game.load.tilemap('map', 'assets/maps/mario1.json', null, Phaser.Tilemap.TILED_JSON);
// game.load.tileset('marioTiles', 'assets/maps/mario1.png', 16, 16);
game.load.tilemap('map', 'assets/maps/newtest.json', null, Phaser.Tilemap.TILED_JSON);
game.load.tileset('tiles', 'assets/maps/ground_1x1.png', 32, 32);
// game.load.image('phaser', 'assets/sprites/phaser-ship.png');
@ -21,25 +24,20 @@ var sprite;
function create() {
game.stage.backgroundColor = '#5c94fc';
// game.stage.backgroundColor = '#5c94fc';
map = game.add.tilemap('map');
// map.setCollisionByIndexRange(80, 97); // mario
map.setCollisionByIndex(1);
// Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) {
// layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);
layer = game.add.tilemapLayer(0, 0, 800, 600, null, map, 0);
// layer2 = game.add.tilemapLayer(0, 0, 400, 600, null, map, 0);
// layer.cameraOffset.x = 400;
// layer.alpha = 0.5;
// tileset = game.add.tileset('tilesNes');
// layer = game.add.tilemapLayer(0, 0, map.layers[0].width*tilesetNes.tileWidth, 600, tileset, map, 0);
// disable this and you can place anywhere, but will almost certainly screw collision
layer.resizeWorld();
sprite = game.add.sprite(260, 100, 'phaser');
@ -51,10 +49,6 @@ function create() {
// In this case the box is 50px in and 25px down.
sprite.body.setSize(16, 16, 8, 8);
// We'll set a lower max angular velocity here to keep it from going totally nuts
sprite.body.maxAngular = 500;

View file

@ -17,8 +17,8 @@
* @param {number} [width=800] - The width of your game in game pixels.
* @param {number} [height=600] - The height of your game in game pixels.
* @param {number} [renderer=Phaser.AUTO] - Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all).
* @param {HTMLElement} [parent=''] - The Games DOM parent.
* @param {any} [state=null] - Description.
* @param {string|HTMLElement} [parent=''] - The DOM element into which this games canvas will be injected. Either a DOM ID (string) or the element itself.
* @param {object} [state=null] - The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null.
* @param {boolean} [transparent=false] - Use a transparent canvas background or not.
* @param {boolean} [antialias=true] - Anti-alias graphics.
*/

View file

@ -10,7 +10,7 @@
* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. If not set, or set to null, it will use game.world.
* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. If undefined it will use game.world.
* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true).
*/
@ -21,7 +21,7 @@ Phaser.Group = function (game, parent, name, useStage) {
*/
this.game = game;
if (typeof parent === 'undefined' || parent === null)
if (typeof parent === 'undefined')
{
parent = game.world;
}

View file

@ -0,0 +1,88 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Create a new DOMSprite.
* @class Phaser.DOMSprite
* @constructor
* @param {Phaser.Game} game - Current game instance.
* @param {string} id - DOM ID.
* @param {number} x - X position of the new text object.
* @param {number} y - Y position of the new text object.
* @param {string} text - The actual text that will be written.
* @param {object} style - The style object containing style attributes like font, font size ,
*/
Phaser.DOMSprite = function (game, element, x, y, style) {
x = x || 0;
y = y || 0;
style = style || '';
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
/**
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
* @default
*/
this.exists = true;
/**
* @property {boolean} alive - This is a handy little var your game can use to determine if an object is alive or not, it doesn't effect rendering.
* @default
*/
this.alive = true;
/**
* @property {Phaser.Group} group - The parent Group of this Text object.
*/
this.group = null;
/**
* @property {string} name - The user defined name given to this object.
* @default
*/
this.name = '';
/**
* @property {number} type - The const type of this object.
* @default
*/
this.type = Phaser.DOMSPRITE;
/**
* @property {boolean} visible - Sets the visible state of this DOMSprite.
* @default
*/
this.visible = true;
/*
if (parent)
{
if (typeof parent === 'string')
{
// hopefully an element ID
target = document.getElementById(parent);
}
else if (typeof parent === 'object' && parent.nodeType === 1)
{
// quick test for a HTMLelement
target = parent;
}
if (overflowHidden)
{
target.style.overflow = 'hidden';
}
}
*/
};
// Phaser.DOMSprite.prototype = Object.create(PIXI.DOMSprite.prototype);
// Phaser.DOMSprite.prototype.constructor = Phaser.DOMSprite;

View file

@ -5,7 +5,7 @@
*/
/**
* Create a new <code>Text</code>.
* Create a new `Text` object.
* @class Phaser.Text
* @constructor
* @param {Phaser.Game} game - Current game instance.

View file

@ -415,8 +415,10 @@ Phaser.Cache.prototype = {
{
return this._canvases[key].canvas;
}
return null;
else
{
console.warn('Phaser.Cache.getCanvas: Invalid key: "' + key + '"');
}
},
@ -433,8 +435,10 @@ Phaser.Cache.prototype = {
{
return this._bitmapDatas[key];
}
return null;
else
{
console.warn('Phaser.Cache.getBitmapData: Invalid key: "' + key + '"');
}
},
@ -469,8 +473,10 @@ Phaser.Cache.prototype = {
{
return this._images[key].data;
}
return null;
else
{
console.warn('Phaser.Cache.getImage: Invalid key: "' + key + '"');
}
},
@ -487,8 +493,10 @@ Phaser.Cache.prototype = {
{
return this._tilesets[key].data;
}
return null;
else
{
console.warn('Phaser.Cache.getTilesetImage: Invalid key: "' + key + '"');
}
},
@ -505,8 +513,10 @@ Phaser.Cache.prototype = {
{
return this._tilesets[key].tileData;
}
return null;
else
{
console.warn('Phaser.Cache.getTileset: Invalid key: "' + key + '"');
}
},
@ -523,8 +533,11 @@ Phaser.Cache.prototype = {
{
return this._tilemaps[key];
}
else
{
console.warn('Phaser.Cache.getTilemapData: Invalid key: "' + key + '"');
}
return null;
},
/**
@ -625,8 +638,10 @@ Phaser.Cache.prototype = {
{
return this._textures[key];
}
return null;
else
{
console.warn('Phaser.Cache.getTexture: Invalid key: "' + key + '"');
}
},
@ -643,8 +658,10 @@ Phaser.Cache.prototype = {
{
return this._sounds[key];
}
return null;
else
{
console.warn('Phaser.Cache.getSound: Invalid key: "' + key + '"');
}
},
@ -661,8 +678,10 @@ Phaser.Cache.prototype = {
{
return this._sounds[key].data;
}
return null;
else
{
console.warn('Phaser.Cache.getSoundData: Invalid key: "' + key + '"');
}
},
@ -726,8 +745,10 @@ Phaser.Cache.prototype = {
{
return this._text[key].data;
}
return null;
else
{
console.warn('Phaser.Cache.getText: Invalid key: "' + key + '"');
}
},

View file

@ -21,7 +21,7 @@ Phaser.Tilemap = function (game, key) {
this.game = game;
/**
* @property {array} layers - An array of Tilemap layers.
* @property {array} layers - An array of Tilemap layer data.
*/
this.layers = null;
@ -30,7 +30,6 @@ Phaser.Tilemap = function (game, key) {
this.key = key;
this.layers = game.cache.getTilemapData(key).layers;
this.calculateIndexes();
}
else
{
@ -45,7 +44,6 @@ Phaser.Tilemap = function (game, key) {
/**
* @property {array} debugMap - Map data used for debug values only.
*/
this.debugMap = [];
/**
@ -117,25 +115,40 @@ Phaser.Tilemap.prototype = {
data: data,
indexes: [],
dirty: true
});
this.currentLayer = this.layers.length - 1;
},
createTilemapLayer: function (x, y, renderWidth, renderHeight, tileset, layer) {
return this.game.world.add(new Phaser.TilemapLayer(this.game, x, y, renderWidth, renderHeight, tileset, this, layer));
},
setCollisionByIndexRange: function (start, stop, layer) {
if (start > stop)
{
return;
}
for (var i = start; i <= stop; i++)
{
this.setCollisionByIndex(i, layer);
}
},
/**
* Sets collision values on a tile in the set.
*
* @method Phaser.Tileset#setCollision
* @param {number} index - The index of the tile within the set.
* @param {boolean} left - Should the tile collide on the left?
* @param {boolean} right - Should the tile collide on the right?
* @param {boolean} up - Should the tile collide on the top?
* @param {boolean} down - Should the tile collide on the bottom?
* @param {number} index - The index of the tile on the layer.
* @param {number} layer - The layer to operate on.
*/
// Sets all tiles matching the given index to collide on the given faces
// Recalculates the collision map
setCollisionByIndex: function (index, layer) {
if (typeof layer === "undefined") { layer = this.currentLayer; }
@ -157,6 +170,9 @@ Phaser.Tilemap.prototype = {
}
}
// Sets all tiles matching the given index to collide on the given faces
// Recalculates the collision map
// Now re-calculate interesting faces
this.calculateFaces(layer);
@ -169,7 +185,7 @@ Phaser.Tilemap.prototype = {
var left = null;
var right = null;
console.log(this.layers[layer].width, 'x', this.layers[layer].height);
// console.log(this.layers[layer].width, 'x', this.layers[layer].height);
for (var y = 0; y < this.layers[layer].height ; y++)
{

View file

@ -16,7 +16,7 @@
* @param {number} renderHeight - Height of the layer.
* @param {Phaser.Tileset|string} tileset - The tile set used for rendering.
* @param {Phaser.Tilemap} tilemap - The tilemap to which this layer belongs.
* @param {number} layer - The layer index within the map.
* @param {number|string} [layer=0] - The layer within the tilemap this TilemapLayer represents.
*/
Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) {
@ -48,7 +48,7 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
/**
* @property {Phaser.Frame} textureFrame - Dimensions of the renderable area.
*/
this.textureFrame = new Phaser.Frame(0, 0, 0, renderWidth, renderHeight, 'tilemaplayer', game.rnd.uuid());
this.textureFrame = new Phaser.Frame(0, 0, 0, renderWidth, renderHeight, 'tilemapLayer', game.rnd.uuid());
Phaser.Sprite.call(this, this.game, x, y, this.texture, this.textureFrame);
@ -248,12 +248,12 @@ Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset,
this.tilemap = null;
/**
* @property {number} layer - Tilemap layer index.
* @property {object} layer - The layer object within the Tilemap that this layer represents.
*/
this.layer = null;
/**
* @property {number} index
* @property {number} index - The index of this layer within the Tilemap.
*/
this.index = 0;
@ -349,13 +349,13 @@ Phaser.TilemapLayer.prototype.updateTileset = function (tileset) {
*/
Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) {
if (typeof layer === 'undefined')
{
layer = 0;
}
if (tilemap instanceof Phaser.Tilemap)
{
if (typeof layer === 'undefined')
{
layer = 0;
}
this.tilemap = tilemap;
this.layer = this.tilemap.layers[layer];
this.tileWidth = this.layer.tileWidth;
@ -690,7 +690,8 @@ Phaser.TilemapLayer.prototype.render = function () {
this.dirty = true;
}
if (!this.dirty || !this.tileset || !this.tilemap || !this.visible)
// if (!this.dirty || !this.tileset || !this.tilemap || !this.visible)
if (!this.dirty || !this.tilemap || !this.visible)
{
return;
}
@ -710,10 +711,8 @@ Phaser.TilemapLayer.prototype.render = function () {
this._ty = this._dy;
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
// this.context.fillStyle = '#000000';
// this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
this.context.strokeStyle = '#00ff00';
this.context.fillStyle = 'rgba(0,255,0,0.3)';
this.context.strokeStyle = 'rgba(0,255,0,0.9)';
for (var y = this._startY, lenY = this._startY + this._maxY; y < lenY; y++)
{
@ -725,25 +724,27 @@ Phaser.TilemapLayer.prototype.render = function () {
// var tile = this.tileset.tiles[this._column[x] - 1];
if (tile)
{
// this.context.drawImage(
// this.tileset.image,
// tile.x,
// tile.y,
// this.tileWidth,
// this.tileHeight,
// Math.floor(this._tx),
// Math.floor(this._ty),
// this.tileWidth,
// this.tileHeight
// );
}
// if (tile && this.tileset)
// {
// this.context.drawImage(
// this.tileset.image,
// tile.x,
// tile.y,
// this.tileWidth,
// this.tileHeight,
// Math.floor(this._tx),
// Math.floor(this._ty),
// this.tileWidth,
// this.tileHeight
// );
// }
if (tile && (tile.faceTop || tile.faceBottom || tile.faceLeft || tile.faceRight))
{
this._tx = Math.floor(this._tx);
this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
this.context.beginPath();
if (tile.faceTop)
@ -770,9 +771,9 @@ Phaser.TilemapLayer.prototype.render = function () {
this.context.lineTo(this._tx + this.tileWidth, this._ty + this.tileHeight);
}
// this.context.closePath();
this.context.stroke();
// this.context.fillRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
// this.context.strokeRect(this._tx, this._ty, this.tileWidth, this.tileHeight);
}

View file

@ -1,39 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
}
function create() {
// var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, 'atari1');
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('ship', 'assets/sprites/mana_card.png');
}
var player;
var aliens;
function create() {
player = game.add.sprite(400, 300, 'ship');
player.alpha = 0.2;
player.body.collideWorldBounds = true;
player.body.bounce.setTo(1, 1);
// The body offset is from the ANCHOR point of the Sprite, not the top-left (or center, etc)
player.body.setSize(60, 60, 0, 0);
player.anchor.setTo(0.5, 0.5);
player.body.velocity.x = 100;
}
function update() {
// console.log(Math.floor(player.center.x), Math.floor(player.center.y));
player.angle++;
player.scale.x += 0.005;
player.scale.y += 0.005;
}
function render() {
// game.debug.renderSpriteCorners(player,true,true);
game.debug.renderRectangle(player.body);
game.debug.renderPixel(400, 300, 'rgb(255,0,0)');
game.debug.renderPoint(player.center, 'rgb(255,254,0)');
}
})();
</script>
</body>
</html>

View file

@ -1,39 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml');
}
function create() {
game.add.bitmapText(200, 100, 'Phaser\nis rocking!', { font: '64px Desyrel', align: 'center' });
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.image('bunny', 'assets/sprites/bunny.png');
}
var bunny;
var bot;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
bunny = game.add.sprite(500, game.world.centerY, 'bunny');
bunny.anchor.setTo(0.5, 0.5);
bot = game.add.sprite(150, game.world.centerY, 'bot');
bot.anchor.setTo(0.5, 0.5);
bot.animations.add('run');
bot.animations.play('run', 10, true);
game.add.tween(bot.scale).to({ x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
}
function update() {
bunny.angle += 1;
bot.angle += 1;
}
function render() {
game.debug.renderSpriteCorners(bunny, true, true);
game.debug.renderSpriteCorners(bot, true, true);
game.debug.renderSpriteInfo(bunny, 20, 32);
game.debug.renderSpriteInfo(bot, 20, 132);
}
})();
</script>
</body>
</html>

View file

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.image('bunny', 'assets/sprites/mana_card.png');
}
var bunny;
var bot;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
bunny = game.add.sprite(500, game.world.centerY, 'bunny');
bunny.body.offset.setTo();
bot = game.add.sprite(150, game.world.centerY, 'bot');
bot.anchor.setTo(0.5, 0.5);
bot.animations.add('run');
bot.animations.play('run', 10, true);
game.add.tween(bot.scale).to({ x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
}
function update() {
bunny.angle += 1;
bot.angle += 1;
}
function render() {
game.debug.renderSpriteCorners(bunny, true, true);
game.debug.renderSpriteCorners(bot, true, true);
game.debug.renderRectangle(bunny.body.hitArea);
}
})();
</script>
</body>
</html>

View file

@ -1,69 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.image('bunny', 'assets/sprites/mana_card.png');
}
var bunny;
var wall;
var bot;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
// game.physics.gravity.y = 10;
bunny = game.add.sprite(200, 100, 'bunny');
bunny.body.bounce.y = 0.5;
// bunny.body.gravity.y = -10;
// bunny.body.setSize(20, 100);
// bunny.body.offset.setTo(25, -20);
// bunny.anchor.setTo(0.5, 0.5);
wall = game.add.sprite(200, 450, 'bunny');
wall.body.immovable = true;
wall.body.allowGravity = false;
// bunny.body.angularVelocity = 1;
bunny.body.velocity.x = 30;
// bunny.body.velocity.y = 120;
// bunny.body.velocity.y = 50;
}
function update() {
// bunny.rotation += 0.01;
game.physics.separate(bunny.body, wall.body);
}
function render() {
game.debug.renderSpriteCorners(bunny, true, true);
game.debug.renderRectangle(bunny.body);
game.debug.renderRectangle(wall.body);
}
})();
</script>
</body>
</html>

View file

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.image('atari4', 'assets/sprites/atari800.png');
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
game.load.image('firstaid', 'assets/sprites/firstaid.png');
game.load.image('diamond', 'assets/sprites/diamond.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
// This returns an array of all the image keys in the cache
var images = game.cache.getImageKeys();
// Now let's create some random sprites and enable them all for drag and 'bring to top'
for (var i = 0; i < 20; i++)
{
var img = game.rnd.pick(images);
var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, img);
tempSprite.inputEnabled = true;
tempSprite.input.enableDrag(false, true);
}
}
function render() {
game.debug.renderInputInfo(32, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,55 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
game.load.image('atari4', 'assets/sprites/atari800.png');
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
game.load.image('firstaid', 'assets/sprites/firstaid.png');
game.load.image('diamond', 'assets/sprites/diamond.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
// This returns an array of all the image keys in the cache
var images = game.cache.getImageKeys();
var test = game.add.group();
// Now let's create some random sprites and enable them all for drag and 'bring to top'
for (var i = 0; i < 20; i++)
{
var tempSprite = test.create(game.world.randomX, game.world.randomY, game.rnd.pick(images));
tempSprite.inputEnabled = true;
tempSprite.input.enableDrag(false, true);
}
}
function render() {
game.debug.renderInputInfo(32, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,341 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('carrot', 'assets/sprites/carrot.png');
}
var s;
var a;
var b;
var c;
var d;
var e;
var f;
var g;
var h;
var i;
var tests;
function create() {
s = game.add.sprite(600, 100, 'sonic');
s.name = 'X';
a = game.add.child(s, -70, 200, 'sonic');
b = game.add.child(s, -140, 200, 'sonic');
c = game.add.child(s, -210, 200, 'sonic');
d = game.add.child(s, -280, 200, 'sonic');
e = game.add.child(s, -350, 200, 'sonic');
f = game.add.child(s, -420, 200, 'sonic');
g = game.add.child(f, -50, 0, 'carrot');
h = game.add.child(f, -80, 0, 'carrot');
i = game.add.child(f, -110, 0, 'carrot');
a.name = 'A';
b.name = 'B';
c.name = 'C';
d.name = 'D';
e.name = 'E';
f.name = 'F';
g.name = 'g';
h.name = 'h';
i.name = 'i';
tests = [a,b,c,d,e,f,g,h,i];
game.input.onUp.add(runChange, this);
scanList(game.world._stage);
}
function runChange () {
changeOrder(a, h);
}
function changeOrder (node1, node2) {
if (node1 === node2 || !node1.parent || !node2.parent)
{
console.warn("You cannot swap a node with itself or swap un-parented nodes");
return;
}
console.log('Changing order of', node1.name,'and',node2.name);
// var index1 = s.children.indexOf(node1);
// var index2 = s.children.indexOf(node2);
// if (index1 !== -1 && index2 !== -1)
// {
// Cache the node values
var node1Prev = node1._iPrev;
var node1Next = node1._iNext;
var node2Prev = node2._iPrev;
var node2Next = node2._iNext;
// Now deep scan search and replace
var currentNode = game.world._stage;
var endNode = currentNode.last._iNext;
currentNode = currentNode.first;
do
{
if (currentNode !== node1 && currentNode !== node2)
{
if (currentNode.first === node1)
{
currentNode.first = node2;
}
else if (currentNode.first === node2)
{
currentNode.first = node1;
}
if (currentNode.last === node1)
{
currentNode.last = node2;
}
else if (currentNode.last === node2)
{
currentNode.last = node1;
}
}
currentNode = currentNode._iNext;
}
while (currentNode != endNode)
// Check for neighbours (cater for any order parameters)
if (node1._iNext == node2)
{
console.log('A-B neighbour swap');
// Starting
// Node 1 (A) Node 2 (B) X C
// Next: B Next: C Next: A Next: D
// Prev: X Prev: A Prev: - Prev: B
// Ending
// Node 1 (A) Node 2 (B) X C
// Next: C Next: A Next: B Next: D
// Prev: B Prev: X Prev: - Prev: A
node1._iNext = node2Next;
node1._iPrev = node2;
node2._iNext = node1;
node2._iPrev = node1Prev;
// Notify the head and tail
if (node1Prev)
{
node1Prev._iNext = node2;
}
if (node2Next)
{
node2Next._iPrev = node1;
}
}
else if (node2._iNext == node1)
{
console.log('B-A neighbour swap');
// Starting
// Node 1 (B) Node 2 (A) X C
// Next: C Next: B Next: A Next: D
// Prev: A Prev: X Prev: - Prev: B
// Ending
// Node 1 (B) Node 2 (A) X C
// Next: A Next: C Next: B Next: D
// Prev: X Prev: B Prev: - Prev: A
node1._iNext = node2;
node1._iPrev = node2Prev;
node2._iNext = node1Next;
node2._iPrev = node1;
// Notify the head and tail
if (node2Prev)
{
node2Prev._iNext = node1;
}
if (node1Next)
{
node2Next._iPrev = node2;
}
}
else
{
// Nodes are far apart
console.log('Nodes are far apart');
// Pre-swap:
// X next: a prev: - first: X last: d
// a next: b prev: X first: a last: a
// b next: c prev: a first: b last: b
// c next: d prev: b first: c last: c
// d next: e prev: c first: d last: d
// e next: f prev: d first: e last: e
// f next: - prev: e first: f last: f
// Post-swap:
// X next: d prev: - first: X last: d ***
// d next: b prev: X first: d last: d ***
// b next: c prev: d first: b last: b ***
// c next: a prev: b first: c last: c ***
// a next: e prev: c first: a last: a ***
// e next: f prev: a first: e last: e ***
// f next: - prev: e first: f last: f
// Starting
// Node 1 (A) Node 2 (D) N1 Prev (X) N1 Next (B) N2 Prev (C) N2 Next (E)
// Next: B Next: E Next: A Next: C Next: D Next: F
// Prev: X Prev: C Prev: - Prev: A Prev: B Prev: D
// Ending
// Node 1 (A) Node 2 (D) N1 Prev (X) N1 Next (B) N2 Prev (C) N2 Next (E)
// Next: E Next: B Next: D Next: C Next: A Next: F
// Prev: C Prev: X Prev: - Prev: D Prev: B Prev: A
// Simple node 1-2 swap
node1._iNext = node2Next;
node1._iPrev = node2Prev;
node2._iNext = node1Next;
node2._iPrev = node1Prev;
// Now the head and tail for node 1.
if (node1Prev)
{
node1Prev._iNext = node2;
}
if (node1Next)
{
node1Next._iPrev = node2;
}
// Now the head and tail for node 2.
if (node2Prev)
{
node2Prev._iNext = node1;
}
if (node2Next)
{
node2Next._iPrev = node1;
}
}
// }
scanList(game.world._stage);
}
function scanList (sprite) {
console.log('Node | Next | Prev | First | Last');
console.log('------|--------|--------|---------|---------');
var displayObject = sprite;
var testObject = displayObject.last._iNext;
displayObject = displayObject.first;
do
{
var name = displayObject.name || '~';
var nameNext = '-';
var namePrev = '-';
var nameFirst = '-';
var nameLast = '-';
if (displayObject._iNext)
{
nameNext = displayObject._iNext.name;
}
if (displayObject._iPrev)
{
namePrev = displayObject._iPrev.name;
}
if (displayObject.first)
{
nameFirst = displayObject.first.name;
}
if (displayObject.last)
{
nameLast = displayObject.last.name;
}
if (typeof nameNext === 'undefined')
{
nameNext = '-';
}
if (typeof namePrev === 'undefined')
{
namePrev = '-';
}
if (typeof nameFirst === 'undefined')
{
nameFirst = '-';
}
if (typeof nameLast === 'undefined')
{
nameLast = '-';
}
console.log(name + ' | ' + nameNext + ' | ' + namePrev + ' | ' + nameFirst + ' | ' + nameLast);
displayObject = displayObject._iNext;
}
while(displayObject != testObject)
}
function update() {
}
function render() {
for (var i = 0; i < tests.length; i++)
{
game.debug.renderText(tests[i].name, s.x + tests[i].x, s.y + tests[i].y - 20);
}
// game.debug.renderSpriteCorners(s, false, false);
game.debug.renderSpriteInfo(a, 20, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,41 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('card', 'assets/sprites/mana_card.png');
}
function create() {
game.add.sprite(game.world.randomX, game.world.randomY, 'card');
}
function runChange () {
// changeOrder(a, h);
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,94 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
function preload() {
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.load.image('card', 'assets/sprites/mana_card.png');
}
var group;
var s;
var a;
var b;
var c;
var d;
var e;
var f;
var g;
var h;
var i;
var group2;
var a2;
var b2;
var c2;
function create() {
group = game.add.group(null, 'group1');
a = group.create(70, 200, 'sonic');
b = group.create(140, 200, 'sonic');
c = group.create(210, 200, 'sonic');
d = group.create(280, 200, 'sonic');
e = group.create(350, 200, 'sonic');
f = group.create(420, 200, 'sonic');
g = group.create(50, 300, 'sonic');
h = group.create(80, 300, 'sonic');
i = group.create(110, 300, 'sonic');
a.name = 'A';
b.name = 'B';
c.name = 'C';
d.name = 'D';
e.name = 'E';
f.name = 'F';
g.name = 'g';
h.name = 'h';
i.name = 'i';
/*
group2 = game.add.group(group, 'group2');
a2 = group2.create(500, 200, 'card');
b2 = group2.create(550, 200, 'card');
c2 = group2.create(600, 200, 'card');
a2.name = 'A2';
b2.name = 'B2';
c2.name = 'C2';
*/
// console.log(group2._container.parent);
group.dump(true);
game.input.onUp.add(runChange, this);
}
function runChange () {
group.swap(a, i);
group.dump(true);
}
})();
</script>
</body>
</html>

View file

@ -1,67 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, render: render });
function preload() {
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
}
var image;
var button;
function create() {
game.stage.backgroundColor = 0xefefef;
// This is just an image that we'll toggle the display of when you click the button
image = game.add.sprite(game.world.centerX, 0, 'beast');
image.anchor.setTo(0.5, 0);
// This button is created from a sprite sheet.
// Frame 0 = the 'down' state
// Frame 1 = the 'out' state
// Frame 2 = the 'over' state
// The function "clickedIt" will be called when the button is clicked or touched
button = game.add.button(game.world.centerX, 400, 'button', clickedIt, this, 2, 1, 0);
// Just makes the button anchor set to the middle, we only do this to center the button on-screen, no other reason
button.anchor.setTo(0.5, 0.5);
}
function clickedIt() {
if (image.visible == true)
{
image.visible = false;
}
else
{
image.visible = true;
}
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,72 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
// Make our game world 2000x2000 pixels in size (the default is to match the game size)
game.world.setSize(2000, 2000);
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
s.scrollFactor.setTo(0.5, 0.5);
}
for (var i = 0; i < 50; i++)
{
game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
}
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
s.scrollFactor.setTo(2, 2);
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 4;
}
}
})();
</script>
</body>
</html>

View file

@ -1,175 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('mushroom', 'assets/sprites/mana_card.png');
}
var s;
var c;
var r;
var p;
var tl;
var tr;
var bl;
var br;
var half = { width: 0, height: 0 };
var angle = 0;
var distance = 0;
/**
* Returns an array containing 4 Point objects corresponding to the 4 corners of the sprite bounds.
* @method getAsPoints
* @param {Sprite} sprite The Sprite that will have its cameraView property modified
* @return {Array} An array of Point objects.
*/
function getAsPoints(sprite) {
var out = [];
// top left
out.push(new Phaser.Point(sprite.x, sprite.y));
// top right
out.push(new Phaser.Point(sprite.x + sprite.width, sprite.y));
// bottom right
out.push(new Phaser.Point(sprite.x + sprite.width, sprite.y + sprite.height));
// bottom left
out.push(new Phaser.Point(sprite.x, sprite.y + sprite.height));
return out;
}
var midpoint;
function create() {
// Make our game world 2000x2000 pixels in size (the default is to match the game size)
game.world.setSize(2000, 2000);
s = game.add.sprite(400, 300, 'mushroom');
midpoint = new Phaser.Point(s.x + s.width / 2, s.y + s.height / 2);
var points = getAsPoints(s);
tl = points[0];
tr = points[1];
br = points[2];
bl = points[3];
s.anchor.setTo(2, 0.5);
// PIXI worldTransform order:
// |a c tx|
// |b d ty|
// |0 0 1|
// 0 = scaleX (a)
// 1 = skewY (c)
// 2 = translateX
// 3 = skewX (b)
// 4 = scaleY (d)
// 5 = translateY
}
function update() {
s.angle += 0.5;
if (s.scale.x > -2)
{
s.scale.x -= 0.01;
s.scale.y -= 0.01;
}
}
function render() {
game.debug.renderSpriteInfo(s, 32, 32);
// var p1 = getLocalPosition(midpoint.x, midpoint.y, s);
var offsetX = s.anchor.x * s.width;
var offsetY = s.anchor.y * s.height;
var sx = s.x - offsetX;
var sy = s.y - offsetY;
// top left
var p1 = getLocalPosition(sx, sy, s);
// top right
var p2 = getLocalPosition(sx + s.width, sy, s);
// bottom left
var p3 = getLocalPosition(sx, sy + s.height, s);
// bottom right
var p4 = getLocalPosition(sx + s.width, sy + s.height, s);
p1.add(s.x, s.y);
p2.add(s.x, s.y);
p3.add(s.x, s.y);
p4.add(s.x, s.y);
// game.debug.renderPoint(tl, 'rgb(255,0,0)');
// game.debug.renderPoint(tr, 'rgb(0,255,0)');
// game.debug.renderPoint(bl, 'rgb(0,0,255)');
// game.debug.renderPoint(br, 'rgb(255,0,255)');
game.debug.renderPoint(p1, 'rgb(255,0,0)');
game.debug.renderPoint(p2, 'rgb(0,255,0)');
game.debug.renderPoint(p3, 'rgb(0,0,255)');
game.debug.renderPoint(p4, 'rgb(255,0,255)');
game.debug.renderText('tx: ' + tr.x, 32, 250);
game.debug.renderText('ty: ' + tr.y, 32, 265);
game.debug.renderText('px: ' + p2.x, 32, 280);
game.debug.renderText('py: ' + p2.y, 32, 295);
game.debug.renderText('ox: ' + offsetX, 32, 350);
game.debug.renderText('oy: ' + offsetY, 32, 370);
}
function getLocalPosition (x, y, displayObject) {
var a00 = displayObject.worldTransform[0]; // scaleX
var a01 = displayObject.worldTransform[1]; // skewY
var a02 = displayObject.worldTransform[2]; // translateX
var a10 = displayObject.worldTransform[3]; // skewX
var a11 = displayObject.worldTransform[4]; // scaleY
var a12 = displayObject.worldTransform[5]; // translateY
a01 *= -1;
a10 *= -1;
var id = 1 / (a00 * a11 + a01 * -a10);
var dx = a11 * id * x + -a01 * id * y + (a12 * a01 - a02 * a11) * id;
var dy = a00 * id * y + -a10 * id * x + (-a12 * a00 + a02 * a10) * id;
return new Phaser.Point(dx * displayObject.scale.x, dy * displayObject.scale.y);
}
})();
</script>
</body>
</html>

View file

@ -1,74 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
var s;
var s2;
function preload() {
game.load.image('card', 'assets/sprites/mana_card.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
s = game.add.sprite(game.world.centerX, game.world.centerY, 'card');
s2 = game.add.sprite(100, 100, 'mushroom');
s.addChild(s2);
s.scale.x = 2;
s.scale.y = 2;
s2.scale.x = 0.5;
s2.scale.y = 0.5;
s.anchor.setTo(0.5, 0.5);
s2.anchor.setTo(0, 0);
}
function update() {
s.angle += 0.5;
s2.angle += 1;
}
function render() {
game.debug.renderWorldTransformInfo(s, 32, 32);
game.debug.renderLocalTransformInfo(s, 300, 32);
game.debug.renderWorldTransformInfo(s2, 32, 450);
game.debug.renderLocalTransformInfo(s2, 300, 450);
game.debug.renderPoint(s.topLeft, 'rgb(255,0,0)');
game.debug.renderPoint(s.topRight, 'rgb(0,255,0)');
game.debug.renderPoint(s.bottomLeft, 'rgb(0,0,255)');
game.debug.renderPoint(s.bottomRight, 'rgb(255,0,255)');
game.debug.renderPoint(s2.topLeft, 'rgb(255,0,0)');
game.debug.renderPoint(s2.topRight, 'rgb(0,255,0)');
game.debug.renderPoint(s2.bottomLeft, 'rgb(0,0,255)');
game.debug.renderPoint(s2.bottomRight, 'rgb(255,0,255)');
}
})();
</script>
</body>
</html>

View file

@ -1,56 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
var mummy;
function preload() {
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
mummy = game.add.sprite(0, 300, 'mummy');
mummy.scale.setTo(2, 2);
mummy.animations.add('walk');
mummy.animations.play('walk', 50, true);
game.add.tween(mummy).to({ x: game.width - 100 }, 20000, Phaser.Easing.Linear.None, true);
}
function update() {
mummy.angle += 1;
}
function render() {
game.debug.renderRectangle(mummy.bounds, 'rgba(255,255,0,0.1)');
game.debug.renderPoint(mummy.topLeft, 'rgb(255,0,0)');
game.debug.renderPoint(mummy.topRight, 'rgb(0,255,0)');
game.debug.renderPoint(mummy.bottomLeft, 'rgb(0,0,255)');
game.debug.renderPoint(mummy.bottomRight, 'rgb(255,0,255)');
}
})();
</script>
</body>
</html>

View file

@ -1,70 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
var core;
var core2;
function preload() {
game.load.image('bling', 'assets/sprites/diamond.png');
}
function create() {
core = game.add.sprite(game.world.centerX, game.world.centerY, 'bling');
core.anchor.setTo(0.5, 0.5);
core2 = game.add.sprite(game.world.centerX, game.world.centerY, 'bling');
core2.anchor.setTo(0.5, 0.5);
for (var i = 1; i < 50; i++)
{
var d = game.add.sprite(Math.cos(i) * 300, Math.sin(i) * 100, 'bling')
d.anchor.setTo(0.5, 0.5);
d.angle = Math.random() * 300;
core.addChild(d);
var d = game.add.sprite(Math.cos(i) * 360, Math.sin(i) * 100, 'bling')
d.anchor.setTo(0.5, 0.5);
d.angle = Math.random() * 300;
core2.addChild(d);
}
}
function update() {
core.angle += 1;
core2.angle -= 1;
for (var d in core.children) {
core.children[d].angle += 4;
}
for (var d in core2.children) {
core2.children[d].angle -= 4;
}
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,68 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
}
var s;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.rotation += 0.01;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
function render() {
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteInfo(s, 20, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,79 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
// Lots of assets
game.load.image('stars', 'assets/misc/starfield.jpg');
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var s;
var p;
function create() {
// Make our world big ...
game.world.setSize(4000, 2000);
// Scrolling background
s = game.add.tileSprite(0, 0, 800, 600, 'stars');
s.scrollFactor.setTo(0, 0);
// Now let's create loads of stuff moving around it
for (var i = 0; i < 250; i++)
{
var temp = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
temp.autoCull = true;
}
p = game.add.sprite(200, 200, 'atari1');
p.body.velocity.setTo(200 + Math.random() * 100, 200 + Math.random() * 100);
p.body.bounce.setTo(1, 1);
p.body.collideWorldBounds = true;
game.camera.follow(p);
}
function update() {
if (!game.camera.atLimit.x)
{
s.tilePosition.x -= p.body.deltaX();
}
if (!game.camera.atLimit.y)
{
s.tilePosition.y -= p.body.deltaY();
}
}
function render() {
game.debug.renderCameraInfo(game.camera, 32, 32);
game.debug.renderText('Sprites rendered: ' + game.world.currentRenderOrderID, 32, 100);
}
})();
</script>
</body>
</html>

View file

@ -1,45 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
var c = new Phaser.Circle(100, 100, 32);
console.log(c.toString());
var p = { x: 0, y: 0 };
Phaser.Circle.circumferencePoint(c, 45, true, p);
console.log('Circumference Point', p);
c.radius = 200;
console.log(c.toString());
</script>
</body>
</html>

View file

@ -1,117 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
game.load.image('bullet', 'assets/misc/bullet0.png');
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
}
var sprite;
var bullets;
var veggies;
var bulletTime = 0;
var bullet;
function create() {
game.stage.backgroundColor = '#2d2d2d';
// This will check Group vs. Group collision (bullets vs. veggies!)
veggies = game.add.group();
for (var i = 0; i < 50; i++)
{
var c = veggies.create(game.world.randomX, Math.random() * 500, 'veggies', game.rnd.integerInRange(0, 36));
c.name = 'veg' + i;
c.body.immovable = true;
}
bullets = game.add.group();
for (var i = 0; i < 10; i++)
{
var b = bullets.create(0, 0, 'bullet');
b.name = 'bullet' + i;
b.exists = false;
b.visible = false;
b.events.onOutOfBounds.add(resetBullet, this);
}
sprite = game.add.sprite(400, 550, 'phaser');
}
function update() {
sprite.velocity.x = 0;
sprite.velocity.y = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
sprite.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
sprite.velocity.x = 200;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
{
fireBullet();
}
game.physics.collide(bullets, veggies, collisionHandler, null, this);
}
function fireBullet () {
if (game.time.now > bulletTime)
{
bullet = bullets.getFirstExists(false);
if (bullet)
{
bullet.reset(sprite.x + 6, sprite.y - 8);
bullet.velocity.y = -300;
bulletTime = game.time.now + 250;
}
}
}
// Called if the bullet goes out of the screen
function resetBullet (bullet) {
bullet.kill();
}
function collisionHandler (bullet, veg) {
bullet.kill();
veg.kill();
}
})();
</script>
</body>
</html>

View file

@ -1,100 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
}
var sprite;
var group;
function create() {
game.stage.backgroundColor = '#2d2d2d';
// This will check Sprite vs. Group collision
sprite = game.add.sprite(32, 200, 'phaser');
sprite.name = 'phaser-dude';
group = game.add.group();
for (var i = 0; i < 50; i++)
{
var c = group.create(100 + Math.random() * 700, game.world.randomY, 'veggies', game.rnd.integerInRange(0, 36));
c.name = 'veg' + i;
c.body.immovable = true;
}
for (var i = 0; i < 20; i++)
{
// Here we'll create some chillis which the player can pick-up. They are still part of the same Group.
var c = group.create(100 + Math.random() * 700, game.world.randomY, 'veggies', 17);
c.name = 'chilli' + i;
c.body.immovable = true;
}
}
function update() {
sprite.velocity.x = 0;
sprite.velocity.y = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
sprite.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
sprite.velocity.x = 200;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
sprite.velocity.y = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
sprite.velocity.y = 200;
}
game.physics.collide(sprite, group, collisionHandler, null, this);
}
function collisionHandler (obj1, obj2) {
// If the player collides with the chillis then they get eaten :)
// The chilli frame ID is 17
console.log('Hit', obj2.name);
if (obj2.frame == 17)
{
obj2.kill();
}
}
})();
</script>
</body>
</html>

View file

@ -1,65 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var sprite1;
var sprite2;
function create() {
game.stage.backgroundColor = '#2d2d2d';
// This will check Sprite vs. Sprite collision
sprite1 = game.add.sprite(50, 200, 'atari');
sprite1.name = 'atari';
sprite1.body.velocity.x = 100;
sprite2 = game.add.sprite(700, 220, 'mushroom');
sprite2.name = 'mushroom';
sprite2.body.velocity.x = -100;
}
function update() {
// object1, object2, collideCallback, processCallback, callbackContext
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,96 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var sprite1;
var sprite2;
function create() {
game.stage.backgroundColor = '#2d2d2d';
// This will check Sprite vs. Sprite collision using a custom process callback
sprite1 = game.add.sprite(0, 200, 'atari');
sprite1.name = 'atari';
// We'll use a random velocity here so we can test it in our processHandler
sprite1.body.velocity.x = 50 + Math.random() * 100;
// This tells phaser to not use the built-in body separation, instead you should handle it in your process callback (see below)
sprite1.body.customSeparateX = true;
sprite2 = game.add.sprite(750, 220, 'mushroom');
sprite2.name = 'mushroom';
// We'll use a random velocity here so we can test it in our processHandler
sprite2.body.velocity.x = -(50 + Math.random() * 100);
// This tells phaser to not use the built-in body separation, instead you should handle it in your process callback (see below)
sprite2.body.customSeparateX = true;
}
function update() {
game.physics.collide(sprite1, sprite2, collisionHandler, processHandler, this);
}
function processHandler (obj1, obj2) {
// This function can perform your own additional checks on the 2 objects that collided.
// For example you could test for velocity, health, etc.
// If you want the collision to be deemed successful this function must return true.
// In which case the collisionHandler will be called, otherwise it won't.
// Note: the objects will have already been separated by this point unless you have set
// their customSeparateX/Y flags to true. If you do that it's up to you to handle separation.
// Whichever one is going fastest wins, the other dies :)
if (obj1.body.velocity.x > Math.abs(obj2.body.velocity.x))
{
obj2.kill();
obj1.body.velocity.x = 0;
}
else
{
obj1.kill();
obj2.body.velocity.x = 0;
}
return true;
}
function collisionHandler (obj1, obj2) {
game.stage.backgroundColor = '#992d2d';
console.log(obj1.name + ' collided with ' + obj2.name);
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,46 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
}
var r;
var pic;
function create() {
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
pic.anchor.setTo(0.5, 1);
r = new Phaser.Rectangle(0, 0, pic.width, 0);
game.add.tween(r).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
}
function update() {
// Apply the new crop Rectangle to the sprite
pic.crop = r;
}
})();
</script>
</body>
</html>

View file

@ -1,46 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
}
var r;
var pic;
function create() {
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
pic.anchor.setTo(0.5, 1);
r = new Phaser.Rectangle(0, 0, 200, pic.height);
game.add.tween(r).to( { x: pic.width - 200 }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
}
function update() {
// Apply the new crop Rectangle to the sprite
pic.crop = r;
}
})();
</script>
</body>
</html>

View file

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
}
var r;
var pic;
function create() {
pic = game.add.sprite(0, 0, 'trsi');
r = new Phaser.Rectangle(0, 0, 200, 200);
}
function update() {
r.x = game.input.x;
r.y = game.input.y;
pic.x = game.input.x;
pic.y = game.input.y;
// Apply the new crop Rectangle to the sprite
pic.crop = r;
}
})();
</script>
</body>
</html>

View file

@ -1,43 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
game.load.image('atari', 'assets/sprites/atari800xl.png');
}
function create() {
game.add.sprite(0, 0, 'grid');
atari1 = game.add.sprite(300, 300, 'atari');
// Input Enable the sprites
atari1.inputEnabled = true;
// Allow dragging
// enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
atari1.input.enableDrag(true);
}
})();
</script>
</body>
</html>

View file

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
}
function create() {
var tempSprite = game.add.sprite(0, 0, 'atari1');
game.stage.backgroundColor = '#e3ed49';
// Testing iOS7 lack of fullscreen. Damnit.
document.documentElement['style'].minHeight = '2000px';
window.scrollTo(0, document.body.scrollHeight);
game.input.onDown.add(gofull, this);
}
function gofull() {
game.stage.scale.startFullScreen();
}
function update() {
if (document.getElementsByTagName('body')[0].scrollTop > 1000)
{
game.stage.backgroundColor = '#87ff55';
window.scrollTo(0, 0);
}
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,47 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
var s;
function preload() {
game.load.image('test', 'assets/sprites/mana_card.png');
}
function create() {
s = game.add.sprite(game.world.centerX, game.world.centerY, 'test');
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.angle += 1;
}
function render() {
game.debug.renderRectangle(s.bounds);
}
})();
</script>
</body>
</html>

View file

@ -1,80 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
}
var graphics;
function create() {
graphics = game.add.graphics(0, 0);
// set a fill and line style
graphics.beginFill(0xFF3300);
graphics.lineStyle(10, 0xffd900, 1);
// draw a shape
graphics.moveTo(50,50);
graphics.lineTo(250, 50);
graphics.lineTo(100, 100);
graphics.lineTo(250, 220);
graphics.lineTo(50, 220);
graphics.lineTo(50, 50);
graphics.endFill();
// set a fill and line style again
graphics.lineStyle(10, 0xFF0000, 0.8);
graphics.beginFill(0xFF700B, 1);
// draw a second shape
graphics.moveTo(210,300);
graphics.lineTo(450,320);
graphics.lineTo(570,350);
graphics.lineTo(580,20);
graphics.lineTo(330,120);
graphics.lineTo(410,200);
graphics.lineTo(210,300);
graphics.endFill();
// draw a rectangel
graphics.lineStyle(2, 0x0000FF, 1);
graphics.drawRect(50, 250, 100, 100);
// draw a circle
graphics.lineStyle(0);
graphics.beginFill(0xFFFF0B, 0.5);
graphics.drawCircle(470, 200,100);
graphics.lineStyle(20, 0x33FF00);
graphics.moveTo(30,30);
graphics.lineTo(600, 300);
game.add.tween(graphics).to({ x: 200 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,84 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('diamond', 'assets/sprites/diamond.png');
game.load.image('carrot', 'assets/sprites/carrot.png');
}
var g;
var t;
var s;
function create() {
t = game.add.sprite(100, 100, 'carrot');
t.name = 'c0';
t.body.bounce.y = Math.random();
t.body.collideWorldBounds = true;
g = game.add.group();
// g.x = 400;
// g.y = 300;
// g._container.anchor.x = 0.5;
// g._container.anchor.y = 0.5;
for (var i = 0; i < 10; i++)
{
var x = 50 + (i * 64);
s = g.create(x, 100, 'diamond');
s.name = 'd' + i;
s.anchor.setTo(0.5, 0.5);
}
// g.forEach(setAlpha, this);
// g.dump();
// g.replace(s, t);
// g.dump();
// g.callAll('dump', game, 123, 456, 789);
// g.getRandom().y += 200;
// g.setAll('body.velocity.y', 250);
// g.divideAll('y', 2);
// g.multiplyAll('y', 3);
}
function setAlpha (sprite) {
sprite.alpha = 0.4;
}
function update() {
g.addAll('angle', 10);
// g.angle++;
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,167 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
//require('js.php');
?>
</head>
<body>
<script type="text/javascript">
function isPlainObject ( obj ) {
// Not plain objects:
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// - DOM nodes
// - window
if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window) {
return false;
}
// Support: Firefox <20
// The try/catch suppresses exceptions thrown when attempting to access
// the "constructor" property of certain host objects, ie. |window.location|
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
try {
if ( obj.constructor &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false;
}
} catch ( e ) {
return false;
}
// If the function hasn't returned already, we're confident that
// |obj| is a plain object, created by {} or constructed with new Object
return true;
}
function extend () {
var options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// extend jQuery itself if only one argument is passed
if ( length === i ) {
target = this;
--i;
}
console.log('extending',length,options,deep);
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
for ( name in options ) {
src = target[ name ];
copy = options[ name ];
console.log('extending',src,copy);
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( isPlainObject(copy) || (copyIsArray = Array.isArray(copy)) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && Array.isArray(src) ? src : [];
} else {
clone = src && isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[ name ] = extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};
Bob = {};
Bob.Coke = function (x, y) {
this.x = x;
this.y = y;
}
Bob.Coke.prototype = {
fizz: function () {
console.log('fizz', this.x, this.y);
}
}
Bob.Sprite = function (x, y) {
this.x = x;
this.y = y;
}
Bob.Sprite.prototype = {
test: function () {
console.log('bob', this.x, this.y);
},
nipples: function () {
console.log('bob nipples');
}
}
Bob.Extra = function (x, y) {
Bob.Sprite.call(this, x, y);
// Bob.Coke.call(this, x, y);
}
// Bob.Extra.prototype = Object.create(Bob.Sprite.prototype);
Bob.Extra.prototype.solid = function () {
console.log('extra solids');
}
Bob.Extra.prototype = extend(true, Bob.Extra.prototype, Bob.Sprite.prototype, Bob.Coke.prototype);
var rich = new Bob.Extra(99,100);
console.log(rich);
var sus = new Bob.Extra(500,123);
console.log(sus);
rich.test();
rich.solid();
rich.fizz();
console.log('ssssss');
sus.test();
sus.solid();
sus.fizz();
</script>
</body>
</html>

View file

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<input type="text" id="mx" value="0" />
<input type="text" id="my" value="0" />
<br />
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
game.add.sprite(0, 0, 'mushroom');
game.input.onDown.add(newMushroom, this);
}
function newMushroom(pointer) {
game.add.sprite(pointer.x, pointer.y, 'mushroom');
}
function update() {
document.getElementById('mx').value = game.input.x;
document.getElementById('my').value = game.input.y;
}
})();
</script>
</body>
</html>

View file

@ -1,60 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
<style type="text/css">
body {
margin: 0;
}
</style>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(400, 300, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var m;
function create() {
// game.stage.canvas.style['-webkit-transform-origin'] = 'top left';
// game.stage.canvas.style['-webkit-transform'] = 'scale(3,3)';
// game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT;
// game.stage.scale.
// game.stage.scale.setScreenSize();
m = game.add.sprite(0, 0, 'mushroom');
m.anchor.setTo(0.5, 0.5);
// game.input.onDown.add(newMushroom, this);
}
function newMushroom(pointer) {
// game.add.sprite(pointer.x, pointer.y, 'mushroom');
}
function update() {
m.x = game.input.x;
m.y = game.input.y;
}
})();
</script>
</body>
</html>

View file

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('alien', 'assets/sprites/space-baddie.png');
game.load.image('ship', 'assets/sprites/shmup-ship.png');
}
var player;
var aliens;
function create() {
player = game.add.sprite(400, 500, 'ship');
player.anchor.setTo(0.5, 0.5);
aliens = game.add.group();
for (var y = 0; y < 4; y++)
{
for (var x = 0; x < 10; x++)
{
aliens.create(x * 48, y * 50, 'alien');
}
}
aliens.x = 100;
aliens.y = 50;
var tween = game.add.tween(aliens).to({x: 200}, 3000, Phaser.Easing.Linear.None, true, 0, 1000, true);
tween.onComplete.add(descend, this);
}
function descend() {
aliens.y += 10;
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,26 +0,0 @@
<?php
// All JS files in build order.
// Much easier for debugging
?>
<script src="../src/physics/advanced/Math.js"></script>
<script src="../src/physics/advanced/Util.js"></script>
<script src="../src/physics/advanced/Collision.js"></script>
<script src="../src/physics/advanced/Body.js"></script>
<script src="../src/physics/advanced/Joint.js"></script>
<script src="../src/physics/advanced/Shape.js"></script>
<script src="../src/physics/advanced/Contact.js"></script>
<script src="../src/physics/advanced/ContactSolver.js"></script>
<script src="../src/physics/advanced/Space.js"></script>
<script src="../src/physics/advanced/joints/Angle.js"></script>
<script src="../src/physics/advanced/joints/Revolute.js"></script>
<script src="../src/physics/advanced/joints/Weld.js"></script>
<script src="../src/physics/advanced/joints/Wheel.js"></script>
<script src="../src/physics/advanced/joints/Prismatic.js"></script>
<script src="../src/physics/advanced/joints/Distance.js"></script>
<script src="../src/physics/advanced/joints/Rope.js"></script>
<script src="../src/physics/advanced/joints/Mouse.js"></script>
<script src="../src/physics/advanced/shapes/Circle.js"></script>
<script src="../src/physics/advanced/shapes/Segment.js"></script>
<script src="../src/physics/advanced/shapes/Poly.js"></script>
<script src="../src/physics/advanced/shapes/Triangle.js"></script>
<script src="../src/physics/advanced/shapes/Box.js"></script>

View file

@ -1,109 +0,0 @@
<?php
// All JS files in build order. Much easier for debugging
// <xscript src="../src/pixi/extras/Spine.js"></script> <xscript src="../src/pixi/display/MovieClip.js"></script>
?>
<script src="../src/Intro.js"></script>
<script src="../src/pixi/Pixi.js"></script>
<script src="../src/Phaser.js"></script>
<script src="../src/utils/Utils.js"></script>
<script src="../src/pixi/core/Matrix.js"></script>
<script src="../src/pixi/core/Point.js"></script>
<script src="../src/pixi/core/Rectangle.js"></script>
<script src="../src/pixi/display/DisplayObject.js"></script>
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
<script src="../src/pixi/display/Sprite.js"></script>
<script src="../src/pixi/display/Stage.js"></script>
<script src="../src/pixi/extras/CustomRenderable.js"></script>
<script src="../src/pixi/extras/Strip.js"></script>
<script src="../src/pixi/extras/Rope.js"></script>
<script src="../src/pixi/extras/TilingSprite.js"></script>
<script src="../src/pixi/filters/FilterBlock.js"></script>
<script src="../src/pixi/filters/MaskFilter.js"></script>
<script src="../src/pixi/primitives/Graphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
<script src="../src/pixi/text/BitmapText.js"></script>
<script src="../src/pixi/text/Text.js"></script>
<script src="../src/pixi/textures/BaseTexture.js"></script>
<script src="../src/pixi/textures/Texture.js"></script>
<script src="../src/pixi/textures/RenderTexture.js"></script>
<script src="../src/pixi/utils/EventTarget.js"></script>
<script src="../src/pixi/utils/Polyk.js"></script>
<script src="../src/core/Camera.js"></script>
<script src="../src/core/State.js"></script>
<script src="../src/core/StateManager.js"></script>
<script src="../src/core/LinkedList.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Plugin.js"></script>
<script src="../src/core/PluginManager.js"></script>
<script src="../src/core/Stage.js"></script>
<script src="../src/core/Group.js"></script>
<script src="../src/core/World.js"></script>
<script src="../src/core/Game.js"></script>
<script src="../src/input/Input.js"></script>
<script src="../src/input/Keyboard.js"></script>
<script src="../src/input/Mouse.js"></script>
<script src="../src/input/MSPointer.js"></script>
<script src="../src/input/Pointer.js"></script>
<script src="../src/input/Touch.js"></script>
<script src="../src/input/InputHandler.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/gameobjects/Events.js"></script>
<script src="../src/gameobjects/GameObjectFactory.js"></script>
<script src="../src/gameobjects/Sprite.js"></script>
<script src="../src/gameobjects/TileSprite.js"></script>
<script src="../src/gameobjects/Text.js"></script>
<script src="../src/gameobjects/Button.js"></script>
<script src="../src/gameobjects/Graphics.js"></script>
<script src="../src/gameobjects/RenderTexture.js"></script>
<script src="../src/gameobjects/BitmapText.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/system/StageScaleMode.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/math/QuadTree.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Rectangle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/AnimationManager.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/loader/Parser.js"></script>
<script src="../src/sound/Sound.js"></script>
<script src="../src/sound/SoundManager.js"></script>
<script src="../src/utils/Debug.js"></script>
<script src="../src/utils/Color.js"></script>
<script src="../src/physics/arcade/ArcadePhysics.js"></script>
<script src="../src/physics/arcade/Body.js"></script>
<script src="../src/particles/Particles.js"></script>
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
<script src="../src/particles/arcade/Emitter.js"></script>
<script src="../src/tilemap/Tilemap.js"></script>
<script src="../src/tilemap/TilemapLayer.js"></script>
<script src="../src/tilemap/Tile.js"></script>
<script src="../src/tilemap/TilemapRenderer.js"></script>

View file

@ -1,120 +0,0 @@
<?php
// All JS files in build order.
// Much easier for debugging
?>
<script src="../src/Phaser.js"></script>
<script src="../src/utils/Utils.js"></script>
<script src="../src/pixi/Pixi.js"></script>
<script src="../src/pixi/InteractionManager.js"></script>
<script src="../src/pixi/core/Circle.js"></script>
<script src="../src/pixi/core/Ellipse.js"></script>
<script src="../src/pixi/core/Matrix.js"></script>
<script src="../src/pixi/core/Point.js"></script>
<script src="../src/pixi/core/Polygon.js"></script>
<script src="../src/pixi/core/Rectangle.js"></script>
<script src="../src/pixi/display/DisplayObject.js"></script>
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
<script src="../src/pixi/display/Sprite.js"></script>
<script src="../src/pixi/display/MovieClip.js"></script>
<script src="../src/pixi/display/Stage.js"></script>
<script src="../src/pixi/extras/CustomRenderable.js"></script>
<script src="../src/pixi/extras/Strip.js"></script>
<script src="../src/pixi/extras/Rope.js"></script>
<script src="../src/pixi/extras/Spine.js"></script>
<script src="../src/pixi/extras/TilingSprite.js"></script>
<script src="../src/pixi/filters/FilterBlock.js"></script>
<script src="../src/pixi/filters/MaskFilter.js"></script>
<script src="../src/pixi/primitives/Graphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
<script src="../src/pixi/text/BitmapText.js"></script>
<script src="../src/pixi/text/Text.js"></script>
<script src="../src/pixi/textures/BaseTexture.js"></script>
<script src="../src/pixi/textures/Texture.js"></script>
<script src="../src/pixi/textures/RenderTexture.js"></script>
<script src="../src/pixi/utils/EventTarget.js"></script>
<script src="../src/pixi/utils/Polyk.js"></script>
<script src="../src/pixi/utils/Utils.js"></script>
<script src="../src/core/Camera.js"></script>
<script src="../src/core/State.js"></script>
<script src="../src/core/StateManager.js"></script>
<script src="../src/core/LinkedList.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Plugin.js"></script>
<script src="../src/core/PluginManager.js"></script>
<script src="../src/core/Stage.js"></script>
<script src="../src/core/Group.js"></script>
<script src="../src/core/World.js"></script>
<script src="../src/core/Game.js"></script>
<script src="../src/input/Input.js"></script>
<script src="../src/input/Keyboard.js"></script>
<script src="../src/input/Mouse.js"></script>
<script src="../src/input/MSPointer.js"></script>
<script src="../src/input/Pointer.js"></script>
<script src="../src/input/Touch.js"></script>
<script src="../src/input/InputHandler.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/gameobjects/Events.js"></script>
<script src="../src/gameobjects/GameObjectFactory.js"></script>
<script src="../src/gameobjects/Sprite.js"></script>
<script src="../src/gameobjects/TileSprite.js"></script>
<script src="../src/gameobjects/Text.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/math/QuadTree.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Rectangle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/AnimationManager.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/sound/Sound.js"></script>
<script src="../src/sound/SoundManager.js"></script>
<script src="../src/utils/Debug.js"></script>
<script src="../src/physics/arcade/ArcadePhysics.js"></script>
<script src="../src/physics/arcade/Body.js"></script>
<script src="../src/physics/advanced/Math.js"></script>
<script src="../src/physics/advanced/Util.js"></script>
<script src="../src/physics/advanced/Collision.js"></script>
<script src="../src/physics/advanced/Body.js"></script>
<script src="../src/physics/advanced/Joint.js"></script>
<script src="../src/physics/advanced/Shape.js"></script>
<script src="../src/physics/advanced/Contact.js"></script>
<script src="../src/physics/advanced/ContactSolver.js"></script>
<script src="../src/physics/advanced/Space.js"></script>
<script src="../src/physics/advanced/joints/Angle.js"></script>
<script src="../src/physics/advanced/joints/Revolute.js"></script>
<script src="../src/physics/advanced/joints/Weld.js"></script>
<script src="../src/physics/advanced/joints/Wheel.js"></script>
<script src="../src/physics/advanced/joints/Prismatic.js"></script>
<script src="../src/physics/advanced/joints/Distance.js"></script>
<script src="../src/physics/advanced/joints/Rope.js"></script>
<script src="../src/physics/advanced/joints/Mouse.js"></script>
<script src="../src/physics/advanced/shapes/Circle.js"></script>
<script src="../src/physics/advanced/shapes/Segment.js"></script>
<script src="../src/physics/advanced/shapes/Poly.js"></script>
<script src="../src/physics/advanced/shapes/Triangle.js"></script>
<script src="../src/physics/advanced/shapes/Box.js"></script>

View file

@ -1,74 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('alien', 'assets/sprites/space-baddie.png');
game.load.image('ship', 'assets/sprites/shmup-ship.png');
}
var a;
var b;
var c;
var d;
var e;
var f;
var list;
function create() {
a = game.add.sprite(100, 100, 'ship');
a.name = 's1';
b = game.add.sprite(130, 100, 'ship');
b.name = 's2';
c = game.add.sprite(160, 100, 'ship');
c.name = 's3';
d = game.add.sprite(190, 100, 'alien');
d.name = 'a1';
e = game.add.sprite(220, 100, 'alien');
e.name = 'a2';
f = game.add.sprite(250, 100, 'alien');
f.name = 'a3';
list = new Phaser.LinkedList();
list.add(a.input);
list.add(b.input);
list.add(c.input);
list.add(d.input);
list.add(e.input);
list.add(f.input);
list.dump();
// list.remove(d.input);
// list.dump();
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,59 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
// Let's try adding an image to the DOM
document.body.appendChild(game.cache.getImage('cockpit'));
// And some text
var para = document.createElement('pre');
para.innerHTML = game.cache.getText('copyright');
document.body.appendChild(para);
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.image('cockpit', 'assets/pics/cockpit.png');
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
game.load.text('copyright', 'assets/warning - copyright.txt');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
// Let's try adding an image to the DOM
document.body.appendChild(game.cache.getImage('bot'));
// Dump the animation data out
console.log(game.cache.getFrameData('bot'));
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.atlasJSON('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
// Let's try adding an image to the DOM
document.body.appendChild(game.cache.getImage('bot'));
// Dump the animation data out
console.log(game.cache.getFrameData('bot'));
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.atlasXML('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
// Let's try adding an image to the DOM
//document.body.appendChild(game.cache.getImage('mummy'));
// Dump the animation data out
//console.log(game.cache.getFrameData('mummy'));
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.audio('music', [ 'assets/audio/oedipus_wizball_highscore.mp3', 'assets/audio/oedipus_wizball_highscore.ogg' ], true);
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
// Let's try adding an image to the DOM
document.body.appendChild(game.cache.getImage('mummy'));
// Dump the animation data out
console.log(game.cache.getFrameData('mummy'));
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45);
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
function loadCompleted() {
console.log('Loader finished');
}
var game = new Phaser.Game(this, '', 800, 600);
game.load.image('cockpit', 'assets/pics/cockpit.png');
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
</script>
</body>
</html>

View file

@ -1,85 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
game.load.image('player', 'assets/sprites/phaser-dude.png');
}
var map;
var p;
function create() {
game.stage.backgroundColor = '#787878';
map = game.add.tilemap(0, 0, 'mario');
// floor
map.setCollisionRange(80, 97, true, true, true, true);
// one-ways
map.setCollisionRange(15, 17, true, true, false, true);
p = game.add.sprite(32, 32, 'player');
p.body.bounce.y = 0.4;
p.body.collideWorldBounds = true;
game.camera.follow(p);
}
function update() {
map.collide(p);
p.body.velocity.x = 0;
p.body.acceleration.y = 500;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
p.body.velocity.x = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
p.body.velocity.x = 150;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
if (p.body.touching.down)
{
p.body.velocity.y = -200;
}
}
}
function render() {
game.debug.renderSpriteCorners(p);
game.debug.renderSpriteCollision(p, 32, 320);
}
})();
</script>
</body>
</html>

View file

@ -1,60 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
}
function create() {
game.stage.backgroundColor = '#787878';
game.add.tilemap(0, 0, 'mario');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 8;
}
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - Super Mario Combo</title>
<script src="phaser-min.js"></script>
<style type="text/css">
body: {
margin: 0;
}
</style>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('nes', 'gfx/mario1.png', 'gfx/mario1.json', null, Phaser.Tilemap.JSON);
game.load.tilemap('snes', 'gfx/smb_tiles.png', 'gfx/smb_level1.json', null, Phaser.Tilemap.JSON);
}
function create() {
game.stage.backgroundColor = '#5c94fc';
game.add.tilemap(0, 0, 'nes');
game.add.tilemap(0, 168, 'snes');
game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
game.input.onDown.add(goFull, this);
}
function goFull() {
game.stage.scale.startFullScreen();
}
})();
</script>
</body>
</html>

View file

@ -1,45 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - Super Mario Combo</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('nes', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
}
function create() {
game.stage.backgroundColor = '#5c94fc';
game.add.tilemap(0, 0, 'nes');
game.add.tilemap(0, 168, 'snes');
game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
game.input.onDown.add(goFull, this);
}
function goFull() {
game.stage.scale.startFullScreen();
}
})();
</script>
</body>
</html>

View file

@ -1,48 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
var data = game.math.sinCosGenerator(10);
console.log('Sin', data.sin);
console.log('Cos', data.cos);
console.log('Shift value 1', game.math.shift(data.sin));
console.log('Shift value 2', game.math.shift(data.sin));
console.log('Shift value 3', game.math.shift(data.sin));
console.log('Shift value 4', game.math.shift(data.sin));
console.log('Sin', data.sin);
</script>
</body>
</html>

View file

@ -1,98 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('car', 'assets/sprites/car90.png');
game.load.image('ship', 'assets/sprites/xenon2_ship.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
}
var car;
var ship;
var total;
var aliens;
function create() {
aliens = [];
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
s.name = 'alien' + s;
s.body.collideWorldBounds = true;
s.body.bounce.setTo(1, 1);
s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40);
aliens.push(s);
}
car = game.add.sprite(400, 300, 'car');
car.anchor.setTo(0.5, 0.5);
car.body.collideWorldBounds = true;
car.body.bounce.setTo(0.5, 0.5);
car.body.allowRotation = true;
ship = game.add.sprite(400, 400, 'ship');
ship.body.collideWorldBounds = true;
ship.body.bounce.setTo(0.5, 0.5);
}
function update() {
car.body.velocity.x = 0;
car.body.velocity.y = 0;
car.body.angularVelocity = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
car.body.angularVelocity = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
car.body.angularVelocity = 200;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
car.body.velocity.copyFrom(game.physics.velocityFromAngle(car.angle, 300));
}
game.physics.collideGroup(aliens);
// total = game.physics.overlap(ship);
}
function render() {
// game.debug.renderQuadTree(game.physics.quadTree);
// game.debug.renderRectangle(ship.body.bounds);
// game.debug.renderText('total: ' + total.length, 32, 50);
// game.debug.renderText('up: ' + ship.body.touching.up, 32, 70);
// game.debug.renderText('down: ' + ship.body.touching.down, 32, 90);
// game.debug.renderText('left: ' + ship.body.touching.left, 32, 110);
// game.debug.renderText('right: ' + ship.body.touching.right, 32, 130);
}
})();
</script>
</body>
</html>

View file

@ -1,139 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/pixi/Pixi.js"></script>
<script src="../src/pixi/InteractionManager.js"></script>
<script src="../src/pixi/core/Circle.js"></script>
<script src="../src/pixi/core/Ellipse.js"></script>
<script src="../src/pixi/core/Matrix.js"></script>
<script src="../src/pixi/core/Point.js"></script>
<script src="../src/pixi/core/Polygon.js"></script>
<script src="../src/pixi/core/Rectangle.js"></script>
<script src="../src/pixi/display/DisplayObject.js"></script>
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
<script src="../src/pixi/display/Sprite.js"></script>
<script src="../src/pixi/display/MovieClip.js"></script>
<script src="../src/pixi/display/Stage.js"></script>
<script src="../src/pixi/extras/CustomRenderable.js"></script>
<script src="../src/pixi/extras/Strip.js"></script>
<script src="../src/pixi/extras/Rope.js"></script>
<script src="../src/pixi/extras/Spine.js"></script>
<script src="../src/pixi/extras/TilingSprite.js"></script>
<script src="../src/pixi/filters/FilterBlock.js"></script>
<script src="../src/pixi/filters/MaskFilter.js"></script>
<script src="../src/pixi/primitives/Graphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
<script src="../src/pixi/text/BitmapText.js"></script>
<script src="../src/pixi/text/Text.js"></script>
<script src="../src/pixi/textures/BaseTexture.js"></script>
<script src="../src/pixi/textures/Texture.js"></script>
<script src="../src/pixi/textures/RenderTexture.js"></script>
<script src="../src/pixi/utils/Detector.js"></script>
<script src="../src/pixi/utils/EventTarget.js"></script>
<script src="../src/pixi/utils/Polyk.js"></script>
<script src="../src/pixi/utils/Utils.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
// PIXI it
var stage = new PIXI.Stage(0x000044);
var renderer = PIXI.autoDetectRenderer(800, 600);
document.body.appendChild(renderer.view);
game.load.image('cockpit', 'assets/pics/cockpit.png');
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
var bunny;
function loadCompleted() {
console.log('Loader finished, creating base textures');
// Create a basetexture
var base = new PIXI.BaseTexture(game.cache.getImage('overdose'));
var texture = new PIXI.Texture(base);
bunny = new PIXI.Sprite(texture);
// center the sprites anchor point
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
// move the sprite t the center of the screen
bunny.position.x = 200;
bunny.position.y = 150;
stage.addChild(bunny);
requestAnimFrame(animate);
}
function animate() {
requestAnimFrame( animate );
// just for fun, lets rotate mr rabbit a little
bunny.rotation += 0.1;
bunny.scale.x += 0.01;
bunny.scale.y += 0.01;
// render the stage
renderer.render(stage);
}
</script>
</body>
</html>

View file

@ -1,44 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
var a = new Phaser.Point(100, 100);
var b = new Phaser.Point(200, 100);
console.log('Point A', a.toString());
console.log('Point B', b.toString());
a.add(b.x, b.y);
console.log('Point A + B', a.toString());
console.log('Distance between A and B', Phaser.Point.distance(a, b));
</script>
</body>
</html>

View file

@ -1,110 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('ship', 'assets/sprites/xenon2_ship.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
}
var ship;
var total;
var aliens;
function create() {
game.world.setSize(2000, 2000);
aliens = [];
for (var i = 0; i < 1000; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
s.name = 'alien' + s;
s.body.collideWorldBounds = true;
s.body.bounce.setTo(1, 1);
s.body.velocity.setTo(10 + Math.random() * 10, 10 + Math.random() * 10);
aliens.push(s);
}
ship = game.add.sprite(400, 400, 'ship');
ship.body.collideWorldBounds = true;
ship.body.bounce.setTo(0.5, 0.5);
}
function update() {
for (var i = 0; i < aliens.length; i++)
{
aliens[i].alpha = 0.3;
}
total = game.physics.quadTree.retrieve(ship);
// Get the ships top-most ID. If the length of that ID is 1 then we can ignore every other result,
// it's simply not colliding with anything :)
for (var i = 0; i < total.length; i++)
{
total[i].sprite.alpha = 1;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
ship.body.velocity.x -= 2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
ship.body.velocity.x += 2;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
ship.body.velocity.y -= 2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
ship.body.velocity.y += 2;
}
}
function render() {
for (var i = 0; i < aliens.length; i++)
{
// game.debug.renderRectangle(aliens[i].bounds);
}
game.debug.renderText(total.length, 32, 32);
game.debug.renderQuadTree(game.physics.quadTree);
// game.debug.renderRectangle(ship);
game.debug.renderText('Index: ' + ship.body.quadTreeIndex, 32, 80);
for (var i = 0; i < ship.body.quadTreeIDs.length; i++)
{
game.debug.renderText('ID: ' + ship.body.quadTreeIDs[i], 32, 100 + (i * 20));
}
}
})();
</script>
</body>
</html>

View file

@ -1,90 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('ship', 'assets/sprites/xenon2_ship.png');
game.load.image('baddie', 'assets/sprites/space-baddie.png');
}
var ship;
var total;
var aliens;
function create() {
aliens = [];
for (var i = 0; i < 50; i++)
{
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
s.name = 'alien' + s;
s.body.collideWorldBounds = true;
s.body.bounce.setTo(1, 1);
s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40);
aliens.push(s);
}
ship = game.add.sprite(400, 400, 'ship');
ship.body.collideWorldBounds = true;
ship.body.bounce.setTo(1, 1);
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
ship.body.velocity.x -= 2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
ship.body.velocity.x += 2;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
ship.body.velocity.y -= 2;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
ship.body.velocity.y += 2;
}
game.physics.collideGroup(aliens);
total = game.physics.overlap(ship);
}
function render() {
game.debug.renderQuadTree(game.physics.quadTree);
game.debug.renderRectangle(ship.body);
// game.debug.renderText('total: ' + total.length, 32, 50);
game.debug.renderText('up: ' + ship.body.touching.up, 32, 70);
game.debug.renderText('down: ' + ship.body.touching.down, 32, 90);
game.debug.renderText('left: ' + ship.body.touching.left, 32, 110);
game.debug.renderText('right: ' + ship.body.touching.right, 32, 130);
}
})();
</script>
</body>
</html>

View file

@ -1,45 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<pre id="raf">?</pre>
<pre id="time">Game Time: </pre>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600, null, null, update);
document.getElementById('raf').innerHTML = 'Browser using requestAnimationFrame: ' + game.raf.isRAF();
function update() {
document.getElementById('time').innerHTML = 'Game Time: ' + game.time.now;
}
</script>
</body>
</html>

View file

@ -1,22 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game();
var r = new Phaser.Rectangle(0,0,100,100);
console.log(r);
</script>
</body>
</html>

View file

@ -1,42 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
}
function create() {
var tempSprite = game.add.sprite(0, 0, 'atari1');
tempSprite.visible = false;
var renderTexture = game.add.renderTexture('fuji', 320, 200);
renderTexture.render(tempSprite);
var texturedSprite = game.add.sprite(400, 300, renderTexture);
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,25 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
console.log(game.rnd.integer());
console.log(game.rnd.frac());
console.log(game.rnd.real());
console.log(game.rnd.integerInRange(100,200));
</script>
</body>
</html>

View file

@ -1,35 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
function action(aString, aNumber, aObject) {
console.log('Signal received:', aString, aNumber, aObject);
}
var game = new Phaser.Game(this, '', 800, 600);
// create a new signal
var s = new Phaser.Signal();
// add a listener to it (the 'action' function)
s.add(action, this);
// dispatch it with some parameters
s.dispatch('Atari forever', 520, { x: 100, y: 200 });
</script>
</body>
</html>

View file

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('atari2', 'assets/sprites/atari800xl.png');
}
function create() {
game.add.sprite(0, 0, 'grid');
atari1 = game.add.sprite(128, 128, 'atari1');
atari2 = game.add.sprite(256, 256, 'atari2');
// Input Enable the sprites
atari1.inputEnabled = true;
atari2.inputEnabled = true;
// Allow dragging
// enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
atari1.input.enableDrag();
atari2.input.enableDrag();
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
// The snap is set to every 32x32 pixels.
atari1.input.enableSnap(32, 32, true, true);
// For the atari2 sprite it will snap only when released, not on drag.
atari2.input.enableSnap(32, 32, false, true);
}
})();
</script>
</body>
</html>

View file

@ -1,71 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
music.play();
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changeVolume, this);
}
function changeVolume(pointer) {
if (pointer.y < 300)
{
music.volume += 0.1;
}
else
{
music.volume -= 0.1;
}
}
function update() {
s.rotation += 0.01;
}
function render() {
game.debug.renderSoundInfo(music, 20, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,43 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var bunny;
function preload() {
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
function create() {
var test = new Phaser.Sprite(game, 0, 0, 'mushroom');
test.x = 200;
game.world.add(test);
console.log(test.alpha);
}
function update() {
}
})();
</script>
</body>
</html>

View file

@ -1,55 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var bunny;
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('ms', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
bunny = game.add.sprite(40, 100, 'ms');
bunny.animations.add('walk');
bunny.animations.play('walk', 50, true);
game.add.tween(bunny).to({ x: game.width }, 10000, Phaser.Easing.Linear.None, true);
}
// update isn't called until 'create' has completed. If you need to process stuff before that point (i.e. while the preload is still happening)
// then create a function called loadUpdate() and use that
function update() {
if (bunny.x >= 300)
{
bunny.scale.x += 0.01;
bunny.scale.y += 0.01;
}
}
})();
</script>
</body>
</html>

View file

@ -1,65 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, false);
var timer = 0;
var total = 0;
function preload() {
// 37x45 is the size of each frame
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
// blank frames at the end, so we tell the loader how many to load
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
}
function create() {
releaseMummy();
}
function releaseMummy() {
var mummy = game.add.sprite(-(Math.random() * 800), game.world.randomY, 'mummy');
mummy.scale.setTo(2, 2);
// If you prefer to work in degrees rather than radians then you can use Phaser.Sprite.angle
// otherwise use Phaser.Sprite.rotation
mummy.angle = game.rnd.angle();
mummy.animations.add('walk');
mummy.animations.play('walk', 50, true);
game.add.tween(mummy).to({ x: game.width + (1600 + mummy.x) }, 20000, Phaser.Easing.Linear.None, true);
total++;
timer = game.time.now + 100;
}
function update() {
if (total < 200 && game.time.now > timer)
{
releaseMummy();
}
}
})();
</script>
</body>
</html>

View file

@ -1,70 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
var s;
function create() {
// game.world._stage.backgroundColorString = '#182d3b';
s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot');
// s.anchor.setTo(0.5, 0.5);
s.scale.setTo(2, 2);
s.animations.add('run');
s.animations.play('run', 10, true);
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
function render() {
game.debug.renderSpriteCorners(s, false, false);
game.debug.renderSpriteInfo(s, 20, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,56 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
// Here is a custom game object
MonsterBunny = function (game, x, y) {
Phaser.Sprite.call(this, game, x, y, 'bunny');
};
MonsterBunny.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
MonsterBunny.prototype.constructor = MonsterBunny;
/**
* Automatically called by World.update
*/
MonsterBunny.prototype.update = function() {
this.angle++;
};
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
game.load.image('bunny', 'assets/sprites/bunny.png');
}
function create() {
var wabbit = new MonsterBunny(game, 400, 300);
wabbit.lifespan = 3000;
wabbit.anchor.setTo(0.5, 0.5);
game.add.existing(wabbit);
}
})();
</script>
</body>
</html>

View file

@ -1,55 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, true);
var bunny;
function preload() {
game.load.image('bunny', 'assets/sprites/bunny.png');
}
function create() {
var base = new PIXI.BaseTexture(game.cache.getImage('bunny'));
var texture = new PIXI.Texture(base);
bunny = new PIXI.Sprite(texture);
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
bunny.position.x = game.world.centerX;
bunny.position.y = game.world.centerY;
game.world.add(bunny);
}
function update() {
if (game.paused == false)
{
bunny.rotation += 0.01;
// bunny.scale.x += 0.01;
// bunny.scale.y += 0.01;
}
}
})();
</script>
</body>
</html>

View file

@ -1,66 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, true);
var bunny;
function preload() {
game.load.atlasJSONHash('monsters', 'assets/sprites/pixi_monsters.png', 'assets/sprites/pixi_monsters.json');
}
function create() {
// This is created by the very act of loading a texture atlas in
frameData = game.cache.getFrameData('monsters');
// Both of these work - they look fugly I know, but they'll be hidden behind a Phaser Sprite anyway
bunny = PIXI.Sprite.fromFrame(frameData.getFrame(0).uuid);
// bunny = PIXI.Sprite.fromFrame(frameData.getFrameByName('skully.png').uuid);
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
bunny.position.x = game.world.centerX;
bunny.position.y = game.world.centerY;
game.world.add(bunny);
n = game.time.now + 1000;
}
var frameData;
var f = 0;
var n = 0;
function update() {
if (game.time.now > n)
{
f = game.math.wrapValue(f, 1, 4);
bunny.setTexture(PIXI.TextureCache[frameData.getFrame(f).uuid]);
n = game.time.now + 500;
}
}
})();
</script>
</body>
</html>

View file

@ -1,68 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update }, false, false);
var bunny;
function preload() {
game.load.spritesheet('metalslug', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
}
function create() {
// This is created by the very act of loading a sprite sheet in
frameData = game.cache.getFrameData('metalslug');
// Both of these work - they look fugly I know, but they'll be hidden behind a Phaser Sprite anyway
bunny = PIXI.Sprite.fromFrame(frameData.getFrame(0).uuid);
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
bunny.scale.x = 6;
bunny.scale.y = 6;
bunny.position.x = game.world.centerX;
bunny.position.y = game.world.centerY;
game.world.add(bunny);
n = game.time.now + 20;
}
var frameData;
var f = 0;
var n = 0;
function update() {
if (game.time.now > n)
{
f = game.math.wrapValue(f, 1, frameData.total);
bunny.setTexture(PIXI.TextureCache[frameData.getFrame(f).uuid]);
n = game.time.now + 40;
}
}
})();
</script>
</body>
</html>

View file

@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
function create() {
// You can set the stage color using a hex value:
game.stage.backgroundColor = '#550000';
// Or a direct color value:
game.stage.backgroundColor = 0xbbaa44;
}
})();
</script>
</body>
</html>

View file

@ -1,85 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
game.load.image('player', 'assets/sprites/phaser-dude.png');
}
var map;
var p;
function create() {
game.stage.backgroundColor = '#787878';
map = game.add.tilemap(0, 0, 'mario');
// floor
map.setCollisionRange(80, 97, true, true, true, true);
// one-ways
map.setCollisionRange(15, 17, true, true, false, true);
p = game.add.sprite(32, 32, 'player');
p.body.bounce.y = 0.4;
p.body.collideWorldBounds = true;
game.camera.follow(p);
}
function update() {
map.collide(p);
p.body.velocity.x = 0;
p.body.acceleration.y = 500;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
p.body.velocity.x = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
p.body.velocity.x = 150;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
if (p.body.touching.down)
{
p.body.velocity.y = -200;
}
}
}
function render() {
game.debug.renderSpriteCorners(p);
game.debug.renderSpriteCollision(p, 32, 320);
}
})();
</script>
</body>
</html>

View file

@ -1,79 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
</head>
<body>
<script type="text/javascript">
var BigGame = function(context) {
console.log(context);
console.log(context['hello']);
// this.pendingCallback = callback;
this.pendingCallback = context['hello'];
var _this = this;
this._onLoop = function () {
return _this.boot();
}
if (document.readyState === 'complete' || document.readyState === 'interactive')
{
window.setTimeout(this._onLoop, 0);
}
else
{
document.addEventListener('DOMContentLoaded', this._onLoop, false);
window.addEventListener('load', this._onLoop, false);
}
};
BigGame.prototype = {
isBooted: false,
pendingCallback: null,
_onLoop: null,
boot: function () {
if (this.isBooted) {
return;
}
else
{
document.removeEventListener('DOMContentLoaded', this._onLoop);
window.removeEventListener('load', this._onLoop);
this.pendingCallback();
}
},
check: function () {
console.log(Math.random());
}
};
(function () {
// because this is in a closure we have to pass a reference to the function directly, it can't guess it
// var bob = new BigGame(hello);
//var bob = new BigGame(this);
function hello() {
console.log('hello world 2');
console.log(bob);
bob.check();
}
})();
</script>
</body>
</html>

View file

@ -1,31 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
function create() {
var text = "- phaser -\nwith a sprinkle of\npixi dust";
var style = { font: "65px Arial", fill: "#ff0044", align: "center" };
game.add.text(game.world.centerX, game.world.centerY, text, style).anchor.setTo(0.5, 0.5);
}
})();
</script>
</body>
</html>

View file

@ -1,41 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create, update: update, render: render });
var s;
function create() {
var text = "--- phaser ---\nwith a sprinkle of\npixi dust";
var style = { font: "bold 40pt Arial", fill: "#ffffff", align: "center", stroke: "#258acc", strokeThickness: 8 };
s = game.add.text(game.world.centerX, game.world.centerY, text, style);
s.anchor.setTo(0.5, 0.5);
}
function update() {
s.angle += 1;
}
function render() {
game.debug.renderSpriteCorners(s, true, true);
}
})();
</script>
</body>
</html>

View file

@ -1,82 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var content = [
" ",
"photon storm presents",
"a phaser production",
" ",
"Kern of Duty",
" ",
"directed by rich davey",
"rendering by mat groves",
" ",
"03:45, November 4th, 2014",
"somewhere in the north pacific",
"mission control bravo ...",
];
var t = 0;
var s;
var index = 0;
var line = '';
function preload() {
game.load.image('cod', 'assets/pics/cod.jpg');
}
function create() {
game.add.sprite(0, 0, 'cod');
var style = { font: "30pt Courier", fill: "#19cb65", stroke: "#119f4e", strokeThickness: 2 };
s = game.add.text(32, 380, '', style);
t = game.time.now + 80;
}
function update() {
if (game.time.now > t && index < content.length)
{
// get the next character in the line
if (line.length < content[index].length)
{
line = content[index].substr(0, line.length + 1);
s.setText(line);
t = game.time.now + 80;
}
else
{
t = game.time.now + 2000;
if (index < content.length)
{
index++;
line = '';
}
}
}
}
})();
</script>
</body>
</html>

View file

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('catastrophi', 'assets/tiles/catastrophi_tiles_16.png', 'assets/maps/catastrophi_level2.csv', null, Phaser.Tilemap.CSV);
}
function create() {
// This creates the tilemap using the csv and tile sheet we loaded.
// We tell it use to CSV format parser. The 16x16 are the tile sizes.
// The 4th parameter (true) tells the game world to resize itself based on the map dimensions or not.
game.add.tilemap(0, 0, 'catastrophi', true, 16, 16);
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += 8;
}
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
function preload() {
game.load.image('disk', 'assets/sprites/p2.jpeg');
}
var s;
var count = 0;
function create() {
s = game.add.tileSprite(0, 0, 512, 512, 'disk');
}
function update() {
count += 0.005
s.tileScale.x = 2 + Math.sin(count);
s.tileScale.y = 2 + Math.cos(count);
s.tilePosition.x += 1;
s.tilePosition.y += 1;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
})();
</script>
</body>
</html>

View file

@ -1,54 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
var s;
function preload() {
game.load.image('disk', 'assets/misc/starfield.jpg');
}
function create() {
s = game.add.tileSprite(0, 0, 800, 600, 'disk');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.tilePosition.x += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.tilePosition.x -= 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.tilePosition.y += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.tilePosition.y -= 8;
}
}
})();
</script>
</body>
</html>

View file

@ -1,62 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('ship', 'assets/sprites/mana_card.png');
}
var a;
var p = new Phaser.Point;
function create() {
a = game.add.sprite(game.world.centerX, game.world.centerX, 'ship');
a.name = 'sh';
a.inputEnabled = true;
a.angle = 30;
a.events.onInputDown.add(clicked, this);
}
function clicked (sprite, pointer) {
sprite.alpha -= 0.1;
}
function update() {
}
function render() {
// game.debug.renderText('over: ' + a.input.checkPointerOver(game.input.activePointer), 32, 32);
// game.debug.renderPoint(p, 'rgb(255,255,0)');
// game.debug.renderText('px: ' + game.input.activePointer.x, 32, 32);
// game.debug.renderText('py: ' + game.input.activePointer.y, 32, 64);
// game.debug.renderPointer(game.input.activePointer);
game.debug.renderSpriteInputInfo(a, 32, 32);
}
})();
</script>
</body>
</html>

View file

@ -1,47 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
var test = { x: 0 };
var tween = game.tweens.create(test);
tween.onComplete.add(onComplete, this);
tween.to({x: 100}, 1000, Phaser.Easing.Linear.None, true);
function onComplete() {
console.log('tween finished, new data: ', test);
}
</script>
</body>
</html>

View file

@ -1,42 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('atari1', 'assets/sprites/atari130xe.png');
}
function create() {
var tempSprite = game.add.sprite(0, 0, 'atari1');
game.add.tween(tempSprite).to({ x: 600 }, 4000, Phaser.Easing.Linear.None, true);
game.add.tween(tempSprite).to({ y: 500 }, 4000, Phaser.Easing.Linear.None, true);
}
function update() {
}
function render() {
}
})();
</script>
</body>
</html>

View file

@ -1,141 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a(nother) new beginning</title>
<script src="../src/Phaser.js"></script>
<script src="../src/pixi/Pixi.js"></script>
<script src="../src/pixi/InteractionManager.js"></script>
<script src="../src/pixi/core/Circle.js"></script>
<script src="../src/pixi/core/Ellipse.js"></script>
<script src="../src/pixi/core/Matrix.js"></script>
<script src="../src/pixi/core/Point.js"></script>
<script src="../src/pixi/core/Polygon.js"></script>
<script src="../src/pixi/core/Rectangle.js"></script>
<script src="../src/pixi/display/DisplayObject.js"></script>
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
<script src="../src/pixi/display/Sprite.js"></script>
<script src="../src/pixi/display/MovieClip.js"></script>
<script src="../src/pixi/display/Stage.js"></script>
<script src="../src/pixi/extras/CustomRenderable.js"></script>
<script src="../src/pixi/extras/Strip.js"></script>
<script src="../src/pixi/extras/Rope.js"></script>
<script src="../src/pixi/extras/Spine.js"></script>
<script src="../src/pixi/extras/TilingSprite.js"></script>
<script src="../src/pixi/filters/FilterBlock.js"></script>
<script src="../src/pixi/filters/MaskFilter.js"></script>
<script src="../src/pixi/primitives/Graphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
<script src="../src/pixi/text/BitmapText.js"></script>
<script src="../src/pixi/text/Text.js"></script>
<script src="../src/pixi/textures/BaseTexture.js"></script>
<script src="../src/pixi/textures/Texture.js"></script>
<script src="../src/pixi/textures/RenderTexture.js"></script>
<script src="../src/pixi/utils/Detector.js"></script>
<script src="../src/pixi/utils/EventTarget.js"></script>
<script src="../src/pixi/utils/Polyk.js"></script>
<script src="../src/pixi/utils/Utils.js"></script>
<script src="../src/system/RequestAnimationFrame.js"></script>
<script src="../src/system/Device.js"></script>
<script src="../src/core/SignalBinding.js"></script>
<script src="../src/core/Signal.js"></script>
<script src="../src/core/PluginManager.js"></script>
<script src="../src/core/Plugin.js"></script>
<script src="../src/math/RandomDataGenerator.js"></script>
<script src="../src/math/Math.js"></script>
<script src="../src/geom/Point.js"></script>
<script src="../src/geom/Circle.js"></script>
<script src="../src/net/Net.js"></script>
<script src="../src/tween/TweenManager.js"></script>
<script src="../src/tween/Tween.js"></script>
<script src="../src/tween/Easing.js"></script>
<script src="../src/time/Time.js"></script>
<script src="../src/animation/Animation.js"></script>
<script src="../src/animation/Frame.js"></script>
<script src="../src/animation/FrameData.js"></script>
<script src="../src/animation/Parser.js"></script>
<script src="../src/loader/Cache.js"></script>
<script src="../src/loader/Loader.js"></script>
<script src="../src/Game.js"></script>
</head>
<body>
<script type="text/javascript">
var game = new Phaser.Game(this, '', 800, 600);
// PIXI it
var stage = new PIXI.Stage(0x000044);
var renderer = PIXI.autoDetectRenderer(800, 600);
document.body.appendChild(renderer.view);
game.load.image('cockpit', 'assets/pics/cockpit.png');
game.load.image('rememberMe', 'assets/pics/remember-me.jpg');
game.load.image('overdose', 'assets/pics/lance-overdose-loader_eye.png');
game.load.onLoadStart.add(loadStarted, this);
game.load.onFileComplete.add(fileLoaded, this);
game.load.onLoadComplete.add(loadCompleted, this);
game.load.start();
function loadStarted(size) {
console.log('Loader started, queue size:', size);
}
// this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize
function fileLoaded(progress, key, success, remaining, total) {
console.log('File Loaded:', key);
console.log('Progress: ' + progress + '%');
console.log('File: ' + remaining + ' out of ' + total);
}
var bunny;
function loadCompleted() {
console.log('Loader finished, creating base textures');
// Create a basetexture
var base = new PIXI.BaseTexture(game.cache.getImage('overdose'));
var texture = new PIXI.Texture(base);
bunny = new PIXI.Sprite(texture);
// center the sprites anchor point
bunny.anchor.x = 0.5;
bunny.anchor.y = 0.5;
// move the sprite t the center of the screen
bunny.position.x = 200;
bunny.position.y = 150;
stage.addChild(bunny);
requestAnimFrame(animate);
}
function animate() {
requestAnimFrame( animate );
// just for fun, lets rotate mr rabbit a little
bunny.rotation += 0.1;
bunny.scale.x += 0.01;
bunny.scale.y += 0.01;
// render the stage
renderer.render(stage);
}
</script>
</body>
</html>

View file

@ -1,106 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>phaser.js - a new beginning</title>
<?php
require('js.php');
?>
</head>
<body>
<script type="text/javascript">
(function () {
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
function preload() {
// Lots of assets
game.load.image('stars', 'assets/misc/starfield.jpg');
game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var camSpeed = 8;
var s;
function create() {
// Make our world big ...
game.world.setSize(4000, 2000);
// Scrolling background
s = game.add.tileSprite(0, 0, 800, 600, 'stars');
s.scrollFactor.setTo(0, 0);
// Now let's create loads of stuff moving around it
for (var i = 0; i < 50; i++)
{
var temp = game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom');
temp.body.velocity.setTo(50 + Math.random() * 90, 50 + Math.random() * 90);
temp.body.bounce.setTo(1, 1);
temp.body.collideWorldBounds = true;
var temp = game.add.sprite(game.world.randomX, game.world.randomY, 'atari1');
temp.body.velocity.setTo(10 + Math.random() * 90, 10 + Math.random() * 90);
temp.body.bounce.setTo(1, 1);
temp.body.collideWorldBounds = true;
}
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
game.camera.x -= camSpeed;
if (!game.camera.atLimit.x)
{
s.tilePosition.x += camSpeed;
}
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
game.camera.x += camSpeed;
if (!game.camera.atLimit.x)
{
s.tilePosition.x -= camSpeed;
}
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.camera.y -= camSpeed;
if (!game.camera.atLimit.y)
{
s.tilePosition.y += camSpeed;
}
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
game.camera.y += camSpeed;
if (!game.camera.atLimit.y)
{
s.tilePosition.y -= camSpeed;
}
}
}
function render() {
game.debug.renderCameraInfo(game.camera, 32, 32);
}
})();
</script>
</body>
</html>

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more