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

2019/5/19

I want to add an object when an actor is in certain position but the world doesn't add it

1
2
Tasya16 Tasya16

2019/5/20

#
public class Ratu extends Actor
{
  private int frame=0;
    private GreenfootImage dialog1 = new GreenfootImage("dialog4.png");
   // private GreenfootImage gerak2 = new GreenfootImage("ratu2.png");
    public void act() 
    {
dialog();
      setLocation(getX(),getY()+2);
      if(getY()== 500){setLocation(getX(),getY()-2); 
    }   
}
public void dialog()
{ Actor cakap1 = new Dialog1();
    if(frame==200) { getWorld().addObject(new Dialog1(),570,300); } 
else if(frame==220) { getWorld().addObject(new Dialog2(),300,400);}
else if(frame==225) { cakap1.setImage(dialog1);}
frame++;
}
}
i try to use setimage too and it cant work but for adding object it works
danpost danpost

2019/5/20

#
Tasya16 wrote...
<< Code Omitted >> but dialog1 doesn't disappear from the world
That is because dialog1 was never in the world. Again, you have "new Dialog1()" in your code more than once.
You need to login to post a reply.
1
2