Okay, after line 8 add the if for the platform check.
public void checkfall()
{
if(onGround())
{
vSpeed = 0;
}else
{
fall();
}
}
public void fall()
{
setLocation(getX(), getY() + vSpeed);
vSpeed = vSpeed + acceleration;
int worldBottom = getWorld().getHeight() - getImage().getHeight()/2;
boolean ground = (getY() == worldBottom);
if(getY()>=worldBottom)
{
setLocation(getX(),worldBottom);
}
if(getY()>=worldBottom)
{
Actor platform = getOneObjectAtOffset(0,getImage().getHeight()/2,Platform.class);
int platformX = platform.getX();
int platformHeight = platform.getImage().getHeight();
setLocation(platformX,platformHeight/2);
}
}
public boolean onGround()
{
Actor under = getOneObjectAtOffset(0,getImage().getHeight()/2,Platform.class);
return under !=null;
}Actor platform = getOneObjectAtOffset(0,getImage().getHeight()/2,Platform.class);
if (platform != null)
{vSpeed = 0;
public void fall()
{
vSpeed = vSpeed + acceleration;
setLocation(getX(), getY() + vSpeed);
int worldBottom = getWorld().getHeight() - getImage().getHeight()/2;
boolean ground = (getY() == worldBottom);
if(getY()>=worldBottom)
{
setLocation(getX(),worldBottom);
vSpeed = 0;
}
Actor platform = getOneObjectAtOffset(0,getImage().getHeight()/2,Platform.class);
if(platform !=null)
{
int platformX = platform.getX();
int platformHeight = platform.getImage().getHeight();
setLocation(platformX,platformHeight/2);
vSpeed = 0;
}
}public void fall()
{
int worldBottom = getWorld().getHeight();
int myMidHeight = getImage().getHeight()/2;
vSpeed = vSpeed + acceleration;
setLocation(getX(), getY() + vSpeed);
if (getY() >= worldBottom)
{
setLocation(getX(), worldBottom-myMidHeight);
vSpeed = 0;
}
Actor platform = getOneObjectAtOffset(0, myMidHeight, Platform.class);
if (platform != null)
{
int platformHeight = platform.getImage().getHeight();
setLocation(getX(), platform.getY()-platformHeight/2-myMidHeight);
vSpeed = 0;
}
}setLocation(getX(), worldBottom-myMidHeight);
setLocation(getX(), worldBottom-myMidHeight);