SpineGameObject import

Hi

I added phaser 3.55.2 zip folder in my project which is available here - Phaser - Download - Phaser 3.55.2 "Ichika"

I am using Spine in my project and everything goes well when I use this.add.spine keyword but I want to use new SpineGameObject and problem is that I cant import SpineGameObject class from ‘phaser/plugins/spine/src/gameobject/SpineGameObject.js’

file is found, but I have this error :arrow_down_small:

maybe there is some problem in this file itself

any help?

Try this.
import SpinePlugin from “phaser/plugins/spine/dist/SpinePlugin”;

add this in config
plugins: {
[{
key: “SpinePlugin”,
plugin: window.SpinePlugin,
mapping: “spine”,
}]
}
this.add.spine(x, y, “idle”, false);

the plugin works perfectly itself,
as I said I have a problem with importing SpineGameObject!
thank you anyway

What’s your import statement? I assume it should be

import SpineGameObject from 'phaser/plugins/spine/src/gameobject/SpineGameObject.js';

If that doesn’t work remove the import and use Phaser.GameObjects.SpineGameObject instead.

the address of import is correct, but file says that it does not contain export named with SpineGameObject, while there is export named with SpineGameObject indeed.

I tried to use Phaser.GameObjects.SpineGameObject and I have this error now
image

What was the import statement, please?

class ExtSpineGameObject extends SpinePlugin.SpineGameObject {}

Cf. https://labs.phaser.io/edit.html?src=src\spine\extended%20class.js, not really extended.

‘phaser/plugins/spine/src/gameobject/SpineGameObject.js’; generally
and in my case it was - ‘…/…/lib/phaser/plugins/spine/src/gameobject/SpineGameObject.js’

yeah, I thought about this way but extended class would be better in my case

I mean what is the entire line of code, starting with import …?

import { SpineGameObject } from ‘…/…/lib/phaser/plugins/spine/src/gameobject/SpineGameObject.js’

without curly braces, error said that file does not contain default export while with curly braces it’s saying there is no export named with SpineGameObject :thinking:

I think you may have to use the global.

/* global SpinePlugin */

class ExtSpineGameObject extends SpinePlugin.SpineGameObject {}

image
there is not error, but i cant see spinegameobject on browser and there is new kind of error


some of the properties are null

That’s normal, add

this.add.existing(a);

that had error too, it said - SpineGameObject is not constructor;
thanks for helping :smiling_face_with_three_hearts:

do you have another idea? :grin:

That comes from this.add.existing(…)?

i’ll take a screen later, my working computer is not with me before monday
:smiling_face_with_three_hearts:
we can continue conversation after that, if you are not against
happy new year :smiling_face_with_three_hearts::smiling_face_with_three_hearts:

see
image
image

I also tried to pass the plugin as a second parameter
image

Constructor args must be (scene, spinePlugin, x, y, key, …), yes.

The error is strange. Try stepping through in the debugger.