फ़ॉरकेड फ़ॉरकेड अपडेट (वर्तमान समय: सीएफटीईइन्इंटरवल) {var पसंद = arc4random_uniform (2) अगर (पसंद == 0) {var Redball = SKSpriteNode (imageNamed: "Redball") redBall.setScale (0.5) redBall.position = CGPointMake (self.size.width / 2, self.size.height) redBall.size.height = 20 redBall.size.width = 30 redBall.physicsBody = SKPhysicsBody (circleOfRadius: redBall.size.height / 2.75)? redBall.physicsBody .dynamic = सच self.addChild (Redball)} अगर (विकल्प == 1) {var Redball = SKSpriteNode (imageNamed: "Redball ") redBall.setScale (0.5) redBall.position = CGPointMake (self.size.width / 5, self.size.height) redBall.size.height = 20 redBall.size.width = 30 redBall.physicsBody = SKPhysicsBody (circleOfRadius: RedBall.size.height / 2.75) redBall.physicsBody? .dynamic = true self.addChild (redBall) } यदि (पसंद == 2) {var redBall = SKSpriteNode (imageNamed: "redBall") redBall.setScale (0.5) redBall.position = CGPointMake (self.size.width * 5, self.size.height) redBall.size। ऊंचाई = 20 redBall.size.width = 30 redBall.physicsBody = SKPhysicsBody (circleOfRadius: redBall.size.height / 2.75)? redBall.physicsBody .dynamic = सच self.addChild (Redball)}}
आप बस एक SKAction
का उपयोग कर सकते हैं जो कि अद्यतन
समारोह
समारोह yourFunction () {// आपकी कोड} ओवरराइड समारोह didMoveToView (देखें: SKView)। {super.didMoveToView (देखें) जाने updateAction = SKAction.runBlock {( ) - & gt; self.yourFunction में शून्य ()} जाने waitDuration: NSTimeInterval = 5.0 जाने updateAndWaitAction = SKAction.sequence ([updateAction, SKAction.waitForDuration (waitDuration)]) जाने repeatForeverAction = SKAction.repeatActionForever (updateAndWaitAction) self.runAction (repeatForeverAction)} कोड>
No comments:
Post a Comment