// You cannot do this until `SpinePlugin` is available // which it isn't until the plugin has loaded. function createNewClass () { window.Enemy = new Phaser.Class({ Extends: SpinePlugin.SpineGameObject, initialize: function Enemy (scene, x, y, skeleton, animation) { // SpinePlugin.SpineGameObject.call(this, scene, scene.sys.SpinePlugin, x, y, skeleton, animation, true); SpinePlugin.SpineGameObject.call(this, scene, scene.spine, x, y, skeleton, animation, true); scene.sys.displayList.add(this); scene.sys.updateList.add(this); } }); } var config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, backgroundColor: '#2d2d2d', scene: { preload: preload, create: create, pack: { files: [ { type: 'scenePlugin', key: 'SpinePlugin', url: 'https://cdn.phaserfiles.com/v385/plugins/spine4.1/SpinePluginDebug.js', sceneKey: 'spine' } ] } } }; var game = new Phaser.Game(config); function preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.setPath('assets/spine/4.1/demos/'); this.load.spine('set1', 'demos.json', [ 'atlas1.atlas' ], true); } function create () { createNewClass(); var boy = new Enemy(this, 400, 600, 'set1.spineboy', 'idle'); console.log(boy); }
Scan to open on your mobile device
// You cannot do this until `SpinePlugin` is available // which it isn't until the plugin has loaded. function createNewClass () { window.Enemy = new Phaser.Class({ Extends: SpinePlugin.SpineGameObject, initialize: function Enemy (scene, x, y, skeleton, animation) { // SpinePlugin.SpineGameObject.call(this, scene, scene.sys.SpinePlugin, x, y, skeleton, animation, true); SpinePlugin.SpineGameObject.call(this, scene, scene.spine, x, y, skeleton, animation, true); scene.sys.displayList.add(this); scene.sys.updateList.add(this); } }); } var config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, backgroundColor: '#2d2d2d', scene: { preload: preload, create: create, pack: { files: [ { type: 'scenePlugin', key: 'SpinePlugin', url: 'https://cdn.phaserfiles.com/v385/plugins/spine4.1/SpinePluginDebug.js', sceneKey: 'spine' } ] } } }; var game = new Phaser.Game(config); function preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.setPath('assets/spine/4.1/demos/'); this.load.spine('set1', 'demos.json', [ 'atlas1.atlas' ], true); } function create () { createNewClass(); var boy = new Enemy(this, 400, 600, 'set1.spineboy', 'idle'); console.log(boy); }