@@ -50,19 +50,10 @@ class GameScene: SKScene, IRenderScreen {
5050 }
5151
5252 override func didChangeSize( _ oldSize: CGSize ) {
53- // 防止递归调用
54- // if screenSize.width > oldSize.width {
55- // return
56- // }
5753 print ( oldSize)
5854 screenSize = oldSize
59- // guard !isUpdatingLayout else { return }
60- guard oldSize. width > 200 else { return } //, oldSize.height > 0 else { return }
61- // print(oldSize)
62- // isUpdatingLayout = true
63- // defer { isUpdatingLayout = false }
64-
65- //self.adjRenderCanvasSize(oldSize)
55+ guard oldSize. width > 200 else { return }
56+
6657 }
6758
6859 func adjRenderCanvasSize( _ viewSize: CGSize ) {
@@ -74,12 +65,9 @@ class GameScene: SKScene, IRenderScreen {
7465 return
7566 }
7667
77- //self.size = viewSize
7868 scaleMode = . resizeFill
79- //会使场景自动适应视图大小
8069
8170 if windowWidth / windowHeight > 256.0 / 240.0 {
82- // 宽屏模式:高度撑满,宽度按比例计算
8371 gameCanvasHeight = Int ( windowHeight)
8472 gameCanvasWidth = gameCanvasHeight * 256 / 240
8573
@@ -89,7 +77,6 @@ class GameScene: SKScene, IRenderScreen {
8977 gameCanvasCenterX = halfCanvasWidth + extraXOffset
9078 gameCanvasCenterY = gameCanvasHeight / 2
9179 } else {
92- // 窄屏模式:宽度撑满,高度按比例计算
9380 gameCanvasWidth = Int ( windowWidth)
9481 gameCanvasHeight = Int ( windowWidth * 240 / 256 )
9582
@@ -99,9 +86,6 @@ class GameScene: SKScene, IRenderScreen {
9986 let extraYOffset = Int ( ( windowHeight - canvasHeightFloat) / 2 )
10087 gameCanvasCenterY = halfCanvasHeight + extraYOffset
10188 }
102-
103- //bgSKSpriteNode?.position = CGPoint(x: gameCanvasCenterX, y: gameCanvasCenterY)
104- //bgSKSpriteNode?.size = CGSize(width: gameCanvasWidth, height: gameCanvasHeight)
10589 }
10690
10791 // MARK: - 平台特定的初始化入口
0 commit comments