gpt4 book ai didi

ios - 背景 block 粒子效果

转载 作者:行者123 更新时间:2023-11-30 13:34:44 25 4
gpt4 key购买 nike

我向我的应用程序添加了背景和爆炸粒子效果。背景和 Sprite 一起工作得很好,但爆炸效果出现在背景后面。背景的 zposition 设置为零,一些帮助是合法的。

   background = SKSpriteNode(imageNamed: "Starfield")
background.size = CGSize(width: 430, height: 700)
background.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2 )
self.addChild(background)
background.zPosition = 0

func explosion(pos: CGPoint) {
var emitterNode = SKEmitterNode(fileNamed: "Explosion.sks")
emitterNode!.particlePosition = pos
self.addChild(emitterNode!)
// Don't forget to remove the emitter node after the explosion
self.runAction(SKAction.waitForDuration(2), completion: { emitterNode!.removeFromParent() })

}

最佳答案

这是为有需要的人提供的解决方案。

func explosion(pos: CGPoint) {
var emitterNode = SKEmitterNode(fileNamed: "Explosion.sks")
emitterNode!.particlePosition = pos
self.addChild(emitterNode!)
// Don't forget to remove the emitter node after the explosion
self.runAction(SKAction.waitForDuration(2), completion: { emitterNode!.removeFromParent() })
emitterNode?.zPosition = 2

}

关于ios - 背景 block 粒子效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36206060/

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