Showing Errors in Xcode Playground that was never before

import SpriteKit
public class GameScene: SKView {
    public override func didMove(view: SKView) {
        physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
    }
}

Showing Error in didMove func and physicsBody.

Have any of you ever had issues like that?
Or maybe you just know what’s going on and how to fix it?
Answered by OOPer in 667572022

Showing Error in didMove func and physicsBody.

What sort of error do you get? Please show more context.

But assuming you are using the code shown as is, the code would never run or would never have run in any versions of Xcode Playgrounds. It is not a valid code in Swift.
  • SKView does not have a method didMove(view:), you cannot override non-existing method.

  • SKView (or your GameScene) does not have a property named physicsBody, you cannot assign something to non-existing property.

I guess you want to make a subclass of SKScene and override didMove(to:)?
Code Block
public class GameScene: SKScene {
public override func didMove(to view: SKView) {
physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
}
}


Accepted Answer

Showing Error in didMove func and physicsBody.

What sort of error do you get? Please show more context.

But assuming you are using the code shown as is, the code would never run or would never have run in any versions of Xcode Playgrounds. It is not a valid code in Swift.
  • SKView does not have a method didMove(view:), you cannot override non-existing method.

  • SKView (or your GameScene) does not have a property named physicsBody, you cannot assign something to non-existing property.

I guess you want to make a subclass of SKScene and override didMove(to:)?
Code Block
public class GameScene: SKScene {
public override func didMove(to view: SKView) {
physicsBody = SKPhysicsBody(edgeLoopFrom: frame)
}
}


Thank you very much :)
Showing Errors in Xcode Playground that was never before
 
 
Q