gpt4 book ai didi

ios - 让 SKEmitterNode 看起来自然?

转载 作者:搜寻专家 更新时间:2023-11-01 06:23:38 25 4
gpt4 key购买 nike

在我的 SpriteKit 游戏中,我试图将 SKEmitterNode 添加到 SKSpriteNode。当我在屏幕上移动手指时,在这种情况下,火应该随之移动。

 override func touchesBegan(touches: NSSet, withEvent event:UIEvent) {
var touch = touches.anyObject() as UITouch!
var touchLocation = touch.locationInNode(self)

let body = self.nodeAtPoint(touchLocation)
if body.name == FireCategoryName {
println("Began touch on body")

firePosition = body.position
isFingerOnGlow = true

}


}

override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {

if isFingerOnGlow{

let touch = touches.anyObject() as UITouch!
let touchLocation = touch.locationInNode(self)
let previousLocation = touch.previousLocationInNode(self)
let distanceX = touchLocation.x - previousLocation.x
let distanceY = touchLocation.y - previousLocation.y


firePosition = CGPointMake(firePosition.x + distanceX, firePosition.y + distanceY)


}
}

override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
isFingerOnGlow = false
}

我有这样的 firePosition,允许它改变 SKSpriteNode 火和 SKEmitterNode bloss 上的位置。

var bloss = SKEmitterNode()
var fire = SKSpriteNode()
var firePosition : CGPoint = CGPointMake(100, 200) { didSet { fire.position = firePosition ; bloss.position = firePosition } }

正如预期的那样,两者出现在同一个地方,但即使 bloss 节点将其 .targetNode 设置为 fire,它看起来也不自然。对于自然,我的意思是如果 targetNode 移动,发射器将在 body 移动的路径上传播粒子。对我来说,发射器只是向上燃烧,不会改变形状或任何东西。当我尝试让 firePosition 仅设置 sprite 位置并为发射器设置一个恒定位置时,它会根据我移动 sprite 的方式将其粒子散布到不同的侧面。抱歉,如果解释含糊...有没有办法解决这个问题?

最佳答案

将 bloss emitterNode 的 targetNode 属性设置为场景。

bloss.targetNode = self

它看起来不自然,因为您将 targetNode 设为 Sprite 。发射器相对于 Sprite 总是处于相同的位置,所以你不会得到我认为你想要的那种波浪效果。

关于ios - 让 SKEmitterNode 看起来自然?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28568401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com