Jump to content

Any idea how to stop object from flickering


Recommended Posts

Currently I am working on a project that requires moving the clock hands, where the hour hand moves 30 degrees while the minute hand moves by 6 degrees.


However,  I have this issue of the object flickering whenever I stopped at a point.

Issue Example:

Right now this is my code for moving the minute hand and the hour hand


dragMinutes: function(){
        minutes += direction; //0.5 is speed
        hours = (minutes/1440)*24; //24h = 1440 minutes,


    dragHours: function(){
        hours += direction; //0.05 is speed

        //minutes = hours* 60;

    calculateAngles: function(dial){
        //round to whole numbers
        mouseangle = Math.floor(this.game.physics.arcade.angleToPointer(dial)*180/Math.PI);
        //difference between mouse and dial
        difference = Math.abs(mouseangle - dial.angle);
        //if reached 9 o clock going counterclockwise, reverse the difference calculation.
            difference = 180 - mouseangle + dial.angle;
            difference = mouseangle - dial.angle;
        if(difference < 0){
            direction = -1;
        }else if (difference == 0){
            direction = 0;
        }else if (difference > 0){
            direction = 1;

In the Update Function:


if (minute.input.pointerDown())
            minutes = hours*60;
        if (hour.input.pointerDown())


 minute.angle = minutes*6 -90;//6 degrees = 1 minute, 90 degrees, because 12 o clock is facing upward
        minute.angle = Math.round(minute.angle);

hour.angle = hours*30-90; //30 degrees = 1 hour
        hour.angle = Math.round(hour.angle);

Is there anyway to fix it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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