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

2019/2/18

I need help with Objects spawning on each other

Zestix Zestix

2019/2/18

#
Hey, I was trying to prevent Objects (no specific ones) from spawning on eachother. The code looks like this:
public void newObject(Actor r)
    {
        if (getObjectsAt(met,met2,Meteorite.class).isEmpty())
        {
            
        }
    }
The code itself seems to be okay but I dont know how to implement the addObject command, since I dont want to add a specific class.
danpost danpost

2019/2/18

#
Zestix wrote...
Hey, I was trying to prevent Objects (no specific ones) from spawning on eachother. << Code Omitted >> The code itself seems to be okay but I dont know how to implement the addObject command, since I dont want to add a specific class.
Correct me if I am mistaken, but I would presume that the actor to be added would be r, from the parameter of the method. I am not sure how the method will eliminate overlapping. It will probably make it such that less than half any object already in the world will be overlapped by that which is added; but it will not completely eliminate overlapping. At any rate, to check for any actor already in the world, use Actor.class instead of Meteorite.class.
You need to login to post a reply.