Jump to content

Confused About Pre-Loading PNG Image Sprites...


Recommended Posts


Making good progress with our new PixiJSv4 Internet game.

I am confused about pre-loading PNG image sprites.

I loaded the open-source demo on the tutorial page and have been modifying it to my own needs.

The following code confuses me:

	function setup()
        //Make the game scene and add it to the stage
        gameScene = new Container();
        //Make the sprites and add them to the `gameScene`
        //Create an alias for the texture atlas frame ids
        id = resources["images/treasureHunter.json"].textures;
        dungeon = new Sprite(id["dungeon.png"]);
        door = new Sprite(id["door.png"]);
        door.position.set(32, 0);
        explorer = new Sprite(id["explorer.png"]);
        explorer.x = 68;
        explorer.y = gameScene.height / 2 - explorer.height / 2;
        explorer.vx = 0;
        explorer.vy = 0;

        treasure = new Sprite(id["treasure.png"]);
        treasure.x = gameScene.width - treasure.width - 48;
        treasure.y = gameScene.height / 2 - treasure.height / 2;

What is: "id = resources["images/treasureHunter.json"].textures;" ?

I plan to have all PNG image sprites in a sub folder called "images".

Any help would be appreciated, thanks!


Link to comment
Share on other sites

it comes from PIXI.loader : http://pixijs.download/dev/docs/PIXI.loaders.Loader.html


function setup(loader, resources)
	var id = resources["images/treasureHunter.json"].textures;
	// object with generated textures (dungeon.png, door.png, ..)


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...