This site requires JavaScript, please enable it in your browser!
Greenfoot back
Kingslayer
Kingslayer wrote ...

2021/3/1

Could someone explain to me how this code works?

Kingslayer Kingslayer

2021/3/1

#
I'm making a game for school and I'm not sure how to get the X and the Y coords of my player. So I looked online and I saw this most of the time or a variation of this, but the "Actor Wombat = Goku.get(0);" keeps giving an error; Incompatible types: java.lang.Object could not be converted to greenfoot.Actor. java.util.List Goku = getWorld().getObjects(Wombat.class); if (!Goku.isEmpty()) { Actor Wombat = Goku.get(0); int playerX = Wombat.getX(); int playerY = Wombat.getY(); } thanks
danpost danpost

2021/3/1

#
The middle line should be:
Actor Wombat = (Actor)Goku.get(0);
You need to login to post a reply.