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

2020/9/1

little-crab scenario, changing the crabs image

Bambus Bambus

2020/9/1

#
I tried the little-crab scenario and wanted to change the crabs image everytime it moves by 1 ( public void act() { if (isTouching(worm.class)){ eatWorm(); } else{ move(1); checkKeys(); } ) but I do not know how to change it as setImage and get Image won't work. It says wrong reciever parameter whenever I use public void setImage​(java.lang.String crab2.png); Appreciate your time trrying to help me (:
danpost danpost

2020/9/1

#
Bambus wrote...
I tried the little-crab scenario and wanted to change the crabs image everytime it moves by << Code Omitted >> but I do not know how to change it as setImage and get Image won't work. It says wrong reciever parameter whenever I use public void setImage​(java.lang.String crab2.png); Appreciate your time trrying to help me (:
java.lang.String is the type of parameter. "crab2.png" is a literal of that type. The proper usage is:
setImage("crab2.png");
Bambus Bambus

2020/9/1

#
Thanks. It wokred (:
You need to login to post a reply.