Jump to content

Getting width/height of Sprite when loaded?


Recommended Posts

Yes, it's possible to use `fromImage`, but it's not a good idea - for exactly the reason you've discovered.

It's better to preload images with Pixi's `AssetLoader` and then initialize the sprites in a separate `setup` function.

var loader = new PIXI.AssetLoader([  "images/imageOne.png",  "images/imageTwo.png",  "images/imageThree.png"]);loader.onComplete = setup;loader.load();function setup() {   //Create the sprite from the loaded image texture  var texture = PIXI.TextureCache["images/imageOne.png"];  var anySprite = new PIXI.Sprite(texture);}
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.

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.


  • Recently Browsing   0 members

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