Have a boolean variable that tracks the state of the icon.
When the icon is clicked, toggle the boolean's value.
When updating the positions of the people on the map, only do so if the value of the boolean is false.
Also draw the names of the people on the map next to them if the value of the boolean is true.
Here is an example sketch:
- boolean moveOk = true;
- class Bloop{
- float x, y;
- color c;
- Bloop(){
- x = random(width);
- y = random(height);
- c = color( random(255),random(255),random(255) );
- }
- void simulate(){
- if( moveOk ){
- x+=random(-2,2);
- y+=random(-2,1);
- x+=width;
- y+=height;
- x%=width;
- y%=height;
- }
- }
- void render(){
- stroke(0);
- fill(c);
- ellipse( x, y, 10, 10 );
- if( !moveOk ){
- noFill();
- stroke(255);
- ellipse( x, y, 15, 15 );
- }
- }
- }
-
- Bloop[] bloops;
-
- void setup(){
- size(200,200);
- smooth();
- bloops = new Bloop[10];
- for( int i = 0; i < bloops.length; i++){
- bloops[i] = new Bloop();
- }
- }
- void draw(){
- background(0,64,0);
- if( !moveOk ){
- background(64,0,0);
- }
- for( int i = 0; i < bloops.length; i++){
- bloops[i].simulate();
- bloops[i].render();
- }
- }
- void mousePressed(){
- moveOk = !moveOk;
- }