Jump to content

How to get cached Texture into from Frame animation


migasubi
 Share

Recommended Posts

I'm having trouble accessing a cached Texture and using it in fromFrame function.

var app = new PIXI.Application(1500,900, { backgroundColor : 0xEAEAEA, antialias: true }); 
   
document.body.appendChild(app.view).setAttribute("id", "myCanvas");
 
var image_1 = new Image(); 
image_1.src = "data:image/png;base64......"; 
var fighterBase = new PIXI.BaseTexture(image_1);
var fighterTexture = new PIXI.Texture(fighterBase);
 
  
 PIXI.loader
 	.add( "./migasubi/img/fighter.json", ) 
 	.load(tieFighterSetup);  
        
 function tieFighterSetup() {
   
	PIXI.Texture.addToCache(fighterTexture, "fighter.png"); 

         var frames = [];
     
         for (var i = 0; i < 4; i++) {
             
             var val = i < 10 ? '0' + i : i;
      
             frames.push(PIXI.Texture.fromFrame('rollSequence00' + val + '.png'));
         
          }
      
         var anim = new PIXI.extras.AnimatedSprite(frames);
      
         anim.x = app.renderer.width / 2;
         anim.y = app.renderer.height / 2;
         anim.anchor.set(1); 
         anim.scale.x = 0.5;
         anim.scale.y = 0.5;
         anim.animationSpeed = 0.5;
         anim.play(); 
         app.stage.addChild(anim);
       
 }


{"frames": {

"rollSequence0000.png":
{
    "frame": {"x":483,"y":692,"w":169,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":4,"w":169,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0001.png":
{
    "frame": {"x":468,"y":2,"w":169,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":4,"w":169,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0002.png":
{
    "frame": {"x":639,"y":2,"w":167,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":5,"w":167,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0003.png":
{
    "frame": {"x":808,"y":2,"w":165,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":5,"w":165,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0004.png":
{
    "frame": {"x":654,"y":688,"w":161,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":5,"w":161,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0005.png":
{
    "frame": {"x":817,"y":458,"w":151,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":6,"y":5,"w":151,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0006.png":
{
    "frame": {"x":817,"y":686,"w":137,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":11,"y":5,"w":137,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0007.png":
{
    "frame": {"x":290,"y":2,"w":113,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":22,"y":3,"w":113,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0008.png":
{
    "frame": {"x":284,"y":692,"w":79,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":40,"y":3,"w":79,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0009.png":
{
    "frame": {"x":405,"y":2,"w":61,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":53,"y":3,"w":61,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0010.png":
{
    "frame": {"x":444,"y":462,"w":49,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":64,"y":3,"w":49,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0011.png":
{
    "frame": {"x":377,"y":462,"w":65,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":52,"y":3,"w":65,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0012.png":
{
    "frame": {"x":272,"y":462,"w":103,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":37,"y":3,"w":103,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0013.png":
{
    "frame": {"x":143,"y":692,"w":139,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":20,"y":3,"w":139,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0014.png":
{
    "frame": {"x":2,"y":462,"w":163,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":7,"y":3,"w":163,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0015.png":
{
    "frame": {"x":2,"y":2,"w":171,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":2,"y":3,"w":171,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0016.png":
{
    "frame": {"x":2,"y":232,"w":163,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":4,"y":3,"w":163,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0017.png":
{
    "frame": {"x":2,"y":692,"w":139,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":16,"y":3,"w":139,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0018.png":
{
    "frame": {"x":167,"y":462,"w":103,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":35,"y":3,"w":103,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0019.png":
{
    "frame": {"x":365,"y":692,"w":65,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":58,"y":3,"w":65,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0020.png":
{
    "frame": {"x":432,"y":692,"w":49,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":62,"y":3,"w":49,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0021.png":
{
    "frame": {"x":389,"y":232,"w":61,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":61,"y":3,"w":61,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0022.png":
{
    "frame": {"x":306,"y":232,"w":81,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":55,"y":3,"w":81,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0023.png":
{
    "frame": {"x":175,"y":2,"w":113,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":39,"y":3,"w":113,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0024.png":
{
    "frame": {"x":167,"y":232,"w":137,"h":228},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":26,"y":3,"w":137,"h":228},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0025.png":
{
    "frame": {"x":664,"y":458,"w":151,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":18,"y":5,"w":151,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0026.png":
{
    "frame": {"x":792,"y":230,"w":161,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":11,"y":5,"w":161,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0027.png":
{
    "frame": {"x":623,"y":230,"w":167,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":6,"y":5,"w":167,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0028.png":
{
    "frame": {"x":495,"y":460,"w":167,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":5,"y":5,"w":167,"h":226},
    "sourceSize": {"w":175,"h":240}
},
"rollSequence0029.png":
{
    "frame": {"x":452,"y":232,"w":169,"h":226},
    "rotated": false,
    "trimmed": true,
    "spriteSourceSize": {"x":3,"y":4,"w":169,"h":226},
    "sourceSize": {"w":175,"h":240}
}},
"meta": {
    "app": "http://www.texturepacker.com",
    "version": "1.0",
    "image": "fighter.png",
    "format": "RGBA8888",
    "size": {"w":1024,"h":1024},
    "scale": "1",
    "smartupdate": "$TexturePacker:SmartUpdate:2f213a6b451f9f5719773418dfe80ae8$"
}
}

Getting the following errors:

  1. fighter.png 404 (Not Found)

  2. frame does not fit inside the base Texture dimensions: X: 483 + 169 > 1 Y: 692 + 226 > .....

 

 

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