Alebrijes Posted June 30, 2015 Share Posted June 30, 2015 Hi, I try to load a an image from a sprite sheet, This is my code: loadAssets: function() { // The coordinates for the sprite sheet PIXI.loader .add(['assets/interface.json']) .once('complete', this.onLoadAssets.bind(this)) .load();},onLoadAssets: function() { // This is the background image I try to load... var bgtexture = new PIXI.Texture.fromImage('bg.png'); var paperBG = new PIXI.Sprite(bgtexture); this.stage.addChild(paperBG);} When I load the page I can see the space should have the image in the screen, but its all black, I cant see the image, What I´m doing wrong ? Thanks for your help! Quote Link to comment Share on other sites More sharing options...
xerver Posted June 30, 2015 Share Posted June 30, 2015 http://www.html5gamedevs.com/topic/14524-v3-access-cached-texture-by-name/?p=82661http://www.html5gamedevs.com/topic/14981-v3-loader-accessing-the-keys/?p=84973http://www.html5gamedevs.com/topic/15452-loader-usage-pixi-v3/?p=87504Don't try to mix the loader and fromX() methods, just use the loader. Your callback gets all the loaded assets. Just use them.loadAssets: function() { // The coordinates for the sprite sheet PIXI.loader .add('interface', 'assets/interface.json') .once('complete', this.onLoadAssets.bind(this)) .load();},onLoadAssets: function(loader, resources) { // check out this object, it likely already has texture objects for you to use directly // they are named based on your sheet, so I am only guessing when I try to use it below console.log(resources.interface, resources.interface.textures); var paperBG = new PIXI.Sprite(resources.interface.textures['bg.png']); this.stage.addChild(paperBG);} Quote Link to comment Share on other sites More sharing options...
Alebrijes Posted June 30, 2015 Author Share Posted June 30, 2015 Thank you very much!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.