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

2022/2/18

When the object spawns, the game pauses itself.

Kwantum Kwantum

2022/2/18

#
When I click on World (w) the code (w.addObject(new Boomerang(), 100, 300);) makes it crash. I am sure that that line is the problem because the code didn't crash when I commented it out. context: code is in Actor subclass called Items and Boomerang is a subclass from items.
public void act()
    {
        if(boomCheck == 0)
        {
            throwBoomerang();
        }
        

    }
    
    public void throwBoomerang()
     {
       //Zorgt ervoor dat je een boomerang kan gooien.
       
       if(Greenfoot.mousePressed(w))
        {
           
            Minion2X = minion.MinionX;
            Minion2Y = minion.MinionY;
        
            
            w.addObject(new Boomerang(), 100, 300);
            boomCheck = 1;
        }
     }
Super_Hippo Super_Hippo

2022/2/18

#
The title says “pauses itself”, you text says “crashes”. If it crashed, there should be an error message guiding you to the error. I guess that “w” is “null” is the error is a nullpointer exception. As a sidenote, you probably don’t want that a boomerang adds a boomerang which then adds another boomerang etc.
Kwantum Kwantum

2022/2/18

#
I'm sorry for being unclear. This code is from the boomerang's superclass called Items, and the game doesn't crash. It just pauses itself
Kwantum Kwantum

2022/2/18

#
There is no error message, it just pauses the simulation.
danpost danpost

2022/2/18

#
Kwantum wrote...
There is no error message, it just pauses the simulation.
Please provide full Boomerang class codes. Also, please provide full Items class codes. As well, please provide a little insight as to when a boomerang is to be created. If an actor type throws it, specify which type a how that actor plays a role in your scenario.
You need to login to post a reply.