Search code examples
adobecreatejs

UP ans DOWN in Adobe Animator and with CreateJS


enter image description here I use Adobe Animate, I'm not a basic coder.

I am creating an animation to understand the effect of the moon on the tide.

I manage to run: -The earth on itself indefinitely. -The moon around the earth AND at the same time on itself (we only have the same side of the moon).

For example, I use these functions:

createjs.Ticker.addEventListener("tick", revolution_moon);

function revolution_moon(){
_this.moon_bon.rotation+=-0.009164222874;
}

Per frame the moon rotates by -0.009164222874°

I would like, on the same principle, to evolve an object which goes up and down according to the number of frames. (Rise during so many frames until y=? then go down during so many frames until y=?-1 ).

Anyone have an idea?


Solution

  • According to the link that I posted in the comments and assuming that the "waving" will be somehow synchronized with the rotation you can try something like this:

    createjs.Ticker.addEventListener("tick", revolution_moon);
    
    function revolution_moon(){
      _this.moon_bon.rotation+=-0.009164222874;
      _this.mov_obj.y = Math.sin(2 * Math.PI * _this.moon_bon.rotation / 360) * 204 + 204;
    }
    

    If you need more help, please add a minimal reproducible example of your code.