成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

XNA游戲開發中橫豎屏的設置

移動開發 游戲開發
手機設備里面,會有橫豎屏的狀態,一般會有3種情況,一個是豎屏,一個是右橫屏,一個是左橫屏,橫屏的設置是通過GraphicsDeviceManager類的SupportedOrientations屬性來設置的,GraphicsDeviceManager類在XNA類庫介紹中提到的該類型是非常重要的。

手機設備里面,會有橫豎屏的狀態,一般會有3種情況,一個是豎屏,一個是右橫屏,一個是左橫屏。XNA游戲開發中,橫屏的設置是通過GraphicsDeviceManager類的SupportedOrientations屬性來設置的,GraphicsDeviceManager類在XNA類庫介紹中提到的該類型是非常重要的。它為開發者提供方法來管理目標設備的顯卡資源。簡單地說就是調用顯卡的一個接口,該對象的GraphicsDevice屬性代表當前目標設備的顯卡。

代碼示例:

 

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using Microsoft.Xna.Framework;  
  5. using Microsoft.Xna.Framework.Audio;  
  6. using Microsoft.Xna.Framework.Content;  
  7. using Microsoft.Xna.Framework.GamerServices;  
  8. using Microsoft.Xna.Framework.Graphics;  
  9. using Microsoft.Xna.Framework.Input;  
  10. using Microsoft.Xna.Framework.Input.Touch;  
  11. using Microsoft.Xna.Framework.Media;  
  12.  
  13. namespace SlXnaApp1  
  14. {  
  15.     /// <summary> 
  16.     /// This is the main type for your game  
  17.     /// </summary> 
  18.     public class Game1 : Microsoft.Xna.Framework.Game  
  19.     {  
  20.         GraphicsDeviceManager graphics;  
  21.         SpriteBatch spriteBatch;  
  22.         SpriteFont rotationFont;  
  23.  
  24.         public Game1()  
  25.         {  
  26.             graphics = new GraphicsDeviceManager(this);  
  27.             Content.RootDirectory = "Content";  
  28.  
  29.             // Frame rate is 30 fps by default for Windows Phone.  
  30.             TargetElapsedTime = TimeSpan.FromTicks(333333);  
  31.             //添加橫屏和豎屏的支持  
  32.             graphics.SupportedOrientations = DisplayOrientation.Portrait | DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;  
  33.         }  
  34.  
  35.         /// <summary> 
  36.         /// Allows the game to perform any initialization it needs to before starting to run.  
  37.         /// This is where it can query for any required services and load any non-graphic  
  38.         /// related content.  Calling base.Initialize will enumerate through any components  
  39.         /// and initialize them as well.  
  40.         /// </summary> 
  41.         protected override void Initialize()  
  42.         {  
  43.             // TODO: Add your initialization logic here  
  44.  
  45.             base.Initialize();  
  46.         }  
  47.  
  48.         /// <summary> 
  49.         /// LoadContent will be called once per game and is the place to load  
  50.         /// all of your content.  
  51.         /// </summary> 
  52.         protected override void LoadContent()  
  53.         {  
  54.             // Create a new SpriteBatch, which can be used to draw textures.  
  55.             spriteBatch = new SpriteBatch(GraphicsDevice);  
  56.  
  57.             // TODO: use this.Content to load your game content here  
  58.             rotationFont = Content.Load<SpriteFont>("rotationFont");  
  59.         }  
  60.  
  61.         /// <summary> 
  62.         /// UnloadContent will be called once per game and is the place to unload  
  63.         /// all content.  
  64.         /// </summary> 
  65.         protected override void UnloadContent()  
  66.         {  
  67.             // TODO: Unload any non ContentManager content here  
  68.         }  
  69.  
  70.         /// <summary> 
  71.         /// Allows the game to run logic such as updating the world,  
  72.         /// checking for collisions, gathering input, and playing audio.  
  73.         /// </summary> 
  74.         /// <param name="gameTime">Provides a snapshot of timing values.</param> 
  75.         protected override void Update(GameTime gameTime)  
  76.         {  
  77.             // Allows the game to exit  
  78.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)  
  79.                 this.Exit();  
  80.  
  81.             base.Update(gameTime);  
  82.         }  
  83.  
  84.         /// <summary> 
  85.         /// This is called when the game should draw itself.  
  86.         /// </summary> 
  87.         /// <param name="gameTime">Provides a snapshot of timing values.</param> 
  88.         protected override void Draw(GameTime gameTime)  
  89.         {  
  90.             GraphicsDevice.Clear(Color.CornflowerBlue);  
  91.  
  92.             // TODO: Add your drawing code here  
  93.             spriteBatch.Begin();  
  94.             spriteBatch.DrawString(rotationFont, "你現在手機的擺放狀態是:" + Window.CurrentOrientation.ToString() + ".", new Vector2(50, 50), Color.White);  
  95.             spriteBatch.End();  
  96.  
  97.             base.Draw(gameTime);  
  98.         }  
  99.     }  

 

原文鏈接:http://www.cnblogs.com/linzheng/archive/2012/04/15/2450274.html

【編輯推薦】

  1. 爆料:C#和XNA可以在iOS和Android平臺使用
  2. 詳解Windows Phone XNA 4.0 3D游戲開發
責任編輯:王曉東 來源: 博客
相關推薦

2012-05-28 15:55:47

XNA 重力感應

2010-09-08 11:26:26

Windows PhoXNA 4.0 3D游戲開發

2013-05-23 10:51:28

Android開發移動開發橫豎屏切換

2010-08-10 09:11:12

Windows PhoNXA

2013-08-21 11:15:54

iOS橫豎屏方案

2017-07-25 09:55:10

iOS橫豎屏旋轉

2016-09-18 10:51:01

JavascriptHtml5移動應用

2011-07-29 10:21:03

iPad 橫豎屏 切換

2012-05-25 15:20:38

XNA

2011-06-08 15:05:43

J2ME

2010-01-25 15:23:12

Android橫豎屏切

2013-07-29 05:04:19

Cocos2dx橫屏豎

2013-05-20 16:12:23

2012-12-13 13:27:29

Corona SDK

2024-09-23 10:00:00

Python游戲開發

2010-03-08 19:03:23

Python腳本

2013-05-16 15:08:33

2011-08-24 13:56:12

Lua游戲

2009-07-01 09:27:36

觸摸屏驅動WinCE

2013-06-27 13:46:41

游戲開發
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 久久久久国产一区二区三区四区 | 丁香婷婷综合激情五月色 | 一区二区在线不卡 | 91免费看片 | 久久久2o19精品 | 亚洲人久久 | 91中文字幕在线观看 | 久久高潮| 在线观看国产wwwa级羞羞视频 | 久久无毛| 国产精品亚洲综合 | 日韩免费视频一区二区 | 国产乱码精品一区二区三区忘忧草 | av影音资源| 国产成人精品午夜 | 国产精品亚洲欧美日韩一区在线 | 性高湖久久久久久久久aaaaa | 在线中文一区 | 亚洲最色网站 | 国产日韩欧美 | 欧美日韩亚洲在线 | 久久国产综合 | 玩丰满女领导对白露脸hd | 国产成人精品免费 | 天堂久久一区 | 天堂网av在线 | aaaa日韩 | 日韩成人免费中文字幕 | 性国产xxxx乳高跟 | 日韩中文一区二区三区 | 蜜臀网| 久久一区二区视频 | 亚洲美女一区二区三区 | 日本精品视频一区二区 | 特级做a爰片毛片免费看108 | 天天干b | 亚洲精品久久久 | 波多野结衣中文字幕一区二区三区 | 国产欧美精品一区二区三区 | 性高朝久久久久久久3小时 av一区二区三区四区 | 日日夜夜精品视频 |