Using BitmapMask inside container has interesting behavior.
See original GitHub issueVersion
- Phaser Version:3.17.0 and 3.18.1
- Operating system: Windows 10
- Browser: Google Chrome Version 75.0.3770.100 (Official Build) (64-bit)
Description
We have a container added to scene and 2 sprites in it (sprite0
and sprite1
). Trying to set mask to sprite0 from sprite1 and both of them are becoming invisible.
before applying mask after
Example Test Code
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#000066',
parent: 'phaser-example',
scene: {
preload: preload,
create: create,
}
};
var controls;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('brain', 'assets/sprites/brain.png');
this.load.image('truck', 'assets/sprites/astorm-truck.png');
}
function create ()
{
var container = this.add.container(400, 300);
var sprite0 = this.add.sprite(10, 0, 'truck');
var sprite1 = this.add.sprite(0, 0, 'truck');
container.add(sprite0);
container.add(sprite1)
sprite1.setMask(sprite0.createBitmapMask())
}
Additional Information
lets change texture of sprite0
to brain
and we’ll see another unexpected behavior.
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
backgroundColor: '#000066',
parent: 'phaser-example',
scene: {
preload: preload,
create: create,
}
};
var controls;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('brain', 'assets/sprites/brain.png');
this.load.image('truck', 'assets/sprites/astorm-truck.png');
}
function create ()
{
var container = this.add.container(400, 300);
var sprite0 = this.add.sprite(10, 0, 'brain');
var sprite1 = this.add.sprite(0, 0, 'truck');
container.add(sprite0);
container.add(sprite1)
sprite1.setMask(sprite0.createBitmapMask())
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Masking Bitmaps - Medium
Suppose we have two images represented by Bitmap objects. The first one includes an original image and the the second one contains a...
Read more >Pixel Perfect Collision using bitmap mask - Unity Forum
is it possible to do pixel perfect collision, using a bitmap mask, ... It basically checks first for box collision and in case...
Read more >Phaser 3 API Documentation - Class: BitmapMask
A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. Unlike the Geometry Mask, which is...
Read more >A Short Introduction to HTk - Uni Bremen
This paper introduces the basics of HTK, a toolkit to build graphical user interfaces in Haskell. HTK is an encapsulation of Tcl/Tk [4,...
Read more >Transparent ATL Controls | Mark Nelson
The ability to display transparent GIF files in most popular Web browsers has apparently put quite a few developers into “me-too” mode.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That beta build was probably from before I fixed this yesterday, use the one attached:
dev.zip
Because mask cannot add to container, I’m forced fallback to phaser 2. @RollinSafary Like your situation, I need a batch of cirle mask above avatar. Then attach the root container to dragonbones or spine slot.