ios - Smooth switching between texture atlas animations -


how can make smooth transitions between multiple animations on same character without delay?

i'm developing game in ios swift jumping character. character has few animations, basic animation, jump animation , landing animation.

i set texture atlas every animation follows:

    // basic     let surferbasicanimatedatlas = sktextureatlas(named: "surfer_basic.atlas")      let numimages = surferbasicanimatedatlas.texturenames.count      var i=0; i<numimages; i++ {         let surferbasictexturename = "surfer_basic_000\(i)"         self.surferbasicframes.append(surferbasicanimatedatlas.texturenamed(surferbasictexturename))     }      // jump     let surferjumpanimatedatlas = sktextureatlas(named: "surfer_jump.atlas")      let numjumpimages = surferjumpanimatedatlas.texturenames.count      var i=0; i<numjumpimages; i++ {         let surferjumptexturename = "surfer_jump_000\(i)"         self.surferjumpframes.append(surferjumpanimatedatlas.texturenamed(surferjumptexturename))     }      // landing     let surferlandinganimatedatlas = sktextureatlas(named: "surfer_landing.atlas")      let numlandingimages = surferlandinganimatedatlas.texturenames.count      var i=12; i<numlandingimages; i++ {         let surferlandingtexturename = "surfer_landing_000\(i)"         self.surferlandingframes.append(surferlandinganimatedatlas.texturenamed(surferlandingtexturename))     }      // pick textures     self.surferwalkingframes = surferbasicframes      let firstframe = surferwalkingframes[0]     self.character = skspritenode(texture: firstframe)      self.character.runaction(skaction.repeatactionforever(skaction.animatewithtextures(surferwalkingframes, timeperframe: (1 / 30), resize: false, restore: true)), withkey:"surferbasic") 

when touch screen basic animation should stop , jump animation should run, causes delay. 1 second after touch jump animation starts.

i've tried this:

override func touchesbegan(touches: set<nsobject>, withevent event: uievent) {      self.character.removeactionforkey("surferbasic")      self.surferwalkingframes = surferjumpframes     self.character.runaction(skaction.repeatactionforever(skaction.animatewithtextures(surferwalkingframes, timeperframe: (1 / 30), resize: false, restore: true)), withkey:"surferjump") } 

how can make smooth transitions between multiple animations on same character without delay?

i wrong, looks (1 / 30) offender couple of reasons.

  1. 1/30 return int , 0
  2. if 1.0/30.0 nice float want 0.03333333333333 , asking 2 switch texture 30 times second. rather fast , may not see change.

i try .2 first , see if changes if matter of finding how fast need change texture.

hopefully helps.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -