Hello, I'm trying to compare two images and see if they are the same. However it never returns true. Can someone help me?
there is another class called "Mensch" which has
in it.
So I'm trying to set 'immun' to '1' whenever the object has the image 'immun.png'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | public void KrankenhausRadar() { liste = getObjectsInRange(radius,Mensch. class ); groesse = liste.size(); if (liste.size()> 0 && i < liste.size()) //(!getObjectsInRange(200, Mensch.class).isEmpty()) { if (Greenfoot.getRandomNumber( 100 )< 30 ) { Mensch mensch = getObjectsInRange(radius, Mensch. class ).get(i); GreenfootImage myImage; myImage = new GreenfootImage( "immun.png" ); mensch.setImage(myImage); if (mensch.getImage()==img){ Mensch.immun = 1 ; System.out.println( "yas it works" ); } i=i+ 1 ; } } } |
1 | public static int immun; |