Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var renderer = PIXI.autoDetectRenderer(800, 600,{backgroundColor : 0x1099bb});
- document.body.appendChild(renderer.view);
- // create the root of the scene graph
- var stage = new PIXI.Container();
- // create a texture from an image path
- var texture = PIXI.Texture.fromImage('_assets/basics/bunny.png');
- // create a new Sprite using the texture
- var bunny = new PIXI.Sprite(texture);
- // center the sprite's anchor point
- bunny.anchor.x = 0.5;
- bunny.anchor.y = 0.5;
- // move the sprite to the center of the screen
- bunny.position.x = 400;
- bunny.position.y = 500;
- stage.addChild(bunny);
- // start animating
- var t = 0;
- var v = 7.0;
- var y = bunny.position.y;
- animate();
- function animate() {
- requestAnimationFrame(animate);
- if(bunny.position.y > 500){
- t = 0;
- }
- bunny.position.y -= (7.0) + (-0.1*t)/2;
- y -= v;
- console.log(bunny.position.y,y);
- t++;
- v = v - 0.1;
- // just for fun, let's rotate mr rabbit a little
- // render the container
- renderer.render(stage);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement