Adding a Compass (draft)

Shows how to add an interactive compass UI to the map.

How to add a compass

To test the compass you can rotate the map via a and d.



Check out the

To add a compass you only need the compass object

CompassUI compass;

initialize it in your setup()

compass = new CompassUI(this,map);

and draw it in your draw()


Thats it, easy peasy.


We have also a more complex constructor for you, to make various changes like display a custom compass image.

public CompassUI(PApplet p, AbstractMapDisplay mapDisplay, PImage img, float x, float y)
  • mapDisplay: your mapDisplay
  • img: the PImage you want to use as a compass
  • x: absolute x
  • y: absolute y

To change the compass image you need to initialize a new PImage and initialize the compass with it:

PImage compassImg = loadImage("compass_grey.png");
compass = new CompassUI(this, map.mapDisplay, compassImg, 700, 100, 1);