0

For a project I am making a memory game, but I am trying to make to objects disappear when the are equal. This is my code:

public void opencard(){
    int duiker = 0;
    int duiker2 = 0;
    if (duiker == duiker2){
        if(Greenfoot.mouseClicked(Duiker.class)){
            setImage("duiker_tcm46-175501.jpg");
            if(Greenfoot.mouseClicked(duiker2)){
                duiker2 = 1;
            }

            duiker = 1;{
                getWorld().removeObject(this);
            }
        }
        else if(Greenfoot.mouseClicked(this)){
           setImage("duiker_tcm46-175501.jpg");
           Greenfoot.delay(150);

          setImage("150px_RGB_WEBSAFE_D_B_G_26-29652.gif");
        }
    }
}

But they disappear even when I don't click on them.

  • 3
    1) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve). 2) One way to get image(s) for an example is to hot-link to the images seen in [this answer](http://stackoverflow.com/a/19209651/418556). – Andrew Thompson Jan 17 '14 at 09:56
  • 1
    @AndrewThompson +1 for the new MCVE page. Although it has become MCTRE now :) – Marko Topolnik Jan 17 '14 at 10:19
  • 1
    @MarkoTopolnik Thanks! As to the changes, (eh, shrugs) it is community driven, which is a good thing, so open to change. OTOH I will stick with MCVE *for the moment,* just in case it changes back, or changes yet again. ;) – Andrew Thompson Jan 17 '14 at 10:25
  • my english is not that good but if somebosy can give m advice that would be helpfull – user3058027 Jan 17 '14 at 11:01
  • I think your are messing things up! First you use the "mouseClicked"-function with "Duiker.class" as argument and the second time you use "this" as argument. Please show us more code of the class "Duiker". – EightBitBoy Jan 17 '14 at 12:03

0 Answers0