Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpineContainer delayed masking, or not masking at all, with lower depth spine below #5627

Closed
FloodGames opened this issue Mar 26, 2021 · 3 comments
Labels
🐛 Spine An issue arising from the Spine runtime

Comments

@FloodGames
Copy link

FloodGames commented Mar 26, 2021

Phaser Version: 3.54

Description

1 SpineContainer, containing 1 ship spine and 1 mask
1 SpineObject, a wave, with SpineContainer.depth+1
Result: Masking is somehow delayed.

Here is a gif of the bug:
MaskingBugSpineContainer

Example Test Code

Please add my example code to labs.phaser.io - Spine. Like: SpineContainer with Mask
In this sample, the mask stops working (try commenting out the const coin line!):

var config = {
    type: Phaser.WEBGL,
    parent: 'phaser-example',
    width: 800,
    height: 600,
    backgroundColor: '#2d2d66',
    scene: {
        preload: preload,
        create: create,
        update: update,
        pack: {
            files: [
                { type: 'scenePlugin', key: 'SpinePlugin', url: 'plugins/3.8.95/SpinePluginDebug.js', sceneKey: 'spine' }
            ]
        }
    }
};

var controls;

var game = new Phaser.Game(config);

function preload ()
{
    this.load.image('logo', 'assets/sprites/phaser.png');

    this.load.setPath('assets/spine/3.8/spineboy');

    this.load.spine('boy', 'spineboy-pro.json', 'spineboy-pro.atlas', true);

    this.load.setPath('assets/spine/3.8/coin');

    this.load.spine('coin', 'coin-pro.json', 'coin-pro.atlas');
}

function create ()
{
    const spineContainer = this.add.spineContainer(200, 400);
    
    const spineBoy = this.add.spine(0, 50, 'boy', 'walk', true).setScale(0.5);
    spineContainer.add(spineBoy)

    //add mask to spineContainer
    spineContainer.maskShape = this.add.graphics()
    .fillStyle(0x7fff00, 0.2) //for debugging purposes
    .setVisible(true) //set true for debugging purposes
    .setDepth(5)
    .fillRect(
      Math.ceil(100),
      Math.ceil(100),
      Math.ceil(300),
      Math.ceil(300)
    )
    const mask = new Phaser.Display.Masks.GeometryMask(this, spineContainer.maskShape)
    spineContainer.setMask(mask)

    const coin = this.add.spine(200, 300, 'coin', 'rotate', true).setScale(0.3);

    var cursors = this.input.keyboard.createCursorKeys();

    var controlConfig = {
        camera: this.cameras.main,
        left: cursors.left,
        right: cursors.right,
        up: cursors.up,
        down: cursors.down,
        acceleration: 0.06,
        drag: 0.0005,
        maxSpeed: 1.0
    };

    controls = new Phaser.Cameras.Controls.SmoothedKeyControl(controlConfig);
}

function update (time, delta)
{
    controls.update(delta);
}

@gammafp gammafp added the 🐛 Spine An issue arising from the Spine runtime label Mar 29, 2021
@FloodGames
Copy link
Author

FloodGames commented Apr 13, 2021

Updated with sample code.

  1. please add to labs.phaser.io "SpineContainer with Mask"
  2. please fix if possible

@FloodGames FloodGames changed the title SpineContainer delayed masking SpineContainer delayed masking, or not masking at all, with higher depth spine on top Apr 13, 2021
@FloodGames
Copy link
Author

FloodGames commented Apr 13, 2021

The example I can "fix" with by not giving a depth to the mask.
.setDepth(5)

Still, in the game I have:
image

UPDATE
If you put the coin first in the create - or with lower depth than the SpineContainer - it will mess up, this:
image

to:
image

Note that the coin is not related to the SpineContainer and its mask in any way. Somehow it visually destroys everything.

@FloodGames FloodGames changed the title SpineContainer delayed masking, or not masking at all, with higher depth spine on top SpineContainer delayed masking, or not masking at all, with lower depth spine below Apr 13, 2021
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Spine An issue arising from the Spine runtime
Projects
None yet
Development

No branches or pull requests

3 participants