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

2019/11/1

I need help with my code

kahn kahn

2019/11/1

#
I am trying to make it so character and character2 can see if their x value is greater or less then the others x being their position on the stage but I am struggling to make it work any advice
danpost danpost

2019/11/1

#
kahn wrote...
I am trying to make it so character and character2 can see if their x value is greater or less then the others x being their position on the stage but I am struggling to make it work any advice
You are probably getting the objects from the world and not casting them from an Object type to an Actor type:
Actor c2 = (Actor)getWorld().getObjects(character2.class).get(0);
This, the "(Actor)", would be required to get a coordinate value with getX -- a method from the Actor class. The coordinate can also be gotten with the following:
int c2x = ((Actor)getWorld().getObjects(character2.class).get(0)).getX();
kahn kahn

2019/11/4

#
thx dadpost
You need to login to post a reply.