Phaser API Documentation

  Version: 
erase(entries, [x], [y])

Description:

Draws the given object, or an array of objects, to this Dynamic Texture using a blend mode of ERASE. This has the effect of erasing any filled pixels present in the objects from this texture.

It can accept any of the following:

  • Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite.
  • Tilemap Layers.
  • A Group. The contents of which will be iterated and drawn in turn.
  • A Container. The contents of which will be iterated fully, and drawn in turn.
  • A Scene Display List. Pass in Scene.children to draw the whole list.
  • Another Dynamic Texture, or a Render Texture.
  • A Texture Frame instance.
  • A string. This is used to look-up the texture from the Texture Manager.

Note: You cannot erase a Dynamic Texture from itself.

If passing in a Group or Container it will only draw children that return true when their willRender() method is called. I.e. a Container with 10 children, 5 of which have visible=false will only draw the 5 visible ones.

If passing in an array of Game Objects it will draw them all, regardless if they pass a willRender check or not.

You can pass in a string in which case it will look for a texture in the Texture Manager matching that string, and draw the base frame.

You can pass in the x and y coordinates to draw the objects at. The use of the coordinates differ based on what objects are being drawn. If the object is a Group, Container or Display List, the coordinates are added to the positions of the children. For all other types of object, the coordinates are exact.

Calling this method causes the WebGL batch to flush, so it can write the texture data to the framebuffer being used internally. The batch is flushed at the end, after the entries have been iterated. So if you've a bunch of objects to draw, try and pass them in an array in one single call, rather than making lots of separate calls.

If you are not planning on using this Dynamic Texture as a base texture for Sprite Game Objects, then you should set DynamicTexture.isSpriteTexture = false before calling this method, otherwise you will get vertically inverted frames in WebGL.

Parameters:

name type arguments description
entries any

Any renderable Game Object, or Group, Container, Display List, Render Texture, Texture Frame, or an array of any of these.

x number <optional>

The x position to draw the Frame at, or the offset applied to the object.

y number <optional>

The y position to draw the Frame at, or the offset applied to the object.

Returns:
Description:

This Dynamic Texture instance.

Since: 3.16.0