我在一个项目上工作,我在后台生成随机圆圈,这样我就可以让它们消失并让它们消失并一遍又一遍地完成这个过程(对于一个旅行效果)但是当我这样做时,圆圈会重叠我所有其他节点。 是否可以将它们保留在背景中?
我使用此代码生成我的圈子
let spawn = SKAction.runBlock({() in self.TripEffects()})
let delay = SKAction.waitForDuration(1)
let sequense = SKAction.sequence([spawn, delay])
let Loop = SKAction.repeatActionForever(sequense)
self.runAction(Loop)
func TripEffects() {
// Create Random RGB color
var red = Float(arc4random_uniform(100)+1)
red = red / 100
var green = Float(arc4random_uniform(100)+1)
green = green / 100
var blue = Float(arc4random_uniform(100)+1)
blue = blue / 100
//define a circle
let TripCircle = SKShapeNode(circleOfRadius: 1)
//set the colors
TripCircle.fillColor = SKColor( red: CGFloat(red),green: CGFloat(green),
blue: CGFloat(blue),alpha: 1)
//set the posiotion
TripCircle.position = CGPoint (x: CGFloat(arc4random()%(canvasWidth)),
y: CGFloat(arc4random()%(canvasHeight)))
// add the node to the scene
self.addChild(TripCircle)
//set the Animation
let Grow = SKAction.scaleTo(100, duration: 10)
let Hide = SKAction.fadeAlphaTo(0, duration: 1)
let Remove = SKAction.removeFromParent()
let Sequence = SKAction.sequence([Grow, Hide, Remove])
TripCircle.runAction(Sequence)
}