我有这个在屏幕上下移动的圆圈,我想将这些动作随机化,所以它一遍又一遍不一样。例如,圆圈会上升几个点,然后一直向下并快速恢复。每次用户玩游戏时都会有所不同。这就是我现在所拥有的:
func addCircle() {
circle.position = CGPointMake(self.size.width / 2, self.size.height / 2.0)
circle.zPosition = 32
circle.physicsBody = SKPhysicsBody(circleOfRadius: 75)
circle.physicsBody?.dynamic = false
circle.physicsBody?.categoryBitMask = CircleCategory
circle.physicsBody?.contactTestBitMask = HeroCategory
circle.physicsBody?.collisionBitMask = CircleCategory
let moveDown = SKAction.moveToY(-circle.frame.size.height + 220, duration: 2.5)
let moveUp = SKAction.moveToY(700, duration: 2.5)
let sequenceUpAndDown = SKAction.sequence([moveDown, moveUp])
let repeatSequence = SKAction.repeatActionForever(sequenceUpAndDown)
circle.runAction(repeatSequence)
addChild(circle)
}
答案 0 :(得分:1)
[...]
frame= 28 fps=0.0 q=-0.0 size=N/A time=00:00:01.16 bitrate=N/A speed=2.31x
frame= 55 fps= 54 q=-0.0 size=N/A time=00:00:02.24 bitrate=N/A speed= 2.2x
frame= 84 fps= 55 q=-0.0 size=N/A time=00:00:03.40 bitrate=N/A speed=2.22x
frame= 112 fps= 54 q=-0.0 size=N/A time=00:00:04.52 bitrate=N/A speed=2.17x
[...]
试一试