mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[phaser] Display number of skeletons in batching test
This commit is contained in:
parent
bf0a33876a
commit
24995d28b4
@ -1,75 +1,80 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<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.60.0/dist/phaser.js"></script>
|
|
||||||
<link rel="stylesheet" href="../../index.css" />
|
|
||||||
<title>Spine Phaser Example</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="p-4 flex flex-col items-center">
|
<head>
|
||||||
<h1>Batching test</h1>
|
<meta charset="UTF-8" />
|
||||||
</body>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<script>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
const config = {
|
<script src="//cdn.jsdelivr.net/npm/phaser@3.60.0/dist/phaser.js"></script>
|
||||||
type: Phaser.AUTO,
|
<link rel="stylesheet" href="../../index.css" />
|
||||||
width: 800,
|
<title>Spine Phaser Example</title>
|
||||||
height: 600,
|
</head>
|
||||||
type: Phaser.WEBGL,
|
|
||||||
scene: {
|
<body class="p-4 flex flex-col items-center">
|
||||||
preload: preload,
|
<h1>Batching test</h1>
|
||||||
create: create,
|
</body>
|
||||||
update: update,
|
<script>
|
||||||
pack: {
|
const config = {
|
||||||
files: [
|
type: Phaser.AUTO,
|
||||||
{
|
width: 800,
|
||||||
type: "scenePlugin",
|
height: 600,
|
||||||
key: "spine.SpinePlugin",
|
type: Phaser.WEBGL,
|
||||||
url: "../dist/iife/spine-phaser.js",
|
scene: {
|
||||||
sceneKey: "spine",
|
preload: preload,
|
||||||
},
|
create: create,
|
||||||
],
|
update: update,
|
||||||
},
|
pack: {
|
||||||
|
files: [
|
||||||
|
{
|
||||||
|
type: "scenePlugin",
|
||||||
|
key: "spine.SpinePlugin",
|
||||||
|
url: "../dist/iife/spine-phaser.js",
|
||||||
|
sceneKey: "spine",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const game = new Phaser.Game(config);
|
const game = new Phaser.Game(config);
|
||||||
let debug;
|
let debug;
|
||||||
|
|
||||||
function preload() {
|
function preload() {
|
||||||
this.load.spineJson("raptor-data", "assets/raptor-pro.json");
|
this.load.spineJson("raptor-data", "assets/raptor-pro.json");
|
||||||
this.load.spineAtlas("raptor-atlas", "assets/raptor-pma.atlas");
|
this.load.spineAtlas("raptor-atlas", "assets/raptor-pma.atlas");
|
||||||
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
|
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
|
||||||
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
|
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
|
||||||
}
|
}
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
const plugin = this.spine;
|
const plugin = this.spine;
|
||||||
let x = 25;
|
let x = 25;
|
||||||
let y = 60;
|
let y = 60;
|
||||||
for (let j = 0; j < 10; j++, y += 600 / 10) {
|
let n = 0;
|
||||||
for (let i = 0; i < 20; i++, x += 800 / 20) {
|
for (let j = 0; j < 10; j++, y += 600 / 10) {
|
||||||
const obj =
|
for (let i = 0; i < 20; i++, x += 800 / 20) {
|
||||||
Math.random() > 0.5
|
const obj =
|
||||||
? this.add.spine(x, y, "spineboy-data", "spineboy-atlas")
|
Math.random() > 0.5
|
||||||
: this.add.spine(x, y, "raptor-data", "raptor-atlas");
|
? this.add.spine(x, y, "spineboy-data", "spineboy-atlas")
|
||||||
obj.animationState.setAnimation(0, "walk", true);
|
: this.add.spine(x, y, "raptor-data", "raptor-atlas");
|
||||||
obj.scale = 0.1;
|
obj.animationState.setAnimation(0, "walk", true);
|
||||||
}
|
obj.scale = 0.1;
|
||||||
x = 25;
|
n++;
|
||||||
}
|
}
|
||||||
debug = this.add.text(0, 600 - 40, "FPS: ");
|
x = 25;
|
||||||
}
|
}
|
||||||
|
debug = this.add.text(0, 600 - 40, "FPS: ");
|
||||||
|
this.add.text(0, 600 - 60, "Skeletons: " + n);
|
||||||
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
debug.setText(
|
debug.setText(
|
||||||
"draw calls: " +
|
"draw calls: " +
|
||||||
spine.PolygonBatcher.getAndResetGlobalDrawCalls() +
|
spine.PolygonBatcher.getAndResetGlobalDrawCalls() +
|
||||||
"\ndelta: " +
|
"\ndelta: " +
|
||||||
game.loop.delta
|
game.loop.delta
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</html>
|
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user