Those two lines in your code most likely cause the problem:
player.isPushingRight=false;
player.isPushingLeft=false;
They are executed when there is an object that starts falling. Usually, this fall would be initiated by the player, so it might make some sense here, though there might be a more appropriate place for those lines.
The real problem is how you determine if an object starts falling: you check every platform, and as soon as you find one where the object is not rested on, you let the object start falling. If you later find a platform where the object is rested on, you cancel the fall but the player animation is already stopped.
void objGround(ArrayList<Platform> platforms, ArrayList<Pushable> pushObj) {// to see if the object is standing on a platform.
for (Pushable pu : pushObj) {
pu.render();
let isOnGround = false;
for (Platform plt : platforms) {
if (pu.objectOnGround(plt)) {
pu.moveY=0;
pu.falling=false;
if (pu.y>pu.startingY+20) {
pu.smashed=true;
}
isOnGround = true;
break;
}
}
if (!isOnGround && !pu.falling) {
pu.falling=true;
pu.moveY=2;
pu.startingY=pu.y; // Guess you need that too
player.isPushingRight=false; // only valid if the player is the only cause of a falling object!
player.isPushingLeft=false; // only valid if the player is the only cause of a falling object!
}
}
} // end of objground procedure
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…