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

2012/3/1

Trying to create a "level"

Nemean Nemean

2012/3/1

#
Hey im trying to create levels within the world subclass Basement. This is what I have right now.
public class Basement extends World
{
    private GreenfootSound music = new GreenfootSound("Danny Baranowsky - Enmity of the Dark Lord.mp3");
    private int level = 50;
    /**
     * Constructor for objects of class Basement.
     * 
     */
    public Basement()
    {    
        
        super(795, 598, 1); 
        
        addObject(new Isaac(), 393,500);
        addObject(new Chub(), 393,250);
        addObject(new Charger(), 473, 250);
        addObject(new Charger(), 313, 250);
        
    }
    
    public void act()
    {
       if (numberOfObjects() == 1)
        { 
            getActor().Isaac().setLocation(393,500);
            addObject(new Charger(), 393,250);
            addObject(new Charger(), 473, 250);
            addObject(new Charger(), 313, 250);
        } 
    }
   
    public void started()  
    {  
        music.setVolume(15);
        music.playLoop();  
    } 
}
I want to move the Isaac object but not remove him as he does have health, along with a crap top of other things included with him. However i have yet been able to successfully move him. Any tips?
kiarocks kiarocks

2012/3/1

#
You will need a sewperate world, and when you
setWorld(World w)
your world will be passed an Issac as one of the arguments. Then spawn that Issac in the new wold and it should work.
You need to login to post a reply.