CEDEC2012 Starling開発

Andy Hall
Flashを使った
                      PC、Android、iOS 向けに
                    GPU アクセラレーション対応の
                          2Dゲーム開発
                                                                              Andy Hall
                                                                              Adobe Japan



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Andy Hall アンディ ホール
                                       Game Evangelist ゲームエバンジェリスト
                                         Adobe Japan アドビ システムズ 株式会社
                                                       @fenomas

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Agenda

          1.                Flash、ゲームの背景的な話
          2.                Stage3D、AGALについて
          3.                Starlingについて
          4.                開発に飛び込もう




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Flash and Games




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Why Flash?

          • パフォーマンス
          • ツール
          • リーチ




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Why Flash?

          • パフォーマンス
          • ツール       サイレント
                    自動アップデート
          • リーチ       ユーザ数:
                                                                                    4億人 (!!!)




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Why Flash?

          • パフォーマンス
          • ツール       サイレント
                    自動アップデート
          • リーチ       ユーザ数:
                                                                                           4億人 (!!!)




                                                                                 400M
                                  Wii                                PS3        Xbox 360
                                95.56M                              63.9M        67.2M

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
                                                                                              sales numbers as of April-June 2012. Source: Wikipedia
採用状況




                       9 of 10 top                                            Angry Birds Friends   Ruby Blast
                    Facebook games                                                 (Rovio)           (Zynga)



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
About Flash
          • Flash is:
                • 柔軟で応用が利く
                • クロスプラットフォーム
                • モバイルに最適(Android、iOS 他)

          • Flash isn’t:
                • 「ドラッグ・ドロップでゲーム!」
                • 完全ネイティブパフォーマンス


© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Why the GPU?

                                                                               Tablets,
                                                                               mobiles,
                                                                               retina displays.

                                                                               Pushing pixels
                                                                               through
                                                                               software isn’t
                                                                               an option.

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Stage3D



                                                                                                  Vector
                                                                                            3D
                                                                                                       Video

                                                                                        Display List




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Stage3D

                                                               Flash コンテンツ
                                                                (ActionScript)


               シェーダー
                                                               Stage3D (AGAL)
              パイプライン

                                                            OpenGL or DirectX


                                                                              GPU



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
AGALとは

                                                     m44                      op, va0, vc0
                                                     dp4                      op.x, va0, vc0
                                                     dp4                      op.y, va0, vc1
                                                     dp4                      op.z, va0, vc2
                                                     dp4                      op.w, va0, vc3
                                                     m44                      op, va0, vc0
                                                     mov                      v0, va1

                                                           (ヒトリデハキケンジャ!)

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starlingの場合


                   import starling.display.Sprite;

                   var hero:Sprite = new Sprite();
                   hero.x = 200;
                   hero.y = 200;
                   addChild(hero);


                                                                 (コレヲ サズケヨウ! )

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Stage3D ライブラリー
          • オフィシャルライブラリー (free, open source):

                                • Starling (2D)

                                • Away3D



          • ニーズによって他にも様々…


               N2D2
                                              Genome2D

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starling

          Flash Player
       Display List API
                 (AS3)                                                                   Sparrow
                                                                                         フレームワーク
                                                                                         (ObjC)




               Starling
                 (AS3)



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starling + Stage3D

                                                               Flash コンテンツ
                                                                (ActionScript)

                                                                              Starling

                                                               Stage3D (AGAL)

                                                            OpenGL or DirectX

                                                                               GPU



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starlingが送ること
          • Starling gives you:
                • 生産性
                • 親しみのある習得の早いAPI
                • 拡張性
                • 活発的なコミュニティー
          • Starling doesn’t give you:
                • GPUは何ぞよ、と気にしなくて良いほど
                  の安全性
                • GPUには優しく!

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
コードを見せろってば!




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starling core API
                                                                              starling.events.EventDispatcher


       starling.display.*
                                                                                         DisplayObject



                               DisplayObjectContainer                                                Quad


                                                                                                    Image
              Button                                                             Stage
                                 Sprite                               TextField
                                                                                                  MovieClip


© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starling core API
                                                                              starling.events.EventDispatcher


       starling.display.*
                                                                                         DisplayObject



                               DisplayObjectContainer                                                Quad


                                                                                                    Image
              Button                                                             Stage
                                 Sprite                               TextField
                                                                                                  MovieClip


© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
• Just vertices with a color but no texture
          • Color interpolated on the GPU
                                                                              Quad
          • Simple primitive

          Example :

          q = new Quad(200, 200);
          q.setVertexColor(0, 0x000000);
          q.setVertexColor(1, 0xAA0000);
          q.setVertexColor(2, 0x00FF00);
          q.setVertexColor(3, 0x0000FF);
          addChild (q);

          Solid color :
          q.color = 0x00FF00;

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
• Image is textured quad (extends Quad)
         • Textures should be uploaded and pooled,
                                                                              Image
           rather than created when needed
         • State tracking (setTexture – expensive)
         • Compressed textures

         Example :
         // create a texture, then an image
         var myBitmap:Bitmap = new MyBitmapClass();
         var texture:Texture = Texture.fromBitmap(myBitmap);
         var image:Image = new Image ( texture );
         addChild ( image );

         Tint :
         image.color = 0xFF0000;


© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
• The lightest container available
            (just like with standard Flash display list)
                                                                              Sprite
          • Can be flattened, to display a
            complex tree quickly
          • However, all children’s textures need to be in the same
            texture (or atlas) to see really great performance

          Example :
          // freeze the children
          container.flatten();
          // assign changes to a child
          container.child.scaleX = .5;
          // refresh
          container.flatten(); // or unflatten();
© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Sprite, with a timeline
                                                                              MovieClip
          •
          •       A different texture on each frame
          •       Is not a container.
          •       Does not support scripts on frames.
          •       Completely controllable (custom fps,
                  addFrame, etc).

          Example :
          // retrieve frames from a Flash MC
          var frames:Vector.<Texture> =
          sTextureAtlas.getTextures("running_");

          // creates a MovieClip playing at 40fps
          mMovie = new MovieClip(frames, 40);
© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
TextureAtlas




          • Packaged sets of sprite sheets
          • To optimize, make sure GPU calls each use one Atlas

          Example :
          // get all textures with a common prefix
          myTextureAtlas.getTextures(“fly_”);

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ではコードを書いてみよう。




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
拡張の例
          Particle Editor
          http://onebyonedesign.com/flash/particleeditor/




© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Starlingの最適化
       • Flatten containers if their contents won’t change:
         container.flatten();

       • Prevent unnecessary touch event handling:
         container.touchable = false;

       • Use object pools:
         s = pool.getSprite();
         pool.returnSprite(s);


© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
今後のトピック
          Adobe Texture Format (ATF)
          • A compressed texture format created specially
            for Stage3D
          • The player understand ATF
            natively, which brings
            performance benefits

          Tools and libraries are coming.



© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
ご清聴ありがとうございました。




                                                                              andhall@adobe.com
                                                                              @fenomas

© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
© 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
1 of 32

More Related Content

What's hot(19)

Jax2001 adobe keynoteJax2001 adobe keynote
Jax2001 adobe keynote
Michael Chaize628 views
Montpellier - Flex UGMontpellier - Flex UG
Montpellier - Flex UG
Michael Chaize2.6K views
Jax2010 adobe lcdsJax2010 adobe lcds
Jax2010 adobe lcds
Michael Chaize571 views
Adobe flex at  jax london 2011Adobe flex at  jax london 2011
Adobe flex at jax london 2011
Michael Chaize686 views
Flex and the city in London - KeynoteFlex and the city in London - Keynote
Flex and the city in London - Keynote
Michael Chaize2K views
Oop2012 mobile workshopsOop2012 mobile workshops
Oop2012 mobile workshops
Michael Chaize697 views
Adobe et la stratégie multi-écransAdobe et la stratégie multi-écrans
Adobe et la stratégie multi-écrans
Michael Chaize481 views
Back From MAX in London for CQ5 usersBack From MAX in London for CQ5 users
Back From MAX in London for CQ5 users
Michael Chaize751 views
Adobe flash platform javaAdobe flash platform java
Adobe flash platform java
Michael Chaize887 views
Imaginea product-support-offeringImaginea product-support-offering
Imaginea product-support-offering
RajaneeshChandra866 views
Adobe Max 2008 Cross Channel CampaignsAdobe Max 2008 Cross Channel Campaigns
Adobe Max 2008 Cross Channel Campaigns
Charles Duncan jr.408 views
Flex User Group bretonFlex User Group breton
Flex User Group breton
La French Tech Rennes St Malo 517 views
Process in the Age of Digital InnovationProcess in the Age of Digital Innovation
Process in the Age of Digital Innovation
Charles Duncan jr.835 views

Similar to CEDEC2012 Starling開発(20)

MMT 28: Adobe »Edge to the Flash«MMT 28: Adobe »Edge to the Flash«
MMT 28: Adobe »Edge to the Flash«
MMT - Multimediatreff538 views
Flash performance tuning (EN)Flash performance tuning (EN)
Flash performance tuning (EN)
Andy Hall8.1K views
Adobe Shadow - Amsterdam Adobe CampAdobe Shadow - Amsterdam Adobe Camp
Adobe Shadow - Amsterdam Adobe Camp
Mihai Corlan926 views
Adobe Flash platform の法人利用Adobe Flash platform の法人利用
Adobe Flash platform の法人利用
Keisuke Todoroki985 views
Xebia adobe flash mobile applicationsXebia adobe flash mobile applications
Xebia adobe flash mobile applications
Michael Chaize874 views
Flash: A call for sanityFlash: A call for sanity
Flash: A call for sanity
Andrew Dobson475 views
Flash PlatformアップデートFlash Platformアップデート
Flash Platformアップデート
Mariko Nishimura1.2K views
Adobe flash platform javaAdobe flash platform java
Adobe flash platform java
Ch'ti JUG1.3K views
Flash Applications For MobileFlash Applications For Mobile
Flash Applications For Mobile
Serge Jespers3.2K views
Flex 4.5 and mobile developmentFlex 4.5 and mobile development
Flex 4.5 and mobile development
Michael Chaize969 views
The Flash to HTML5 OpportunityThe Flash to HTML5 Opportunity
The Flash to HTML5 Opportunity
Thomas Burleson555 views
4 adobe gaming on tv4 adobe gaming on tv
4 adobe gaming on tv
Cass Phillipps613 views
Bynet2.3 Adobe Flex builder 4Bynet2.3 Adobe Flex builder 4
Bynet2.3 Adobe Flex builder 4
Транслируем.бел489 views

Recently uploaded(20)

ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web Developers
Maximiliano Firtman143 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation22 views
ThroughputThroughput
Throughput
Moisés Armani Ramírez25 views
Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic Meetup
Rick Ossendrijver20 views

CEDEC2012 Starling開発

  • 1. Flashを使った PC、Android、iOS 向けに GPU アクセラレーション対応の 2Dゲーム開発 Andy Hall Adobe Japan © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 2. Andy Hall アンディ ホール Game Evangelist ゲームエバンジェリスト Adobe Japan アドビ システムズ 株式会社 @fenomas © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 3. Agenda 1. Flash、ゲームの背景的な話 2. Stage3D、AGALについて 3. Starlingについて 4. 開発に飛び込もう © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 4. Flash and Games © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 5. Why Flash? • パフォーマンス • ツール • リーチ © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 6. Why Flash? • パフォーマンス • ツール サイレント 自動アップデート • リーチ ユーザ数: 4億人 (!!!) © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 7. Why Flash? • パフォーマンス • ツール サイレント 自動アップデート • リーチ ユーザ数: 4億人 (!!!) 400M Wii PS3 Xbox 360 95.56M 63.9M 67.2M © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. sales numbers as of April-June 2012. Source: Wikipedia
  • 8. 採用状況 9 of 10 top Angry Birds Friends Ruby Blast Facebook games (Rovio) (Zynga) © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 9. About Flash • Flash is: • 柔軟で応用が利く • クロスプラットフォーム • モバイルに最適(Android、iOS 他) • Flash isn’t: • 「ドラッグ・ドロップでゲーム!」 • 完全ネイティブパフォーマンス © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 10. Why the GPU? Tablets, mobiles, retina displays. Pushing pixels through software isn’t an option. © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 11. Stage3D Vector 3D Video Display List © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 12. Stage3D Flash コンテンツ (ActionScript) シェーダー Stage3D (AGAL) パイプライン OpenGL or DirectX GPU © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 13. AGALとは m44 op, va0, vc0 dp4 op.x, va0, vc0 dp4 op.y, va0, vc1 dp4 op.z, va0, vc2 dp4 op.w, va0, vc3 m44 op, va0, vc0 mov v0, va1 (ヒトリデハキケンジャ!) © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 14. Starlingの場合 import starling.display.Sprite; var hero:Sprite = new Sprite(); hero.x = 200; hero.y = 200; addChild(hero); (コレヲ サズケヨウ! ) © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 15. Stage3D ライブラリー • オフィシャルライブラリー (free, open source): • Starling (2D) • Away3D • ニーズによって他にも様々… N2D2 Genome2D © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 16. Starling Flash Player Display List API (AS3) Sparrow フレームワーク (ObjC) Starling (AS3) © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 17. Starling + Stage3D Flash コンテンツ (ActionScript) Starling Stage3D (AGAL) OpenGL or DirectX GPU © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 18. Starlingが送ること • Starling gives you: • 生産性 • 親しみのある習得の早いAPI • 拡張性 • 活発的なコミュニティー • Starling doesn’t give you: • GPUは何ぞよ、と気にしなくて良いほど の安全性 • GPUには優しく! © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 19. コードを見せろってば! © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 20. Starling core API starling.events.EventDispatcher starling.display.* DisplayObject DisplayObjectContainer Quad Image Button Stage Sprite TextField MovieClip © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 21. Starling core API starling.events.EventDispatcher starling.display.* DisplayObject DisplayObjectContainer Quad Image Button Stage Sprite TextField MovieClip © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 22. • Just vertices with a color but no texture • Color interpolated on the GPU Quad • Simple primitive Example : q = new Quad(200, 200); q.setVertexColor(0, 0x000000); q.setVertexColor(1, 0xAA0000); q.setVertexColor(2, 0x00FF00); q.setVertexColor(3, 0x0000FF); addChild (q); Solid color : q.color = 0x00FF00; © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 23. • Image is textured quad (extends Quad) • Textures should be uploaded and pooled, Image rather than created when needed • State tracking (setTexture – expensive) • Compressed textures Example : // create a texture, then an image var myBitmap:Bitmap = new MyBitmapClass(); var texture:Texture = Texture.fromBitmap(myBitmap); var image:Image = new Image ( texture ); addChild ( image ); Tint : image.color = 0xFF0000; © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 24. • The lightest container available (just like with standard Flash display list) Sprite • Can be flattened, to display a complex tree quickly • However, all children’s textures need to be in the same texture (or atlas) to see really great performance Example : // freeze the children container.flatten(); // assign changes to a child container.child.scaleX = .5; // refresh container.flatten(); // or unflatten(); © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 25. Sprite, with a timeline MovieClip • • A different texture on each frame • Is not a container. • Does not support scripts on frames. • Completely controllable (custom fps, addFrame, etc). Example : // retrieve frames from a Flash MC var frames:Vector.<Texture> = sTextureAtlas.getTextures("running_"); // creates a MovieClip playing at 40fps mMovie = new MovieClip(frames, 40); © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 26. TextureAtlas • Packaged sets of sprite sheets • To optimize, make sure GPU calls each use one Atlas Example : // get all textures with a common prefix myTextureAtlas.getTextures(“fly_”); © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 27. ではコードを書いてみよう。 © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 28. 拡張の例 Particle Editor http://onebyonedesign.com/flash/particleeditor/ © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 29. Starlingの最適化 • Flatten containers if their contents won’t change: container.flatten(); • Prevent unnecessary touch event handling: container.touchable = false; • Use object pools: s = pool.getSprite(); pool.returnSprite(s); © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 30. 今後のトピック Adobe Texture Format (ATF) • A compressed texture format created specially for Stage3D • The player understand ATF natively, which brings performance benefits Tools and libraries are coming. © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 31. ご清聴ありがとうございました。 andhall@adobe.com @fenomas © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
  • 32. © 2012 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.