EvanTheMan Posted November 7, 2014 Share Posted November 7, 2014 Below is the code for SpriteSheet.json:{"frames": {"bunny.png":{ "frame": {"x":208,"y":2,"w":26,"h":37}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":26,"h":37}, "sourceSize": {"w":26,"h":37}, "pivot": {"x":0.5,"y":0.5}},"walking001.png":{ "frame": {"x":2,"y":2,"w":42,"h":42}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":42,"h":42}, "sourceSize": {"w":42,"h":42}, "pivot": {"x":0.5,"y":0.5}},"walking002.png":{ "frame": {"x":46,"y":2,"w":42,"h":42}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":42,"h":42}, "sourceSize": {"w":42,"h":42}, "pivot": {"x":0.5,"y":0.5}},"walking003.png":{ "frame": {"x":134,"y":2,"w":38,"h":42}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":0,"w":38,"h":42}, "sourceSize": {"w":42,"h":42}, "pivot": {"x":0.5,"y":0.5}},"walking004.png":{ "frame": {"x":174,"y":2,"w":32,"h":42}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":5,"y":0,"w":32,"h":42}, "sourceSize": {"w":42,"h":42}, "pivot": {"x":0.5,"y":0.5}},"walking005.png":{ "frame": {"x":90,"y":2,"w":42,"h":42}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":42,"h":42}, "sourceSize": {"w":42,"h":42}, "pivot": {"x":0.5,"y":0.5}}},"meta": { "app": "http://www.codeandweb.com/texturepacker", "version": "1.0", "image": "SpriteSheet.png", "format": "RGBA8888", "size": {"w":236,"h":46}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:395c3df21da85607d6705b30c9e8c168:204ecd49cc53349968e6c2da1202ab95:160eb6758fe4007ba8592b420f92bb0b$"}}Below is the code for Game.js:var RENDER_WIDTH = 800;var RENDER_HEIGHT = 600;// create an new instance of a pixi stagevar stage = new PIXI.Stage(0x66FF99);// create a renderer instancevar renderer = PIXI.autoDetectRenderer(RENDER_WIDTH, RENDER_HEIGHT);// add the renderer view element to the DOMdocument.body.appendChild(renderer.view);var assetsToLoader = ["sprites/SpriteSheet.json"];loader = PIXI.AssetLoader(assetsToLoader);loader.onComplete = onLoadedGame();loader.load();function onLoadedGame() { var ninja = new PIXI.Sprite.fromFrame("walking001.png"); ninja.anchor.x = 0.5; ninja.anchor.y = 0.5; ninja.position.x = RENDER_WIDTH / 2; ninja.position.y = RENDER_HEIGHT / 2; requestAnimFrame( animate );}function animate() { // just for fun, lets rotate mr rabbit a little ninja.rotation += 0.1; var now = new Date().getTime(); var time = now * 0.002; ninja.position.x = (Math.sin( time ) * 96 + 128) + RENDER_WIDTH / 4; ninja.position.y = (Math.cos( time * 0.9 ) * 96 + 128) + RENDER_HEIGHT / 4; // render the stage renderer.render(stage);}Here is a picture of the error:Here is the text of the error:Uncaught Error: The frameId "walking001.png" does not exist in the texture cache[object Object] pixi.js:12 Does anyone know how I can get this working? I'm basically trying to use images from a spritesheet made by TexturePacker. Quote Link to comment Share on other sites More sharing options...
EvanTheMan Posted November 8, 2014 Author Share Posted November 8, 2014 I figured it out, the loader failed to initialize sure to the fact I left out the 'new' keyword.loader = PIXI.AssetLoader(assetsToLoader);Toloader = new PIXI.AssetLoader(assetsToLoader); Quote Link to comment Share on other sites More sharing options...
Mat Groves Posted November 11, 2014 Share Posted November 11, 2014 Nice! Glad to hear you nailed it Quote Link to comment Share on other sites More sharing options...
benunca Posted November 30, 2015 Share Posted November 30, 2015 So how does this now work in v3 since the AssetLoader has been deprecated? Quote Link to comment Share on other sites More sharing options...
mattstyles Posted November 30, 2015 Share Posted November 30, 2015 Basically works the same, I replied to the topic you started for your specific error, hopefully (fingers crossed) that helps! 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.