$30 off During Our Annual Pro Sale. View Details »

まだiOSでリッチな演出に疲弊してるの?

Ryusuke Fuda
February 14, 2015

 まだiOSでリッチな演出に疲弊してるの?

iOSオールスターズ勉強会発表資料です。

Ryusuke Fuda

February 14, 2015
Tweet

More Decks by Ryusuke Fuda

Other Decks in Programming

Transcript

  1. ·ͩiOSͰϦονͳԋग़ʹർฐͯ͠Δͷʁ ໘ന๏ਓ ΧϠοΫ ෍ాོհ @ryusukefuda iOSΦʔϧελʔζษڧձ 14,Feb,2015

  2. ΧϠοΫͷΞϓϦࣄ৘

  3. ʲࣗࣾ։ൃʳ ʲडୗ։ൃʳ

  4. ԋग़ɺػೳͱ΋ʹ ༷ʑͳ΋ͷ͕ΞϓϦʹ ٻΊΒΕΔ

  5. ྫ͑͹

  6. None
  7. None
  8. ർฐ…

  9. ฐࣾઌഐ ʮͲ͏͠Α͏΋ͳ͘ͳͬͯԋग़ʹ ɹಈըΛͭͬ͜Μͩ͜ͱ͋ΔΑɻʯ

  10. ׬શͳΔർฐ…

  11. Ϧονͳԋग़ ɾCoreAnimationʁ ɾUnityʁ ɾCocos2dʁ ɾLibraryʁ

  12. ɾCoreAnimation ɾUnityɾCocos2d ɾLibrary ίʔυྔ૿͑Δ͠ɺେྔͷΦϒδΣΫτΛ ಈ͔͢ͷͱ͔େม…. ԋग़͸࡞Γ΍͍͚͢ͲɺωΠςΟϒͷػೳΛ ͍͍ͪͪϓϥάΠϯͰ͔͘ͷେม… ࣗ෼͕͍ͨ͠ԋग़ݟ͔ͭΒͳ͍…

  13. ଞͷํ๏ͳ͍ͷʁ

  14. ͏ʔΜ…

  15. ͋ͬ!!

  16. SpriteKit

  17. ͱ͍͏͜ͱͰɺ SpriteKitΛΞϓϦͷ ԋग़ʹ࢖ͬͯΈ·ͨ͠

  18. SpriteKitͱ͸ iOS 7 ͔Β௥Ճ͞Εͨɺ
 Apple͕ఏڙ͍ͯ͠Δ
 ήʔϜ༻ͷϑϨʔϜϫʔΫ

  19. ɾΠϯετʔϧෆཁ
 ɾXcodeͰϓϨϏϡʔ͠ͳ͕Β ɹύʔςΟΫϧฤूՄೳ
 ɾUIKitͱಉ͡Α͏ʹهड़Ͱ͖Δ ಛ௃

  20. ࣮ࡍɺSpriteKitΛ ήʔϜͰ͸ͳ͘ɺ
 UIKitϕʔεͷΞϓϦʹ ࢖͑Δͷ͔ʁ

  21. DEMO

  22. Code https://github.com/ryusukefuda/SpriteKit-Demo

  23. SKView SpriteKitΛදࣔ͢Δઐ༻ͷView SKScene( .sks) SKNodeΛܧঝ͠ɺϝΠϯͷॲཧΛߦ͏ɻ SKNode SpriteKitͷίΞͱͳΔΫϥε UIViewControllerͷΑ͏ͳ΋ͷ UIViewͷΑ͏ͳ΋ͷ NSObjectͷΑ͏ͳ΋ͷ

  24. Step.1 ! ύʔςΟΫϧͭ͘Δ

  25. SKSceneͱSKSceneͷαϒΫϥεΛ༻ҙ͠ɺ ύʔςΟΫϧͳͲԋग़Λ௥Ճ͢Δ func fireHeart(point:CGPoint) { let path = NSBundle.mainBundle().
 pathForResource("heartSpark",

    ofType: "sks") let sceneData = NSData(contentsOfFile: path!, ɹɹɹɹɹɹɹɹɹɹɹɹɹɹoptions: .DataReadingMappedIfSafe, error: nil)! let particle = NSKeyedUnarchiver.unarchiveObjectWithFile(path!) as SKEmitterNode particle.position = point self.addChild(particle) } Step.2
  26. SKViewΛͭ͘Γɺ
 UIViewControllerͷViewʹSKViewΛadd͢Δ let skView = SKView(frame: self.view.bounds) self.view.addSubview(skView) Step.3

  27. ޷͖ͳλΠϛϯάͰSKSceneΫϥεͷԋग़ΛݺͿ @IBAction func tapFavoriteButton(sender: AnyObject) {
 let scene = UIScene.unarchiveFromFile("UIScene")

    as UIScene! let location = CGPointMake(sender.position.x - 50, sender.position.y) scene.fireHeart(location) } Step.4
  28. SKActionͰύʔςΟΫϧʹΞχϝʔγϣϯΛ͚ͭΔ let scale = SKAction.scaleTo(1.0, duration: 1.0) let fadeout =

    SKAction.fadeOutWithDuration(0.5) let remove = SKAction.removeFromParent() let sequence = SKAction.sequence([scale, fadeout,remove]) particle.runAction(sequence) Animation
  29. UIKitϕʔεͷΞϓϦʹSpriteKit Λ௥Ճ͢Δͱ͖ͷϙΠϯτ

  30. UIViewͷ্ʹಁ໌ͷSKViewΛͷͤͯ SKViewͷλονΠϕϯτΛແޮʹ͢Δ skView.allowsTransparency = true ! skView.userInteractionEnabled = false UIView

    SKView
  31. UIViewͷ( 0,0 ) ͱSKViewͷ ( 0,0 ) ͸ҧ͏ override func

    touchesBegan(touches: NSSet, withEvent event: UIEvent) { ! for touch: AnyObject in touches { let location = touch.locationInView(self.view) scene.tapCircle(CGPointMake(location.x, self.view.bounds.height - location.y)) } } ! ( 0,0 ) UIView ( 0,0 ) SKView
  32. SpriteKitΛ࢖ͬͯΈͯ ɾApple͕ఏڙ͍ͯ͠Δ҆৺ײ ɾطଘͷίʔυͷअຐΛ͢Δ͜ͱͳ͘ɹɹ ɹಋೖͰ͖Δ ɾσβΠφʔ͞Μ΋࢖͑Δ

  33. ·ͱΊ SpriteKitΛUIKitͱ ૊Έ߹ΘͤΔͷ͸͋Γʂ

  34. Ϧονͳԋग़Λ iOSωΠςΟϒͰɻ

  35. ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ