You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* An internal Camera that can be used to move around the Render Texture.
192
203
* 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({
463
474
returnthis;
464
475
},
465
476
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
+
varblendMode=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
+
returnthis;
539
+
},
540
+
466
541
/**
467
542
* Draws the given object, or an array of objects, to this Render Texture.
468
543
*
@@ -747,7 +822,10 @@ var RenderTexture = new Class({
747
822
varprevX=gameObject.x;
748
823
varprevY=gameObject.y;
749
824
750
-
this.renderer.setBlendMode(gameObject.blendMode);
825
+
if(!this._eraseMode)
826
+
{
827
+
this.renderer.setBlendMode(gameObject.blendMode);
828
+
}
751
829
752
830
gameObject.setPosition(x,y);
753
831
@@ -827,7 +905,19 @@ var RenderTexture = new Class({
0 commit comments