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

2017/5/5

how to keep health between worlds

1
2
danpost danpost

2017/5/6

#
FutureCoder wrote...
i tried this but it didn't change anything, it swaps between the worlds, but the character isn't placed in it.
Do you have a line in the world2 class constructor (or somewhere in the class) that start like this?
addObject(character,
FutureCoder FutureCoder

2017/5/6

#
no, there is no line to add the character in the world2 class
Yehuda Yehuda

2017/5/7

#
danpost wrote...
Do you have a line in the world2 class constructor (or somewhere in the class) that start like this?
addObject(character,
FutureCoder wrote...
no, there is no line to add the character in the world2 class
Well I think the point was that you're supposed to put that line in, not just answer the question.
FutureCoder FutureCoder

2017/5/7

#
i did, it didn't do anything
danpost danpost

2017/5/7

#
FutureCoder wrote...
i did, it didn't do anything
Show your world2 class codes for inspection.
FutureCoder FutureCoder

2017/5/7

#
public class world2 extends World
{
 private Character character;

    public world2()
    {    
        
        this(new Character());




    }

    /**
     * Prepare the world for the start of the program. That is: create the initial
     * objects and add them to the world.
     */
 

 
public world2(Character charctr)
 {
    
            super(1000, 618, 1); 
            character =  charctr;
            
       
   
}

}
danpost danpost

2017/5/7

#
FutureCoder wrote...
i did, it didn't do anything
If you did, where is the line? Add the following at line 27:
addObject(character, 100, 100);
You can adjust the location as needed; but this will place the character (that was originally in the 'world' object) in your 'world2' object.
FutureCoder FutureCoder

2017/5/7

#
i took the line out when it didn't work, but i had used Character character = new Character(); addObject(character, 598, 488); so it didn't work, but now it works great, thank you so much!
You need to login to post a reply.
1
2