日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
XNA游戲開(kāi)發(fā)中橫豎屏的設(shè)置

手機(jī)設(shè)備里面,會(huì)有橫豎屏的狀態(tài),一般會(huì)有3種情況,一個(gè)是豎屏,一個(gè)是右橫屏,一個(gè)是左橫屏。XNA游戲開(kāi)發(fā)中,橫屏的設(shè)置是通過(guò)GraphicsDeviceManager類(lèi)的SupportedOrientations屬性來(lái)設(shè)置的,GraphicsDeviceManager類(lèi)在XNA類(lèi)庫(kù)介紹中提到的該類(lèi)型是非常重要的。它為開(kāi)發(fā)者提供方法來(lái)管理目標(biāo)設(shè)備的顯卡資源。簡(jiǎn)單地說(shuō)就是調(diào)用顯卡的一個(gè)接口,該對(duì)象的GraphicsDevice屬性代表當(dāng)前目標(biāo)設(shè)備的顯卡。

成都創(chuàng)新互聯(lián)為客戶(hù)提供專(zhuān)業(yè)的網(wǎng)站建設(shè)、做網(wǎng)站、程序、域名、空間一條龍服務(wù),提供基于WEB的系統(tǒng)開(kāi)發(fā). 服務(wù)項(xiàng)目涵蓋了網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站程序開(kāi)發(fā)、WEB系統(tǒng)開(kāi)發(fā)、微信二次開(kāi)發(fā)、移動(dòng)網(wǎng)站建設(shè)等網(wǎng)站方面業(yè)務(wù)。

代碼示例:

 
 
 
  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.     ///  
  16.     /// This is the main type for your game  
  17.     ///  
  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.         ///  
  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.         ///  
  41.         protected override void Initialize()  
  42.         {  
  43.             // TODO: Add your initialization logic here  
  44.  
  45.             base.Initialize();  
  46.         }  
  47.  
  48.         ///  
  49.         /// LoadContent will be called once per game and is the place to load  
  50.         /// all of your content.  
  51.         ///  
  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("rotationFont");  
  59.         }  
  60.  
  61.         ///  
  62.         /// UnloadContent will be called once per game and is the place to unload  
  63.         /// all content.  
  64.         ///  
  65.         protected override void UnloadContent()  
  66.         {  
  67.             // TODO: Unload any non ContentManager content here  
  68.         }  
  69.  
  70.         ///  
  71.         /// Allows the game to run logic such as updating the world,  
  72.         /// checking for collisions, gathering input, and playing audio.  
  73.         ///  
  74.         /// Provides a snapshot of timing values. 
  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.         ///  
  85.         /// This is called when the game should draw itself.  
  86.         ///  
  87.         /// Provides a snapshot of timing values. 
  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, "你現(xiàn)在手機(jī)的擺放狀態(tài)是:" + 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


當(dāng)前題目:XNA游戲開(kāi)發(fā)中橫豎屏的設(shè)置
鏈接地址:http://m.5511xx.com/article/djsogoj.html