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

2024/11/9

Could someone tell me where the mistake is?

Shuotso Shuotso

2024/11/9

#
if (Greenfoot.isKeyDown("Enter"))
        {
            if (getImage().equals("Teddy_Sword_colour_smaller_rightlook.png"))
            {
            addObject(new Slash(),getX(), getY());
            }
        }
Somehow I get a "cannot find symbol - method addObject(Slash, int, int)" and I don't know what's wrong could someone help me?
Super_Hippo Super_Hippo

2024/11/10

#
I guess this code is in an Actor subclass. To add an object to the world, you need to call the addObject method on the world the actor is in.
getWorld().addObject(new Slash(), getX(), getY());
You need to login to post a reply.