I'm trying to run this line:
guard let spriteComponent = entity?.componentForClass(SpriteComponent.self) else {
return
}
and receiving this:
Value of type 'GKEntity' has no member 'componentForClass'
Apparently apple has removed this method from GamePlayKit
GkEntity
class. So which method should I use instead?
In Swift 3 this has changed to component(ofType:)
. So your expression will look like;
guard let spriteComponent = entity?.component(ofType: SpriteComponent.self) else {
return
}