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

2016/10/2

pause button

Dayuyu Dayuyu

2016/10/2

#
i try to make pause button that have continue and menu button, but the continue button not working. when player click pause button new world will pop up and show continue and menu button... when player click continue i like to player continue where they stop. pause world
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class pauseWorld here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Pau extends World
{

    /**
     * Constructor for objects of class pauseWorld.
     * 
     */
    
    public World lastWorld;
    
    public Pau(World world)
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(500, 550, 1);
        lastWorld = world;
        prepare();
    }
    
    public World getLastWorld()
    {
        return lastWorld;
    }
    
    public void prepare()
    {
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        addObject(new PauseMenu(),300,215);
        addObject(new sambung(),270,230);
        addObject(new smbg(),420,200);
        addObject(new menusemula(),270,230);
        addObject(new msb(),420,265);
    }
    
}
pause button that has at level1
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Pause here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Pause extends Actor
{
    /**
     * Act - do whatever the Pause wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
       if (Greenfoot.mouseClicked(this)) 
        {
           World world;
           world = getWorld() ;
           Greenfoot.setWorld(new Pau(getWorld()));
        }
    }       
}
continue button that has at pause world
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class smbg here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class smbg extends sambung
{
    /**
     * Act - do whatever the smbg wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        // Add your action code here.
        if (Greenfoot.mouseClicked(this)) 
        {
            // get reference to Q world object
            Pau pauWorld = (Pau)getWorld(); 
            Greenfoot.setWorld(pauWorld.getLastWorld());
        }
    }    
}
danpost danpost

2016/10/2

#
Again, are you sure that no object is overtop of and getting the click instead of the smbg object? Stop the scenario and right-click on the smbg object and select 'Inspect' to ensure that the click is on the smbg object.
Dayuyu Dayuyu

2016/10/2

#
ok i have object overtop...now i fix that... it work.. thank..
You need to login to post a reply.