Jump to content

Custom loader / delay calling "create" on scene?


Pablo Pirata
 Share

Recommended Posts

Hey all.

I'm trying to fetch some data from a server and only want to start creating the scene with the "create" function after it's loaded. I was able to do it with "this.load.json()" but the problem is that I actually need to send a post request.

I currently have 2 solutions:

- When my request is done, I set a custom attribute and in the update function I check if that attribute exists, if it does, then move to a new scene with the new data.

- When my request is done, I set a custom attribute and in the create function I check if that attribute exists, if it doesn't, then I set a timer to call the create function again and return.

I don't like either solutions.

Is there a way to create a custom loader? Like "this.load.myCustomLoader" and then the "create()" function will only be called after this load is done?

If not, how is the correct way to fetch/post data from a server?

Thank you.

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...