Jump to content

Base64 Images


Lizard
 Share

Recommended Posts

Since you are adding this to `this.textures`, and not loading it using the regular `this.load`, Rich mentioned you need to do a little extra work to make this work. He commented on that GitHub issue - https://github.com/photonstorm/phaser/issues/3342#issuecomment-372332727

Note that you must listen out for the onload event from the Texture Manager before you can use the base64 texture in a game object.

So once you do the add the base 64 data to the textures object, you'll also need to do something like:

this.textures.on('onload', function() { /* do something with the texture */ });

 

Link to comment
Share on other sites

  • 2 weeks later...

May be someone know is it possible to use preloaded images as spritesheet? Or may be here is some another way to preload spritesheet as base64?

UPD found how to add frames for already preloaded images in base64 (further it can be used as spritesheet)

this.textures.list.NAMEOFIMAGE.add(index, 0, startX, startY, width, height);

index - number of frame

startX and startY - coordinates for upper left corner cropping rectangle

width and height - size of cropping rectangle

You can easily wrap it into cycle and crop  your spritesheet to frames.

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