mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Removed the FX project as it's no longer needed and tidied up the build folder.
This commit is contained in:
@@ -51,23 +51,6 @@ module.exports = function (grunt) {
|
||||
comments: true
|
||||
}
|
||||
},
|
||||
//tests: {
|
||||
// src: ['Tests/**/*.ts'],
|
||||
// options: {
|
||||
// target: 'ES5',
|
||||
// declaration: true,
|
||||
// comments: true
|
||||
// }
|
||||
// }
|
||||
//fx: {
|
||||
// src: ['SpecialFX/**/*.ts'],
|
||||
// dest: 'build/phaser-fx.js',
|
||||
// options: {
|
||||
// target: 'ES5',
|
||||
// declaration: true,
|
||||
// comments: true
|
||||
// }
|
||||
//}
|
||||
},
|
||||
copy: {
|
||||
main: {
|
||||
@@ -76,12 +59,6 @@ module.exports = function (grunt) {
|
||||
dest: 'Tests/phaser.js'
|
||||
}]
|
||||
},
|
||||
fx: {
|
||||
files: [{
|
||||
src: 'build/phaser-fx.js',
|
||||
dest: 'Tests/phaser-fx.js'
|
||||
}]
|
||||
},
|
||||
mainAmd: {
|
||||
files: [{
|
||||
src: 'build/phaser.js',
|
||||
@@ -91,15 +68,6 @@ module.exports = function (grunt) {
|
||||
processContent: wrapPhaserInUmd
|
||||
}
|
||||
},
|
||||
fxAmd: {
|
||||
files: [{
|
||||
src: 'build/phaser-fx.js',
|
||||
dest: 'build/phaser-fx.amd.js'
|
||||
}],
|
||||
options: {
|
||||
processContent: wrapAddonInUmd
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: '**/*.ts',
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Border
|
||||
*
|
||||
* Creates a border around a camera.
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Border = (function (_super) {
|
||||
__extends(Border, _super);
|
||||
function Border(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.showBorder = false;
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
this.borderColor = 'rgb(255,255,255)';
|
||||
this.camera = parent;
|
||||
}
|
||||
Border.prototype.postRender = function () {
|
||||
if(this.showBorder == true) {
|
||||
this.game.stage.context.strokeStyle = this.borderColor;
|
||||
this.game.stage.context.lineWidth = 1;
|
||||
this.game.stage.context.rect(this.camera.x, this.camera.y, this.camera.width, this.camera.height);
|
||||
this.game.stage.context.stroke();
|
||||
}
|
||||
};
|
||||
return Border;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Border = Border;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -0,0 +1,49 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Border
|
||||
*
|
||||
* Creates a border around a camera.
|
||||
*/
|
||||
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Border extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showBorder: bool = false;
|
||||
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
public borderColor: string = 'rgb(255,255,255)';
|
||||
|
||||
public postRender() {
|
||||
|
||||
if (this.showBorder == true)
|
||||
{
|
||||
this.game.stage.context.strokeStyle = this.borderColor;
|
||||
this.game.stage.context.lineWidth = 1;
|
||||
this.game.stage.context.rect(this.camera.x, this.camera.y, this.camera.width, this.camera.height);
|
||||
this.game.stage.context.stroke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Fade
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Fade = (function (_super) {
|
||||
__extends(Fade, _super);
|
||||
function Fade(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this._fxFadeComplete = null;
|
||||
this._fxFadeDuration = 0;
|
||||
this._fxFadeAlpha = 0;
|
||||
this.camera = parent;
|
||||
}
|
||||
Fade.prototype.start = /**
|
||||
* The camera is gradually filled with this color.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
function (color, duration, onComplete, force) {
|
||||
if (typeof color === "undefined") { color = 0x000000; }
|
||||
if (typeof duration === "undefined") { duration = 1; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = false; }
|
||||
if(force === false && this._fxFadeAlpha > 0) {
|
||||
// You can't fade again unless you force it
|
||||
return;
|
||||
}
|
||||
if(duration <= 0) {
|
||||
duration = 1;
|
||||
}
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFadeDuration = duration;
|
||||
this._fxFadeAlpha = 0.01;
|
||||
this._fxFadeComplete = onComplete;
|
||||
};
|
||||
Fade.prototype.postUpdate = function () {
|
||||
// Update the Fade effect
|
||||
if(this._fxFadeAlpha > 0) {
|
||||
this._fxFadeAlpha += this.game.time.elapsed / this._fxFadeDuration;
|
||||
if(this.game.math.roundTo(this._fxFadeAlpha, -2) >= 1) {
|
||||
this._fxFadeAlpha = 1;
|
||||
if(this._fxFadeComplete !== null) {
|
||||
this._fxFadeComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Fade.prototype.postRender = function () {
|
||||
// "Fade" FX
|
||||
if(this._fxFadeAlpha > 0) {
|
||||
this.game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
|
||||
}
|
||||
};
|
||||
return Fade;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Fade = Fade;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,22 +1,24 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Fade
|
||||
* Phaser - Plugins - Camera FX - Fade
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Fade {
|
||||
export class Fade extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Game) {
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
this._game = game;
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
private _fxFadeColor: string;
|
||||
private _fxFadeComplete = null;
|
||||
@@ -60,9 +62,9 @@ module Phaser.FX.Camera {
|
||||
// Update the Fade effect
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration;
|
||||
this._fxFadeAlpha += this.game.time.elapsed / this._fxFadeDuration;
|
||||
|
||||
if (this._game.math.roundTo(this._fxFadeAlpha, -2) >= 1)
|
||||
if (this.game.math.roundTo(this._fxFadeAlpha, -2) >= 1)
|
||||
{
|
||||
this._fxFadeAlpha = 1;
|
||||
|
||||
@@ -75,13 +77,13 @@ module Phaser.FX.Camera {
|
||||
|
||||
}
|
||||
|
||||
public postRender(camera: Phaser.Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
public postRender() {
|
||||
|
||||
// "Fade" FX
|
||||
if (this._fxFadeAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
this.game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Flash
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Flash = (function (_super) {
|
||||
__extends(Flash, _super);
|
||||
function Flash(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this._fxFlashComplete = null;
|
||||
this._fxFlashDuration = 0;
|
||||
this._fxFlashAlpha = 0;
|
||||
this.camera = parent;
|
||||
}
|
||||
Flash.prototype.start = /**
|
||||
* The camera is filled with this color and returns to normal at the given duration.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
function (color, duration, onComplete, force) {
|
||||
if (typeof color === "undefined") { color = 0xffffff; }
|
||||
if (typeof duration === "undefined") { duration = 1; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = false; }
|
||||
if(force === false && this._fxFlashAlpha > 0) {
|
||||
// You can't flash again unless you force it
|
||||
return;
|
||||
}
|
||||
if(duration <= 0) {
|
||||
duration = 1;
|
||||
}
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFlashDuration = duration;
|
||||
this._fxFlashAlpha = 1;
|
||||
this._fxFlashComplete = onComplete;
|
||||
};
|
||||
Flash.prototype.postUpdate = function () {
|
||||
// Update the Flash effect
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this._fxFlashAlpha -= this.game.time.elapsed / this._fxFlashDuration;
|
||||
if(this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0) {
|
||||
this._fxFlashAlpha = 0;
|
||||
if(this._fxFlashComplete !== null) {
|
||||
this._fxFlashComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Flash.prototype.postRender = function () {
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this.game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
|
||||
}
|
||||
};
|
||||
return Flash;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Flash = Flash;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,22 +1,24 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Flash
|
||||
* Phaser - Plugins - Camera FX - Flash
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Flash {
|
||||
export class Flash extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Game) {
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
this._game = game;
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
private _fxFlashColor: string;
|
||||
private _fxFlashComplete = null;
|
||||
@@ -60,9 +62,9 @@ module Phaser.FX.Camera {
|
||||
// Update the Flash effect
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration;
|
||||
this._fxFlashAlpha -= this.game.time.elapsed / this._fxFlashDuration;
|
||||
|
||||
if (this._game.math.roundTo(this._fxFlashAlpha, -2) <= 0)
|
||||
if (this.game.math.roundTo(this._fxFlashAlpha, -2) <= 0)
|
||||
{
|
||||
this._fxFlashAlpha = 0;
|
||||
|
||||
@@ -75,12 +77,12 @@ module Phaser.FX.Camera {
|
||||
|
||||
}
|
||||
|
||||
public postRender(camera: Phaser.Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
public postRender() {
|
||||
|
||||
if (this._fxFlashAlpha > 0)
|
||||
{
|
||||
this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
this.game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this.game.stage.context.fillRect(this.camera.screenView.x, this.camera.screenView.y, this.camera.width, this.camera.height);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,9 +18,10 @@ module Phaser.Plugins.CameraFX {
|
||||
|
||||
}
|
||||
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
public spacing: number = 4;
|
||||
public color: string = 'rgba(0, 0, 0, 0.3)';
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
public postRender() {
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Shadow
|
||||
*
|
||||
* Creates a drop shadow effect on the camera window.
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Shadow = (function (_super) {
|
||||
__extends(Shadow, _super);
|
||||
function Shadow(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.showShadow = false;
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
this.shadowColor = 'rgb(0,0,0)';
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
this.shadowBlur = 10;
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {Point}
|
||||
*/
|
||||
this.shadowOffset = new Phaser.Point(4, 4);
|
||||
this.camera = parent;
|
||||
}
|
||||
Shadow.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.
|
||||
*/
|
||||
function () {
|
||||
// Shadow
|
||||
if(this.showShadow == true) {
|
||||
this.game.stage.context.shadowColor = this.shadowColor;
|
||||
this.game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this.game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this.game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
};
|
||||
Shadow.prototype.render = /**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
function () {
|
||||
// Shadow off
|
||||
if(this.showShadow == true) {
|
||||
this.game.stage.context.shadowBlur = 0;
|
||||
this.game.stage.context.shadowOffsetX = 0;
|
||||
this.game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
};
|
||||
return Shadow;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Shadow = Shadow;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -0,0 +1,81 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Shadow
|
||||
*
|
||||
* Creates a drop shadow effect on the camera window.
|
||||
*/
|
||||
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Shadow extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showShadow: bool = false;
|
||||
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public shadowColor: string = 'rgb(0,0,0)';
|
||||
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
public shadowBlur: number = 10;
|
||||
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {Point}
|
||||
*/
|
||||
public shadowOffset: Point = new Point(4, 4);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public preRender() {
|
||||
|
||||
// Shadow
|
||||
if (this.showShadow == true)
|
||||
{
|
||||
this.game.stage.context.shadowColor = this.shadowColor;
|
||||
this.game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this.game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this.game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
public render() {
|
||||
|
||||
// Shadow off
|
||||
if (this.showShadow == true)
|
||||
{
|
||||
this.game.stage.context.shadowBlur = 0;
|
||||
this.game.stage.context.shadowOffsetX = 0;
|
||||
this.game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (Plugins) {
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
/**
|
||||
* Phaser - Plugins - Camera FX - Shake
|
||||
*
|
||||
* A simple camera shake effect.
|
||||
*/
|
||||
(function (CameraFX) {
|
||||
var Shake = (function (_super) {
|
||||
__extends(Shake, _super);
|
||||
function Shake(game, parent) {
|
||||
_super.call(this, game, parent);
|
||||
this._fxShakeIntensity = 0;
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeComplete = null;
|
||||
this._fxShakeOffset = new Phaser.Point(0, 0);
|
||||
this._fxShakeDirection = 0;
|
||||
this._fxShakePrevX = 0;
|
||||
this._fxShakePrevY = 0;
|
||||
this.camera = parent;
|
||||
}
|
||||
Shake.SHAKE_BOTH_AXES = 0;
|
||||
Shake.SHAKE_HORIZONTAL_ONLY = 1;
|
||||
Shake.SHAKE_VERTICAL_ONLY = 2;
|
||||
Shake.prototype.start = /**
|
||||
* A simple camera shake effect.
|
||||
*
|
||||
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
|
||||
* @param Duration The length in seconds that the shaking effect should last.
|
||||
* @param OnComplete A function you want to run when the shake effect finishes.
|
||||
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
|
||||
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
||||
*/
|
||||
function (intensity, duration, onComplete, force, direction) {
|
||||
if (typeof intensity === "undefined") { intensity = 0.05; }
|
||||
if (typeof duration === "undefined") { duration = 0.5; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = true; }
|
||||
if (typeof direction === "undefined") { direction = Shake.SHAKE_BOTH_AXES; }
|
||||
if(!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) {
|
||||
return;
|
||||
}
|
||||
// If a shake is not already running we need to store the offsets here
|
||||
if(this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) {
|
||||
this._fxShakePrevX = this.camera.x;
|
||||
this._fxShakePrevY = this.camera.y;
|
||||
}
|
||||
this._fxShakeIntensity = intensity;
|
||||
this._fxShakeDuration = duration;
|
||||
this._fxShakeComplete = onComplete;
|
||||
this._fxShakeDirection = direction;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
};
|
||||
Shake.prototype.postUpdate = function () {
|
||||
// Update the "shake" special effect
|
||||
if(this._fxShakeDuration > 0) {
|
||||
this._fxShakeDuration -= this.game.time.elapsed;
|
||||
if(this.game.math.roundTo(this._fxShakeDuration, -2) <= 0) {
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this.camera.x = this._fxShakePrevX;
|
||||
this.camera.y = this._fxShakePrevY;
|
||||
if(this._fxShakeComplete != null) {
|
||||
this._fxShakeComplete();
|
||||
}
|
||||
} else {
|
||||
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY)) {
|
||||
this._fxShakeOffset.x = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.width * 2 - this._fxShakeIntensity * this.camera.worldView.width);
|
||||
}
|
||||
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY)) {
|
||||
this._fxShakeOffset.y = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.height * 2 - this._fxShakeIntensity * this.camera.worldView.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Shake.prototype.preRender = function () {
|
||||
if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) {
|
||||
this.camera.x = this._fxShakePrevX + this._fxShakeOffset.x;
|
||||
this.camera.y = this._fxShakePrevY + this._fxShakeOffset.y;
|
||||
}
|
||||
};
|
||||
return Shake;
|
||||
})(Phaser.Plugin);
|
||||
CameraFX.Shake = Shake;
|
||||
})(Plugins.CameraFX || (Plugins.CameraFX = {}));
|
||||
var CameraFX = Plugins.CameraFX;
|
||||
})(Phaser.Plugins || (Phaser.Plugins = {}));
|
||||
var Plugins = Phaser.Plugins;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,24 +1,24 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/core/Plugin.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Shake
|
||||
* Phaser - Plugins - Camera FX - Shake
|
||||
*
|
||||
* A simple camera shake effect.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
module Phaser.Plugins.CameraFX {
|
||||
|
||||
export class Shake {
|
||||
export class Shake extends Phaser.Plugin {
|
||||
|
||||
constructor(game: Game, camera: Phaser.Camera) {
|
||||
constructor(game: Phaser.Game, parent) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = camera;
|
||||
super(game, parent);
|
||||
this.camera = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Phaser.Camera;
|
||||
public camera: Phaser.Camera;
|
||||
|
||||
private _fxShakeIntensity: number = 0;
|
||||
private _fxShakeDuration: number = 0;
|
||||
@@ -51,8 +51,8 @@ module Phaser.FX.Camera {
|
||||
// If a shake is not already running we need to store the offsets here
|
||||
if (this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0)
|
||||
{
|
||||
this._fxShakePrevX = this._parent.x;
|
||||
this._fxShakePrevY = this._parent.y;
|
||||
this._fxShakePrevX = this.camera.x;
|
||||
this._fxShakePrevY = this.camera.y;
|
||||
}
|
||||
|
||||
this._fxShakeIntensity = intensity;
|
||||
@@ -68,14 +68,14 @@ module Phaser.FX.Camera {
|
||||
// Update the "shake" special effect
|
||||
if (this._fxShakeDuration > 0)
|
||||
{
|
||||
this._fxShakeDuration -= this._game.time.elapsed;
|
||||
this._fxShakeDuration -= this.game.time.elapsed;
|
||||
|
||||
if (this._game.math.roundTo(this._fxShakeDuration, -2) <= 0)
|
||||
if (this.game.math.roundTo(this._fxShakeDuration, -2) <= 0)
|
||||
{
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._parent.x = this._fxShakePrevX;
|
||||
this._parent.y = this._fxShakePrevY;
|
||||
this.camera.x = this._fxShakePrevX;
|
||||
this.camera.y = this._fxShakePrevY;
|
||||
|
||||
if (this._fxShakeComplete != null)
|
||||
{
|
||||
@@ -86,14 +86,12 @@ module Phaser.FX.Camera {
|
||||
{
|
||||
if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.x = ((this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width) * this._zoom;
|
||||
this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this._parent.worldView.width * 2 - this._fxShakeIntensity * this._parent.worldView.width);
|
||||
this._fxShakeOffset.x = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.width * 2 - this._fxShakeIntensity * this.camera.worldView.width);
|
||||
}
|
||||
|
||||
if ((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY))
|
||||
{
|
||||
//this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height) * this._zoom;
|
||||
this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this._parent.worldView.height * 2 - this._fxShakeIntensity * this._parent.worldView.height);
|
||||
this._fxShakeOffset.y = (this.game.rnd.integer * this._fxShakeIntensity * this.camera.worldView.height * 2 - this._fxShakeIntensity * this.camera.worldView.height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,12 +99,12 @@ module Phaser.FX.Camera {
|
||||
|
||||
}
|
||||
|
||||
public preRender(camera: Phaser.Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
public preRender() {
|
||||
|
||||
if ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))
|
||||
{
|
||||
this._parent.x = this._fxShakePrevX + this._fxShakeOffset.x;
|
||||
this._parent.y = this._fxShakePrevY + this._fxShakeOffset.y;
|
||||
this.camera.x = this._fxShakePrevX + this._fxShakeOffset.x;
|
||||
this.camera.y = this._fxShakePrevY + this._fxShakeOffset.y;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,12 +58,32 @@
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="CameraFX\Scanlines.ts" />
|
||||
<TypeScriptCompile Include="CameraFX\Mirror.ts" />
|
||||
<TypeScriptCompile Include="CameraFX\Border.ts" />
|
||||
<Content Include="CameraFX\Border.js">
|
||||
<DependentUpon>Border.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="CameraFX\Fade.ts" />
|
||||
<Content Include="CameraFX\Fade.js">
|
||||
<DependentUpon>Fade.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="CameraFX\Flash.ts" />
|
||||
<Content Include="CameraFX\Flash.js">
|
||||
<DependentUpon>Flash.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="CameraFX\Mirror.js">
|
||||
<DependentUpon>Mirror.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="CameraFX\Scanlines.js">
|
||||
<DependentUpon>Scanlines.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="CameraFX\Shadow.ts" />
|
||||
<Content Include="CameraFX\Shadow.js">
|
||||
<DependentUpon>Shadow.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="CameraFX\Shake.ts" />
|
||||
<Content Include="CameraFX\Shake.js">
|
||||
<DependentUpon>Shake.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Template.js">
|
||||
<DependentUpon>Template.ts</DependentUpon>
|
||||
</Content>
|
||||
|
||||
@@ -160,6 +160,7 @@ V1.0.0
|
||||
* Added crop support to the Texture component, so you can do Sprite.crop to restrict rendering to a specified Rectangle without distortion.
|
||||
* Added references to all the event listener functions so they can be cleanly destroyed.
|
||||
* Fixed interesting Firefox issue when an audio track ended it fired another 'canplaythrough' event, confusing the Loader.
|
||||
* Added the new PluginManager. Moved all the Camera FX over to plugins. Everything will be a plugin from now on.
|
||||
|
||||
|
||||
V0.9.6
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
|
||||
#ignore thumbnails created by windows
|
||||
Thumbs.db
|
||||
#Ignore files build by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.sln
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
*.map
|
||||
*.orig
|
||||
*.map
|
||||
*.config
|
||||
*.sublime-workspace
|
||||
.DS_Store
|
||||
launcher.html
|
||||
tests.html
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,59 +0,0 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Border
|
||||
*
|
||||
* Creates a border around a camera.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
|
||||
export class Border {
|
||||
|
||||
constructor(game: Game, parent: Camera) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Camera;
|
||||
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showBorder: bool = false;
|
||||
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
public borderColor: string = 'rgb(255,255,255)';
|
||||
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Phaser.Camera) {
|
||||
|
||||
if (this.showBorder == true)
|
||||
{
|
||||
this._game.stage.context.strokeStyle = this.borderColor;
|
||||
this._game.stage.context.lineWidth = 1;
|
||||
this._game.stage.context.rect(camera.x, camera.y, camera.width, camera.height);
|
||||
this._game.stage.context.stroke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
var Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = 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 = {}));
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.d.ts" />
|
||||
/// <reference path="../../Phaser/FXManager.d.ts" />
|
||||
module Phaser.FX.Camera {
|
||||
class Flash {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _fxFlashColor;
|
||||
private _fxFlashComplete;
|
||||
private _fxFlashDuration;
|
||||
private _fxFlashAlpha;
|
||||
public start(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public postUpdate(): void;
|
||||
public postRender(cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
(function (Camera) {
|
||||
var Flash = (function () {
|
||||
function Flash(game) {
|
||||
this._fxFlashComplete = null;
|
||||
this._fxFlashDuration = 0;
|
||||
this._fxFlashAlpha = 0;
|
||||
this._game = game;
|
||||
}
|
||||
Flash.prototype.start = function (color, duration, onComplete, force) {
|
||||
if (typeof color === "undefined") { color = 0xffffff; }
|
||||
if (typeof duration === "undefined") { duration = 1; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = false; }
|
||||
if(force === false && this._fxFlashAlpha > 0) {
|
||||
return;
|
||||
}
|
||||
if(duration <= 0) {
|
||||
duration = 1;
|
||||
}
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFlashDuration = duration;
|
||||
this._fxFlashAlpha = 1;
|
||||
this._fxFlashComplete = onComplete;
|
||||
};
|
||||
Flash.prototype.postUpdate = function () {
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration;
|
||||
this._fxFlashAlpha = this._game.math.roundTo(this._fxFlashAlpha, -2);
|
||||
if(this._fxFlashAlpha <= 0) {
|
||||
this._fxFlashAlpha = 0;
|
||||
if(this._fxFlashComplete !== null) {
|
||||
this._fxFlashComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Flash.prototype.postRender = function (cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
};
|
||||
return Flash;
|
||||
})();
|
||||
Camera.Flash = Flash;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,133 +0,0 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Mirror
|
||||
*
|
||||
* Creates a mirror effect for a camera.
|
||||
* Can mirror the camera image horizontally, vertically or both with an optional fill color overlay.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
|
||||
export class Mirror {
|
||||
|
||||
constructor(game: Game, parent: Phaser.Camera) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
this._canvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
this._canvas.width = parent.width;
|
||||
this._canvas.height = parent.height;
|
||||
this._context = this._canvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Phaser.Camera;
|
||||
private _canvas: HTMLCanvasElement;
|
||||
private _context: CanvasRenderingContext2D;
|
||||
|
||||
private _sx: number;
|
||||
private _sy: number;
|
||||
private _mirrorX: number;
|
||||
private _mirrorY: number;
|
||||
private _mirrorWidth: number;
|
||||
private _mirrorHeight: number;
|
||||
private _mirrorColor: string = null;
|
||||
|
||||
public flipX: bool = false;
|
||||
public flipY: bool = true;
|
||||
|
||||
public x: number;
|
||||
public y: number;
|
||||
public cls: bool = false;
|
||||
|
||||
/**
|
||||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
public start(x: number, y: number, region: Phaser.Rectangle, fillColor?: string = 'rgba(0, 0, 100, 0.5)') {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
this._mirrorX = region.x;
|
||||
this._mirrorY = region.y;
|
||||
this._mirrorWidth = region.width;
|
||||
this._mirrorHeight = region.height;
|
||||
|
||||
if (fillColor)
|
||||
{
|
||||
this._mirrorColor = fillColor;
|
||||
this._context.fillStyle = this._mirrorColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Phaser.Camera) {
|
||||
|
||||
this._sx = camera.screenView.x + this._mirrorX;
|
||||
this._sy = camera.screenView.y + this._mirrorY;
|
||||
|
||||
if (this.flipX == true && this.flipY == false)
|
||||
{
|
||||
this._sx = 0;
|
||||
}
|
||||
else if (this.flipY == true && this.flipX == false)
|
||||
{
|
||||
this._sy = 0;
|
||||
}
|
||||
|
||||
this._context.drawImage(
|
||||
this._game.stage.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._mirrorWidth, // Source Width
|
||||
this._mirrorHeight, // Source Height
|
||||
0, // Destination X (where on the canvas it'll be drawn)
|
||||
0, // Destination Y
|
||||
this._mirrorWidth, // Destination Width (always same as Source Width unless scaled)
|
||||
this._mirrorHeight // Destination Height (always same as Source Height unless scaled)
|
||||
);
|
||||
|
||||
if (this._mirrorColor)
|
||||
{
|
||||
this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
}
|
||||
|
||||
if (this.flipX || this.flipY)
|
||||
{
|
||||
this._game.stage.context.save();
|
||||
}
|
||||
|
||||
if (this.flipX && this.flipY)
|
||||
{
|
||||
this._game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
|
||||
this._game.stage.context.drawImage(this._canvas, -this.x, -this.y);
|
||||
}
|
||||
else if (this.flipX)
|
||||
{
|
||||
this._game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
|
||||
this._game.stage.context.drawImage(this._canvas, -this.x, this.y);
|
||||
}
|
||||
else if (this.flipY)
|
||||
{
|
||||
this._game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
|
||||
this._game.stage.context.drawImage(this._canvas, this.x, -this.y);
|
||||
}
|
||||
|
||||
if (this.flipX || this.flipY)
|
||||
{
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,39 +0,0 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Scanlines
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
|
||||
export class Scanlines {
|
||||
|
||||
constructor(game: Game, parent: Camera) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Camera;
|
||||
|
||||
public spacing: number = 4;
|
||||
public color: string = 'rgba(0, 0, 0, 0.3)';
|
||||
|
||||
public postRender(camera: Phaser.Camera) {
|
||||
|
||||
this._game.stage.context.fillStyle = this.color;
|
||||
|
||||
for (var y = camera.screenView.y; y < camera.screenView.height; y += this.spacing)
|
||||
{
|
||||
this._game.stage.context.fillRect(camera.screenView.x, y, camera.screenView.width, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,87 +0,0 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Shadow
|
||||
*
|
||||
* Creates a drop-shadow effect on the camera window.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
|
||||
export class Shadow {
|
||||
|
||||
constructor(game: Game, parent: Camera) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Camera;
|
||||
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showShadow: bool = false;
|
||||
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public shadowColor: string = 'rgb(0,0,0)';
|
||||
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
public shadowBlur: number = 10;
|
||||
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {Point}
|
||||
*/
|
||||
public shadowOffset: Point = new Point(4, 4);
|
||||
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
// Shadow
|
||||
if (this.showShadow == true)
|
||||
{
|
||||
this._game.stage.context.shadowColor = this.shadowColor;
|
||||
this._game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this._game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this._game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
|
||||
// Shadow off
|
||||
if (this.showShadow == true)
|
||||
{
|
||||
this._game.stage.context.shadowBlur = 0;
|
||||
this._game.stage.context.shadowOffsetX = 0;
|
||||
this._game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,19 +0,0 @@
|
||||
var Shapes;
|
||||
(function (Shapes) {
|
||||
|
||||
var Point = Shapes.Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
Point.prototype.getDist = function () {
|
||||
return Math.sqrt((this.x * this.x) + (this.y * this.y));
|
||||
};
|
||||
Point.origin = new Point(0, 0);
|
||||
return Point;
|
||||
})();
|
||||
|
||||
})(Shapes || (Shapes = {}));
|
||||
|
||||
var p = new Shapes.Point(3, 4);
|
||||
var dist = p.getDist();
|
||||
@@ -1,64 +0,0 @@
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - FX - Camera - Template
|
||||
*
|
||||
* A Template FX file you can use to create your own Camera FX.
|
||||
* If you don't use any of the methods below (i.e. preUpdate, render, etc) then DELETE THEM to avoid un-necessary calls by the FXManager.
|
||||
*/
|
||||
|
||||
module Phaser.FX.Camera {
|
||||
|
||||
export class Template {
|
||||
|
||||
constructor(game: Game, parent: Camera) {
|
||||
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
|
||||
}
|
||||
|
||||
private _game: Game;
|
||||
private _parent: Camera;
|
||||
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
|
||||
*/
|
||||
public preUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
*/
|
||||
public postUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?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>
|
||||
<ProjectGuid>{47390070-8027-4834-B50B-21119DC874DC}</ProjectGuid>
|
||||
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<OutputPath>bin</OutputPath>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<DebugType>full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RootNamespace>SpecialFX</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ProjectExtensions>
|
||||
<VisualStudio>
|
||||
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
|
||||
<WebProjectProperties>
|
||||
<UseIIS>True</UseIIS>
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:64170/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>../build/phaser-fx.js</TypeScriptOutFile>
|
||||
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
|
||||
<TypeScriptIncludeDefaultLib>true</TypeScriptIncludeDefaultLib>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<TypeScriptTarget>ES5</TypeScriptTarget>
|
||||
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
|
||||
<TypeScriptSourceMap>false</TypeScriptSourceMap>
|
||||
<TypeScriptOutFile>../build/phaser-fx.js</TypeScriptOutFile>
|
||||
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
|
||||
<TypeScriptIncludeDefaultLib>true</TypeScriptIncludeDefaultLib>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="Camera\Flash.ts" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="Camera\Border.ts" />
|
||||
<Content Include="Camera\Border.js">
|
||||
<DependentUpon>Border.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Camera\Fade.js">
|
||||
<DependentUpon>Fade.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="Camera\Template.ts" />
|
||||
<TypeScriptCompile Include="Camera\Mirror.ts" />
|
||||
<Content Include="Camera\Mirror.js">
|
||||
<DependentUpon>Mirror.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="Camera\Shadow.ts" />
|
||||
<Content Include="Camera\Shadow.js">
|
||||
<DependentUpon>Shadow.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Camera\Template.js">
|
||||
<DependentUpon>Template.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="Camera\Scanlines.ts" />
|
||||
<Content Include="Camera\Scanlines.js">
|
||||
<DependentUpon>Scanlines.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="Camera\Shake.js">
|
||||
<DependentUpon>Shake.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="Camera\Shake.ts" />
|
||||
<TypeScriptCompile Include="Camera\Fade.ts" />
|
||||
<Content Include="Camera\Flash.js">
|
||||
<DependentUpon>Flash.ts</DependentUpon>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Textures\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>cd $(ProjectDir)..\build
|
||||
copy phaser-fx.js ..\Tests\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -1,2 +0,0 @@
|
||||
tsc --target ES5 --declaration ../Phaser/Game.ts
|
||||
pause
|
||||
-8660
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-8740
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-8983
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
-1
File diff suppressed because one or more lines are too long
-11626
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-12051
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-12294
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
-12539
File diff suppressed because it is too large
Load Diff
Vendored
-1
File diff suppressed because one or more lines are too long
Vendored
-253
@@ -1,253 +0,0 @@
|
||||
/**
|
||||
* Phaser - FX - Camera - Flash
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Flash {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _fxFlashColor;
|
||||
private _fxFlashComplete;
|
||||
private _fxFlashDuration;
|
||||
private _fxFlashAlpha;
|
||||
/**
|
||||
* The camera is filled with this color and returns to normal at the given duration.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public start(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public postUpdate(): void;
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Border
|
||||
*
|
||||
* Creates a border around a camera.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Border {
|
||||
constructor(game: Game, parent: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showBorder: bool;
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
public borderColor: string;
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start(): void;
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Camera): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Template
|
||||
*
|
||||
* A Template FX file you can use to create your own Camera FX.
|
||||
* If you don't use any of the methods below (i.e. preUpdate, render, etc) then DELETE THEM to avoid un-necessary calls by the FXManager.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Template {
|
||||
constructor(game: Game, parent: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start(): void;
|
||||
/**
|
||||
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
|
||||
*/
|
||||
public preUpdate(): void;
|
||||
/**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
*/
|
||||
public postUpdate(): void;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Mirror
|
||||
*
|
||||
* Creates a mirror effect for a camera.
|
||||
* Can mirror the camera image horizontally, vertically or both with an optional fill color overlay.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Mirror {
|
||||
constructor(game: Game, parent: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _canvas;
|
||||
private _context;
|
||||
private _sx;
|
||||
private _sy;
|
||||
private _mirrorX;
|
||||
private _mirrorY;
|
||||
private _mirrorWidth;
|
||||
private _mirrorHeight;
|
||||
private _mirrorColor;
|
||||
public flipX: bool;
|
||||
public flipY: bool;
|
||||
public x: number;
|
||||
public y: number;
|
||||
public cls: bool;
|
||||
/**
|
||||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
public start(x: number, y: number, region: Rectangle, fillColor?: string): void;
|
||||
/**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
public postRender(camera: Camera): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Shadow
|
||||
*
|
||||
* Creates a drop-shadow effect on the camera window.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Shadow {
|
||||
constructor(game: Game, parent: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
public showShadow: bool;
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
public shadowColor: string;
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
public shadowBlur: number;
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {Point}
|
||||
*/
|
||||
public shadowOffset: Point;
|
||||
/**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
public start(): void;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
/**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Scanlines
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Scanlines {
|
||||
constructor(game: Game, parent: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
public spacing: number;
|
||||
public color: string;
|
||||
public postRender(camera: Camera): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Shake
|
||||
*
|
||||
* A simple camera shake effect.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Shake {
|
||||
constructor(game: Game, camera: Camera);
|
||||
private _game;
|
||||
private _parent;
|
||||
private _fxShakeIntensity;
|
||||
private _fxShakeDuration;
|
||||
private _fxShakeComplete;
|
||||
private _fxShakeOffset;
|
||||
private _fxShakeDirection;
|
||||
private _fxShakePrevX;
|
||||
private _fxShakePrevY;
|
||||
static SHAKE_BOTH_AXES: number;
|
||||
static SHAKE_HORIZONTAL_ONLY: number;
|
||||
static SHAKE_VERTICAL_ONLY: number;
|
||||
/**
|
||||
* A simple camera shake effect.
|
||||
*
|
||||
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
|
||||
* @param Duration The length in seconds that the shaking effect should last.
|
||||
* @param OnComplete A function you want to run when the shake effect finishes.
|
||||
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
|
||||
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
||||
*/
|
||||
public start(intensity?: number, duration?: number, onComplete?, force?: bool, direction?: number): void;
|
||||
public postUpdate(): void;
|
||||
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Phaser - FX - Camera - Fade
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
module Phaser.FX.Camera {
|
||||
class Fade {
|
||||
constructor(game: Game);
|
||||
private _game;
|
||||
private _fxFadeColor;
|
||||
private _fxFadeComplete;
|
||||
private _fxFadeDuration;
|
||||
private _fxFadeAlpha;
|
||||
/**
|
||||
* The camera is gradually filled with this color.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
public start(color?: number, duration?: number, onComplete?, force?: bool): void;
|
||||
public postUpdate(): void;
|
||||
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
|
||||
}
|
||||
}
|
||||
@@ -1,535 +0,0 @@
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Flash
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Flash = (function () {
|
||||
function Flash(game) {
|
||||
this._fxFlashComplete = null;
|
||||
this._fxFlashDuration = 0;
|
||||
this._fxFlashAlpha = 0;
|
||||
this._game = game;
|
||||
}
|
||||
Flash.prototype.start = /**
|
||||
* The camera is filled with this color and returns to normal at the given duration.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
function (color, duration, onComplete, force) {
|
||||
if (typeof color === "undefined") { color = 0xffffff; }
|
||||
if (typeof duration === "undefined") { duration = 1; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = false; }
|
||||
if(force === false && this._fxFlashAlpha > 0) {
|
||||
// You can't flash again unless you force it
|
||||
return;
|
||||
}
|
||||
if(duration <= 0) {
|
||||
duration = 1;
|
||||
}
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
this._fxFlashColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFlashDuration = duration;
|
||||
this._fxFlashAlpha = 1;
|
||||
this._fxFlashComplete = onComplete;
|
||||
};
|
||||
Flash.prototype.postUpdate = function () {
|
||||
// Update the Flash effect
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this._fxFlashAlpha -= this._game.time.elapsed / this._fxFlashDuration;
|
||||
if(this._game.math.roundTo(this._fxFlashAlpha, -2) <= 0) {
|
||||
this._fxFlashAlpha = 0;
|
||||
if(this._fxFlashComplete !== null) {
|
||||
this._fxFlashComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Flash.prototype.postRender = function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
if(this._fxFlashAlpha > 0) {
|
||||
this._game.stage.context.fillStyle = this._fxFlashColor + this._fxFlashAlpha + ')';
|
||||
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
};
|
||||
return Flash;
|
||||
})();
|
||||
Camera.Flash = Flash;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Border
|
||||
*
|
||||
* Creates a border around a camera.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Border = (function () {
|
||||
function Border(game, parent) {
|
||||
/**
|
||||
* Whether render border of this camera or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.showBorder = false;
|
||||
/**
|
||||
* Color of border of this camera. (in css color string)
|
||||
* @type {string}
|
||||
*/
|
||||
this.borderColor = 'rgb(255,255,255)';
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
}
|
||||
Border.prototype.start = /**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Border.prototype.postRender = /**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
function (camera) {
|
||||
if(this.showBorder == true) {
|
||||
this._game.stage.context.strokeStyle = this.borderColor;
|
||||
this._game.stage.context.lineWidth = 1;
|
||||
this._game.stage.context.rect(camera.x, camera.y, camera.width, camera.height);
|
||||
this._game.stage.context.stroke();
|
||||
}
|
||||
};
|
||||
return Border;
|
||||
})();
|
||||
Camera.Border = Border;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Template
|
||||
*
|
||||
* A Template FX file you can use to create your own Camera FX.
|
||||
* If you don't use any of the methods below (i.e. preUpdate, render, etc) then DELETE THEM to avoid un-necessary calls by the FXManager.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Template = (function () {
|
||||
function Template(game, parent) {
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
}
|
||||
Template.prototype.start = /**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Template.prototype.preUpdate = /**
|
||||
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Template.prototype.postUpdate = /**
|
||||
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Template.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.
|
||||
*/
|
||||
function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
};
|
||||
Template.prototype.render = /**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
};
|
||||
Template.prototype.postRender = /**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
};
|
||||
return Template;
|
||||
})();
|
||||
Camera.Template = Template;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Mirror
|
||||
*
|
||||
* Creates a mirror effect for a camera.
|
||||
* Can mirror the camera image horizontally, vertically or both with an optional fill color overlay.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Mirror = (function () {
|
||||
function Mirror(game, parent) {
|
||||
this._mirrorColor = null;
|
||||
this.flipX = false;
|
||||
this.flipY = true;
|
||||
this.cls = false;
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
this._canvas = document.createElement('canvas');
|
||||
this._canvas.width = parent.width;
|
||||
this._canvas.height = parent.height;
|
||||
this._context = this._canvas.getContext('2d');
|
||||
}
|
||||
Mirror.prototype.start = /**
|
||||
* This is the rectangular region to grab from the Camera used in the Mirror effect
|
||||
* It is rendered to the Stage at Mirror.x/y (note the use of Stage coordinates, not World coordinates)
|
||||
*/
|
||||
function (x, y, region, fillColor) {
|
||||
if (typeof fillColor === "undefined") { fillColor = 'rgba(0, 0, 100, 0.5)'; }
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this._mirrorX = region.x;
|
||||
this._mirrorY = region.y;
|
||||
this._mirrorWidth = region.width;
|
||||
this._mirrorHeight = region.height;
|
||||
if(fillColor) {
|
||||
this._mirrorColor = fillColor;
|
||||
this._context.fillStyle = this._mirrorColor;
|
||||
}
|
||||
};
|
||||
Mirror.prototype.postRender = /**
|
||||
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
|
||||
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
|
||||
*/
|
||||
function (camera) {
|
||||
this._sx = camera.screenView.x + this._mirrorX;
|
||||
this._sy = camera.screenView.y + this._mirrorY;
|
||||
if(this.flipX == true && this.flipY == false) {
|
||||
this._sx = 0;
|
||||
} else if(this.flipY == true && this.flipX == false) {
|
||||
this._sy = 0;
|
||||
}
|
||||
this._context.drawImage(this._game.stage.canvas, // Source Image
|
||||
this._sx, // Source X (location within the source image)
|
||||
this._sy, // Source Y
|
||||
this._mirrorWidth, // Source Width
|
||||
this._mirrorHeight, // Source Height
|
||||
0, // Destination X (where on the canvas it'll be drawn)
|
||||
0, // Destination Y
|
||||
this._mirrorWidth, // Destination Width (always same as Source Width unless scaled)
|
||||
this._mirrorHeight);
|
||||
// Destination Height (always same as Source Height unless scaled)
|
||||
if(this._mirrorColor) {
|
||||
this._context.fillRect(0, 0, this._mirrorWidth, this._mirrorHeight);
|
||||
}
|
||||
if(this.flipX || this.flipY) {
|
||||
this._game.stage.context.save();
|
||||
}
|
||||
if(this.flipX && this.flipY) {
|
||||
this._game.stage.context.transform(-1, 0, 0, -1, this._mirrorWidth, this._mirrorHeight);
|
||||
this._game.stage.context.drawImage(this._canvas, -this.x, -this.y);
|
||||
} else if(this.flipX) {
|
||||
this._game.stage.context.transform(-1, 0, 0, 1, this._mirrorWidth, 0);
|
||||
this._game.stage.context.drawImage(this._canvas, -this.x, this.y);
|
||||
} else if(this.flipY) {
|
||||
this._game.stage.context.transform(1, 0, 0, -1, 0, this._mirrorHeight);
|
||||
this._game.stage.context.drawImage(this._canvas, this.x, -this.y);
|
||||
}
|
||||
if(this.flipX || this.flipY) {
|
||||
this._game.stage.context.restore();
|
||||
}
|
||||
};
|
||||
return Mirror;
|
||||
})();
|
||||
Camera.Mirror = Mirror;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Shadow
|
||||
*
|
||||
* Creates a drop-shadow effect on the camera window.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Shadow = (function () {
|
||||
function Shadow(game, parent) {
|
||||
/**
|
||||
* Render camera shadow or not. (default is false)
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.showShadow = false;
|
||||
/**
|
||||
* Color of shadow, in css color string.
|
||||
* @type {string}
|
||||
*/
|
||||
this.shadowColor = 'rgb(0,0,0)';
|
||||
/**
|
||||
* Blur factor of shadow.
|
||||
* @type {number}
|
||||
*/
|
||||
this.shadowBlur = 10;
|
||||
/**
|
||||
* Offset of the shadow from camera's position.
|
||||
* @type {Point}
|
||||
*/
|
||||
this.shadowOffset = new Phaser.Point(4, 4);
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
}
|
||||
Shadow.prototype.start = /**
|
||||
* You can name the function that starts the effect whatever you like, but we used 'start' in our effects.
|
||||
*/
|
||||
function () {
|
||||
};
|
||||
Shadow.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.
|
||||
*/
|
||||
function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
// Shadow
|
||||
if(this.showShadow == true) {
|
||||
this._game.stage.context.shadowColor = this.shadowColor;
|
||||
this._game.stage.context.shadowBlur = this.shadowBlur;
|
||||
this._game.stage.context.shadowOffsetX = this.shadowOffset.x;
|
||||
this._game.stage.context.shadowOffsetY = this.shadowOffset.y;
|
||||
}
|
||||
};
|
||||
Shadow.prototype.render = /**
|
||||
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
|
||||
*/
|
||||
function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
// Shadow off
|
||||
if(this.showShadow == true) {
|
||||
this._game.stage.context.shadowBlur = 0;
|
||||
this._game.stage.context.shadowOffsetX = 0;
|
||||
this._game.stage.context.shadowOffsetY = 0;
|
||||
}
|
||||
};
|
||||
return Shadow;
|
||||
})();
|
||||
Camera.Shadow = Shadow;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Scanlines
|
||||
*
|
||||
* Give your game that classic retro feel!
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Scanlines = (function () {
|
||||
function Scanlines(game, parent) {
|
||||
this.spacing = 4;
|
||||
this.color = 'rgba(0, 0, 0, 0.3)';
|
||||
this._game = game;
|
||||
this._parent = parent;
|
||||
}
|
||||
Scanlines.prototype.postRender = function (camera) {
|
||||
this._game.stage.context.fillStyle = this.color;
|
||||
for(var y = camera.screenView.y; y < camera.screenView.height; y += this.spacing) {
|
||||
this._game.stage.context.fillRect(camera.screenView.x, y, camera.screenView.width, 1);
|
||||
}
|
||||
};
|
||||
return Scanlines;
|
||||
})();
|
||||
Camera.Scanlines = Scanlines;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Shake
|
||||
*
|
||||
* A simple camera shake effect.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Shake = (function () {
|
||||
function Shake(game, camera) {
|
||||
this._fxShakeIntensity = 0;
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeComplete = null;
|
||||
this._fxShakeOffset = new Phaser.Point(0, 0);
|
||||
this._fxShakeDirection = 0;
|
||||
this._fxShakePrevX = 0;
|
||||
this._fxShakePrevY = 0;
|
||||
this._game = game;
|
||||
this._parent = camera;
|
||||
}
|
||||
Shake.SHAKE_BOTH_AXES = 0;
|
||||
Shake.SHAKE_HORIZONTAL_ONLY = 1;
|
||||
Shake.SHAKE_VERTICAL_ONLY = 2;
|
||||
Shake.prototype.start = /**
|
||||
* A simple camera shake effect.
|
||||
*
|
||||
* @param Intensity Percentage of screen size representing the maximum distance that the screen can move while shaking.
|
||||
* @param Duration The length in seconds that the shaking effect should last.
|
||||
* @param OnComplete A function you want to run when the shake effect finishes.
|
||||
* @param Force Force the effect to reset (default = true, unlike flash() and fade()!).
|
||||
* @param Direction Whether to shake on both axes, just up and down, or just side to side (use class constants SHAKE_BOTH_AXES, SHAKE_VERTICAL_ONLY, or SHAKE_HORIZONTAL_ONLY).
|
||||
*/
|
||||
function (intensity, duration, onComplete, force, direction) {
|
||||
if (typeof intensity === "undefined") { intensity = 0.05; }
|
||||
if (typeof duration === "undefined") { duration = 0.5; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = true; }
|
||||
if (typeof direction === "undefined") { direction = Shake.SHAKE_BOTH_AXES; }
|
||||
if(!force && ((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0))) {
|
||||
return;
|
||||
}
|
||||
// If a shake is not already running we need to store the offsets here
|
||||
if(this._fxShakeOffset.x == 0 && this._fxShakeOffset.y == 0) {
|
||||
this._fxShakePrevX = this._parent.x;
|
||||
this._fxShakePrevY = this._parent.y;
|
||||
}
|
||||
this._fxShakeIntensity = intensity;
|
||||
this._fxShakeDuration = duration;
|
||||
this._fxShakeComplete = onComplete;
|
||||
this._fxShakeDirection = direction;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
};
|
||||
Shake.prototype.postUpdate = function () {
|
||||
// Update the "shake" special effect
|
||||
if(this._fxShakeDuration > 0) {
|
||||
this._fxShakeDuration -= this._game.time.elapsed;
|
||||
if(this._game.math.roundTo(this._fxShakeDuration, -2) <= 0) {
|
||||
this._fxShakeDuration = 0;
|
||||
this._fxShakeOffset.setTo(0, 0);
|
||||
this._parent.x = this._fxShakePrevX;
|
||||
this._parent.y = this._fxShakePrevY;
|
||||
if(this._fxShakeComplete != null) {
|
||||
this._fxShakeComplete();
|
||||
}
|
||||
} else {
|
||||
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_HORIZONTAL_ONLY)) {
|
||||
//this._fxShakeOffset.x = ((this._game.math.random() * this._fxShakeIntensity * this.worldView.width * 2 - this._fxShakeIntensity * this.worldView.width) * this._zoom;
|
||||
this._fxShakeOffset.x = (this._game.math.random() * this._fxShakeIntensity * this._parent.worldView.width * 2 - this._fxShakeIntensity * this._parent.worldView.width);
|
||||
}
|
||||
if((this._fxShakeDirection == Shake.SHAKE_BOTH_AXES) || (this._fxShakeDirection == Shake.SHAKE_VERTICAL_ONLY)) {
|
||||
//this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this.worldView.height * 2 - this._fxShakeIntensity * this.worldView.height) * this._zoom;
|
||||
this._fxShakeOffset.y = (this._game.math.random() * this._fxShakeIntensity * this._parent.worldView.height * 2 - this._fxShakeIntensity * this._parent.worldView.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Shake.prototype.preRender = function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
if((this._fxShakeOffset.x != 0) || (this._fxShakeOffset.y != 0)) {
|
||||
this._parent.x = this._fxShakePrevX + this._fxShakeOffset.x;
|
||||
this._parent.y = this._fxShakePrevY + this._fxShakeOffset.y;
|
||||
}
|
||||
};
|
||||
return Shake;
|
||||
})();
|
||||
Camera.Shake = Shake;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
(function (FX) {
|
||||
/// <reference path="../../build/phaser.d.ts" />
|
||||
/**
|
||||
* Phaser - FX - Camera - Fade
|
||||
*
|
||||
* The camera is filled with the given color and returns to normal at the given duration.
|
||||
*/
|
||||
(function (Camera) {
|
||||
var Fade = (function () {
|
||||
function Fade(game) {
|
||||
this._fxFadeComplete = null;
|
||||
this._fxFadeDuration = 0;
|
||||
this._fxFadeAlpha = 0;
|
||||
this._game = game;
|
||||
}
|
||||
Fade.prototype.start = /**
|
||||
* The camera is gradually filled with this color.
|
||||
*
|
||||
* @param Color The color you want to use in 0xRRGGBB format, i.e. 0xffffff for white.
|
||||
* @param Duration How long it takes for the flash to fade.
|
||||
* @param OnComplete An optional function you want to run when the flash finishes. Set to null for no callback.
|
||||
* @param Force Force an already running flash effect to reset.
|
||||
*/
|
||||
function (color, duration, onComplete, force) {
|
||||
if (typeof color === "undefined") { color = 0x000000; }
|
||||
if (typeof duration === "undefined") { duration = 1; }
|
||||
if (typeof onComplete === "undefined") { onComplete = null; }
|
||||
if (typeof force === "undefined") { force = false; }
|
||||
if(force === false && this._fxFadeAlpha > 0) {
|
||||
// You can't fade again unless you force it
|
||||
return;
|
||||
}
|
||||
if(duration <= 0) {
|
||||
duration = 1;
|
||||
}
|
||||
var red = color >> 16 & 0xFF;
|
||||
var green = color >> 8 & 0xFF;
|
||||
var blue = color & 0xFF;
|
||||
this._fxFadeColor = 'rgba(' + red + ',' + green + ',' + blue + ',';
|
||||
this._fxFadeDuration = duration;
|
||||
this._fxFadeAlpha = 0.01;
|
||||
this._fxFadeComplete = onComplete;
|
||||
};
|
||||
Fade.prototype.postUpdate = function () {
|
||||
// Update the Fade effect
|
||||
if(this._fxFadeAlpha > 0) {
|
||||
this._fxFadeAlpha += this._game.time.elapsed / this._fxFadeDuration;
|
||||
if(this._game.math.roundTo(this._fxFadeAlpha, -2) >= 1) {
|
||||
this._fxFadeAlpha = 1;
|
||||
if(this._fxFadeComplete !== null) {
|
||||
this._fxFadeComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Fade.prototype.postRender = function (camera, cameraX, cameraY, cameraWidth, cameraHeight) {
|
||||
// "Fade" FX
|
||||
if(this._fxFadeAlpha > 0) {
|
||||
this._game.stage.context.fillStyle = this._fxFadeColor + this._fxFadeAlpha + ')';
|
||||
this._game.stage.context.fillRect(cameraX, cameraY, cameraWidth, cameraHeight);
|
||||
}
|
||||
};
|
||||
return Fade;
|
||||
})();
|
||||
Camera.Fade = Fade;
|
||||
})(FX.Camera || (FX.Camera = {}));
|
||||
var Camera = FX.Camera;
|
||||
})(Phaser.FX || (Phaser.FX = {}));
|
||||
var FX = Phaser.FX;
|
||||
})(Phaser || (Phaser = {}));
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"tags": {
|
||||
"allowUnknownTags": true
|
||||
},
|
||||
"source": {
|
||||
"include": [ "Phaser" ],
|
||||
"exclude": [],
|
||||
"includePattern": ".+\\.js(doc)?$",
|
||||
"excludePattern": "(^|\\/|\\\\)_"
|
||||
},
|
||||
"plugins": [],
|
||||
"opts": {
|
||||
"encoding": "utf8",
|
||||
"destination": "Docs",
|
||||
"recurse": true,
|
||||
"query": "value",
|
||||
"private": true,
|
||||
"lenient": true
|
||||
},
|
||||
"jsVersion": 180
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Phaser",
|
||||
"version": "0.9.1",
|
||||
"version": "1.0.0",
|
||||
"description": "html5 game framework",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user