locked
Windows 8 app Game Animation speed increased when Laptop is on Power chord,Normal speed is seen when on battery-Reason for this behaviour required RRS feed

  • Question

  • The Game is developed for windows 8 app store using HTML5 and JavaScript, CreateJS is also used for most the functions.The object which moves by incrementing coordinates works normally and with normal speed as expected when the laptop is on Battery, the moment laptop is plugged to power the animation picks up speed and overall all game looks as though its fast forwarded.

    Any pointers for this behavior is much appreciated.

    Wednesday, November 28, 2012 5:44 AM

Answers

  • In your gameLoop function you should check how much time has elapsed and update positions accordingly. The exact time between when it is called is not deterministic and so you need to be able to handle if it is called more or less often than planned.

    I'm not familiar enough with how createjs.Ticker works to know exactly what behavior is expected. Often the tick interval is a minimum time before ticks. It is impossible for it to be an exact time.

    --Rob

    • Marked as answer by Song Tian Tuesday, December 4, 2012 2:59 PM
    Wednesday, November 28, 2012 6:43 AM
    Moderator

All replies

  • How is the speed of the object calculated? Is it tied to real time or does it loop?

    Laptops often reduce CPU speed on battery to conserve power.

    --Rob

    Wednesday, November 28, 2012 6:18 AM
    Moderator
  • Hi Rob,

    Thanks for that quick response.

    Please find the pseudo functions:

    On Initializing StartGame function is called ,the game loop simply adds assigns the new co ordinates in to put the object in new location.
    The functions which assigns the new position seems to be called more often ie:2x times when laptop is on power.

    Initialize()
    { startGame();    }

    functionstartGame() {

            createjs.Ticker.setInterval(window.requestAnimationFrame);

            createjs.Ticker.addListener(gameLoop);

        }
    functiongameLoop() {
    update();
    draw();
    }

     

     

     

     

     

     

     

       

     

     

     

     

       

     

     

     

     

    Wednesday, November 28, 2012 6:32 AM
  • In your gameLoop function you should check how much time has elapsed and update positions accordingly. The exact time between when it is called is not deterministic and so you need to be able to handle if it is called more or less often than planned.

    I'm not familiar enough with how createjs.Ticker works to know exactly what behavior is expected. Often the tick interval is a minimum time before ticks. It is impossible for it to be an exact time.

    --Rob

    • Marked as answer by Song Tian Tuesday, December 4, 2012 2:59 PM
    Wednesday, November 28, 2012 6:43 AM
    Moderator