swift - SKScene View Rendering Issues (see photo) -


click ----> pic :) this gamescene of now, hard coded , linked global file of holds scene data

  override func didmovetoview(view: skview) {       super.didmovetoview(view)           playbutton.hidden = true      let background = skspritenode(imagenamed: "us-flag")      background.position = cgpoint(x: size.width/2, y: size.height/2 )      background.blendmode = .replace     background.zposition = -1     background.size = self.size      addchild(background)      gameoverbutton = skspritenode(imagenamed: "gameover")     gameoverbutton.position = cgpoint(x: size.width / 2 , y: scene!.frame.height - 200)     gameoverbutton.zposition = 3     gameoverbutton.xscale = 1.5     gameoverbutton.yscale = 1.5      gameoverbutton.hidden = true      addchild(gameoverbutton)      gamescore = customsklabel(fontnamed: "chalkduster")     gamescore.text = "votes: 0"     gamescore.position = cgpoint(x: int((self.size.width - gamescore.frame.width )) , y: 22)     gamescore.horizontalalignmentmode = .center     gamescore.fontsize = 27     gamescore.zposition = 3     gamescore.fontcolor = skcolor.whitecolor()      addchild(gamescore)     /*   in 0 ..< 5 { createslotat(cgpoint(x: 160 + (i * 170), y: 410)) }     in 0 ..< 4 { createslotat(cgpoint(x: 240 + (i * 170), y: 320)) }     in 0 ..< 5 { createslotat(cgpoint(x: 160 + (i * 170), y: 230)) }     in 0 ..< 4 { createslotat(cgpoint(x: 240 + (i * 170), y: 140)) }      runafterdelay(1) { [unowned self] in         self.createenemy() */       in 0 ..< 5 { createslotat(cgpoint(x: 680 + (i * 170), y: 535)) }     in 0 ..< 4 { createslotat(cgpoint(x: 715 + (i * 170), y: 435)) }     in 0 ..< 5 { createslotat(cgpoint(x: 680 + (i * 170), y: 335)) }     in 0 ..< 4 { createslotat(cgpoint(x: 715 + (i * 170), y: 245)) }     runafterdelay(1) { [unowned self] in         self.createenemy() 

my game scene hard coded other scenes built in scene editor, attempt universal app, yet decided release iphone used work properly, until ported game on spritekit

gameviewcontroller:

 if let scene = welcomescene (filenamed:"welcomescene") {      let skview = self.view as! skview     skview.showsfps = constant.dev.debug     skview.showsnodecount = constant.dev.debug     skview.ignoressiblingorder = true     scene.scalemode = .aspectfit     skview.presentscene(scene)        }      }   override func prefersstatusbarhidden() -> bool {     return false }  override func shouldautorotate() -> bool {     return true }  override func supportedinterfaceorientations() -> uiinterfaceorientationmask {     return [uiinterfaceorientationmask.landscaperight ,uiinterfaceorientationmask.landscapeleft]  } 

}

globalscenedataswift:

 if let scene = scenetoload {     scene.size = size     scene.scalemode = scalemode     let transition = sktransition.fadewithduration(3)     self.view?.presentscene(scene, transition: transition)        }   } } 

before moved spritekit embedded gameviewcontroller, used regular viewcontroller, , embedded subviews, facilitate gamescene, worked great until turn four, when cpu dropped 0 , memory spiked. went spritekit. other scenes fine iphone. except gamescene. pulls in wrong assets , scene looks picture.

old code gamescene uikit , spritekit mix in case helps:

    let deviceidiom = uiscreen.mainscreen().traitcollection.userinterfaceidiom      switch (deviceidiom) {      case .pad:          let active = skspritenode(imagenamed: self.name!)         active.name = self.name         active.size = cgsizemake(100, 100)         active.position = cgpoint(x: int( active.frame.width + 0), y: int(active.frame.height + 10))         addchild(active)      case .phone: break      case .tv:         let active = skspritenode(imagenamed: self.name!)         active.name = self.name         active.size = cgsizemake(100, 100)         active.position = cgpoint(x: int( active.frame.width + 12), y: int(active.frame.height + 12))         addchild(active)      default: break      }      let w12 = int(self.size.width / 12)     let w6 = int(self.size.width / 6)     let w5 = int(self.size.width / 5)     let h3 = int(self.size.height / 3)      in 0 ..< 5 { createslotat(cgpoint(x: w12 + (i * w5), y: h3 + 120 )) }     in 0 ..< 4 { createslotat(cgpoint(x: w6  + (i * w5), y: h3 + 60)) }     in 0 ..< 5 { createslotat(cgpoint(x: w12 + (i * w5), y: h3 + 10 )) }     in 0 ..< 4 { createslotat(cgpoint(x: w6  + (i * w5), y: h3 - 50)) }      runafterdelay(1) { [unowned self] in         self.createenemy()     } } 

im sticking spritekit, solo because been lot more stable, transitioning scenes ones lot moving parts. scene size 1920 * 1080 ground images match setup, chose size in case decide port apple tv later. again takes time answer questions on here. pic included

legacy update checked assets , noticed background size off, being part of game created 2 months ago forgot manually adjusted picture in code**** has not solved problem yet, images show, , background not picnic blanket.

when reviewing code noticed lack of comments in original project created. bring because if commented, noticed changes take effect when port uikit + spritekit mix using strictly spritekit.

1st) mention thinking of doing universal app, specified in old code gameviewcontroller. embedded views inside view controller, collection view, skcontainer view, uiimage view, created using constraints of gameviewcontroller.

2.) game scene sks @ aspect ratio apple tv, , cgpoints utilized make assets fit size. (smh)

3.) each node had different scale factor accomplish rendering right view, these images populated database swift file, posted in earlier post, skemitters,

4.) porting spritekit, lose of cool uibutton functionality, yet transitioning scene through segues. (causes memory spikes , cpu drops) if not know doing.

   node.xscale = 0.5    node.yscale = 0.5 

was code needed render proper sizes, adjusting assets conform dimensions. comes down small piece of code, out of 30 swift files there was. if had //commented purpose of saved myself hours of "learning experience"

spritekit transformation using scene editor, can fun, , code amount can rather small or large depending on game. subclass buttons, in touches began method, if there lot of them, , use global scene/data base/or dict store data, avoid strong references.

finally: tutorials awesome bunch of code make project excited, take time go line line learn "exactly" code doing. comment discoveries. if ever have refactor project enlighten coder, not reaching straws in dark.

(had few redbulls) :)

legacy


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -