Search code examples
sprite-kitgame-physics

Kind of platformer game in Spritekit


I read that using a physics engine can be the cause of many problems in programming platformer type of games.

I am making something similar to the platformer game(not a classic platformer).

  • Game will have a platforms, but not many.
  • Game will not have moving platforms
  • Game will not have slopes
  • Game will have ladders
  • Hero can shoot the enemies
  • Hero can jump
  • Hero can access ladders from the air

I have to choose between physics engine and tile tehnique...

The first problems I can think of are:

  1. problem with physics engine and the ladders because physics rules are applied to hero and his movement,so I guess it would be hard to get him on the ladders while his physicsBody.dynamic property is set to YES.

  2. problem with the tile tehnique - how to make hero falling from the ledge(while running) with an realistic arc (when we use physics this is done by engine itself...)?

And the main problem, based on the type of the game I am making, is, sholud I combine tiles tehinque(let's say for hero's moving) and physics engine for collision detection, and shooting enemies?

I know there are a lot of questions about this subject, but I must start from something...

Tnx in advance


Solution

  • I would recommend the physics engine. It is very straight forward... what you expect is generally what happens.

    Run, Jump, Shoot, Fall, etc. - Very easy to do using the physics engine.

    Ladders will be problematic but you could set a bool flag that lets you know when the ladder and hero are touching, therefore allowing you to exhibit different behaviors depending if this bool is true or not. Ex. Make hero not affected by gravity if touching a ladder.

    It is very smart that you are planning this out ahead of time and have outlined all of your core requirements. IMHO, the rest of the requirements will be so easy using the physics engine that it will outweigh additional time spent on the harder part with ladders.