This site requires JavaScript, please enable it in your browser!
Greenfoot back
vtn2@calvin.edu
vtn2@calvin.edu wrote ...

2016/6/6

Subclass of subclass of World not constructed?

vtn2@calvin.edu vtn2@calvin.edu

2016/6/6

#
I have created a subclass VicWorld of class ScratchWorld which is a subclass of World.
public class VicWorld extends ScratchWorld
{
    public VicWorld()
    {
        super();
        System.err.println("Callig addSprite(Sprite1)");
        addSprite("Sprite1");
        addSprite("Apple");
    }
}
Everything compiles, but when I reset the scenario, I never see the "Callig addSprite(Sprite1)" message come out... Does greenfoot support this? VIc
danpost danpost

2016/6/6

#
I bet if you compile and then right-click on the world and select 'Inspect' from the drop-down menu, that it will not show the object as being a 'VicWorld' object; that is will show as a 'ScratchWorld' object (at the top header line of the Inspect frame). Try right-clicking on the 'VicWorld' class (in the classes frame) and select the 'new VicWorld()' option.
vtn2@calvin.edu vtn2@calvin.edu

2016/6/6

#
Thanks. Running new VicWorld() did help. The Inspect said it did know that it was a VicWorld object.
You need to login to post a reply.