Jump to content

bionicGirl
 Share

Recommended Posts

Hi,

this is my first try with Pixi and I would love to animate it using my fav tweening library Greensock. ABove is my pen. I don't get any errors, yet my displacementMap isn't animating... What am I doing wrong here? Any other improvements are also welcome. Thank you so much!

Link to comment
Share on other sites

Greensock repeat - as per codepen. Thanks!

Also, when I check the debug view and inspect the DOM, it looks like the canvas element has been added after the scripts at the bottom of the page with a width:800 and a height:600px. I never defined that anywhere...

My intention is to actually use a preexisting canvas element in the order that it had been added to the DOM structure as I need to layer it below some other divs. Please advise and see screenshot attached. Thanks!

canvasElement.png

Link to comment
Share on other sites

Take the timeline instance out of the animate method. Right now the animate method is being called on every requestAnimationFrame event, so on every one of those you're creating a new timeline instance which ultimately creates an overwrite issue, that's why the endless loop doesn't happens.

This code works:

animate();

function animate() {
  requestAnimationFrame(animate);
  renderer.render(stage);
}

var tl = new TimelineMax();
tl
 .to(displacementSprite, 10, {
    ease: Linear.easeNone,
    repeat: -1,
    x: -800, 
    y: 800
});

 

Link to comment
Share on other sites

Thanks so much Rodrigo! I am almost there! Now I just don't understand why the canvas element is being added to the bottom of my DOM (where the scripts are).
When I check the debug view and inspect the DOM, it looks like the canvas element has been added after the scripts at the bottom of the page with a width:800 and a height:600px. I never defined that anywhere...My intention is to actually use a preexisting canvas element in the order that it had been added to the DOM structure as I need to layer it below some other divs. Please advise and see screenshot attached. How would I be able to control this?

Thanks!

Link to comment
Share on other sites

I managed that the canvas dimensions are displaying correctly by moving the vars defining width and height above the PIXI.autoDetectRenderer code.

I also changed the z-index of my divs to accommodate the same structure as in the DOM, but I am still curious if there is another way of accomplishing this, since I am already targeting an existing canvas element.

Or is the canvas tag always moved to the bottom before the body closing tag? Thanks!

Link to comment
Share on other sites

Sorry this escaped when I checked the codepen:

document.body.appendChild(renderer.view);

You're basically appending the renderer to the body tag, after the code is executed, hence it goes after the script tags. Append the renderer to the DOM element you want and it'll solve the issue:

var pixiWrap = document.getElementById("banner");

pixiWrap.appendChild(renderer.view);

 

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