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

2021/6/15

Problem with executing a method from another class

Turbo_Thorsten Turbo_Thorsten

2021/6/15

#
How can I execute a method in a class which is from another class without using static (i can't use static because I use methods like the getObjects method)?
Roshan123 Roshan123

2021/6/15

#
//global
A a = new A();
//Act method
if(it's true)..then
a.xyzMethod();
Hope it works properly
Turbo_Thorsten Turbo_Thorsten

2021/6/15

#
Roshan123 wrote...
//global
A a = new A();
//Act method
if(it's true)..then
a.xyzMethod();
Hope it works properly
Sry I don't get how I should implement this. If I want a method from Class: A executed from Class: B How can I do this then?
Roshan123 Roshan123

2021/6/15

#
//global
A a = new A();
//in act method
a.move(2);
I hope that from this u might be able to understand well
Turbo_Thorsten Turbo_Thorsten

2021/6/15

#
Roshan123 wrote...
//global
A a = new A();
//in act method
a.move(2);
I hope that from this u might be able to understand well
So in which class do I need to type this in?
Gabe1098 Gabe1098

2021/6/15

#
getWorld().getObjects(Actor.class).get(0).test();
I think that should work
Turbo_Thorsten Turbo_Thorsten

2021/6/15

#
Gabe1098 wrote...
getWorld().getObjects(Actor.class).get(0).test();
I think that should work
I don'T know how and where to use this
Turbo_Thorsten Turbo_Thorsten

2021/6/15

#
Ok I'm ending this thread bc I found a solution. I don't really understand it but it's working so thank y'all
You need to login to post a reply.