Is the cat's act method just (assuming the dot is Mouse.class):
if(!getWorld().getObjects(Mouse.class).isEmpty()) {
Mouse mouse = getWorld().getObjects(Mouse.class).get(0);
setRotation((int)(180*Math.atan2(mouse.getY()-getY(), mouse.getX()-getX())/Math.PI));
}
(Would check myself but for some reason I can't DL the source code)
Well actually the line:
Mouse mouse = getWorld().getObjects(Mouse.class).get(0);
should be:
Mouse mouse = (Mouse) getWorld().getObjects(Mouse.class).get(0);
(Just realised after I posted >.<)
Actually, instead of 'getWorld().getObjects(Class class)', what was used was 'getObjectsInRange(int range, Class class)' with a range of 1000. Everything else was pretty much on target, except used 'Math.toDegrees(...)' instead of '180 * (...) / Math.PI'.
This scenario is the example for a blog post I've written explaining the principle. I'll put a link up here once I've published it (either this week or next)
2012/2/15
2012/2/15
2012/2/15
2012/2/15
2012/2/15
2012/2/16
2012/8/6