JackParke Posted September 22, 2017 Share Posted September 22, 2017 How does one create a base texture from a "named" image referencing the "alias" used in loader. PIXI.loader.add("sprites", "sprites.png") new PIXI.BaseTexture.fromImage("sprites.png", false, PIXI.SCALE_MODES.NEAREST) It seems to me it would make more sense to stick to "sprites" instead of "sprites.png". Quote Link to comment Share on other sites More sharing options...
xerver Posted September 22, 2017 Share Posted September 22, 2017 No need to use fromX methods, just use the resources the loader made for you: PIXI.loader.add("sprites", "sprites.png"); PIXI.loader.load(function () { const baseTexture = PIXI.loader.resources.sprites.texture.baseTexture; // loader made you a base texture, no need to create your own. }); Additionally, don't do "new PIXI.BaseTexture.fromX()" the from methods are not a constructor. Either do "new PIXI.BaseTexture()" or do "PIXI.BaseTexture.from()" or (my preference) do neither and just use the one the loader made for you. Quote Link to comment Share on other sites More sharing options...
JackParke Posted September 23, 2017 Author Share Posted September 23, 2017 My sprites has no baseTexture: So it's crashing here: PIXI.loader .add("sprites", "sprites.png") .load(function() { g.ui.sprites.base = PIXI.loader.resources.sprites.baseTexture; // Next line fails as g.ui.sprites.base is undefined g.ui.sprites.player = new PIXI.Texture(g.ui.sprites.base, new PIXI.Rectangle(0, 0, 160, 110)); g.restart(); }); Quote Link to comment Share on other sites More sharing options...
JackParke Posted September 23, 2017 Author Share Posted September 23, 2017 Looks like it's PIXI.loader.resources.sprites.texture.baseTexture ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 23, 2017 Share Posted September 23, 2017 5 dots! that's why I use local variables for that king of things, please don't copy & paste it over all the code Quote Link to comment Share on other sites More sharing options...
xerver Posted September 23, 2017 Share Posted September 23, 2017 2 hours ago, JackParke said: Looks like it's PIXI.loader.resources.sprites.texture.baseTexture Yup, sorry about that; I'll edit my original post. ivan.popelyshev 1 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.