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

2020/3/23

Asking for a command

HarveyP30 HarveyP30

2020/3/23

#
Is there a command that could be used in an if statement wherein it determines if a certain actor is at a certain World? I have a dodgeball game that has 2 levels. The throwers are called into Court and Court 2, and that they would randomly spawn balls (Actor Shot); however, if I put a command that would make my throwers spawn balls (Actor Shot), it would error since my Shot has a command that if it is in a certain area in World Court, it would add a score then remove. Since it has a command that involves World Court, if it is in World Court 2, the error starts.
Super_Hippo Super_Hippo

2020/3/23

#
You are probably looking for instanceof. It checks if an object belongs to a given class.
if (getWorld() instanceof Court)
{
    //...
}
RcCookie RcCookie

2020/3/23

#
I would simply try this:
if(theActor.getWorld()==yourWorld){
    //your Code here
}
HarveyP30 HarveyP30

2020/3/24

#
Thank you for helping!
You need to login to post a reply.