123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <!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/[email protected]/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">
- <h1>Render to texture</h1>
- </body>
- <script>
- const config = {
- type: Phaser.AUTO,
- width: 800,
- height: 600,
- type: Phaser.WEBGL,
- scene: {
- preload: preload,
- create: create,
- pack: {
- files: [
- {
- type: "scenePlugin",
- key: "spine.SpinePlugin",
- url: "../dist/iife/spine-phaser-v3.js",
- sceneKey: "spine",
- },
- ],
- },
- },
- };
- const 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() {
- const renderTexture = this.add.renderTexture(400, 300, 800, 600);
- console.log(renderTexture.renderMode);
- const spineboy = this.add.spine(
- 400,
- 300,
- "spineboy-data",
- "spineboy-atlas"
- );
- spineboy.scale = 0.5;
- spineboy.animationState.setAnimation(0, "walk", true);
- this.add.text(200, 8, "Click to stamp SpineBoy");
- this.input.on(
- "pointermove",
- function (pointer) {
- spineboy.setPosition(pointer.x, pointer.y);
- },
- this
- );
- this.input.on(
- "pointerdown",
- function (pointer) {
- renderTexture.draw(spineboy);
- spineboy.angle += 10;
- },
- this
- );
- }
- </script>
- </html>
|