Question

I'm implementing a side scrolling game with SpriteKit:

As long as my sprite stays in the middle of the screen, I'm moving the sprite

enter image description here

When the sprite reaches the left or the right part of the screen, I'm moving the level instead of my sprite:

enter image description here

This works quite well, unless my sprite collides with another object. In that case the level (triggered by my code) and the sprite (triggered by the physics engine) are moved and the sprite moves outside the screen:

enter image description here

I tried to stop the impulse which is applied from the physics engine. This hasn't worked.

Any idea how to handle this?

Thanks Stefan

Was it helpful?

Solution

I suppose by "moving the level" you mean moving the background view.

Why don't you just have an area in which your sprite moves that is the same size as your background? You can scroll to keep the sprite visible without disturbing the logic of physics and other manipulation of the movement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top