的路径这是在XCode中SKEmitter编辑器(我想做到这一点在iPhone上)动画:无法使粒子按照spriteKit
这是iPhone上的动画(我不希望这个动画):
使用此代码:
let sparkEmmiter = SKEmitterNode(fileNamed: "fireflies.sks")
self.addChild(sparkEmmiter) // self is a SKScene
var circle: CGPathRef? = nil
circle = CGPathCreateWithEllipseInRect(CGRectMake(400, 200, 200, 200), nil)
let followTrack = SKAction.followPath(circle!, asOffset: false, orientToPath: true, duration: 3.0)
let followTrackForever = SKAction.repeatActionForever(followTrack)
//sparkEmmiter.runAction(followTrackForever)
sparkEmmiter.particleAction = followTrackForever;
这是发射器设置:
我参照本question尝试都runAction和particleAction,但我希望它不工作...
- --------------- 更新 -------------------------------- --------------
试过hamobi提到的解决方案(仍然不起作用):
//If I were you:
// 1) I'd make a sprite and
let texture = SKTexture(imageNamed: "spark")
let mySprite = SKSpriteNode(texture: texture)
self.addChild(mySprite)
// 2) add the emitter in your first example as a child.
let sparkEmmiter = SKEmitterNode(fileNamed: "fireflies.sks")
mySprite.addChild(sparkEmmiter)
// 3) I'd set the emitters targetNode to the scene.
sparkEmmiter.targetNode = self
// 4) Then I'd just animate the sprite itself in an arc.
var circle: CGPathRef? = nil
circle = CGPathCreateWithEllipseInRect(CGRectMake(400, 200, 200, 200), nil)
let followTrack = SKAction.followPath(circle!, asOffset: false, orientToPath: true, duration: 3.0)
let followTrackForever = SKAction.repeatActionForever(followTrack)
//sparkEmmiter.runAction(followTrackForever)
sparkEmmiter.particleAction = followTrackForever;
----------------- 更新2 ------------------ ----------------------------
Got it! THX到hamobi:d是这样的结果:d:d
嗨@hamobi THX的回答粒子,我已经试过遵循您的建议,但仍无法解决它...你可以请看看我的代码上面,在更新行下... – user1872384 2015-04-01 05:26:44
明白了!非常感谢你......之前被particleAction弄糊涂了...... – user1872384 2015-04-01 06:00:08