Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dexxa

while changing the angle of an entity, i encountered a problem. this is my code and it's in the update function.

            if(this.direction == "up")
                this.anims.idle.angle += 0.1;
            else
                this.anims.idle.angle -= 0.1;

            if(this.anims.idle.angle < -1.1)
                this.direction = 'up';
            else if(this.anims.idle.angle > 0.3)
                this.direction = 'down';

it slows down to almost complete stop after 5 or 6 hundred runs of the update function. anyone know why?

1 decade ago by dominic

Your code seems fine. It shouldn't slow down. Maybe you're manipulating the .angle somewhere else, too?

You should however multiply your rotation speed with the tick value, to be framerate independent. E.g.:

this.anims.idle.angle += 6 * ig.system.tick;
Page 1 of 1
« first « previous next › last »