question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using BitmapMask inside container has interesting behavior.

See original GitHub issue

Version

  • 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 image after image

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())
}

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
photonstormcommented, Sep 24, 2020

That beta build was probably from before I fixed this yesterday, use the one attached:

dev.zip

1reaction
taoabccommented, Sep 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found