Group Group Group Group Group Group Group Group Group Forums

Video Tutorial: How to Make a Game Like Flappy Bird in Swift Part 3: Adding the Player

Learn about GameplayKit by adding the star of the show, Felipe.

This is a companion discussion topic for the original entry at

Hi Tammy,

When I converted to Swift 3, I resolved all post-conversion errors except one! In SpriteComponent.swift the ‘var entity : GKEntity!’ is causing all sort of errors, as ‘entity’ is now a property with type GKEntity? If I rename it to ‘entityNew’ (or any other name), then the error is transferred to other statements. Please review and advise, thank you heaps in advance.

import SpriteKit
import GameplayKit

class EntityNode: SKSpriteNode {

## weak var entity: GKEntity! // GKEntity!



class SpriteComponent: GKComponent {

let node: EntityNode

init(entity: GKEntity, texture: SKTexture, size: CGSize) {
    node = EntityNode(texture: texture, color: SKColor.white, size: size)
    node.entity = entity
} // end init

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")


Hi @paradox927 have an Error on this line. how can I solve it?
and Thank you! for the great tutorials.

Binary operator ‘*’ cannot be applied to operands of type ‘CGPoint’ and ‘CGFloat’

    // Apply Gravity
    let  gravityStep = CGPoint(x: 0, y: gravity) * CGFloat(seconds)
    velocity += gravityStep
    //Apply Velocity
    let velocityStep = velocity * CGFloat(seconds)
    spriteNode.position += velocityStep

I fixed this Error with declare an extension :

extension CGPoint {
static func * ( left : CGPoint , right : CGFloat) -> CGPoint {
    return CGPoint(x: left.x * right, y: left.y * right)

static func * ( left : CGFloat , right : CGPoint) -> CGPoint {
    return CGPoint(x: right.x * left, y: right.y * left)