swift - How to initial correctly between two class -


i want make sure in class home invoke class hud, , these 2 part code test okay when run in xcode, crash , show issue:

"fatal error: use of unimplemented initializer 'init(size:)' class 'leftbehind.hud'"

i hope told me how fixed it, thanks.

    import uikit     import spritekit      class hud: skscene {          let positionx:cgfloat         let positiony:cgfloat         let sceneself: skscene          let year = sklabelnode()         let month = sklabelnode()         let day = sklabelnode()         let hour = sklabelnode()         let minute = sklabelnode()          init(positionx:cgfloat,positiony:cgfloat,scene:skscene) {             self.positionx = positionx             self.positiony = positiony             self.sceneself = scene             super.init()         }          required init?(coder adecoder: nscoder) {             fatalerror("init(coder:) has not been implemented")         }          func hudshow() {             year.fontname = "arial"             year.fontsize = 70             year.text = "this year"             year.fontcolor = uicolor.whitecolor()             year.position = cgpoint(x: positionx , y: positiony)             sceneself.addchild(year)         }     } 

below class invoke above class

import spritekit class home: skscene {     override func didmovetoview(view: skview) {         let hud = hud(positionx: frame.midx, positiony: frame.midy, scene: self)         hud.hudshow()     } } 

edit: upload way work not perfect way want implement initial rather function refer. enter image description here enter image description here

instead of calling super.init() call super.init(size size: cgsize)

you can use skview's bounds.size property pass initializer.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -