我正在尝试创建一个弹簧启动器,当触摸在场景上移动时,弹簧将盘绕触摸向下拖动的量,然后在触摸结束方法上启动弹簧上方的项目。为此,我将触摸移动方法中 SKSpriteNode 的大小和位置更改为 -
launcher.position = CGPointMake(frame.size.width*0.97, launcher.position.y-1)
launcher.size = CGSizeMake(frame.size.width*0.05, launcher.frame.size.height-2)
But the Physics body of SKSpriteNode not changing it comes like this - ![enter image description here](https://i.stack.imgur.com/nSiQc.png)
请帮忙..如果 SKSpriteNode 的物理主体发生变化,那么它在设备上会滞后太多..
let springTexture = SKTexture(imageNamed: "spring-wire")
launcher.physicsBody = SKPhysicsBody(texture: springTexture, size: launcher.size)
launcher.physicsBody?.dynamic = false
创建一次后有什么方法可以改变物理体的大小吗?
我通过更改 SKSpriteNode 的 yScale 而不是在 TouchMoved 方法中更改其大小来修复它
launcher.yScale = launcher.yScale-0.008
launcher.position = CGPointMake(frame.size.width*0.97, launcher.size.height/2)
我不知道这是否是正确的方法,但是这个 SKSpriteNode 的物理主体会相应改变。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)