Thank you for your continuous support.
I would like to display the background of SKScene, but why?It will remain black.
The code is the same as the 2D game programming that starts with SpriteKit from Sho Young, but
Where should I go?
If you understand, could you tell me?
Below is the code.
GameScene.swift
import SpriteKit
classGameScene:SKScene{
override func DidMoveToView (view:SKView) {
letbackGround=SKSpriteNode(imageNamed: "haikei.png")
backGround.position = CGPoint (x:self.size.width*0.5, y:self.size.height*0.5)
backGround.size = self.size
self.addChild (backGround)
}
}
GameViewController.swift
import UIKit import SpriteKit
classGameViewController:UIViewController {
override func viewDidLoad(){
super.viewDidLoad()
letscene=GameScene()
let view=self.view as!SKView
view.showsFPS=true
view.showsNodeCount=true
scene.size=view.frame.size
view.presentScene(scene)
}
}
I finally figured out the cause.It seems that the png image was too large to display.
When I reduced the size, I was able to see it clearly.
This post was posted as a community wiki based on @woodpecker's comments.
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.