Jump to content

PIXI.Sprite.call () passing an id of loaded texture atlas


batman
 Share

Recommended Posts

Hi, everyone. Could you advise how correctly pass id of image form atlas when you create class? 

Thank you in advance, 

My class code: 

 
var id= PIXI.loader.resources ["assets/images/sprites.json"].textures; 
function Tower() {
//var towerTexture = TextureCache["Tower_1.png"]//PIXI.Texture.fromImage() // this one works fine
PIXI.Sprite.call(this, id["Tower_1.png"]); // when i use like this i got error that  Cannot read property 'Tower_1.png' of undefined
this.x = 20;
this.y = 20;
}
Tower.prototype = Object.create(PIXI.Sprite.prototype);
 
And of course loader from main:
loader
.add("assets/images/tower/sprites.json")
.load(setup);
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...