- Edited
Invisible spine game object in an added scene causes the first image to be rendered wrong
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="//cdn.jsdelivr.net/npm/phaser@3.80.1/dist/phaser.js"></script>
<script src="https://unpkg.com/@esotericsoftware/spine-phaser@4.2.*/dist/iife/spine-phaser.min.js"></script>
<link rel="stylesheet" href="../../index.css" />
<title>Spine Phaser Example</title>
</head>
<body class="p-4 flex flex-col items-center">
<h1>Basic example</h1>
</body>
<script>
class AddedScene extends Phaser.Scene {
preload() {
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
}
create() {
const spineboy = this.add.spine(
400,
500,
"spineboy-data",
"spineboy-atlas"
);
spineboy.scale = 0.5;
spineboy.animationState.setAnimation(0, "walk", true);
spineboy.setVisible(false);
}
}
class BasicExample extends Phaser.Scene {
preload() {
this.load.image("asdf", "asdf.png");
}
create() {
const image = this.add.image(0, 0, 'asdf').setOrigin(0);
this.game.scene.add('AddedScene', AddedScene, true);
}
}
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
type: Phaser.WEBGL,
scene: [BasicExample],
plugins: {
scene: [
{
key: "spine.SpinePlugin",
plugin: spine.SpinePlugin,
mapping: "spine",
},
],
},
};
const game = new Phaser.Game(config);
</script>
</html>
Expected result: the image at the top left corner is 'asdf.png'
What actually happened: the image at the top left corner is the spineboy png image
If you do not set the spineboy to be invisible, then the image will be rendered correctly