I am using the game_loop pub package to handle my eventloop. The problem is that it updates way too often. I don't need to update or redraw that often, and input key repetition is also too fast. I do not know much about eventloops or browser redraws, so I might think of it the wrong way, but is there a way to slow the loop down?
            Asked
            
        
        
            Active
            
        
            Viewed 397 times
        
    1
            
            
         
    
    
        Mathias Bak
        
- 4,687
- 4
- 32
- 42
- 
                    I think you should always draw as fast as possible. What do you mean by input key repetition? – Robert Jun 05 '14 at 06:32
- 
                    I think the input key repetition is an operating system setting. – Günter Zöchbauer Sep 07 '14 at 09:05
2 Answers
1
            
            
        Run heavy tasks in the separate Isolate while keeping game loop as lightweight as possible. The game loop should be implemented with  window.animationFrame. How do I drive an animation loop at 60fps with Dart? You should learn all about requestAnimationFrame  - it's the key to the smooth animations.
And your game logic speed should not depend on the browser FPS(Frames Per Second) use scheduler instead Does Dart have a scheduler?
0
            
            
        Try adding a timer and avoid adding an onUpdate or onRender handler to your GameLoop instance:
//timer fires 20 times per second, as an example
gameLoop.addTimer(render,0.05,periodic: true);
...
...
render(GameLoopTimer timer)
{
    //draw or update code here
}
 
    
    
        Günter Zöchbauer
        
- 623,577
- 216
- 2,003
- 1,567
 
    
    
        NullPumpkinException
        
- 1,396
- 1
- 18
- 22
 
    