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

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

问题描述

例如,如果我想做自己的自定义动画并按照 x + = 10 以编程方式每帧移动SKSpriteNode,Sprite Kit是否仍会正确应用物理或必须我总是使用SKAction?

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天全站免登陆