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

2014/12/15

HELP PLEASE

danpost danpost

2014/12/15

#
I think it would help more if you just posted the entire class codes instead of snippets from them. Also, please use the 'code' link below the reply box for inserting code into you posts.
beliuga beliuga

2014/12/15

#
woops sorry!
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

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

    /**
     * Constructor for objects of class background2.
     * 
     */
    public background2()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
    
        super(500, 350, 1); 
        start2 secondstart2 = new start2();
        addObject(secondstart2,318,395);
       
        player1 player1 = new player1();
        addObject(player1,165,152); 
        
        player2 player2 = new player2();
        addObject(player2,454,149); 
        
        langa langa = new langa();
        addObject(langa,84,273); 
        
        langb6 langb6 = new langb6();
        addObject(langb6,454,149); 
        
        langb56 langb56 = new langb56();
        addObject(langb56,454,149); 
        
        langb5 langb5 = new langb5();
        addObject(player1,454,149);  
    }
}
second code :
     public void act()
    
    {
       if (Greenfoot.mouseClicked(start)); 
       getWorld().setBackground(new GreenfootImage("background2.png"));
    }
}
danpost danpost

2014/12/15

#
Again, I cannot tell where this act method is with it by itself like that. I will say this much, however. It appears you are trying to create and start a new world by changing the background image of the first world. If you are, it is not done that way. It would still be the first world with a different background image; and, the constructor of the second world would never be executed. You need to use 'new background2()' to create a 'background2' world. You can create and set one active using 'Greenfoot.setWorld(new background2());'.
You need to login to post a reply.