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

2014/11/18

Click Two or More Places

1
2
meazalplaq meazalplaq

2014/11/18

#
I have been using the MouseInfo mouse = Greenfoot.getMouseInfo() and the if (Greenfoot.mouseClicked(this) && mouse.getX() > 308 && mouse.getX() < 355 && mouse.getY() > 259 && mouse.getY() < 297) to create areas on an image that when clicked will perform an action. Is it possible to create a condition statement that requires the mouse to be click in two or more areas on the image before something is allowed to occur? So far, this is what I have; however, it does not work:
  public void wireRed_01() 
    {
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
           
             if (Greenfoot.mouseClicked(this) && mouse.getX() > 308 && mouse.getX() < 355 && mouse.getY() > 259 && mouse.getY() < 297 && Greenfoot.mouseClicked(this) && mouse.getX() > 521 && mouse.getX() < 575 && mouse.getY() > 259 && mouse.getY() < 297)
             
            {          
                 getWorld().addObject(new Wire_Red_01(), 445,274);          
                 getWorld().setPaintOrder(Wire_Red_01.class);
                 
                  

        }
        }
    }
jimboweb jimboweb

2014/11/18

#
If you want them to click more than once on the same image, create a variable like
int timesImageClicked = 0;
then replace what's inside your 'if' statement with something like:
timesImageClicked++;
if (timesImageClicked >1)
{
//...whatever you want to happen when they've clicked twice here
timesImageClicked = 0; //to reset it after they've clicked twice. 
}
danpost danpost

2014/11/18

#
Asking if the mouse was clicked on the same object twice within the same codeset will not change what is returned. In other words, you will be testing the same state twice and get a duplicate response. You need to have a click detected twice with a group of act cycles in between where the mouse did not click anything else (and possibly within a specified time-frame or limited number of act cycles in between). An instance int field could be used -- if the value of it is at zero then the state will be that it is waiting for its first click, when you will set its value to the number of act cycles (or frames) that the second click must be detected by. While the value of the field is not zero, the value should be decremented and a check should be made for any mouse clicks anywhere. If a second mouse click is detected, first reset the field back to zero; then if the second click was in the specified area, do whatever needs to occur.
meazalplaq meazalplaq

2014/11/19

#
Thank you for the replies and help. This code functions when it does not have to look for a second point on the image. Am I on the right track with this set up??
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Puzzle_01 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Puzzle_01 extends Actor

{
       
      int timesImageClicked = 0;
        
    public Puzzle_01()
    {
        GreenfootImage myPic = new GreenfootImage(1024, 640);
        myPic.fill();
        myPic.drawImage(new GreenfootImage("Puzzle_01.jpg"),0,0);
//         myPic.drawImage(new GreenfootImage("exit.png"), 540, 10);
        setImage(myPic);
    }
    public void act() 
    {
      
            wireRed_01();

    }    
     
   

  public void wireRed_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
             if (Greenfoot.mouseClicked(this) && mouse.getX() > 308 && mouse.getX() < 355 && mouse.getY() > 259 && mouse.getY() < 297 )
                  
            {          
                    timesImageClicked++;  
                  
               if (timesImageClicked >1)
                    
               {
//                      timesImageClicked = 0; 
                     
                    if (Greenfoot.mouseClicked(this) && mouse.getX() > 521 && mouse.getX() < 575 && mouse.getY() > 259 && mouse.getY() < 297 )
                  
            {        
                
                   
                    timesImageClicked++;  
                    
                     if (timesImageClicked >1)
                     {
                     
                  timesImageClicked = 0; 
                 getWorld().addObject(new Wire_Red_01(), 445,274);          
                 getWorld().setPaintOrder(Wire_Red_01.class);
                 
                
                 
                 
                  }

        }
        }
    }
    }
}
}
danpost danpost

2014/11/19

#
You do not need a 'timesImageClicked' field, you need a 'timeWindowForSecondClick' field (a shorter name, but not quite as descriptive, might be 'clickTimer'). Basically, you would use something like the following:
// instance field
private int clickTimer;
// in act or method it calls
if (clickTimer > 0) clickTimer--;
if (clickTimer == 0 && Greenfoot.mouseClicked(this)) clickTimer = 200); // first click
if (clickTimer > 0 && Greenfoot.mouseClicked(null)) // second click
{
    if (Greenfoot.mouseClicked(this))
    {
        // perform actions here
    }
    clickTimer = 0;
}
I did not include the checks for the area here; but, you can add them in where needed.
meazalplaq meazalplaq

2014/11/19

#
Thanks. What is the clickTimer = 200 ? What does it do?
danpost danpost

2014/11/19

#
meazalplaq wrote...
Thanks. What is the clickTimer = 200 ? What does it do?
It starts the timer. The user will have about 3.5 to 4.0 seconds to click on the second location before the first click is disregarded. Line 4 runs the timer and the 'if' block at lines 6 through 13 stops the timer (with or without any action being performed depending on if the second click was where it was supposed to be).
meazalplaq meazalplaq

2014/11/21

#
The code does work in my scenario; however, for some reason, it is a little unstable. I am trying to create a scenario where the user has to rewire a fuse box that will unlock a door. The code does work, but sometimes the locations that are clicked on connect the wrong wires. I am using setTransparency to hide and unhide the wires according to where the user clicks on the image, and an Actor subclass called Overlay_Puzzle_01 with its transparency set to zero for the user to click to connect the wires. Any ideas where I need to start to make things a bit more stable? Thank you. ------------------------------
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
 * Write a description of class Overlay_Puzzle_01 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Overlay_Puzzle_01 extends Actor
{
        private int clickTimer_Red_01;
        private int clickTimer_Red_02;
        private int clickTimer_Red_03;
        public int clickTimer_Blue_01;  
        private int clickTimer_Blue_02;  
        private int clickTimer_Blue_03;
        private int clickTimer_Yellow_01;
        private int clickTimer_Yellow_02;
         private int clickTimer_Yellow_03;
        
    
         public Overlay_Puzzle_01()
    {
    GreenfootImage fade = new GreenfootImage (1024, 640);
    Color black = new Color (0,0,0);
        fade.fill();
fade.drawImage(new GreenfootImage("Overlay_Puzzle_01.jpg"),0,0);
        fade.setTransparency (50);
        setImage (fade);

    }
    /**
     * Act - do whatever the Overlay_Puzzle_01 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
         wireRed_01();
         wireRed_02();
         wireRed_03();
         wireBlue_01();
         wireBlue_02();
         wireBlue_03(); 
         wireYellow_01();
         wireYellow_02();
         wireYellow_03(); 
         
         
    }    
    
     public void wireRed_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_01 > 0) clickTimer_Red_01--;  
if (clickTimer_Red_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 255 && mouse.getY() < 306) // first click  
 clickTimer_Red_01 = 200;
if (clickTimer_Red_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{  
       showWire_Red_01();
       hideWire_Red_02(); 
       hideWire_Red_03();
    
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_01.class).isEmpty())
                     {
              
                 
                 getWorld().addObject(new Wire_Red_01(), 446,273);
                   
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Red_01.class, Button_01_off.class);

                  }
                    clickTimer_Red_01 = 0;

        }
        }
    }
    
      public void wireRed_02() 
    {
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_02 > 0) clickTimer_Red_02--;  
if (clickTimer_Red_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 244 && mouse.getY() < 306) // first click  
 clickTimer_Red_02 = 200;
if (clickTimer_Red_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  
     showWire_Red_02();
     hideWire_Red_01(); 
     hideWire_Red_03();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_02.class).isEmpty() )
{
                    
                
                 getWorld().addObject(new Wire_Red_02(), 446,230);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Red_02.class, Button_01_off.class);
                 

 }
                    clickTimer_Red_02 = 0;  

        }
       
        }
    }
    
  public void wireRed_03() 
    {

       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_03 > 0) clickTimer_Red_03--;  
if (clickTimer_Red_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 244 && mouse.getY() < 306) // first click  
 clickTimer_Red_03 = 200;
if (clickTimer_Red_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  
     showWire_Red_03();
     hideWire_Red_01(); 
     hideWire_Red_02();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_03.class).isEmpty())
                     {
                 
                 
                 getWorld().addObject(new Wire_Red_03(), 447,176);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Red_03.class, Button_01_off.class);

                  }
                     clickTimer_Red_03 = 0; 

        }
       
        }
 
    }
    
     public void wireBlue_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Blue_01 > 0) clickTimer_Blue_01--;  
if (clickTimer_Blue_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207) // first click  

  clickTimer_Blue_01 = 200;
if (clickTimer_Blue_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{  
       showWire_Blue_01();
       hideWire_Blue_02(); 
       hideWire_Blue_03();
    
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_01.class).isEmpty())
    
                     {
                

                 getWorld().addObject(new Wire_Blue_01(), 444,226);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Blue_01.class,Button_01_off.class);
               

                 
                    
                  }
               
                   clickTimer_Blue_01 = 0;  
        }
        }
    }
    
     public void wireBlue_02() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
if (clickTimer_Blue_02  > 0) clickTimer_Blue_02--;  
if (clickTimer_Blue_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207)// first click  

  clickTimer_Blue_02 = 200;
if (clickTimer_Blue_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  
       showWire_Blue_02();
       hideWire_Blue_01(); 
       hideWire_Blue_03();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_02.class).isEmpty())
                     {
                

                 getWorld().addObject(new Wire_Blue_02(), 445,176);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Blue_02.class,Button_01_off.class);
               

                 
                    
                  }
               
                   clickTimer_Blue_02 = 0;  
        }
        }
    }
    
     public void wireBlue_03() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Blue_03 > 0)clickTimer_Blue_03--;  
if (clickTimer_Blue_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207)// first click  

 clickTimer_Blue_03 = 200;
if (clickTimer_Blue_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  
        showWire_Blue_03();
       hideWire_Blue_01(); 
       hideWire_Blue_02();
    
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_03.class).isEmpty())
                     {
                
                 getWorld().addObject(new Wire_Blue_03(), 444,127);  
                 

                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Blue_03.class,Button_01_off.class);

                  }
               
                  clickTimer_Blue_03 = 0;  
        }
    }
}
    
  public void wireYellow_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Yellow_01 > 0) clickTimer_Yellow_01--;  
if (clickTimer_Yellow_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115) // first click  

  clickTimer_Yellow_01 = 200;
if (clickTimer_Yellow_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >  532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{
    
       showWire_Yellow_01();
       hideWire_Yellow_02(); 
       hideWire_Yellow_03();
    
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
                     {
                

                 getWorld().addObject(new Wire_Yellow_01(), 443,180);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Yellow_01.class, Button_01_off.class);
               

                 
                    
                  }
               
                   clickTimer_Yellow_01 = 0;  
        }
        }
    }
    
     public void wireYellow_02() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if ( clickTimer_Yellow_02  > 0) clickTimer_Yellow_02--;  
if (clickTimer_Yellow_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115)// first click  

  clickTimer_Yellow_02 = 200;
if (clickTimer_Yellow_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >  532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  
        showWire_Yellow_02();
       hideWire_Yellow_01(); 
       hideWire_Yellow_03();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
                     {
                

                 getWorld().addObject(new Wire_Yellow_02(), 446,132);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Yellow_02.class,Button_01_off.class);
               

                 
                    
                  }
               
                   clickTimer_Yellow_02 = 0;  
        }
        }
    }
    
     public void wireYellow_03() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Yellow_03 > 0) clickTimer_Yellow_03--;  
if (clickTimer_Yellow_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115)// first click  

  clickTimer_Yellow_03 = 200;
if (clickTimer_Yellow_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  
        showWire_Yellow_03();
       hideWire_Yellow_01(); 
       hideWire_Yellow_02();
    
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_03.class).isEmpty())
                     {
                
                 getWorld().addObject(new Wire_Yellow_03(), 443,89);  
                 

                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Yellow_03.class,Button_01_off.class);

                  }
               
                   clickTimer_Yellow_03 = 0;  
        }
    }
}

    public void hideWire_Red_01()
    {
        if (!getWorld().getObjects(Wire_Red_01.class).isEmpty())
        {
        Wire_Red_01 red_01 = (Wire_Red_01) getWorld().getObjects(Wire_Red_01.class).get(0);
                 red_01.getImage().setTransparency(0);
                }
               
    
    }
    
     public void hideWire_Red_02()
    {
        
         if (!getWorld().getObjects(Wire_Red_02.class).isEmpty())
         {
        Wire_Red_02 red_02 = (Wire_Red_02) getWorld().getObjects(Wire_Red_02.class).get(0);
                 red_02.getImage().setTransparency(0);
                }
              
    
    }
    
    public void hideWire_Red_03()
    {
         if (!getWorld().getObjects(Wire_Red_03.class).isEmpty())
         {
        Wire_Red_03 red_03 = (Wire_Red_03) getWorld().getObjects(Wire_Red_03.class).get(0);
                 red_03.getImage().setTransparency(0);
                }
                
               
    
    }
    
     public void showWire_Red_01()
    {
        if (!getWorld().getObjects(Wire_Red_01.class).isEmpty())
        {
        Wire_Red_01 red_01 = (Wire_Red_01) getWorld().getObjects(Wire_Red_01.class).get(0);
                 red_01.getImage().setTransparency(250);
                }
               
    
    }
    
     public void showWire_Red_02()
    {
        
         if (!getWorld().getObjects(Wire_Red_02.class).isEmpty())
         {
        Wire_Red_02 red_02 = (Wire_Red_02) getWorld().getObjects(Wire_Red_02.class).get(0);
                 red_02.getImage().setTransparency(255);
                }
              
    
    }
    
    public void showWire_Red_03()
    {
         if (!getWorld().getObjects(Wire_Red_03.class).isEmpty())
         {
        Wire_Red_03 red_03 = (Wire_Red_03) getWorld().getObjects(Wire_Red_03.class).get(0);
                 red_03.getImage().setTransparency(255);
                }
                
               
    
    }

    public void hideWire_Blue_01()
    {
        if (!getWorld().getObjects(Wire_Blue_01.class).isEmpty())
        {
        Wire_Blue_01 blue_01 = (Wire_Blue_01) getWorld().getObjects(Wire_Blue_01.class).get(0);
                 blue_01.getImage().setTransparency(0);
                }
               
    
    }
    
     public void hideWire_Blue_02()
    {
        
         if (!getWorld().getObjects(Wire_Blue_02.class).isEmpty())
         {
        Wire_Blue_02 blue_02 = (Wire_Blue_02) getWorld().getObjects(Wire_Blue_02.class).get(0);
                 blue_02.getImage().setTransparency(0);
                }
              
    
    }
    
    public void hideWire_Blue_03()
    {
         if (!getWorld().getObjects(Wire_Blue_03.class).isEmpty())
         {
        Wire_Blue_03 blue_03 = (Wire_Blue_03) getWorld().getObjects(Wire_Blue_03.class).get(0);
                 blue_03.getImage().setTransparency(0);
                }
                
               
    
    }
    
     public void showWire_Blue_01()
    {
        if (!getWorld().getObjects(Wire_Blue_01.class).isEmpty())
        {
        Wire_Blue_01 blue_01 = (Wire_Blue_01) getWorld().getObjects(Wire_Blue_01.class).get(0);
                 blue_01.getImage().setTransparency(250);
                }
               
    
    }
    
     public void showWire_Blue_02()
    {
        
         if (!getWorld().getObjects(Wire_Blue_02.class).isEmpty())
         {
        Wire_Blue_02 blue_02 = (Wire_Blue_02) getWorld().getObjects(Wire_Blue_02.class).get(0);
                 blue_02.getImage().setTransparency(255);
                }
              
    
    }
    
    public void showWire_Blue_03()
    {
         if (!getWorld().getObjects(Wire_Blue_03.class).isEmpty())
         {
        Wire_Blue_03 blue_03 = (Wire_Blue_03) getWorld().getObjects(Wire_Blue_03.class).get(0);
                 blue_03.getImage().setTransparency(255);
                }
                
               
    
    }
    
    public void hideWire_Yellow_01()
    {
        if (!getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
        {
        Wire_Yellow_01 yellow_01 = (Wire_Yellow_01) getWorld().getObjects(Wire_Yellow_01.class).get(0);
                 yellow_01.getImage().setTransparency(0);
                }
               
    
    }
    
     public void hideWire_Yellow_02()
    {
        
         if (!getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
         {
        Wire_Yellow_02 yellow_02 = (Wire_Yellow_02) getWorld().getObjects(Wire_Yellow_02.class).get(0);
                 yellow_02.getImage().setTransparency(0);
                }
              
    
    }
    
    public void hideWire_Yellow_03()
    {
         if (!getWorld().getObjects(Wire_Yellow_03.class).isEmpty())
         {
        Wire_Yellow_03 yellow_03 = (Wire_Yellow_03) getWorld().getObjects(Wire_Yellow_03.class).get(0);
                 yellow_03.getImage().setTransparency(0);
                }
                
               
    
    }
    
     public void showWire_Yellow_01()
    {
        if (!getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
        {
        Wire_Yellow_01 yellow_01 = (Wire_Yellow_01) getWorld().getObjects(Wire_Yellow_01.class).get(0);
                 yellow_01.getImage().setTransparency(250);
                }
               
    
    }
    
     public void showWire_Yellow_02()
    {
        
         if (!getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
         {
        Wire_Yellow_02 yellow_02 = (Wire_Yellow_02) getWorld().getObjects(Wire_Yellow_02.class).get(0);
                 yellow_02.getImage().setTransparency(255);
                }
              
    
    }
    
    public void showWire_Yellow_03()
    {
         if (!getWorld().getObjects(Wire_Yellow_03.class).isEmpty())
         {
        Wire_Yellow_03 yellow_03 = (Wire_Yellow_03) getWorld().getObjects(Wire_Yellow_03.class).get(0);
                 yellow_03.getImage().setTransparency(255);
                }
                
               
    
    }
    
}
meazalplaq meazalplaq

2014/11/21

#
Well, I may have improved the scenario by reducing the clickTimer to a lower count of 100. At least, things seem more stable than before. But I have another question. How would I go about creating a scenario where the user has to get specific wires to connect before a condition is true. For example, after specific wires are connected, the user can then be allowed to press a button that will unlock a door? Thank you.
danpost danpost

2014/11/21

#
The button part is pretty straight-forward. Have an 'if' statement in its act method that checks the connections when it is clicked on. If the conditions are satisfactory, unlock the door (whatever that entails). I was wondering if it might be easier to use mouse drag ops to place the wires instead of click-n-click. You could place actors at the connection points and use them as the actors that are "dragged" (mouse pressed while over them and the mouse moved to another location before mouse button release -- the actor itself should not move). Clicking, without mouse movement, on these actors could change their colors between the three colors; so, you would only need three starting connection point actors. Three ending connection point actors could be used in conjunction with the starting connection point to determine which wire to add into the world. The conditions for unlocking the door can be determined by which wires are in and not in the world.
meazalplaq meazalplaq

2014/11/23

#
Well, this code seems to do the trick. When the user connects the correct wires, the user can push a button, and the door will unlock. However, If the user has connected the correct wires together, the code does not recheck the condition if the user decides to unhook one of the correct connections. Once the condition is met, it is met. Is there a way to make the code more realistic by constantly checking the true or false state of the wires? I have managed to trigger the condition to false if the user unhooks one or all of the correct wires, but when the user puts the wire or wires back in the correct configuration nothing happens. Great idea about dragging the wires instead of just clicking. I will look into that. Think you for your help. ----------------------------------
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Color;
/**
 * Write a description of class Overlay_Puzzle_01 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Overlay_Puzzle_01 extends Actor
{
        private int clickTimer_Red_01;
        private int clickTimer_Red_02;
        private int clickTimer_Red_03;
        public int clickTimer_Blue_01;  
        private int clickTimer_Blue_02;  
        private int clickTimer_Blue_03;
        private int clickTimer_Yellow_01;
        private int clickTimer_Yellow_02;
         private int clickTimer_Yellow_03;
        private boolean connected_Red = false;
        private boolean connected_Blue = false;
        private boolean connected_Yellow = false;
        
    
         public Overlay_Puzzle_01()
    {
    GreenfootImage fade = new GreenfootImage (1024, 640);
    Color black = new Color (0,0,0);
        fade.fill();
fade.drawImage(new GreenfootImage("Overlay_Puzzle_01.jpg"),0,0);
        fade.setTransparency (50);
        setImage (fade);

    }
    /**
     * Act - do whatever the Overlay_Puzzle_01 wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {

         wireRed_01();
         wireRed_02();
         wireRed_03();
         wireBlue_01();
         wireBlue_02();
         wireBlue_03(); 
         wireYellow_01();
         wireYellow_02();
         wireYellow_03(); 
         checkConnections();
         checkConnections_Off();
         
    }    
    
     public void wireRed_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_01 > 0) clickTimer_Red_01--;  
if (clickTimer_Red_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 255 && mouse.getY() < 306) // first click  
 clickTimer_Red_01 = 100;
if (clickTimer_Red_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{  
       showWire_Red_01();
       hideWire_Red_02(); 
       hideWire_Red_03();
   
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_01.class).isEmpty())
                     {
              
                  clickTimer_Red_01 = 0;
                 getWorld().addObject(new Wire_Red_01(), 446,273);
                   
                 getWorld().setPaintOrder( Overlay_Puzzle_01.class, Wire_Red_01.class, Button_01_off.class, connected_Off.class);
                  connected_Red = true;
//                   return;
                  }
        }
        }
    }
    
      public void wireRed_02() 
    {
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_02 > 0) clickTimer_Red_02--;  
if (clickTimer_Red_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 244 && mouse.getY() < 306) // first click  
 clickTimer_Red_02 = 100;
if (clickTimer_Red_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  connected_Red = false;
     showWire_Red_02();
     hideWire_Red_01(); 
     hideWire_Red_03();
//      connected_Red = false;
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_02.class).isEmpty() )
{
                     clickTimer_Red_02 = 0;  

                 getWorld().addObject(new Wire_Red_02(), 446,230);          
                 getWorld().setPaintOrder( Overlay_Puzzle_01.class, Wire_Red_02.class, Button_01_off.class,  connected_Off.class);

 }
        }
       
        }
    }
    
  public void wireRed_03() 
    {

       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Red_03 > 0) clickTimer_Red_03--;  
if (clickTimer_Red_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 244 && mouse.getY() < 306) // first click  
 clickTimer_Red_03 = 100;
if (clickTimer_Red_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  connected_Red = false;
     showWire_Red_03();
     hideWire_Red_01(); 
     hideWire_Red_02();
     
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Red_03.class).isEmpty())
                     {
//                  
                 clickTimer_Red_03 = 0; 
                 getWorld().addObject(new Wire_Red_03(), 447,176);          
                 getWorld().setPaintOrder( Overlay_Puzzle_01.class, Wire_Red_03.class,Button_01_off.class, connected_Off.class);
                     connected_Red = false;
                  }


        }
       
        }
 
    }
    
     public void wireBlue_01() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {

           if (clickTimer_Blue_01 > 0) clickTimer_Blue_01--;  
if (clickTimer_Blue_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207) // first click  

  clickTimer_Blue_01 = 100;
if (clickTimer_Blue_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{  
       showWire_Blue_01();
       hideWire_Blue_02(); 
       hideWire_Blue_03();

    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_01.class).isEmpty())
    
                     {
                         
                       
                 clickTimer_Blue_01 = 0;  
                 getWorld().addObject(new Wire_Blue_01(), 444,226);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Blue_01.class,Button_01_off.class, connected_Off.class);
                 connected_Blue = true; 

                    
                  }
        }
        }
    }
    
     public void wireBlue_02() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
if (clickTimer_Blue_02  > 0) clickTimer_Blue_02--;  
if (clickTimer_Blue_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207)// first click  

  clickTimer_Blue_02 = 100;
if (clickTimer_Blue_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  
    connected_Blue = false; 
       showWire_Blue_02();
       hideWire_Blue_01(); 
       hideWire_Blue_03();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_02.class).isEmpty())
                     {
                clickTimer_Blue_02 = 0;  
//                 
                 getWorld().addObject(new Wire_Blue_02(), 445,176);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Blue_02.class, Button_01_off.class, connected_Off.class);
                    
                  }
        }
        }
    }
    
     public void wireBlue_03() 
    {
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
           if (clickTimer_Blue_03 > 0)clickTimer_Blue_03--;  
if (clickTimer_Blue_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 145 && mouse.getY() < 207)// first click  

 clickTimer_Blue_03 = 100;
if (clickTimer_Blue_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() > 532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  
    connected_Blue = false;  
        showWire_Blue_03();
       hideWire_Blue_01(); 
       hideWire_Blue_02();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Blue_03.class).isEmpty())
                     {
              
                 clickTimer_Blue_03 = 0; 
                 getWorld().addObject(new Wire_Blue_03(), 444,127);  
                 getWorld().setPaintOrder( Overlay_Puzzle_01.class, Wire_Blue_03.class, Button_01_off.class, connected_Off.class);
                  }
               
        }
    }
}
    
  public void wireYellow_01() 
    {
        
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
     
               
           if (clickTimer_Yellow_01 > 0) clickTimer_Yellow_01--;  
if (clickTimer_Yellow_01 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115) // first click  

  clickTimer_Yellow_01 = 100;
if (clickTimer_Yellow_01 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >  532 && mouse.getX() < 591 && mouse.getY() > 244 && mouse.getY() < 306 ) // second click  
{
    
       showWire_Yellow_01();
       hideWire_Yellow_02(); 
       hideWire_Yellow_03();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
                     {
               
                             clickTimer_Yellow_01 = 0;  
                 getWorld().addObject(new Wire_Yellow_01(), 443,180);          
                 getWorld().setPaintOrder( Overlay_Puzzle_01.class, Wire_Yellow_01.class, Button_01_off.class, connected_Off.class);
               
                  connected_Yellow = true;
                    
                  }
        }
        }
    }
    
     public void wireYellow_02() 
    {
       
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
           if ( clickTimer_Yellow_02  > 0) clickTimer_Yellow_02--;  
if (clickTimer_Yellow_02 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115)// first click  

  clickTimer_Yellow_02 = 100;
if (clickTimer_Yellow_02 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >  532 && mouse.getX() < 591 && mouse.getY() > 145 && mouse.getY() < 207 ) // second click  
{  
    connected_Yellow = false;
        showWire_Yellow_02();
       hideWire_Yellow_01(); 
       hideWire_Yellow_03();
   
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
                     {
                
                         clickTimer_Yellow_02 = 0;  
                 getWorld().addObject(new Wire_Yellow_02(), 446,132);          
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Yellow_02.class,Button_01_off.class, connected_Off.class);
                    
                  }
        }
        }
    }
    
     public void wireYellow_03() 
    {
       MouseInfo mouse = Greenfoot.getMouseInfo();
        {
           if (clickTimer_Yellow_03 > 0) clickTimer_Yellow_03--;  
if (clickTimer_Yellow_03 == 0 && Greenfoot.mouseClicked(this)&& mouse.getX() > 303 && mouse.getX() < 362 && mouse.getY() > 53 && mouse.getY() < 115)// first click  

  clickTimer_Yellow_03 = 100;
if (clickTimer_Yellow_03 > 0 && Greenfoot.mouseClicked(null)&& mouse.getX() >532 && mouse.getX() < 591 && mouse.getY() > 53 && mouse.getY() < 115 ) // second click  
{  connected_Yellow = false;
       showWire_Yellow_03();
       hideWire_Yellow_01(); 
       hideWire_Yellow_02();
    if (Greenfoot.mouseClicked(this)&& getWorld().getObjects(Wire_Yellow_03.class).isEmpty())
                     {
                         clickTimer_Yellow_03 = 0;  
                 getWorld().addObject(new Wire_Yellow_03(), 443,89);  
                 getWorld().setPaintOrder(Overlay_Puzzle_01.class, Wire_Yellow_03.class,Button_01_off.class, connected_Off.class);

                  }

        }
    }
}

    public void hideWire_Red_01()
    {
        if (!getWorld().getObjects(Wire_Red_01.class).isEmpty())
        {
        Wire_Red_01 red_01 = (Wire_Red_01) getWorld().getObjects(Wire_Red_01.class).get(0);
                 red_01.getImage().setTransparency(0);
                }
    }
    
     public void hideWire_Red_02()
    {
        
         if (!getWorld().getObjects(Wire_Red_02.class).isEmpty())
         {
        Wire_Red_02 red_02 = (Wire_Red_02) getWorld().getObjects(Wire_Red_02.class).get(0);
                 red_02.getImage().setTransparency(0);
                }
    }
    
    public void hideWire_Red_03()
    {
         if (!getWorld().getObjects(Wire_Red_03.class).isEmpty())
         {
        Wire_Red_03 red_03 = (Wire_Red_03) getWorld().getObjects(Wire_Red_03.class).get(0);
                 red_03.getImage().setTransparency(0);
                }
    }
    
     public void showWire_Red_01()
    {
        if (!getWorld().getObjects(Wire_Red_01.class).isEmpty())
        {
        Wire_Red_01 red_01 = (Wire_Red_01) getWorld().getObjects(Wire_Red_01.class).get(0);
                 red_01.getImage().setTransparency(250);
                }
    }
    
     public void showWire_Red_02()
    {
        
         if (!getWorld().getObjects(Wire_Red_02.class).isEmpty())
         {
        Wire_Red_02 red_02 = (Wire_Red_02) getWorld().getObjects(Wire_Red_02.class).get(0);
                 red_02.getImage().setTransparency(255);
                }
    }
    
    public void showWire_Red_03()
    {
         if (!getWorld().getObjects(Wire_Red_03.class).isEmpty())
         {
        Wire_Red_03 red_03 = (Wire_Red_03) getWorld().getObjects(Wire_Red_03.class).get(0);
                 red_03.getImage().setTransparency(255);
                }
    }

    public void hideWire_Blue_01()
    {
        if (!getWorld().getObjects(Wire_Blue_01.class).isEmpty())
        {
        Wire_Blue_01 blue_01 = (Wire_Blue_01) getWorld().getObjects(Wire_Blue_01.class).get(0);
                 blue_01.getImage().setTransparency(0);
                }
    }
    
     public void hideWire_Blue_02()
    {
        
         if (!getWorld().getObjects(Wire_Blue_02.class).isEmpty())
         {
        Wire_Blue_02 blue_02 = (Wire_Blue_02) getWorld().getObjects(Wire_Blue_02.class).get(0);
                 blue_02.getImage().setTransparency(0);
                }
    }
    
    public void hideWire_Blue_03()
    {
         if (!getWorld().getObjects(Wire_Blue_03.class).isEmpty())
         {
        Wire_Blue_03 blue_03 = (Wire_Blue_03) getWorld().getObjects(Wire_Blue_03.class).get(0);
                 blue_03.getImage().setTransparency(0);
                }
    }
    
     public void showWire_Blue_01()
    {
        if (!getWorld().getObjects(Wire_Blue_01.class).isEmpty())
        {
        Wire_Blue_01 blue_01 = (Wire_Blue_01) getWorld().getObjects(Wire_Blue_01.class).get(0);
                 blue_01.getImage().setTransparency(250);
                }
    }
    
     public void showWire_Blue_02()
    {
        
         if (!getWorld().getObjects(Wire_Blue_02.class).isEmpty())
         {
        Wire_Blue_02 blue_02 = (Wire_Blue_02) getWorld().getObjects(Wire_Blue_02.class).get(0);
                 blue_02.getImage().setTransparency(255);
                }
    }
    
    public void showWire_Blue_03()
    {
         if (!getWorld().getObjects(Wire_Blue_03.class).isEmpty())
         {
        Wire_Blue_03 blue_03 = (Wire_Blue_03) getWorld().getObjects(Wire_Blue_03.class).get(0);
                 blue_03.getImage().setTransparency(255);
                }  
    }
    
    public void hideWire_Yellow_01()
    {
        if (!getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
        {
        Wire_Yellow_01 yellow_01 = (Wire_Yellow_01) getWorld().getObjects(Wire_Yellow_01.class).get(0);
                 yellow_01.getImage().setTransparency(0);
                }
    }
    
     public void hideWire_Yellow_02()
    {
        
         if (!getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
         {
        Wire_Yellow_02 yellow_02 = (Wire_Yellow_02) getWorld().getObjects(Wire_Yellow_02.class).get(0);
                 yellow_02.getImage().setTransparency(0);
                }
              
    
    }
    
    public void hideWire_Yellow_03()
    {
         if (!getWorld().getObjects(Wire_Yellow_03.class).isEmpty())
         {
        Wire_Yellow_03 yellow_03 = (Wire_Yellow_03) getWorld().getObjects(Wire_Yellow_03.class).get(0);
                 yellow_03.getImage().setTransparency(0);
                }
    }
    
     public void showWire_Yellow_01()
    {
        if (!getWorld().getObjects(Wire_Yellow_01.class).isEmpty())
        {
        Wire_Yellow_01 yellow_01 = (Wire_Yellow_01) getWorld().getObjects(Wire_Yellow_01.class).get(0);
                 yellow_01.getImage().setTransparency(250);
                }
    }
    
     public void showWire_Yellow_02()
    {
        
         if (!getWorld().getObjects(Wire_Yellow_02.class).isEmpty())
         {
        Wire_Yellow_02 yellow_02 = (Wire_Yellow_02) getWorld().getObjects(Wire_Yellow_02.class).get(0);
                 yellow_02.getImage().setTransparency(255);
                }
    }
    
    public void showWire_Yellow_03()
    {
         if (!getWorld().getObjects(Wire_Yellow_03.class).isEmpty()) 
         {
        Wire_Yellow_03 yellow_03 = (Wire_Yellow_03) getWorld().getObjects(Wire_Yellow_03.class).get(0);
                 yellow_03.getImage().setTransparency(255);
                }
    }
    
    public void checkConnections()
    
    {
        if (connected_Red && connected_Blue && connected_Yellow && getWorld().getObjects(connected_On.class).isEmpty())
        {
             getWorld().addObject(new connected_On(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_Off.class)); 
              getWorld().setPaintOrder(Button_01_off.class, Overlay_Puzzle_01.class,connected_On.class);
          
        }        
   }
    
    public void checkConnections_Off()
    {
     if (!connected_Red && getWorld().getObjects(connected_Off.class).isEmpty()) //selected = !selected;
        {
             getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class)); 
              getWorld().setPaintOrder(Overlay_Puzzle_01.class, connected_Off.class, connected_On.class);

        }
        
         if (!connected_Blue && getWorld().getObjects(connected_Off.class).isEmpty())
        {
                  getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class)); 
              getWorld().setPaintOrder(Overlay_Puzzle_01.class, connected_Off.class, connected_On.class);
        }
        
          if (!connected_Yellow && getWorld().getObjects(connected_Off.class).isEmpty())
        {
              getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class)); 

              getWorld().setPaintOrder(Overlay_Puzzle_01.class, connected_Off.class, connected_On.class);
        }
    }     
    }
    
danpost danpost

2014/11/23

#
meazalplaq wrote...
I have managed to trigger the condition to false if the user unhooks one or all of the correct wires, but when the user puts the wire or wires back in the correct configuration nothing happens.
Does not clicking the button unlock the door again?
meazalplaq meazalplaq

2014/11/24

#
It only unlocks the door once during the scenario, but if the user unhooks the wires again before clicking the button and exciting the puzzle and then reattaches them correctly a second time, it does not work. Maybe I need create a loop to keep checking if the condition is true or false? It does work once, so I guess that is all that matters, but for realism, I was hoping that it would respond accordingly to user input.
danpost danpost

2014/11/24

#
You must not be doing the check when the button is clicked. That is the correct time to do so.
meazalplaq meazalplaq

2014/11/24

#
It seems like the code only checks once to see if the user has either correctly or incorrectly connected the wires. Is there a way to tell the code to all ways check to see what the condition is currently? This is my code to check if the wires have been connected correctly followed by the code that tells the scenario what to do if the user backtracks and disconnects the correct wires. -----------------------------------------
 public void checkConnections()
    
    {
        
        if (connected_Red && connected_Blue && connected_Yellow && getWorld().getObjects(connected_On.class).isEmpty()&&  getWorld().getObjects(Button_01_off.class).isEmpty())
        {
             getWorld().addObject(new connected_On(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_Off.class)); 
              getWorld().addObject(new Button_01_off(),584,541);
             getWorld().removeObjects(getWorld().getObjects(Button_01_off_notready.class)); 
              getWorld().setPaintOrder(Button_01_off.class, Overlay_Puzzle_01.class,connected_On.class);
            
          
        }        

   }
    
    public void checkConnections_Off()
    {
     if (!connected_Red && getWorld().getObjects(connected_Off.class).isEmpty() &&  getWorld().getObjects(Button_01_off_notready.class).isEmpty()) //selected = !selected;
        {
             getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class));
             getWorld().addObject(new Button_01_off_notready(), 584,541);
             getWorld().removeObjects(getWorld().getObjects(Button_01_off.class)); 
              getWorld().setPaintOrder(Button_01_off_notready.class, Overlay_Puzzle_01.class, connected_Off.class);

        }
        
         if (!connected_Blue && getWorld().getObjects(connected_Off.class).isEmpty()&&  getWorld().getObjects(Button_01_off_notready.class).isEmpty())
        {
               getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class));
             getWorld().addObject(new Button_01_off_notready(), 584,541);
             getWorld().removeObjects(getWorld().getObjects(Button_01_off.class)); 
              getWorld().setPaintOrder(Button_01_off_notready.class, Overlay_Puzzle_01.class, connected_Off.class);

        }
        
          if (!connected_Yellow && getWorld().getObjects(connected_Off.class).isEmpty()&&  getWorld().getObjects(Button_01_off_notready.class).isEmpty())
        {
              getWorld().addObject(new connected_Off(), 627,206);
             getWorld().removeObjects(getWorld().getObjects(connected_On.class));
             getWorld().addObject(new Button_01_off_notready(), 584,541);
             getWorld().removeObjects(getWorld().getObjects(Button_01_off.class)); 
              getWorld().setPaintOrder(Button_01_off_notready.c//                checkConnections();
        }
       
    }     
There are more replies on the next page.
1
2