Jump to content

time interval between elements of a group


julilopez
 Share

Recommended Posts

I create a group based on a spritesheet and random. 

 

I want a timespan whenever my group elements are generated occur.

 


this.circles= this.add.group();


for (var numCircles = 0; numCircles < 50; numCircles++) { 
            randomCircle = this.game.rnd.integerInRange(0, 10),  
            circle = this.circles.create(this.randomWorldX(), this.randomWorldY(), "circlesImage", randomCircle);            
            this.circles.forEach(this.distanceCircle(), this); 
         } 


this.circles.setAll("body.velocity.x", - 100); 
distanceCircle: function(circles) { 
        var positionX = this.circle.position.x;         
        positionX = positionX * positionX; 
   
        var positionY = this.circle.position.y; 
        positionY = positionY * positionY; 
   
        if (Math.sqrt( positionX + positionY ) < 40 ) { 
            this.circle.reset(this.randomWorldX(), this.randomWorldY()); 
            this.circles.forEach(separate, this);

}

But this returns the following error: 

 

Uncaught TypeError: Can not call method 'apply' of undefined. 

 

Thanks. 

       

    

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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