• RuntimesBugs
  • Property 'spine' does not exist on type 'LoaderPlugin'.ts(2339)

Hello. I haven't been able to solve this problem all day. Why am I getting the error: "Property 'spine' does not exist on type 'LoaderPlugin'.ts(2339)"? I created a globals.d.ts file with this code:

// declare interface Window {
//     SpinePlugin: any;
//   }
  
//   declare module Phaser.Loader {
//     interface LoaderPlugin {
//       spine(key: string, jsonURL: string, atlasURL: string, premultipliedAlpha?: boolean): void;
//     }
//   }
  
//   declare module Phaser.GameObjects {
//     interface GameObjectFactory {
//       spine(x: number, y: number, key: string, animationName?: string, loop?: boolean): SpineGameObject;
//     }
//   }

And it helped, the error disappeared, but it didn't solve the problem, because when I tried to load the character, I got an error in the browser console.

gunger.ts:16 Uncaught TypeError: this.load.spine is not a function
    at Gunger.preload (gunger.ts:16:19)
    at SceneManager2.bootScene (chunk-T7R5QQBG.js?v=75adfa8d:110284:37)
    at SceneManager2.start (chunk-T7R5QQBG.js?v=75adfa8d:110829:26)
    at SceneManager2.bootQueue (chunk-T7R5QQBG.js?v=75adfa8d:110118:28)
    at EventEmitter.emit (chunk-T7R5QQBG.js?v=75adfa8d:137:43)
    at Game2.texturesReady (chunk-T7R5QQBG.js?v=75adfa8d:8582:33)
    at TextureManager2.emit (chunk-T7R5QQBG.js?v=75adfa8d:137:43)
    at TextureManager2.updatePending (chunk-T7R5QQBG.js?v=75adfa8d:121500:28)
    at TextureManager2.emit (chunk-T7R5QQBG.js?v=75adfa8d:119:45)
    at image.onload (chunk-T7R5QQBG.js?v=75adfa8d:121606:31)

Could you please take a look at my project? All other files, like the ones for entities, are not relevant at the moment.

I only ask you to check main.ts, the file with the game configuration, and gunger.ts, where the spine character is being loaded.

Please help, I really appreciate it. Thanks!
yto4ka78/lags_phaser

Related Discussions
...

Hello 🙂

You should refer to the spine-phaser documentation to use our official runtime.

You should use this.load.spineJson ( or spineBinary spineAtlas) to load spine assets.
Then this.add.spine(x, y, SKELETON_NAME, ATLAS_NAME) to add to the scene.

You can also have a look at our examples. This is the example with a ts project.

    Davide I did it before. But it didn't work. Now I understand what the problem was. In the atlas file, the first line was empty, and then the name of the png file. That's why I got the error.