I am attempting to make a program and I'm going well, but have run into an issue. At some point I would like the user to be able to swap the postitions of two different images. I am attempting a simplified version of the issue now and have gotten stuck
The following code is in the actor "one". What I want it to do is to get the location of itself as well as an actor named "two", and swap them.
As of now all the code does is move actor "one" to actor "two", so the two are on top of each other.
if (Greenfoot.mouseClicked(this)) { Actor two = getWorld().getObjects(two.class).get(0); int oneX = this.getX(); int oneY = this.getY(); int twoX = two.getX(); int twoY = two.getY(); two.setLocation(oneX,oneY); this.setLocation(twoX,twoY); }