I did a moving platform:
But I'm having an issue when my character walks on it, when it moves horizontally the char isn't moved together with the platform but that's ok since the character can move on its on. The real problem is when I try to move on a platform that is moving vertically cause my character does not move within the movement of the platform so when the platform goes up my character stays the same place and then get inside the block of platform.
My character code:
Can Somebody help me?
public MovingAreia(int distancia) { this.distancia = distancia; this.limiteContagem = distancia*2; } public void act() { contagem++; movementX(); movementY(); resetContagem(); } public void movementY() { if(contagem < distancia)setLocation(getX(), getY() + vSpeed); if(contagem > distancia)setLocation(getX(), getY() - vSpeed); } public void movementX() { if(contagem < distancia)setLocation(getX() + speed, getY()); if(contagem > distancia)setLocation(getX() - speed, getY()); } public void resetContagem(){if(contagem == limiteContagem)contagem=0;}
public boolean onGround() { Actor under = getOneObjectAtOffset(0, getImage().getHeight()/2, Plataforma.class); return under != null; } public void checkFall() { if(onGround()){ vSpeed =0; } else { fall(); } } public void fall() { setLocation(getX(), getY() + vSpeed); vSpeed = vSpeed + acceleration; } public void moveRight() { setLocation(getX() + speed, getY()); } public void moveLeft() { setLocation(getX() - speed, getY()); }