Cannot assign value of type 'GameScene.CGPoint' to type 'CGPoint'

import SpriteKit

class GameScene: SKScene{

struct CGPoint {
    var x: CGFloat
    var y: CGFloat

struct CGSize {
    var width:CGFloat
    var height:CGFloat

override func didMove(to view: SKView) {
    let background = SKSpriteNode(imageNamed: "backGround1")

*background.position = CGPoint(x: size.width/2, y: size.height/2)**:joy:here

backgroundColor =

@melrain Thanks very much for your question! I found the following potential solution to your problem:

You need to make GameScene conform to SKPhysicsContactDelegate, like so:

class GameScene: SKScene, SKPhysicsContactDelegate {
// …

Now you can implement the delegate methods you want, all the methods in SKPhysicsContactDelegate are optional, and they’ll get called at the appropriate time.

For more information on Protocols, I would recommend looking at The Swift Programming Language: Protocols

The above answer was found here.

I hope this helps!

All the best!

This topic was automatically closed after 166 days. New replies are no longer allowed.