Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var renderer = PIXI.autoDetectRenderer(800, 600,{backgroundColor : 0x1099bb});
  2. document.body.appendChild(renderer.view);
  3.  
  4. // create the root of the scene graph
  5. var stage = new PIXI.Container();
  6.  
  7. // create a texture from an image path
  8. var texture = PIXI.Texture.fromImage('_assets/basics/bunny.png');
  9.  
  10. // create a new Sprite using the texture
  11. var bunny = new PIXI.Sprite(texture);
  12.  
  13. // center the sprite's anchor point
  14. bunny.anchor.x = 0.5;
  15. bunny.anchor.y = 0.5;
  16.  
  17. // move the sprite to the center of the screen
  18. bunny.position.x = 400;
  19. bunny.position.y = 500;
  20.  
  21. stage.addChild(bunny);
  22.  
  23. // start animating
  24. var t = 0;
  25. var v =  7.0;
  26. var y = bunny.position.y;
  27. animate();
  28.  
  29. function animate() {
  30.     requestAnimationFrame(animate);
  31.     if(bunny.position.y > 500){
  32.       t = 0;
  33.     }
  34.     bunny.position.y -= (7.0) + (-0.1*t)/2;
  35.     y -= v;
  36.     console.log(bunny.position.y,y);
  37.     t++;
  38.     v = v - 0.1;
  39.     // just for fun, let's rotate mr rabbit a little
  40.    
  41.  
  42.     // render the container
  43.     renderer.render(stage);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement