swift - Animation of a circle in iOS -


i'm learning how use spritekit , have circle that:

  • grows , shrinks smoothly
  • pulses colour
  • is displayed crisp edges

so far, i've come following code:

import spritekit  class gamescene: skscene {      override func didmovetoview(view: skview) {         addcircle()     }      func addcircle(){         let circle = skshapenode(circleofradius: 50 ) // size of circle         circle.position = cgpointmake(frame.midx, frame.midy)  //middle of screen         circle.glowwidth = 0.0 // no border         circle.fillcolor = skcolor.yellowcolor() // start yellow         let actualduration = 1 // animate 1s         // basic actions grow, shrink, colour up, colour down         let actiongrow = skaction.scaleto(cgfloat(2), duration: nstimeinterval(actualduration))         actiongrow.timingmode = skactiontimingmode.easeineaseout         let actionshrink = skaction.scaleto(cgfloat(0.5), duration: nstimeinterval(actualduration))         actionshrink.timingmode = skactiontimingmode.easeineaseout         let actioncolorup = skaction.colorizewithcolor(uicolor.redcolor(), colorblendfactor: 1.0, duration: nstimeinterval(actualduration))         let actioncolordown = skaction.colorizewithcolor(uicolor.redcolor(), colorblendfactor: 0.0, duration: nstimeinterval(actualduration))         // combine actions         let actiongrowwithcolor = skaction.group([actiongrow,actioncolorup])         let actionshrinkwithcolor = skaction.group([actionshrink,actioncolordown])         // run , repeat         circle.runaction(skaction.repeatactionforever(skaction.sequence([actiongrowwithcolor,actionshrinkwithcolor])))         // add circle         self.addchild(circle)      } } 

the first of 3 criteria met, other 2 not.

  • as skshapenode not vector, grows edges not crisp. there better way draw circle, or should start circle sufficiently large?
  • is there reason why colorizewithcolor section doesn't appear have effect?

many in advance!


Comments