Moving background to infinite scroll help Swift Sprite Kit -
i'm having trouble understanding did wrong here. it's supposed infinite scroll downwards , can't fix it. help!
func movebackground() { let movebackground = skaction.movebyx(0, y: -self.size.height, duration: 1.0) let repeatbackground = skaction.repeatactionforever(movebackground) let removebackground = skaction.removefromparent() let sequencethis = skaction.sequence([movebackground, repeatbackground, removebackground]) } func repeatbackground() { let generatebackground = skaction.sequence([ skaction.runblock(self.movebackground), skaction.waitforduration(2.7)]) let endlessaction = skaction.repeatactionforever(generatebackground) runaction(endlessaction) } override func didmovetoview(view: skview) { scene?.scalemode = .aspectfill var backgroundtexture = sktexture(imagenamed: "background.png") background.position = cgpoint(x: self.frame.size.width/2, y: self.frame.size.height/2) background.texture = backgroundtexture background.size.width = self.frame.size.width background.size.height = self.frame.size.height self.addchild(background) }
whenever run app background stays in position , won't move.
first of movebackground()
doesn't except creating actions, doesn't run them. forgot run runaction(sequencethis)
in end.
there many more issues like, removing sprite reason making action repeat forever, remove sprite again, nothing adding back.
repeatbackground()
runs movebackground()
forever doesn't create new background, moves 1 forever.
lastly didmovetoview
doesn't call repeatbackground()
nor movebackground()
.
Comments
Post a Comment