developing wp7 apps using xna

Upload: jefersonbruno

Post on 06-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Developing WP7 apps using XNA

    1/55

    http://blogs.msdn.com/glengordon

  • 8/3/2019 Developing WP7 apps using XNA

    2/55

  • 8/3/2019 Developing WP7 apps using XNA

    3/55

  • 8/3/2019 Developing WP7 apps using XNA

    4/55

    Windows Phone will extend theXbox LIVE brand beyond the

    console for the first timeWindows Phone is the first steptowards our vision of aubiquitous gaming service

    Differentiates your title fromthe rest

    Gamertag

    Friends

    Achievements

    MerchandisingPremium Placement

  • 8/3/2019 Developing WP7 apps using XNA

    5/55

    Without Xbox LIVE You can still write

    andpublish games forWindows Phone

    Create great games for marketplace

    http://developer.windowsphone.com

    Were interested in your great games!

    [email protected]

    To use the greatfeatures of Xbox LIVE

    Find a publisher!Lots to choose from!

  • 8/3/2019 Developing WP7 apps using XNA

    6/55

    Consistent sets of hardware capabilitiesdefined by Microsoft

    ResolutionTouch InputCPU / GPURAM

    Hardware keyboard is optional

  • 8/3/2019 Developing WP7 apps using XNA

    7/55

    Modern XAML/event-driven application UIframework

    Rapid creation of visuallyrich apps

    HTML/Javascript

    Mature, robust, widelydeployed technology

    High performance gameframework

    Rapid creation of multi-screen2D and 3D games

    Rich content pipeline

    Mature, robust, widelyadopted technologyspanning Xbox,Windows, and Zune

    GAMES(and applications)

    APPLICATIONS(and games)

  • 8/3/2019 Developing WP7 apps using XNA

    8/55

    Powerful

    Productive

    Portable

  • 8/3/2019 Developing WP7 apps using XNA

    9/55

    Makes game development easier

    XNA Framework provides robust APIs for games

    C#, .NET and Visual Studio tooling

    Solutions for game content processing

    Not an engine solution

    CreatingGames

  • 8/3/2019 Developing WP7 apps using XNA

    10/55

    XNA Game Studio 4.0

    Develop for

    Windows

    Phone 7

    Simplifiedgraphics APIs

    Visual Studio2010

    integration

    Enhanced

    audio

    support

    New

    configurable

    effects

  • 8/3/2019 Developing WP7 apps using XNA

    11/55

  • 8/3/2019 Developing WP7 apps using XNA

    12/55

    Uses the .NET platform

    Windows Phone 7

    Managed code platform, no unsafe code

    XNA Game Studio 4.0 is C# exclusive

    800+ managed code

    games on XBLA/XBLIG

    Windows gamespublished

    through portals

    .NET/XNA is usedfor games today!

    [email protected]

  • 8/3/2019 Developing WP7 apps using XNA

    13/55

    Frameworksdesigned

    for performance

    Frameworksdesigned

    for performance

    Frameworksdesigned

    for performance

    Frameworksdesigned

    for performance

    XNA Frameworkdesigned for

    gaming scenarios

    Commitment tofuture

    of managed codeNo unnecessary

    garbage generation

    Math libraries optimized

    Efficient APIs with tunedtransitions to native code

    Three + years of profilingand investment

    Weve built for performanceon Windows Phone 7

  • 8/3/2019 Developing WP7 apps using XNA

    14/55

  • 8/3/2019 Developing WP7 apps using XNA

    15/55

  • 8/3/2019 Developing WP7 apps using XNA

    16/55

  • 8/3/2019 Developing WP7 apps using XNA

    17/55

    Productive development with .NET and C#

    High performance IDE

    Intellisense makes coding faster

    Integrated build/deploy/debug experience

    MSBuild engine for build automation

  • 8/3/2019 Developing WP7 apps using XNA

    18/55

    Simplify Your Content Usage

  • 8/3/2019 Developing WP7 apps using XNA

    19/55

  • 8/3/2019 Developing WP7 apps using XNA

    20/55

    The XNA Framework Game Loop is layered ontop of the Silverlight Application object onWindows Phone 7

    Provides the bulk of integration of APIs

    Most of the XNA Framework can be accessed from

    Silverlight applicationsIncluding Gamer Services (Xbox LIVE)

    In this release some sharing/composition is notcomplete

    Scenes using GraphicsDevice from XNA Frameworkand UIElements from Silverlight

    Youll want to choose the technology that worksbest for your scenarios

  • 8/3/2019 Developing WP7 apps using XNA

    21/55

    GraphicsUI control heavy consider Silverlight

    Desire vector graphics in XAML

    MediaRich video support in application

    ToolingIf you use Microsoft Blend in yourpipeline

  • 8/3/2019 Developing WP7 apps using XNA

    22/55

    GraphicsUsing 3D graphics

    Sprite heavy 2D applications should considerthe XNA Framework Game Loop

    Simulation/DrawingThose who prefer a traditional update/draw/present frame loop

    Tooling

    Those who want to use the XNA FrameworkContent Pipeline graphics types

  • 8/3/2019 Developing WP7 apps using XNA

    23/55

    XNA Framework Game Loop Example

    System integration withWindows Phone 7 best practices

    Translated to existingXNA Framework concepts

    Traditional update/draw/present frame loop

    Core programming model

    consistent with previous releasesChanges implemented yield betterpower performance on devices

    protectedoverridevoid Update(GameTime gameTime){

    // Allows the game to exit

    if

    (GamePad.GetState(PlayerIndex.One).Buttons.Back ==

    ButtonState.Pressed)

    this.Exit();

    // TODO: Add your update logic here

    base.Update(gameTime);

    }

    protectedoverridevoid Draw(GameTime gameTime)

    {

    GraphicsDevice.Clear(Color.CornflowerBlue);

    // TODO: Add your drawing code here

    base.Draw(gameTime);

    }

    Start simple and customize!

  • 8/3/2019 Developing WP7 apps using XNA

    24/55

  • 8/3/2019 Developing WP7 apps using XNA

    25/55

  • 8/3/2019 Developing WP7 apps using XNA

    26/55

    Evolution of our existing immediate mode rendering API

    Simplifies for resource and render state management

    Feature segmentation between Reach/HiDef profiles

    Rendering primitives 2D and 3D

  • 8/3/2019 Developing WP7 apps using XNA

    27/55

    New configurable effectclasses on all platforms

    BasicEffect

    SkinnedEffect

    EnvironmentMapEffect

    DualTextureEffect

    AlphaTestEffect

    Custom effects not availableon Windows Phone 7

  • 8/3/2019 Developing WP7 apps using XNA

    28/55

    Scaler

    Write your game without worrying about native resolution or orientationAutomatic rotation between portrait and landscapeTouch automatically supports both scale and orientation changes

    Scaler can drastically improve performance

    Trade off performance for crispness and shade fewer pixels800x480 = 384,000 pixels, 480x320 = 153,600 pixels

    Upsample an arbitrary back buffer to native device resolution

    Far higher quality than bilinear filteringAllows for easier porting from other platforms

    Scaling/Rotation comes for free from Hardware

  • 8/3/2019 Developing WP7 apps using XNA

    29/55

  • 8/3/2019 Developing WP7 apps using XNA

    30/55

  • 8/3/2019 Developing WP7 apps using XNA

    31/55

    Audio Capture Example

    publicvoid EventDrivenCapture()

    {

    mic = Microphone.Default;

    buffer = new byte[mic.GetSampleSizeInBytes(mic.BufferDuration)];

    mic.BufferReady += newEventHandler(OnBufferReady);

    DynamicPlayback = newDynamicSoundEffectInstance (mic.SampleRate,AudioChannels.Mono);

    }

    publicvoid OnBufferReady(object sender, EventArgs args)

    {

    // Get the latest captured audio.

    int duration = mic.GetData(buffer);

    // Do some post-capture processing and playback.

    MakeMeSoundLikeARobot(buffer, duration);DynamicPlayback.SubmitBuffer(buffer);

    }

    Audio Capture andPlayback

    Simple API to play back WAV data

    Modify pitch, volume, pan audio

    Ability to play synthesized/buffered audio

    Serialize captured data

    Provides more control over System.Mediatypes on Windows Phone 7

    Microphone/BluetoothSupport

    Playback through headset

    Capture through mic or headset

    Audio Playback Example

    // Load a sound effect from a raw stream

    SoundEffecteffect1 =

    SoundEffect.FromStream(GetStreamFromTheWeb( "http://url.wav"));

    effect1.Play();

    // Create dynamic audio on the fly

    byte[] fluteSound = GetFluteNote();

    effect2 = newSoundEffect(fluteSound, SampleRate,

    AudioChannels.Stereo);

    SoundEffectInstanceinstance = effect2.CreateInstance();

    instance.Pan = -1; instance.Pitch = 1.5f;

    instance.Play();

  • 8/3/2019 Developing WP7 apps using XNA

    32/55

    URI Song Playback Example

    Retrieve Image Data

    Music Enumeration and Playback// Constructs a song from a URIUri mediaStreamUri = new

    Uri("http://song.asx");

    Song streamedSong =

    Song.FromUri("Song",

    mediaStreamUri);

    // Play the song

    MediaPlayer.Play(streamedSong);

    MediaLibrarymedia = newMediaLibrary();

    // Get the JPEG image dataStreammyJpegImage =

    ReadAndModifyPicture(somePicture);

    // Save texture to Media Library

    media.SavePicture("Awesome", myJpegImage);

    Picture Enumeration and Playback

    Video Playback

    Control and enumerate usersmedia within a game

    Ability to play songs from URI/URL(i.e. music app)

    Supports photopicking/editing/publishing

    Uses standard video player API

    Show/Hide controls

  • 8/3/2019 Developing WP7 apps using XNA

    33/55

  • 8/3/2019 Developing WP7 apps using XNA

    34/55

  • 8/3/2019 Developing WP7 apps using XNA

    35/55

    Touch Input Handling

    Cross Platform Input API

    Touch API

    Xbox 360 Controllers(Xbox/Windows)

    Keyboard(Xbox/Windows/Windows Phone 7)

    Available across platforms for portability(fewer #ifdefs)

    Multipoint on Windows Phone 7and Windows

    Orientation and resolution aware

    Developer can override

    var touchCollection = TouchPanel.GetState();

    //...

    foreach (var touchLocation in touchCollection)

    {

    if (touchLocation.State ==

    TouchLocationState.Released)

    {

    //...}

    }

  • 8/3/2019 Developing WP7 apps using XNA

    36/55

  • 8/3/2019 Developing WP7 apps using XNA

    37/55

    Accelerometer Example

    VibrationExampleLeverage Platform Featureson Windows Phone 7

    Location

    Accelerometer

    Vibration

    Accelerometer accelerometer = new

    Accelerometer();

    accelerometer.ReadingChanged +=

    AccelerometerReadingChanged;

    accelerometer.Start();

    VibrateController rumbler;

    rumbler.Start(TimeSpan.FromSeconds(2));

  • 8/3/2019 Developing WP7 apps using XNA

    38/55

  • 8/3/2019 Developing WP7 apps using XNA

    39/55

  • 8/3/2019 Developing WP7 apps using XNA

    40/55

    Windows Phone 7 OS

    Xbox LIVE

    Gamer Services

    HTTP

    Invites

    ProfileAchieve-

    ments

    Leader-

    boards

    Trial

    Mode

    Push

    Avatars

  • 8/3/2019 Developing WP7 apps using XNA

    41/55

  • 8/3/2019 Developing WP7 apps using XNA

    42/55

    Read a Players Profile

    // Profile access

    SignedInGamer gamer =Gamer.SignedInGamers[0];

    // Get the player's GamerTag to display

    string gamerTag = gamer.Gamertag;

    // A SignedInGamer has a ProfileGamerProfile profile = gamer.GetProfile();

    // Get the player's current GamerScore

    int gamerScore = profile.GamerScore;

    // get the gamer picture (PNG file stream)Stream gamerPictureStream = profile.GamerPicture;

  • 8/3/2019 Developing WP7 apps using XNA

    43/55

    Award an Achievement

    // Award an achievementSignedInGamer gamer = Gamer.SignedInGamers[0];

    gamer.AwardAchievement("Attended TechEd 2010");

    Read Achievements

    // Get achievements

    AchievementCollection achievements =gamer.GetAchievements();

    // walk through achievements

    foreach (Achievement ain achievements)

    {

    string name = a.Name;

    string description = a.Description;

    bool earned = a.IsEarned;

    int score = a.GamerScore;

    Stream icon = a.Picture;

    }

    Real achieventments Real gamerscore Up to 20 awards,

    200G total Dead simple API,

    deep game design

  • 8/3/2019 Developing WP7 apps using XNA

    44/55

    Write to a Leaderboard

    // Create leaderboard identity with game mode 1

    LeaderboardIdentity id =

    LeaderboardIdentity.Create(LeaderboardKey.BestScoreLifeTime, 1);

    // get the leaderboard writer from the signed in gamer

    LeaderboardWriterwriter = gamer.LeaderboardWriter;

    // get the leaderboard entry for the identity

    LeaderboardEntry entry = writer.GetLeaderboard(id);

    // write new leaderboard data

    entry.Rating = 1000;

    entry.columns.SetValue("Outcome",LeaderboardOutcome.Win);

    Read From a Leaderboard

    // Read from leaderboard with page size of 10

    LeaderboardReader reader =LeaderboardReader.Read(id, gamer, 10);

    foreach (LeaderboardEntryein reader.Entries)

    {

    // score or time, as defined by identity. Rating determines

    rank.

    long rating = e.Rating;

    // read additional column data

    long wins = e.Columns.GetValueInt64("Wins");

    Stream blob = e.Columns.GetValueStream("Blob");

    }

    reader.PageDown();

    Compete withFriends

    Score- or Time-based

    Fixed columns

    10k blob data

    Pivot on gamer

  • 8/3/2019 Developing WP7 apps using XNA

    45/55

    Trial Mode

    Guide.SimulateTrialMode =true;

    // if we are in trial mode, show a marketplace offering

    if(Guide.IsTrialMode)

    {

    PlayerIndex playerIndex =Gamer.SignedInGamers[0].PlayerIndex;

    Guide.ShowMarketplace(playerIndex);

    }

    Simple check Simulate for testing

    Send user to your Marketplace offer

  • 8/3/2019 Developing WP7 apps using XNA

    46/55

    http://avatar.xboxlive.com/avatar/Major%20Nelson/avatar-body.png

    Currently supported through web service only

    Static pose rendered on LIVE back-end

    Download as a stream

  • 8/3/2019 Developing WP7 apps using XNA

    47/55

    Game invites are handled through email Guide.ShowGameInvite() invokes platform picker UI

    Player chooses game invite recipients

    Friends see invitations in their games hub

  • 8/3/2019 Developing WP7 apps using XNA

    48/55

  • 8/3/2019 Developing WP7 apps using XNA

    49/55

    XNA Framework designedto be cross platform

    Smaller time investmentand target more sockets

    Project synchronization

    between platforms

  • 8/3/2019 Developing WP7 apps using XNA

    50/55

    HiDef

    Reach Designed for compatibility across screens/devicesThis profile includes Windows Phone 7

    Platform showcase features

    Xbox 360/Windows Only

  • 8/3/2019 Developing WP7 apps using XNA

    51/55

    SummaryPowerful

    Productive

    Portable

    Great managed code games, working today

    Windows Phone provides a powerful platform for gaming

    Focus on being a game developer

    Great tools make you more productive

    Target more platforms easily

    Focus on your game differences, not the technology

  • 8/3/2019 Developing WP7 apps using XNA

    52/55

    Call to ActionDownload the Windows Phone Developer Tools

    http://developer.windowsphone.com

    Create awesome games!

  • 8/3/2019 Developing WP7 apps using XNA

    53/55

    Additional Resources

    Hundreds of samples

    Lots of MVPs and experts tohelp you get started

    XNA Creators Club @http://creators.xna.com

    Team Blog @http://blogs.msdn.com/xna/

    Shawn Hargreaves @http://blogs.msdn.com/shawnhar/

    (Great Tech Info!)

    Email:[email protected]

    On the web:http://developer.windowsphone.com

    Peer Support @http://forums.xna.com

    Blogs Contact Microsoft

    http://creators.xna.com/http://blogs.msdn.com/xna/http://blogs.msdn.com/shawnhar/mailto:[email protected]://developer.windowsphone.com/http://forums.xna.com/http://forums.xna.com/http://developer.windowsphone.com/mailto:[email protected]://blogs.msdn.com/shawnhar/http://blogs.msdn.com/xna/http://creators.xna.com/
  • 8/3/2019 Developing WP7 apps using XNA

    54/55

  • 8/3/2019 Developing WP7 apps using XNA

    55/55