New to JS, and web programming.
I have an image moving in the horizontal axis on a canvas. WHen the image gets to a certain point I want it to stop, scale and then rotate. The method i'm using causes an infinite loop and I can't see why.
Here's the method being called
while(this.getScale()<= this.mScale * 5)
this.mScale += 0.5;
while(this.getRotation() <= 360)
this.mRotation += 5;
this.mX += 10;
if(this.goingRight){
this.mX += 5;
}
else
this.mX -=5;
And here's where it's called
update()
...
if(this.mX >400 && this.mX < 403)
this.rotateAndScale();
I'm from a C#/C++ background so this in my eyes should have the effect of halting the execution of the sprite moving left or right until it's been scaled and rotated.
Get rotation:
Sprite.prototype.getRotation = function(){
return this.mRotation;
};
Cheers for your time!