Do I need to create a new SpriteKit level editor file for every new .swift file?

前端 未结 1 1039
耶瑟儿~
耶瑟儿~ 2021-02-11 06:13

I\'m trying to get comfortable with Sprite Kit level editor. By default, there is one \"gamescene.sks\" file that\'s attached to \"gamescene.swift\".

If i\'m making a \"

1条回答
  •  抹茶落季
    2021-02-11 07:08

    Short Answer. Yes.

    Reason..

    Every time you want to present or load an .sks file, You need to load it with a class like so

    let doors = SKTransition.doorwayWithDuration(1.0)
            let archeryScene = GameScene(fileNamed: "GameScene")
            self.view?.presentScene(archeryScene, transition: doors)
    

    If you look a the constant loads the file with a class

    MyScene(fileNamed: "MyScene")

    So yeah you do need a .swift file for each .sks file.

    For more info on .sks files look here.

    Techotopia - An iOS 8 Swift Sprite Kit Level Editor Game Tutorial

    Also when I use the Spritekit Level Editor, I usually set the Scene size to 960 x 640 to support the smallest iPhone. Alsong as you have @1x, @2x, @3x and possibly @1x~iPad and @2x~iPad, Everything will be fine. Just to be sure in the ViewDidLoad or the initWithSize(CGSize) to add self.scaleMode = .AspectFill. You can set it to what ever it may be. Your options are,

    SKSceneScaleMode.Fill
    

    Each axis of the scene is scaled independently so that each axis in the scene exactly maps to the length of that axis in the view.

    SKSceneScaleMode.ResizeFill
    

    The scene is not scaled to match the view. Instead, the scene is automatically resized so that its dimensions always matches those of the view.

    SKSceneScaleMode.AspectFit
    

    The scaling factor of each dimension is calculated and the smaller of the two is chosen. Each axis of the scene is scaled by the same scaling factor. This guarantees that the entire scene is visible, but may require letterboxing in the view.

    SKSceneScaleMode.AspectFill
    

    The scaling factor of each dimension is calculated and the larger of the two is chosen. Each axis of the scene is scaled by the same scaling factor. This guarantees that the entire area of the view is filled, but may cause parts of the scene to be cropped.

    (Credits to @epicbyte - Dealing with different iOS device resolutions in SpriteKit)

    0 讨论(0)
提交回复
热议问题