Jump to content

Can load 2 images , but not 4 ?


vmars316
 Share

Recommended Posts

Hello & Thanks ,

 

Ugh! I have been working on this all day .

Below is code to load and move 2 images :

 

   //Create the `truth02` sprite 
   truth02 = new Sprite(resources["images/truth02.png"].texture);
   truth02.y = 228; 
   stage.addChild(truth02);
  
   //Create the `lies02` sprite
   lies02 = new Sprite(resources["images/lies02.png"].texture);
   lies02.y = 304
   stage.addChild(lies02);
...
  //Move the truth02 1 pixel per frame
  truth02.x += 1;
  //Move the lies02 1 pixel per frame
  lies02.x += 2;
 
And all works well , until i add one or two more images .
I can't spot my error ,need help ! 
Pics are in the attached .zip .truth-lies.zip
 
Thanks...Vern
 
<!doctype html><meta charset="utf-8"><title>Moving sprites</title><body><!-- <script src="../pixi.js/bin/pixi.js"></script> --><script src="C:\pixi.js\bin\pixi.js"></script><script>//Aliasesvar Container = PIXI.Container,    autoDetectRenderer = PIXI.autoDetectRenderer,    loader = PIXI.loader,    resources = PIXI.loader.resources,    TextureCache = PIXI.utils.TextureCache,    Texture = PIXI.Texture,    Sprite = PIXI.Sprite;//Create a Pixi stage and renderer and add the //renderer.view to the DOMvar stage = new Container(),    renderer = autoDetectRenderer(500, 700);document.body.appendChild(renderer.view);loader//  .add("images/truth01png")//  .add("images/lies01.png")  .add("images/truth02.png")  .add("images/lies02.png")  .load(setup);//Define any variables that are used in more than one function//var truth01;//var lies01;var truth02;var lies02;function setup() {   //Create the `truth01` sprite //   truth01 = new Sprite(resources["images/truth01.png"].texture);//   truth01.y = 2; //   stage.addChild(truth01);      //Create the `lies01` sprite//   lies01 = new Sprite(resources["images/lies01.png"].texture);//   lies01.y = 150;//   stage.addChild(lies01);         //Create the `truth02` sprite    truth02 = new Sprite(resources["images/truth02.png"].texture);   truth02.y = 228;    stage.addChild(truth02);     //Create the `lies02` sprite   lies02 = new Sprite(resources["images/lies02.png"].texture);   lies02.y = 304   stage.addChild(lies02);  //Start the game loop  gameLoop();}function gameLoop(){  //Loop this function 60 times per second  requestAnimationFrame(gameLoop);  //Move the truth01 1 pixel per frame//  truth01.x += 1;  //Move the lies02 1 pixel per frame//  lies01.x += 2;    //Move the truth02 1 pixel per frame  truth02.x += 1;  //Move the lies02 1 pixel per frame  lies02.x += 2;  //Render the stage  renderer.render(stage);}</script></body>

 

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