While debugging your application it can be useful to show the x- and y-coordinates of a Vec2 on the screen. You could do this the hard way:
Vec2 pos = Ms.pos();
D.text(Vec2(0, 0), S + ”x: ” + pos.x + ” y: ” + pos.y);
However, you’re certainly not the first programmer to draw a Vec2 on screen to check on its value. That’s why the class as a method to make your life a little easier:
Vec2 pos = Ms.pos();
D.text(Vec2(0, 0), S + pos.asText());
// or without the extra step:
D.text(Vec2(0, 0), Ms.pos().asText());
5