让 SKEmitterNode 看起来自然?
Making SKEmitterNode look natural?
在我的 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 设为精灵。发射器相对于精灵总是处于相同的位置,所以你不会得到我认为你想要的那种波浪效果。
在我的 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 设为精灵。发射器相对于精灵总是处于相同的位置,所以你不会得到我认为你想要的那种波浪效果。