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

2019/2/26

check which image has the character

CodeMaster1234 CodeMaster1234

2019/2/26

#
GreenfootImage image1 = new GreenfootImage("ninja.png"); GreenfootImage image2 = new GreenfootImage("ninjastg.png"); i have this and i need to know when the character has image1 and when the character has image2 is there a method like: if(Greenfootimage==image1) ??
danpost danpost

2019/2/26

#
CodeMaster1234 wrote...
GreenfootImage image1 = new GreenfootImage("ninja.png"); GreenfootImage image2 = new GreenfootImage("ninjastg.png"); i have this and i need to know when the character has image1 and when the character has image2 is there a method like: if(Greenfootimage==image1) ??
There is a comparison like:
if (getImage() == image1)
CodeMaster1234 CodeMaster1234

2019/2/27

#
and if i want to write this but in another actor code is someting like: if (getImage(actor1.class) == image1)?? //i tried this but doesn t work=))
Andrew.2 Andrew.2

2019/2/27

#
you'd have to use something like this
youractor actor = (youractor) getWorld().getObjects(youractor.class).get(0);
if (actor.getImage()==image1)
CodeMaster1234 CodeMaster1234

2019/2/27

#
can you help me a little more like i have to chech image of actor1 in actor2 editor, Where should i write these codes and which is actor1 and which is actor2? sorry i m a begginer. :((
You need to login to post a reply.