Jump to content
Search Community

Images animation on canvas using pixijs & greenshok

himanshu negi test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

i have put two images but the issue is that both images will be loaded at same time. so animation of first image will be hide due to overlappping of second image.here my code please help me

 

<!doctype html>
<html>
    <head>
        <title>Pixi</title>
    </head>
    <style>
    body{
  background-color: #CB9805;
}
       
    </style>
    <body>
        <canvas id="c"></canvas>
    </body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/TweenMax.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/4.7.3/pixi.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/plugins/PixiPlugin.min.js"></script>
    <script>// Rendering using PIXI
var app = new PIXI.Application(700, 700, {
  view: document.getElementById("c")
});


// Animating using GSAP
         var tl = new TimelineMax();
        
//tl.to(rect, 1, {
//  pixi: {
//    x: 200,
//    rotation:270
//  }
//} ,1)
         // create a new Sprite from an image path
var bunny = PIXI.Sprite.fromImage('layer1.jpg')
app.stage.addChild(bunny); 
        
   
tl.to(bunny, 1, {
  pixi: {
    x: 200,
    autoAlpha: 1
  }
},0.1)
        tl.to(bunny, 1, {
  pixi: {
   autoAlpha: 0
  }
},1)  
    var bunny2 = PIXI.Sprite.fromImage('layer2.jpg')
app.stage.addChild(bunny2);              
tl.to(bunny2, 1, {
  pixi: {
    x: 200,
      autoAlpha: 1
  }

}, 1)
        tl.to(bunny2, 4, {
  pixi: {
    x: 700,
      autoAlpha: 0
  }

},1);
</script>
</html>

Link to comment
Share on other sites

I'm still a little unsure what the problem is. Can you make a demo?

 

 

If your images are on top of each other, just move them.

 

bunny.x = 300;
bunny.y = 400;

// Or use position...

// Sets x to 300 and y to 400
bunny.position.set(300, 400);

// Sets x and y to 500
bunny.position.set(500);

 

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...