Skip to content

Commit 1a02f51

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents 0557ee0 + 06688ee commit 1a02f51

7 files changed

Lines changed: 341 additions & 21 deletions

File tree

src/gameobjects/GameObject.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,9 @@ var GameObject = new Class({
531531
* Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.
532532
*
533533
* @method Phaser.GameObjects.GameObject#destroy
534+
* @fires Phaser.GameObjects.GameObject#destroyEvent
534535
* @since 3.0.0
535-
*
536+
*
536537
* @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown?
537538
*/
538539
destroy: function (fromScene)
@@ -607,3 +608,8 @@ var GameObject = new Class({
607608
GameObject.RENDER_MASK = 15;
608609

609610
module.exports = GameObject;
611+
612+
/**
613+
* The Game Object will be destroyed.
614+
* @event Phaser.GameObjects.GameObject#destroyEvent
615+
*/

src/gameobjects/rendertexture/RenderTexture.js

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
var BlendModes = require('../../renderer/BlendModes');
78
var Camera = require('../../cameras/2d/BaseCamera');
89
var CanvasPool = require('../../display/canvas/CanvasPool');
910
var Class = require('../../utils/Class');
@@ -187,6 +188,16 @@ var RenderTexture = new Class({
187188
*/
188189
this._saved = false;
189190

191+
/**
192+
* Internal erase mode flag.
193+
*
194+
* @name Phaser.GameObjects.RenderTexture#_eraseMode
195+
* @type {boolean}
196+
* @private
197+
* @since 3.16.0
198+
*/
199+
this._eraseMode = false;
200+
190201
/**
191202
* An internal Camera that can be used to move around the Render Texture.
192203
* Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what
@@ -463,6 +474,70 @@ var RenderTexture = new Class({
463474
return this;
464475
},
465476

477+
/**
478+
* Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE.
479+
* This has the effect of erasing any filled pixels in the objects from this Render Texture.
480+
*
481+
* It can accept any of the following:
482+
*
483+
* * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite.
484+
* * Dynamic and Static Tilemap Layers.
485+
* * A Group. The contents of which will be iterated and drawn in turn.
486+
* * A Container. The contents of which will be iterated fully, and drawn in turn.
487+
* * A Scene's Display List. Pass in `Scene.children` to draw the whole list.
488+
* * Another Render Texture.
489+
* * A Texture Frame instance.
490+
* * A string. This is used to look-up a texture from the Texture Manager.
491+
*
492+
* Note: You cannot erase a Render Texture from itself.
493+
*
494+
* If passing in a Group or Container it will only draw children that return `true`
495+
* when their `willRender()` method is called. I.e. a Container with 10 children,
496+
* 5 of which have `visible=false` will only draw the 5 visible ones.
497+
*
498+
* If passing in an array of Game Objects it will draw them all, regardless if
499+
* they pass a `willRender` check or not.
500+
*
501+
* You can pass in a string in which case it will look for a texture in the Texture
502+
* Manager matching that string, and draw the base frame.
503+
*
504+
* You can pass in the `x` and `y` coordinates to draw the objects at. The use of
505+
* the coordinates differ based on what objects are being drawn. If the object is
506+
* a Group, Container or Display List, the coordinates are _added_ to the positions
507+
* of the children. For all other types of object, the coordinates are exact.
508+
*
509+
* Calling this method causes the WebGL batch to flush, so it can write the texture
510+
* data to the framebuffer being used internally. The batch is flushed at the end,
511+
* after the entries have been iterated. So if you've a bunch of objects to draw,
512+
* try and pass them in an array in one single call, rather than making lots of
513+
* separate calls.
514+
*
515+
* @method Phaser.GameObjects.RenderTexture#erase
516+
* @since 3.16.0
517+
*
518+
* @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these.
519+
* @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object.
520+
* @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object.
521+
*
522+
* @return {this} This Render Texture instance.
523+
*/
524+
erase: function (entries, x, y)
525+
{
526+
this._eraseMode = true;
527+
528+
var blendMode = this.renderer.currentBlendMode;
529+
530+
this.renderer.setBlendMode(BlendModes.ERASE);
531+
532+
this.draw(entries, x, y, 1, 16777215);
533+
534+
this.renderer.setBlendMode(blendMode);
535+
536+
this._eraseMode = false;
537+
538+
return this;
539+
},
540+
466541
/**
467542
* Draws the given object, or an array of objects, to this Render Texture.
468543
*
@@ -747,7 +822,10 @@ var RenderTexture = new Class({
747822
var prevX = gameObject.x;
748823
var prevY = gameObject.y;
749824

750-
this.renderer.setBlendMode(gameObject.blendMode);
825+
if (!this._eraseMode)
826+
{
827+
this.renderer.setBlendMode(gameObject.blendMode);
828+
}
751829

752830
gameObject.setPosition(x, y);
753831

@@ -827,7 +905,19 @@ var RenderTexture = new Class({
827905

828906
if (this.gl)
829907
{
908+
if (this._eraseMode)
909+
{
910+
var blendMode = this.renderer.currentBlendMode;
911+
912+
this.renderer.setBlendMode(BlendModes.ERASE);
913+
}
914+
830915
this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null);
916+
917+
if (this._eraseMode)
918+
{
919+
this.renderer.setBlendMode(blendMode);
920+
}
831921
}
832922
else
833923
{

src/input/InputPlugin.js

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,9 @@ var InputPlugin = new Class({
748748
*
749749
* @method Phaser.Input.InputPlugin#processDownEvents
750750
* @private
751+
* @fires Phaser.GameObjects.GameObject#pointerdownEvent
752+
* @fires Phaser.Input.InputPlugin#gameobjectdownEvent
753+
* @fires Phaser.Input.InputPlugin#pointerdownEvent
751754
* @since 3.0.0
752755
*
753756
* @param {Phaser.Input.Pointer} pointer - The Pointer being tested.
@@ -809,6 +812,20 @@ var InputPlugin = new Class({
809812
*
810813
* @method Phaser.Input.InputPlugin#processDragEvents
811814
* @private
815+
* @fires Phaser.GameObjects.GameObject#dragendEvent
816+
* @fires Phaser.GameObjects.GameObject#dragenterEvent
817+
* @fires Phaser.GameObjects.GameObject#dragEvent
818+
* @fires Phaser.GameObjects.GameObject#dragleaveEvent
819+
* @fires Phaser.GameObjects.GameObject#dragoverEvent
820+
* @fires Phaser.GameObjects.GameObject#dragstartEvent
821+
* @fires Phaser.GameObjects.GameObject#dropEvent
822+
* @fires Phaser.Input.InputPlugin#dragendEvent
823+
* @fires Phaser.Input.InputPlugin#dragenterEvent
824+
* @fires Phaser.Input.InputPlugin#dragEvent
825+
* @fires Phaser.Input.InputPlugin#dragleaveEvent
826+
* @fires Phaser.Input.InputPlugin#dragoverEvent
827+
* @fires Phaser.Input.InputPlugin#dragstartEvent
828+
* @fires Phaser.Input.InputPlugin#dropEvent
812829
* @since 3.0.0
813830
*
814831
* @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects.
@@ -1077,6 +1094,8 @@ var InputPlugin = new Class({
10771094
*
10781095
* @method Phaser.Input.InputPlugin#processMoveEvents
10791096
* @private
1097+
* @fires Phaser.GameObjects.GameObject#pointermoveEvent
1098+
* @fires Phaser.Input.InputPlugin#gameobjectmoveEvent
10801099
* @since 3.0.0
10811100
*
10821101
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
@@ -1142,6 +1161,10 @@ var InputPlugin = new Class({
11421161
*
11431162
* @method Phaser.Input.InputPlugin#processOverOutEvents
11441163
* @private
1164+
* @fires Phaser.GameObjects.GameObject#pointeroutEvent
1165+
* @fires Phaser.GameObjects.GameObject#pointeroverEvent
1166+
* @fires Phaser.Input.InputPlugin#gameobjectoutEvent
1167+
* @fires Phaser.Input.InputPlugin#gameobjectoverEvent
11451168
* @since 3.0.0
11461169
*
11471170
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
@@ -1312,6 +1335,8 @@ var InputPlugin = new Class({
13121335
*
13131336
* @method Phaser.Input.InputPlugin#processUpEvents
13141337
* @private
1338+
* @fires Phaser.GameObjects.GameObject#pointerupEvent
1339+
* @fires Phaser.Input.InputPlugin#gameobjectupEvent
13151340
* @since 3.0.0
13161341
*
13171342
* @param {Phaser.Input.Pointer} pointer - The pointer to check for events against.
@@ -2493,3 +2518,161 @@ var InputPlugin = new Class({
24932518
PluginCache.register('InputPlugin', InputPlugin, 'input');
24942519

24952520
module.exports = InputPlugin;
2521+
2522+
/**
2523+
* A Pointer stopped dragging the Game Object.
2524+
* @event Phaser.GameObjects.GameObject#dragendEvent
2525+
* @param {Phaser.Input.Pointer} pointer - The Pointer that was dragging this Game Object.
2526+
* @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space.
2527+
* @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space.
2528+
* @param {boolean} dropped - True if the object was dropped within its drop target. (In that case, 'drop' was emitted before this.)
2529+
*
2530+
* The Game Object entered its drop target, while being dragged.
2531+
* @event Phaser.GameObjects.GameObject#dragenterEvent
2532+
* @param {Phaser.Input.Pointer} pointer - The pointer dragging this Game Object.
2533+
* @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target.
2534+
*
2535+
* The Game Object is being dragged by a Pointer.
2536+
* @event Phaser.GameObjects.GameObject#dragEvent
2537+
* @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object.
2538+
* @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space.
2539+
* @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space.
2540+
*
2541+
* The Game Object left its drop target, while being dragged.
2542+
* @event Phaser.GameObjects.GameObject#dragleaveEvent
2543+
* @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object.
2544+
* @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target.
2545+
*
2546+
* The Game Object is within its drop target, while being dragged.
2547+
* @event Phaser.GameObjects.GameObject#dragoverEvent
2548+
* @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object.
2549+
* @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target.
2550+
*
2551+
* A Pointer began dragging the Game Object.
2552+
* @event Phaser.GameObjects.GameObject#dragstartEvent
2553+
* @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object.
2554+
* @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space.
2555+
* @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space.
2556+
*
2557+
* The Game Object was released on its drop target, after being dragged.
2558+
* @event Phaser.GameObjects.GameObject#dropEvent
2559+
* @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object.
2560+
* @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target.
2561+
*
2562+
* A Pointer was pressed on the Game Object.
2563+
* @event Phaser.GameObjects.GameObject#pointerdownEvent
2564+
* @param {Phaser.Input.Pointer}
2565+
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2566+
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2567+
* @param {object} eventContainer
2568+
*
2569+
* A Pointer moved while over the Game Object.
2570+
* @event Phaser.GameObjects.GameObject#pointermoveEvent
2571+
* @param {Phaser.Input.Pointer}
2572+
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2573+
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2574+
* @param {object} eventContainer
2575+
*
2576+
* A Pointer left the Game Object, after being over it.
2577+
* @event Phaser.GameObjects.GameObject#pointeroutEvent
2578+
* @param {Phaser.Input.Pointer} - The Pointer.
2579+
* @param {object} eventContainer
2580+
*
2581+
* A Pointer entered the Game Object, after being outside it.
2582+
* @event Phaser.GameObjects.GameObject#pointeroverEvent
2583+
* @param {Phaser.Input.Pointer} - The Pointer.
2584+
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2585+
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2586+
* @param {object} eventContainer
2587+
*
2588+
* A Pointer was released while over the Game Object, after being pressed on the Game Object.
2589+
* @event Phaser.GameObjects.GameObject#pointerupEvent
2590+
* @param {Phaser.Input.Pointer} - The Pointer.
2591+
* @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2592+
* @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position.
2593+
* @param {object} eventContainer
2594+
*/
2595+
2596+
/**
2597+
* A Game Object was released, after being dragged.
2598+
* @event Phaser.Input.InputPlugin#dragendEvent
2599+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2600+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2601+
* @param {boolean} dropped - True if the Game Object was dropped onto its drop target.
2602+
*
2603+
* A dragged Game Object entered it drop target.
2604+
* @event Phaser.Input.InputPlugin#dragenterEvent
2605+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2606+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2607+
* @param {Phaser.GameObjects.GameObject} target - The drop target.
2608+
*
2609+
* A Game Object is being dragged by a Pointer.
2610+
* @event Phaser.Input.InputPlugin#dragEvent
2611+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2612+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2613+
* @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space.
2614+
* @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space.
2615+
*
2616+
* A dragged Game Object left its drop target.
2617+
* @event Phaser.Input.InputPlugin#dragleaveEvent
2618+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2619+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2620+
* @param {?Phaser.GameObjects.GameObject} target - The drop target.
2621+
*
2622+
* A dragged Game Object is within its drop target.
2623+
* @event Phaser.Input.InputPlugin#dragoverEvent
2624+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2625+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2626+
* @param {?Phaser.GameObjects.GameObject} target - The drop target.
2627+
*
2628+
* A Pointer started dragging a Game Object.
2629+
* @event Phaser.Input.InputPlugin#dragstartEvent
2630+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2631+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2632+
*
2633+
* A Game Object was dropped within its drop target.
2634+
* @event Phaser.Input.InputPlugin#dropEvent
2635+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2636+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2637+
* @param {?Phaser.GameObjects.GameObject} target - The drop target.
2638+
*
2639+
* A Pointer was pressed while over a Game Object.
2640+
* @event Phaser.Input.InputPlugin#gameobjectdownEvent
2641+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2642+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2643+
* @param {object} eventContainer
2644+
*
2645+
* A Pointer moved while over a Game Object.
2646+
* @event Phaser.Input.InputPlugin#gameobjectmoveEvent
2647+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2648+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2649+
* @param {object} eventContainer
2650+
*
2651+
* A Pointer moved off of a Game Object, after being over it.
2652+
* @event Phaser.Input.InputPlugin#gameobjectoutEvent
2653+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2654+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2655+
* @param {object} eventContainer
2656+
*
2657+
* A Pointer moved onto a Game Object, after being off it.
2658+
* @event Phaser.Input.InputPlugin#gameobjectoverEvent
2659+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2660+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2661+
* @param {object} eventContainer
2662+
*
2663+
* A Pointer was released while over a Game Object, after being pressed on the Game Object.
2664+
* @event Phaser.Input.InputPlugin#gameobjectupEvent
2665+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2666+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object.
2667+
* @param {object} eventContainer
2668+
*
2669+
* A Pointer was pressed down.
2670+
* @event Phaser.Input.InputPlugin#pointerdownEvent
2671+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2672+
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer.
2673+
*
2674+
* A Pointer was released, after being pressed down.
2675+
* @event Phaser.Input.InputPlugin#pointerupEvent
2676+
* @param {Phaser.Input.Pointer} pointer - The Pointer.
2677+
* @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer.
2678+
*/

src/physics/arcade/Body.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ var Body = new Class({
401401
* @type {boolean}
402402
* @default false
403403
* @since 3.0.0
404-
* @see Phaser.Physics.Arcade.World#event:worldbounds
404+
* @see Phaser.Physics.Arcade.World#worldboundsEvent
405405
*/
406406
this.onWorldBounds = false;
407407

@@ -412,7 +412,7 @@ var Body = new Class({
412412
* @type {boolean}
413413
* @default false
414414
* @since 3.0.0
415-
* @see Phaser.Physics.Arcade.World#event:collide
415+
* @see Phaser.Physics.Arcade.World#collideEvent
416416
*/
417417
this.onCollide = false;
418418

@@ -423,7 +423,7 @@ var Body = new Class({
423423
* @type {boolean}
424424
* @default false
425425
* @since 3.0.0
426-
* @see Phaser.Physics.Arcade.World#event:overlap
426+
* @see Phaser.Physics.Arcade.World#overlapEvent
427427
*/
428428
this.onOverlap = false;
429429

0 commit comments

Comments
 (0)