Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameScene: CCNode {
- // 物理ノード
- weak var _physicsNode:CCPhysicsNode!
- // フレーム毎に呼び出されるメソッド
- override func update(delta: CCTime) {
- // ランダムに気球を生成します。
- if arc4random_uniform(100) == 0 {
- // バルーンを生成します。
- let balloonNode = CCBReader.load("Parts/BalloonNode")
- // 大きさをランダムにします。
- balloonNode.scale = Float(arc4random_uniform(25) + 25) * 0.01
- // 現在の大きさを取得します。
- let width = balloonNode.children[0].contentSizeInPoints.width * CGFloat(balloonNode.scale)
- let height = balloonNode.children[0].contentSizeInPoints.height * CGFloat(balloonNode.scale)
- // 上部へランダムに表示させます。
- balloonNode.position.x = CGFloat(arc4random_uniform(UInt32(self.contentSizeInPoints.width - width))) + width / 2
- balloonNode.position.y = self.contentSizeInPoints.height + height
- // 物理ノードにバルーンを設置
- _physicsNode.addChild(balloonNode)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement