Jump to content

Problems using PIXI.Loader resources


Sternmiracle
 Share

Recommended Posts

Hello!

I am trying to set up a callback that fires whenever an asset starts loading in pixi v5. I did something like this:

loader.add(myKey,....)
loader.resources[myKey].onStart.add(...)

The problem is that onStart (or any other signals for that matter) are not defined for the LoaderResource class. According to the docs, these exist, but I can't seem to get them. LoaderResource has all other properties like url, data, texture and such, just no signals. Am I missing something?

The relevant packages I installed through npm are: pixi-js, pixi-sound, pixi-spine

Link to comment
Share on other sites

Hello and Welcome to the forums!

Do you use typescript or do you get undefined type error in js?

Yes, they might be not defined because we have a bit of a problem to make correct typings considering that resource-loader is separated from pixi: https://github.com/englercj/resource-loader 

We dont have time to fix it in current version because soon we are working on completely new typings that are not generated from jsdoc. We will also need to persuade resource-loader author to make changes to typings to make it better connect to pixi.

Link to comment
Share on other sites

While waiting for solution you could skip the warning by casting the resources to dynamic type (loader.resources[mykey] as any).onStart.add.

You would lose autocompletion and other type security in that case though for those lines.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...