0

I have a parent class that is inherited from the standard SKScene, named as - SKSParent. It is created to perform the parent function of creating custom scenes by identifier. The problem is that when I launch the project on iOS 11 + everything works correctly, but when I launch on ios 10.3.1. My objects that I create by the scene ID do not accept the desired child class based on identifier. All objects are created as objects of the SKSParent class, regardless of their identifier and created .swift files.

Perhaps someone has encountered this behavior

import SpriteKit

class Parent: SKScene {

}

class StoryScene: Parent {

}

class Story1: StoryScene {

}

class Story2: StoryScene {

}

class Story3: StoryScene {

}

Some condition for chose story(for example save current user progress to user default like story name) Created some story with using for init by Name from super class like below:

let storyName = UserDefaults.standard.string(forKey: "current_user_story") ?? "Story1"

let currentStory = Parent(fileNamed: storyName)


/* some configurations with using object like Parent object */
/* presenting to user. */

In this case on iOS 10 current story is object of class 'Parant'... In this case on iOS 11 and higher it's object of a specific type of Story(*)

The fact is that on ios 10 in such cases, objects load components from the .sks file but do not execute the life cycle methods of a particular class from the .swift file.

Cœur
  • 37,241
  • 25
  • 195
  • 267
VladislavT
  • 21
  • 4

0 Answers0