如果我在没有 SKAction 的情况下直接修改 SKSpriteNode 的位置和旋转,SpriteKit 会应用物理吗? [英] Does SpriteKit apply physics if I modify the position and rotation of a SKSpriteNode directly without an SKAction?

查看:15
本文介绍了如果我在没有 SKAction 的情况下直接修改 SKSpriteNode 的位置和旋转,SpriteKit 会应用物理吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,如果我想制作自己的自定义动画并以编程方式每帧移动一个 SKSpriteNode x += 10,Sprite Kit 是否仍能正确应用物理,还是我必须始终使用 SKAction?p>

For example if I want to do my own custom animation and move an SKSpriteNode every frame programmatically by x += 10, will Sprite Kit still apply physics correctly or must I always use SKAction?

推荐答案

无论何时何地,都可以手动移动带有物理体的节点.但无论如何都不建议这样做,因为它会对物理模拟产生不利影响.节点(视图)可能与身体位置不同步 1 帧,您可能会将身体移动到物理引擎将强制解决的碰撞中,从而导致跳跃、抖动、爆炸速度或跳过碰撞.

Manually moving a node with a physics body is possible regardless of how or when you do it. But in any case it's not recommended since it can adversely affect the physics simulation. The node (view) could be out of sync with the position of the body for 1 frame, and you might move the body into a collision which the physics engine will forcibly resolve, causing jumps, jitter, exploding velocities or skipping collisions.

当你使用物理时,坚持通过力、冲量或直接改变体速度来移动物理体.

这篇关于如果我在没有 SKAction 的情况下直接修改 SKSpriteNode 的位置和旋转,SpriteKit 会应用物理吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆