javascriptanimate-cc

Can't loop layers in animateCC using javascript


I have a project to do about the solar system and as my main page, I want to put an animation of all planets circuling about the sun, but since each planet has it's time for the loop around the sun, I need to repeat each layer diferent amount of times so it all ends at some point when all the planets are aligned just as they started.

So, for this I'm working with javascript and animations in AnimateCC.enter image description here

As you can see, each layer repeats itself the times it needs to but to make them all aligned again, it would take a lot of copy paste. So I want to know if there is any function that allows to repeat a layer X times.


Solution

  • So, instead of repeating the layers, I just made de code for the planets to get a circular motion and it will repeat it self always.

    Here is the code:

    var _this = this;
    var velocidadeFundo = 0.001;
    var radianosFundo = 0;
    var coordenadaFundoX = _this.Fundo.x; 
    var coordenadaFundoY = _this.Fundo.y; 
    
    function circularFundo (){
        radianosFundo += velocidadeFundo;
        _this.Fundo.x = coordenadaFundoX + Math.cos(radianosFundo)*20;
        _this.Fundo.y = coordenadaFundoY + Math.sin(radianosFundo)*20;
    }
    
    setInterval(circularFundo, 1);