building windows phone games with xna
DESCRIPTION
Session Code. Building Windows Phone Games with XNA. Larry Lieberman Product Manager, Windows Phone Developer Experience Microsoft Corporation. Agenda. Games on Windows Phones Let’s build Let’s go mango ! What now ? You’ll leave with examples of how to - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/1.jpg)
![Page 2: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/2.jpg)
Session Code
Building Windows Phone Games with XNA
Larry LiebermanProduct Manager,Windows Phone Developer ExperienceMicrosoft Corporation
![Page 3: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/3.jpg)
AgendaGames on Windows PhonesLet’s buildLet’s go mango!What now?
You’ll leave with examples of how toUse XNA Game Studio to build a gameIntegrate XNA and Silverlight together
![Page 4: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/4.jpg)
Windows Phone for Games
Powerful HardwarePremium Gaming FeaturesAccelerated Development
![Page 5: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/5.jpg)
Powerful HardwareV1 – Windows Phone OS 7.0 (Nov. 2010)
WVGA 800x480, D3D11 API enabled GPUMSM8x55 CPU 1 GHz, 256 MB RAM, 8 GB flash4x Touch/aGPS/Accel/Compass/Light/Proximity
V2 – New Chassis Specification for OS 7.1
MSM7x30 / MSM8x55 CPU, 800 MHz or higher
Optional gyro
![Page 6: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/6.jpg)
Premium Gaming FeaturesXbox LIVE on Windows Phone
Achievements & LeaderboardsAvatars + AwardsDownloadable contentCross-platform gaming: Full House Poker
For Registered Developers
![Page 7: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/7.jpg)
Accelerated DevelopmentSilverlight for event-driven, control-rich apps
XNA Game Studio for games, simulation, and real-time graphics
Using C#/VB.NET in VS2010
OS 7.1: XNA + Silverlight Interop
![Page 8: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/8.jpg)
Let’s Build a Game with XNA Game Studio
![Page 9: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/9.jpg)
The XNA Framework Game Loop
LoadContentInitialize Update Draw UnloadContent
![Page 10: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/10.jpg)
Introducing the XNA Content PipelineIntegrated into Visual Studio 2010 build processIncremental building of content, separate from codeBuilt-in support for many standard typesExtensible for your in-house formats
![Page 11: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/11.jpg)
Simple Drawing in the XNA Framework
protected override void LoadContent(){ spriteBatch = new SpriteBatch(GraphicsDevice); playerSprite = Content.Load<Texture2D>("player");}protected override void Draw(GameTime gameTime){ GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(playerSprite, position,
Color.White); spriteBatch.End(); base.Draw(gameTime);}
![Page 12: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/12.jpg)
2D Graphics in XNA Game StudioXNA Game Studio 2D is about “blitting” textures to the screenSpriteBatch
Batched rendering of 2D: Alpha, Additive, Rotate, Flip, Scale
SpriteFontConverts fonts to sprites, draw with SpriteBatch
2D primitives can be drawn using 3D callsIf you are drawing complex 2D curves, consider Silverlight
![Page 13: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/13.jpg)
3D Graphics in XNA Game Studio3D graphics through D3D11Five configurable effects…
Lacks developer programmable shader supportEnvironmentMapEffect SkinnedEffectAlphaTestEffectDualTextureEffectBasicEffect
![Page 14: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/14.jpg)
Taking Input in the XNA Framework
protected override void Initialize(){ TouchPanel.EnabledGestures = GestureType.FreeDrag;}protected override void Update(GameTime gameTime){ while (TouchPanel.IsGestureAvailable) { GestureSample gesture = TouchPanel.ReadGesture(); if (gesture.GestureType ==
GestureType.FreeDrag) { position += gesture.Delta; } }}
![Page 15: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/15.jpg)
Input: Touch, Accelerometer, MoreGesture-based Touch through GestureSample
Up to two touch pointsFull gesture list—drag, tap, pinch, etc.
Raw Touch input through TouchPanel.GetState()Up to four touch points
Accelerometer input through eventsIn OS 7.1, optional gyro, Motion API
![Page 16: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/16.jpg)
Adding a Bad Guy
protected override void Update(GameTime gameTime){ enemyPosition.X -= enemySpeed; enemyPosition.Y += (float)Math.Sin(enemyPosition.X * enemySpeed / GraphicsDevice.Viewport.Width) * enemySpeed; if(Rectangle.Intersect( new Rectangle((int)position.X, (int)position.Y, playerSprite.Width, playerSprite.Height), new Rectangle((int)enemyPosition.X, (int)enemyPosition.Y, enemySprite.Width, enemySprite.Height)) != Rectangle.Empty) { //Hit! OnCollisionSound(); enemyPosition = enemyStartPosition; }}
![Page 17: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/17.jpg)
Math for Logic, Collision, and MotionBuilt-in classes:
Motion: Curve, Lerp, SmoothStep, CatmullRom, HermiteTransformation: Vector2/3/4, Point, Matrix, QuaternionCollision: BoundingBox/Sphere, Plane, Ray, RectangleIncludes .Intersects and .Contains methodsAnd, don’t forget Random
![Page 18: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/18.jpg)
Audio in Two Lines
protected override void LoadContent(){ explosionSound = Content.Load<SoundEffect>("explosion");}private void OnCollisionSound(){ explosionSound.Play();}
![Page 19: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/19.jpg)
Audio the Simple WaySoundEffect / SoundEffectInstance
Load WAV files (PCM, ADPCM) or from raw PCM bufferSoundEffect fire and forget, SoundEffectInstance to keep/modifyCan play up to 64 concurrent soundsCustom formats supported through ContentProcessor
Music through MediaPlayer
![Page 20: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/20.jpg)
Audio the Dynamic WayDynamicSoundEffectInstanceManages own internal queue of buffersExpensive, and 16-bit PCM onlyConsider dynamic for synthesized or data-sourced audioMost games will not need to use this, stick with SoundEffect
![Page 21: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/21.jpg)
Going Mango
![Page 22: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/22.jpg)
New Game Dev Features in Mango
Fast App SwitchingXNA + SilverlightBackground AgentsUnified Motion APILive Camera AccessSQL CETCP/UDP Sockets
FrameworkCPU/Memory ProfilerIso. Storage ExplorerAccel/Location Emulator
Tools16 New RegionsMarketplace Test KitIntegrated Ad SDK
Ecosystem
![Page 23: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/23.jpg)
Fast App Switching
running
deactivated
dormant
activated
Phone resources detachedThreads and timers suspended
Fast app resume
Save State!
State preserved!IsAppInstancePreserved == trueRestore state!IsAppInstancePreserved == false
Resuming ...
Tombstone the oldest app tombstone
d
![Page 24: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/24.jpg)
XNA and Silverlight IntegrationEnables XNA Graphics in a Silverlight applicationUse the Silverlight application modelSwitch into XNA rendering modeUse UIElementRenderer to draw Silverlight controls on XNA Surface
![Page 25: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/25.jpg)
Moving to the Silverlight + XNA Game Loop
OnNavigatedTo OnUpdate OnDraw OnNavigatedFrom
LoadContentInitialize Update Draw UnloadContent
![Page 26: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/26.jpg)
Let’s Integrate XNA/SL
demo
![Page 27: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/27.jpg)
What Now?
![Page 28: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/28.jpg)
Considerations as You Build Your Game…90 MB memory limit for your gameGarbage collector kicks off at every 1 MB of allocationsMore objects created/released = memory churnOS 7.1, generational GC better than OS 7.0, but stay vigilant
Full collection still happens…just less frequently
![Page 29: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/29.jpg)
Considerations as You Build Your Game…Easy to start with dynamic types (List<>, etc.), but trade-offsConsider fixed arrays for performance, watch your profilerAvoid LINQ (and its extension methods)Prefer value types to ref typesNever fear: Classes in the XNA Math library are value types!
![Page 30: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/30.jpg)
Performance and Memory ProfilerNew profiler in Windows Phone SDK 7.1Memory mode to find allocationsPerformance mode to find CPU spikesAvailable even on Express!
![Page 31: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/31.jpg)
Marketplace Opportunities$99/yr fee to develop/submit on physical devices, free on emulatorFree apps, can use Microsoft Advertising SDK with XNA
Up to 100 for free, $19.99 per submission after
Paid apps, can charge from $0.99 to $499.99
Submissions free, 70/30 split
![Page 32: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/32.jpg)
What About Xbox LIVE?If represented, contact Xbox LIVE through your publisherIf not, many publishers are available, one is MS StudiosSend info about your company and portfolio first, no cold pitching [email protected]
![Page 33: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/33.jpg)
More Resources… Start with samples at App Hub
Full games to pull apartTechnique samples to add to your gamesWhite papers and tutorials for even more
http://create.msdn.com/gamedevelopment
![Page 34: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/34.jpg)
Feedback Your feedback is very important! Please complete an evaluation form!
Thank you!
![Page 35: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/35.jpg)
Questions? Session Code Speaker Name
Title Email Blog …
You can ask your questions at “Ask the expert” zone within an hour after end of this session
![Page 36: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/36.jpg)
Session Code
Title of Presentation
Name Company
Name Company
Name Company
![Page 37: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/37.jpg)
Contents
![Page 38: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/38.jpg)
Slide Title First level
Second levelThird level
Fourth level Fifth level
![Page 39: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/39.jpg)
PowerPoint GuidelinesFont, size, and color for text have been formatted for you in the Slide MasterUse the color palette shown belowHyperlink color: www.microsoft.com
Sample FillSample FillSample Fill
Sample FillSample FillSample Fill
![Page 40: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/40.jpg)
Bar Chart Example
Category 1
Category 2
Category 3
Category 4
012345
Series 1Series 2Series 3
![Page 41: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/41.jpg)
demo
Demo Title Name
![Page 42: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/42.jpg)
video
Video Title
![Page 43: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/43.jpg)
announcement
Announcement Title
![Page 44: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/44.jpg)
Code Sample
Get-Process –computername srv1
class TechEdProgram{
public static void Main(){
System.Console.WriteLine("Hello, Tech·Ed!");
}}
![Page 45: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/45.jpg)
Summary
![Page 46: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/46.jpg)
Related Content
![Page 47: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/47.jpg)
Resources
![Page 48: Building Windows Phone Games with XNA](https://reader036.vdocument.in/reader036/viewer/2022062814/56816782550346895ddc9053/html5/thumbnails/48.jpg)