Jump to content
GreenSock

Michael71

Animating with the new KineticJS

Moderator Tag

Recommended Posts

Hello,

 

I was working with the new KineticJS version and the 2D Physics from GSAP.

 

Although there is no visible error, I can't seem to animate an element the way I used to, with TimelineMax/Lite and "onUpdate:stage.draw", "onUpdateScope:stage"

Anyone has any ideas or has faced similar problem?

 

I have set up a codepen here: http://cdpn.io/lzkbu

 

Thanks in advance!

 

Link to comment
Share on other sites

Hi Michael,

 

I see the problem. I don't know how familiar you are with KineticJS, but Kinetic objects don't have x and y properties. They have setX(), setY(), getX() and getY() methods.

 

The physics2D plugin assumes you mean to change the x/y properties of the target object (which Kinetic objects don't have).

 

The plugin is very flexible and allows you to specify the yProp and xProp (see docs)

 

 

 

TweenMax.to(dot,2,{physics2D:{
      velocity:getRandom(80, 380), 
      angle:-10, 
      gravity:400,
     xProp:"setX",
     yProp:"setY"
    }
    }));

 

I modified your code and forked your pen

 

See the Pen baae401528b749d711124008bace83ca by GreenSock (@GreenSock) on CodePen

  • Like 1
Link to comment
Share on other sites

Ah yes... I always seem to forget that part... Thanks Carl, once again to save my poor animations :)

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