here the code
the Dialogue class there in HowToplay World
here the world code
my question is how to change the picture in METAL_WOLF_ANTHRO.class if in dialogue length at 0,2, and 7?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class METAL_WOLF_ANTHRO here. * * @author (your name) * @version (a version number or a date) */ public class METAL_WOLF_ANTHRO extends NPC { /** * Act - do whatever the MGX wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() {((Dialogue)getWorld().getObjects(Dialogue.class).get(0)) this.class.setImage("Char/MGX/MGX 1.png"); ((Dialogue)getWorld().getObjects(Dialogue.class).get(2)) this.class.setImage("Char/MGX/MGX 2.png"); ((Dialogue)getWorld().getObjects(Dialogue.class).get(7)) this.class.setImage("Char/MGX/MGX 2.png"); } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class HowToplay here. * * @author (your name) * @version (a version number or a date) */ public class HowToplay extends World {public String[] dialogue5 = {"Oh hi !", "My name is MWA MK CCCVIX or you can call me Metal Wolf Anthro MK CCCVIX.", "I will explain how the mechanism of this game The Wolf,", "Press A for move left,", "Press D for move right,", "Press S for move backward,", "Press W for move forward,", "Let's help Blizzard to complete his mission!" }; /** * Constructor for objects of class HowToplay. * */ public HowToplay() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(1024, 768, 1); prepare(); METAL_WOLF_ANTHRO mETAL_WOLF_ANTHRO = new METAL_WOLF_ANTHRO(); addObject(mETAL_WOLF_ANTHRO,204,419); adddialog(); } public void adddialog() { Dialogue dialogue = new Dialogue(dialogue5); addObject(dialogue, 600,26); } public void act() {if (!getObjects(Dialogue.class).isEmpty() && "z".equals(Greenfoot.getKey())) { ((Dialogue)getObjects(Dialogue.class).get(0)).nextText(); } } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { } }