mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
70 lines
1.9 KiB
HTML
70 lines
1.9 KiB
HTML
<!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.55.2/dist/phaser.js"></script>
|
|
<script src="../dist/iife/spine-phaser.js"></script>
|
|
<title>Spine Phaser Example</title>
|
|
</head>
|
|
<body>
|
|
<h1>Blend test</h1>
|
|
</body>
|
|
<script>
|
|
var config = {
|
|
type: Phaser.AUTO,
|
|
width: 800,
|
|
height: 600,
|
|
type: Phaser.WEBGL,
|
|
backgroundColor: '#cdcdcd',
|
|
scene: {
|
|
preload: preload,
|
|
create: create,
|
|
update: update
|
|
},
|
|
plugins: {
|
|
scene: [
|
|
{ key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" }
|
|
]
|
|
}
|
|
};
|
|
|
|
let controls;
|
|
let game = new Phaser.Game(config);
|
|
|
|
function preload () {
|
|
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
|
|
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
|
|
}
|
|
|
|
function create () {
|
|
for (var i = 0; i < 4; i++) {
|
|
let obj = this.add.spine(i * 200, 600, 'spineboy-data', 'spineboy-atlas').setScale(0.25);
|
|
obj.setScale(0.25);
|
|
obj.animationState.setAnimation(0, "idle", true);
|
|
obj.animationState.setAnimation(1, "shoot", true);
|
|
}
|
|
var cursors = this.input.keyboard.createCursorKeys();
|
|
|
|
var controlConfig = {
|
|
camera: this.cameras.main,
|
|
left: cursors.left,
|
|
right: cursors.right,
|
|
up: cursors.up,
|
|
down: cursors.down,
|
|
zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q),
|
|
zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E),
|
|
acceleration: 0.35,
|
|
drag: 0.01,
|
|
maxSpeed: 1.2
|
|
};
|
|
|
|
controls = new Phaser.Cameras.Controls.SmoothedKeyControl(controlConfig);
|
|
}
|
|
|
|
function update (time, delta) {
|
|
controls.update(delta);
|
|
}
|
|
</script>
|
|
</html> |