0

Made some simple game at work and used the fallowing code:

Player player = getOneIntersectingObject(player.class);

Which compiles and executes just fine, at work. Home, however, it won't compile it says that

incopatible types: Greenfoot.Actor cannot be converted to Player.

How is this posible? Player is a child of Actor. At work Greenfoot is 3.01 and at home 3.02, is that the problem? Thanks

melpomene
  • 84,125
  • 8
  • 85
  • 148
  • Same problem if you do `Player player = (Player)getOneIntersectingObject(player.class);`?. Thinking your Java version might be slightly older. – cYrixmorten Dec 04 '16 at 00:10

1 Answers1

0

There were changes to the generics in the Greenfoot API between 3.0.0, 3.0.1 and 3.0.2 so that is the reason why it is behaving differently at home to at work. In each case a cast will make sure it works on every version:

Player player = (Player)getOneIntersectingObject(Player.class);
Neil Brown
  • 3,558
  • 1
  • 27
  • 36