I need help. German is my first language. Sorry for my bad english.
Just the first ''Frog"(Actor) does act if the variable "c" is not zero and is intersecting with "KontrollKreuz"(another Actor). The other Frogs do not react until the first Frog is removed.
public class KontrollKreuz extends Actor
{
private int p = 64;
public static int c;
public KontrollKreuz() {
}
public void act() {
control();
}
public void control() {
boolean k = false;
while(Greenfoot.isKeyDown("right") && getX() != 32 + 15*p) {
if(k == false) {
setLocation(getX() + p, getY());
}
k = true;
}
k = false;
while(Greenfoot.isKeyDown("left") && getX() != 32) {
if(k == false) {
setLocation(getX() - p, getY());
}
k = true;
}
while(Greenfoot.isKeyDown("down") && getOneIntersectingObject(Frog.class) != null) {
if(Greenfoot.isKeyDown("right")) {
KontrollKreuz.c = 1;
}
if(Greenfoot.isKeyDown("left")) {
KontrollKreuz.c = -1;
}
}
}
}
public class Frog extends Actor
{
private int p = 64;
private int jp;
public Frog() {
jp = 1;
}
public void act() {
reactOnEntities();
}
public void reactOnEntities() {
Actor lillipad = getOneIntersectingObject(Lillipad.class);
int c = KontrollKreuz.c;
if(c != 0 && getOneIntersectingObject(KontrollKreuz.class) != null) {
setLocation(getX() + p * (jp * c), getY());
if(getOneIntersectingObject(Lillipad.class) == null) {
setLocation(getX() - p * (jp * c), getY());
}
else {
getWorld().removeObject(lillipad);
}
}
KontrollKreuz.c = 0;
}
}

