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

2012/6/27

The addObject() method failed

Mux Mux

2012/6/27

#
I want to creat a Object of the Button class and put it into the world, but nothing happens. No compile mistake and no runtime error is found. It just seems to do nothing.
public void zoomIn(Spiel w)
    {
        Button box = new Button("ZoomBox",1);
        w.addObject(box,0,0);
        
        ZoomStatus = true;
    }
This is the code where i want to add the object. The used part of the constructor is:
public Button(String type, int value)
 {
       group = type;
       definition = value;

        if(group == "ZoomBox")
        {
               if(definition == 1)
                {
                     setImage("ZoomBox.png");
                }
         }
 }
When the "ZoomBox" is clicked a little bit of math go on and it should zoom in where the "ZoomBox" is. The box looks like this: [Disallowed URL] But realy nothing happen. It can't be created, becaus in this case it must zoom in directly or ther must be the image visible but nothing happens. Is it incorrectly programmed? I know you can't follow all steps that happens when the project is running, but is there a mistake so far?
Mux Mux

2012/6/27

#
[Disallowed URL]
Mux Mux

2012/6/27

#
Sry i can't post the image but it looks like a box where you can see the background. EDIT: Maybe this is interesting to know: When i use the right side in greenfoot and right cklick Button and than new Button, i can creat the ZoomBox correctly by entering the type and the value.
Mux Mux

2012/6/27

#
I got it fixed up. It is a stupid idea to remove all objects of a class at the end of a method when you want one left there ^^
You need to login to post a reply.