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

2021/11/30

im having trouble creating a method that takes a class and sets its position

Aaron-aid Aaron-aid

2021/11/30

#
i want to make it where i can do get the location and update it to the player but I'm getting errors
void Weapons()
    {
        Pistols(P_1911.class);
    }
    void Pistols(Class x)
    {
        if(isTouching(x))
        {
            getWorld().getObjects(x).get(0).setLocation(getX(),getY());
        }
        
    }
danpost danpost

2021/11/30

#
Aaron-aid wrote...
i want to make it where i can do get the location and update it to the player but I'm getting errors << Code Omitted >>
Change line 1 to:
public void act()
The getX and getY in line 9 need to be the P_1911 actor location coordinates.
Actor p1911 = (Actor)getWorld().getObjects(x).get(0);
setLocation(p1911.getX(), p1911.getY());
Aaron-aid Aaron-aid

2021/11/30

#
holy crap ur a savior
You need to login to post a reply.