Sign in to follow this  
2dt

Loading a texture directly from image?

Recommended Posts

The most prominent method for loading textures seems to be the .fromImage functions, which use URLs. What if I have a raw image source, but no URL (like an image generated inside the app). How would I go about making a texture out of that?

Share this post


Link to post
Share on other sites

The Texture class is created from a BaseTexture which is created from a texture source (such as an image or canvas). When you do "PIXI.Texture.fromImage('my/url/image.png');" basically what happens is this:

var img = new Image();img.src = 'my/url/image.png';var base = new PIXI.BaseTexture(img),    texture = new PIXI.Texture(base);// return you the texture

If you already have the image, you can just create a base texture from it and thereby a texture that you can use in your sprites. Hope this helps.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.