Mouse Position is not Updated in while-loop

So I’d been racking my brain on this for some time, wondering why my sketch wasn’t working. Then I realized what was wrong. Hopefully anyone in the same predicament and searching the web will find this helpful.

Mouse Position cannot updated inside of a while-loop.

Run this and see:
void setup(){
size(300,300);

}

void draw(){

while (mouseX < 150){
println(“in while-loop”);
println(“frameCount: ” +frameCount);
println(“mouse position: “+mouseX+”, ” +mouseY);
}
println(“out of loop”); //you will never see this

}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.