我正在用SpriteKit实现一个侧滚动游戏:
只要我的精灵停留在屏幕中间,我就会移动精灵
当精灵到达屏幕的左侧或右侧时,我正在移动关卡而不是我的精灵:
这非常有效,除非我的精灵与另一个对象发生碰撞。 在这种情况下,水平(由我的代码触发)和精灵(由物理引擎触发)被移动,精灵移动到屏幕外:
我试图阻止从物理引擎施加的冲动。 这没效果。
知道如何处理这个吗?
谢谢Stefan
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
When the sprite reaches the left or the right part of the screen, I'm moving the level instead of my sprite:
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:
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
最满意答案
我想通过“移动关卡”你的意思是移动背景视图。
你为什么不只有一个你的精灵移动的区域与你的背景大小相同? 您可以滚动以保持精灵可见而不会干扰物理逻辑和其他对运动的操纵。
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.
更多推荐
发布评论