mirror of
https://github.com/wassname/phaser.git
synced 2026-07-10 00:30:50 +08:00
Updated some docs, added the new renderHidden parameter for Canvas and updated the RenderTexture examples as a result.
This commit is contained in:
@@ -102,6 +102,8 @@ Updates:
|
||||
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
|
||||
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
|
||||
* Input doesn't set the cursor to default if it's already set to none.
|
||||
* You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon)
|
||||
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
|
||||
|
||||
|
||||
Bug Fixes:
|
||||
|
||||
@@ -27,9 +27,11 @@ function create() {
|
||||
|
||||
function update() {
|
||||
|
||||
// This time we'll draw the ball sprite twice, in a mirror effect
|
||||
|
||||
texture.renderXY(ball, game.input.activePointer.x, game.input.activePointer.y, false);
|
||||
texture.renderXY(ball, game.input.activePointer.x, 600 - game.input.activePointer.y, false);
|
||||
if (!game.input.activePointer.position.isZero())
|
||||
{
|
||||
// This time we'll draw the ball sprite twice, in a mirror effect
|
||||
texture.renderXY(ball, game.input.activePointer.x, game.input.activePointer.y, false, true);
|
||||
texture.renderXY(ball, game.input.activePointer.x, 600 - game.input.activePointer.y, false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,12 +69,12 @@ function update() {
|
||||
if (i == 0 || i == 100 || i == 200)
|
||||
{
|
||||
// If it's the first star of the layer then we clear the texture
|
||||
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, true);
|
||||
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise just draw the star sprite where we need it
|
||||
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, false);
|
||||
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,12 @@ function create() {
|
||||
|
||||
function update() {
|
||||
|
||||
// Here we draw the mushroom sprite to the renderTexture at the pointer coordinates.
|
||||
// The 'false' parameter at the end tells it not to clear itself, causing the trail effect you see.
|
||||
texture.render(mushroom, game.input.activePointer.position, false);
|
||||
if (!game.input.activePointer.position.isZero())
|
||||
{
|
||||
// Here we draw the mushroom sprite to the renderTexture at the pointer coordinates.
|
||||
// The 'false' parameter 2nd from the end tells it not to clear itself, causing the trail effect you see.
|
||||
// The final 'true' parameter tells it to render sprites even with visible false set.
|
||||
texture.render(mushroom, game.input.activePointer.position, false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-3
@@ -24,7 +24,7 @@ PIXI.CanvasRenderer.prototype.render = function(stage)
|
||||
|
||||
this.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
this.context.clearRect(0, 0, this.width, this.height)
|
||||
this.renderDisplayObject(stage);
|
||||
this.renderDisplayObject(stage, false);
|
||||
|
||||
// Remove frame updates
|
||||
if (PIXI.Texture.frameUpdates.length > 0)
|
||||
@@ -34,7 +34,9 @@ PIXI.CanvasRenderer.prototype.render = function(stage)
|
||||
|
||||
}
|
||||
|
||||
PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
||||
// @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
|
||||
|
||||
PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject, renderHidden)
|
||||
{
|
||||
// Once the display object hits this we can break the loop
|
||||
var testObject = displayObject.last._iNext;
|
||||
@@ -44,7 +46,7 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
||||
{
|
||||
//transform = displayObject.worldTransform;
|
||||
|
||||
if (!displayObject.visible)
|
||||
if (!displayObject.visible && !renderHidden)
|
||||
{
|
||||
displayObject = displayObject.last._iNext;
|
||||
continue;
|
||||
|
||||
@@ -43,7 +43,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* @property {object} _frames
|
||||
* @property {array} _frames
|
||||
* @private
|
||||
*/
|
||||
this._frames = [];
|
||||
@@ -60,7 +60,8 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
|
||||
this.looped = looped;
|
||||
|
||||
/**
|
||||
* @property {boolean} looped - The loop state of the Animation.
|
||||
* @property {boolean} killOnComplete - Should the parent of this Animation be killed when the animation completes?
|
||||
* @default
|
||||
*/
|
||||
this.killOnComplete = false;
|
||||
|
||||
|
||||
@@ -71,16 +71,19 @@ Phaser.RenderTexture.prototype.constructor = PIXI.RenderTexture;
|
||||
/**
|
||||
* This function will draw the display object to the texture. If the display object is a Group or has children it will
|
||||
* draw all children as well.
|
||||
*
|
||||
* @method render
|
||||
*
|
||||
* @method Phaser.RenderTexture#render
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @param {DisplayObject} displayObject - The display object to render this texture on.
|
||||
* @param {Phaser.Point} [position] - Where to draw the display object.
|
||||
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
|
||||
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) {
|
||||
Phaser.RenderTexture.prototype.render = function(displayObject, position, clear, renderHidden) {
|
||||
|
||||
if (typeof position === 'undefined') { position = false; }
|
||||
if (typeof clear === 'undefined') { clear = false; }
|
||||
if (typeof renderHidden === 'undefined') { renderHidden = false; }
|
||||
|
||||
if (displayObject instanceof Phaser.Group)
|
||||
{
|
||||
@@ -89,11 +92,11 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear)
|
||||
|
||||
if (PIXI.gl)
|
||||
{
|
||||
this.renderWebGL(displayObject, position, clear);
|
||||
this.renderWebGL(displayObject, position, clear, renderHidden);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.renderCanvas(displayObject, position, clear);
|
||||
this.renderCanvas(displayObject, position, clear, renderHidden);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -102,29 +105,32 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear)
|
||||
* This function will draw the display object to the texture at the given x/y coordinates.
|
||||
* If the display object is a Group or has children it will draw all children as well.
|
||||
*
|
||||
* @method renderXY
|
||||
* @method Phaser.RenderTexture#renderXY
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @param {DisplayObject} displayObject - The display object to render this texture on.
|
||||
* @param {number} x - The x coordinate to draw the display object at.
|
||||
* @param {number} y - The y coordinate to draw the display object at.
|
||||
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
|
||||
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) {
|
||||
Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear, renderHidden) {
|
||||
|
||||
this._tempPoint.x = x;
|
||||
this._tempPoint.y = y;
|
||||
|
||||
this.render(displayObject, this._tempPoint, clear);
|
||||
this.render(displayObject, this._tempPoint, clear, renderHidden);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the webgl data for this texture
|
||||
*
|
||||
* @method initWebGL
|
||||
* @private
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.initWebGL = function()
|
||||
{
|
||||
* Initializes the webgl data for this texture
|
||||
*
|
||||
* @method Phaser.RenderTexture#initWebGL
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @private
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.initWebGL = function() {
|
||||
|
||||
var gl = PIXI.gl;
|
||||
this.glFramebuffer = gl.createFramebuffer();
|
||||
|
||||
@@ -160,7 +166,12 @@ Phaser.RenderTexture.prototype.initWebGL = function()
|
||||
// this.render = this.renderWebGL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resizes the RenderTexture.
|
||||
*
|
||||
* @method Phaser.RenderTexture#resize
|
||||
* @memberof Phaser.RenderTexture
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.resize = function(width, height)
|
||||
{
|
||||
|
||||
@@ -186,11 +197,12 @@ Phaser.RenderTexture.prototype.resize = function(width, height)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the canvas data for this texture
|
||||
*
|
||||
* @method initCanvas
|
||||
* @private
|
||||
*/
|
||||
* Initializes the canvas data for this texture
|
||||
*
|
||||
* @method Phaser.RenderTexture#initCanvas
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @private
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.initCanvas = function()
|
||||
{
|
||||
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0);
|
||||
@@ -202,14 +214,17 @@ Phaser.RenderTexture.prototype.initCanvas = function()
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will draw the display object to the texture.
|
||||
*
|
||||
* @method renderWebGL
|
||||
* @param displayObject {DisplayObject} The display object to render this texture on
|
||||
* @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
|
||||
* @private
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear)
|
||||
* This function will draw the display object to the texture.
|
||||
*
|
||||
* @method Phaser.RenderTexture#renderWebGL
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @private
|
||||
* @param {DisplayObject} displayObject - The display object to render this texture on.
|
||||
* @param {Phaser.Point} [position] - Where to draw the display object.
|
||||
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
|
||||
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear, renderHidden)
|
||||
{
|
||||
var gl = PIXI.gl;
|
||||
|
||||
@@ -280,12 +295,15 @@ Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, c
|
||||
/**
|
||||
* This function will draw the display object to the texture.
|
||||
*
|
||||
* @method renderCanvas
|
||||
* @param displayObject {DisplayObject} The display object to render this texture on
|
||||
* @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
|
||||
* @private
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear)
|
||||
* @method Phaser.RenderTexture#renderCanvas
|
||||
* @memberof Phaser.RenderTexture
|
||||
* @private
|
||||
* @param {DisplayObject} displayObject - The display object to render this texture on.
|
||||
* @param {Phaser.Point} [position] - Where to draw the display object.
|
||||
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
|
||||
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
|
||||
*/
|
||||
Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear, renderHidden)
|
||||
{
|
||||
var children = displayObject.children;
|
||||
|
||||
@@ -307,9 +325,8 @@ Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position,
|
||||
this.renderer.context.clearRect(0, 0, this.width, this.height);
|
||||
}
|
||||
|
||||
this.renderer.renderDisplayObject(displayObject);
|
||||
this.renderer.renderDisplayObject(displayObject, renderHidden);
|
||||
|
||||
this.renderer.context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
// PIXI.texturesToUpdate.push(this.baseTexture);
|
||||
}
|
||||
|
||||
+2
-1
@@ -68,7 +68,8 @@ Phaser.Mouse = function (game) {
|
||||
this.pointerLock = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
* @property {MouseEvent} event - The browser mouse event.
|
||||
* @property {MouseEvent} event - The browser mouse DOM event. Will be set to null if no mouse event has ever been received.
|
||||
* @default
|
||||
*/
|
||||
this.event = null;
|
||||
|
||||
|
||||
+2
-1
@@ -67,7 +67,8 @@ Phaser.Touch = function (game) {
|
||||
this.preventDefault = true;
|
||||
|
||||
/**
|
||||
* @property {TouchEvent} event - The browser touch event.
|
||||
* @property {TouchEvent} event - The browser touch DOM event. Will be set to null if no touch event has ever been received.
|
||||
* @default
|
||||
*/
|
||||
this.event = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user