Stack pile objects climb



I was wondering what would be the best way to reproduce a stack-pile object that makes you grow in height, where you tap/click to add a new object, which games like BombChicken did.

I think the're possibly two easy approach:

- One being just a jump, which ends up spawning an object bellow you once you left enough space between I guesss.
- Second one could be just spawing the next object and according move and animate the player upwards and snap it.

Here's an example:

The stacked objets would have to act as solid also, as you would lose them on collision.

Any ideas on what the best approach would be?

Thank you very much


Most straightforward, I would imagine, would be a player action that moves them up N pixels per step for several steps, then spawns a box directly beneath the player. If you're working with a state machine, that's a player state with forces the player to move and counts up some variable, and upon reaching certain count spawns a new box and steps back to neutral/idle player state. If your collision code is done and running, everything should work. Spawning the box after the player has been properly repositioned makes it unnecessary to write any collision code exceptions that understands player and box overlapping while player is moved to position.