Plugin Support added and CameraFX re-enabled

This commit is contained in:
Richard Davey
2013-08-02 19:37:43 +01:00
parent 982faeedb8
commit f3dcd3e831
12 changed files with 556 additions and 156 deletions
+22
View File
@@ -0,0 +1,22 @@
// Module
var Shapes;
(function (Shapes) {
// Class
var Point = (function () {
// Constructor
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDist = // Instance member
function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
Point.origin = new Point(0, 0);
return Point;
})();
Shapes.Point = Point;
})(Shapes || (Shapes = {}));
// Local variables
var p = new Shapes.Point(3, 4);
var dist = p.getDist();
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="../Phaser/Game.ts" />
module Phaser {
export interface IPlugin {
game: Game;
active: bool;
visible: bool;
preUpdate();
postUpdate();
preRender();
postRender();
destroy();
}
}
+13 -1
View File
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -52,5 +52,17 @@
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>
<ItemGroup>
<TypeScriptCompile Include="Template.ts" />
</ItemGroup>
<ItemGroup>
<Content Include="IPlugin.js">
<DependentUpon>IPlugin.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="IPlugin.ts" />
<Content Include="Template.js">
<DependentUpon>Template.ts</DependentUpon>
</Content>
</ItemGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
</Project>
+53
View File
@@ -0,0 +1,53 @@
var Phaser;
(function (Phaser) {
/// <reference path="../Phaser/Game.ts" />
/**
* Phaser - Example Plugin
*/
(function (Plugins) {
var Example = (function () {
function Example(game) {
this.game = game;
this.active = true;
this.visible = true;
}
Example.prototype.preUpdate = /**
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
*/
function () {
};
Example.prototype.postUpdate = /**
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
*/
function () {
};
Example.prototype.preRender = /**
* Pre-render is called at the start of the object render cycle, before any transforms have taken place.
* It happens directly AFTER a canvas context.save has happened if added to a Camera.
* @param {Camera} camera
*/
function (camera) {
};
Example.prototype.render = /**
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
* @param {Camera} camera
*/
function (camera) {
};
Example.prototype.postRender = /**
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
*/
function (camera) {
};
Example.prototype.destroy = /**
* Clear down this Plugin and null out references
*/
function () {
this.game = null;
};
return Example;
})();
Plugins.Example = Example;
})(Phaser.Plugins || (Phaser.Plugins = {}));
var Plugins = Phaser.Plugins;
})(Phaser || (Phaser = {}));
+72
View File
@@ -0,0 +1,72 @@
/// <reference path="../Phaser/Game.ts" />
/// <reference path="IPlugin.ts" />
/**
* Phaser - Example Plugin
*/
module Phaser.Plugins {
export class Example implements Phaser.IPlugin {
constructor(game: Phaser.Game) {
this.game = game;
this.active = true;
this.visible = true;
}
/**
* The essential reference to the main game object.
*/
public game: Game;
/**
* Controls whether preUpdate or postUpdate are called
*/
public active: bool;
/**
* Controls whether preRender or postRender are called
*/
public visible: bool;
/**
* Pre-update is called at the start of the update cycle, before any other updates have taken place.
* It is only called if active is set to true.
*/
public preUpdate() {
}
/**
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
* It is only called if active is set to true.
*/
public postUpdate() {
}
/**
* Pre-render is called right before the Game Renderer starts and before any custom preRender callbacks have been run.
* It is only called if visible is set to true.
*/
public preRender() {
}
/**
* Post-render is called after every camera and game object has been rendered, also after any custom postRender callbacks have been run.
* It is only called if visible is set to true.
*/
public postRender() {
}
/**
* Clear down this Plugin and null out references
*/
public destroy() {
this.game = null;
}
}
}