當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.Viewport類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.Viewport的典型用法代碼示例。如果您正苦於以下問題:C# Viewport類的具體用法?C# Viewport怎麽用?C# Viewport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Viewport類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了Viewport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        protected override void Initialize()
        {
            base.Initialize();

            ActiveScreen = new GameplayScreen(Content, Graphics.GraphicsDevice.Viewport);
            Viewport = Graphics.GraphicsDevice.Viewport;
        }
開發者ID:ndssia,項目名稱:Corsair2,代碼行數:7,代碼來源:Game1.cs

示例2: Camera2D

        public Camera2D(Main game, Vector2 translation, float rotation, float scale)
            : base(game)
        {
            this.game = game;

            //we need access to viewport to get dimensions of screen
            //we cant use windowDimensions because we may want to create more than one viewport (i.e. for splitscreen)
            this.viewPort = game.GraphicsDevice.Viewport;

            //sets the position of the camera
            this.translation = translation;

            //sets any rotation around Z (i.e. coming out of the screen)
            this.rotation = rotation;

            //sets the zoom level (i.e. if > 1 zoom in, if < 1 zoom out, bounded at minimum value)
            //call property and not this.scale to ensure scale not set to less than minimum
            SCALE = scale;

            //stored for reset
            this.originalTranslation = translation;
            this.originaRotation = rotation;
            this.originalScale = scale;

            //Calc this properly, with game data etc.
            this.minY = 300;
            this.maxY = GameData.LEVEL_HEIGHT-300;
            this.minX = 400;
            this.maxX = GameData.LEVEL_WIDTH - 400;

            this.cameraElasticity = 0.1f;
            this.difference = Vector2.Zero;
        }
開發者ID:Resinderate,項目名稱:ShadowMadness,代碼行數:33,代碼來源:Camera2D.cs

示例3: GraphicsDevice

        public GraphicsDevice(DrawQueue drawQueue)
        {
            // TODO: Complete member initialization
            this.drawQueue = drawQueue;

            viewport = new Viewport(0,0,UnityEngine.Screen.width, UnityEngine.Screen.height);
        }
開發者ID:Nakato53,項目名稱:FlappyBirdCloneXNAChallenge,代碼行數:7,代碼來源:GraphicsDevice.cs

示例4: Render

        protected override void Render(IntPtr windowHandle)
        {
            // If we have no graphics service, we can't draw
            if (_graphicsService == null)
                return;

            // Get the current width and height of the control
            var width = (int) ActualWidth;
            var height = (int) ActualHeight;

            // This piece of code is copied from the WinForms equivalent
            var deviceResetStatus = HandleDeviceReset(width, height);
            if (deviceResetStatus != GraphicsDeviceResetStatus.Normal)
                return;

            // Create the active viewport to which we'll render our content
            var viewport = new Viewport(0, 0, width, height);
            _graphicsService.GraphicsDevice.Viewport = viewport;

            // Invoke the event to render this control
            RaiseRenderXna(new GraphicsDeviceEventArgs(_graphicsService.GraphicsDevice));

            // Present to the screen, but only use the visible area of the back buffer
            _graphicsService.GraphicsDevice.Present(viewport.Bounds, null, windowHandle);
            //_graphicsService.GraphicsDevice.Present();
        }
開發者ID:DraTeots,項目名稱:gemini,代碼行數:26,代碼來源:GraphicsDeviceControl.cs

示例5: Gui

        public Gui(Viewport viewport)
        {
            this.viewport = viewport;

            mainMenu = new MainMenu(viewport); //for developing only, later it will be moved somewhere and rewritten
            messageBox = new MessageBox(viewport);
        }
開發者ID:Czeslav,項目名稱:Costam,代碼行數:7,代碼來源:Gui.cs

示例6: GameCamera

        public GameCamera(Scene _currentScene, Vector3 _position, Quaternion _rotation, float _aspectRatio)
        {
            currentScene = _currentScene;
            position = _position;
            rotation = _rotation;
            aspectRatio = _aspectRatio;
            up = new Vector3(0, 1, 0);
            target = new Vector3();
            viewMatrix = Matrix.CreateLookAt(position,
                        target, up);
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
                        MathHelper.ToRadians(45.0f), aspectRatio,
                        0.1f, VIEW_DEPTH);
            viewPort = Space394Game.GameInstance.GraphicsDevice.Viewport;
            fourthPort = new Viewport(
                        Space394Game.GameInstance.DefaultViewPort.Width / 2 + 1,
                        Space394Game.GameInstance.DefaultViewPort.Height / 2 + 1,
                        Space394Game.GameInstance.DefaultViewPort.Width / 2 - 1,
                        Space394Game.GameInstance.DefaultViewPort.Height / 2 - 1);

            splitScreen2 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen2"), Vector2.Zero);
            splitScreen3 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen3"), Vector2.Zero);
            splitScreen4 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen4"), Vector2.Zero);
            blackTexture = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\blackTexture"), Vector2.Zero);
            blackTexture.Width = fourthPort.Width;
            blackTexture.Height = fourthPort.Height;
            pausedTexture = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\pausedTexture"), Vector2.Zero);
        }
開發者ID:NatalieWojciechowski,項目名稱:Space394,代碼行數:28,代碼來源:GameCamera.cs

示例7: ToClipSpace

		public static Vector2 ToClipSpace(this Vector2 vector, Viewport viewport)
		{
			float clipX = (vector.X / viewport.Width) * 2f - 1;
			float clipY = (vector.Y / viewport.Height) * 2f - 1;

			return new Vector2(clipX, -clipY);
		}
開發者ID:Hakua,項目名稱:PokeSharp,代碼行數:7,代碼來源:Vector2Extensions.cs

示例8: Camera

 public Camera()
 {
     Viewport = new Viewport();
     Viewport.Width = Engine.Instance.Screen.Width;
     Viewport.Height = Engine.Instance.Screen.Height;
     UpdateMatrices();
 }
開發者ID:saint11,項目名稱:oldskull,代碼行數:7,代碼來源:Camera.cs

示例9: Initialize

 public void Initialize(Viewport viewport, Texture2D texture)
 {
     Texture = texture;
     this.viewport = viewport;
     Active = false;
     AnimationTime = 4f;
 }
開發者ID:nezek6,項目名稱:Wizardry,代碼行數:7,代碼來源:Spell.cs

示例10: Player

        //Player constructor
        //Takes in the Textures for the Box, the ship, the player's starting position,
        //the width, heigh, speed and the player's ID
        public Player(Texture2D boxAura,Texture2D ship, Vector2 position,Rectangle boxRect,
                        Rectangle shipRect, float speed, int playerID, ContentManager content, Viewport gameView)
        {
            //Use of the viewport is allowed
            this.screen = gameView;
            //Ship information being setup
            this.ship = ship;
            sourceRectShip = shipRect;
            destRectShip = new Vector2(position.X , position.Y);

            //not debugging as soon as the game starts

            //center position of the ship
            //" / 2 " gets the center
            center = new Vector2((int)(shipRect.Width / 2), (int)(shipRect.Height / 2));

            //This boxAura's information being setup
            this.boxAura = boxAura;
            this.width = boxRect.Width;
            this.height = boxRect.Height;
            this.speed = speed;
            destRectBox = new Rectangle((int)position.X  , (int)position.Y , width, height);

            //Initiate the weapons
            init(content);

            //The player's ID
            this.playerID = playerID;

            //The player ID and KeyBoard setup (For 1 computer currently)
            if (this.playerID == 0)
                setKeys(Keys.Up, Keys.Down, Keys.Left, Keys.Right,Keys.End);
            else
                setKeys(Keys.W, Keys.S, Keys.A, Keys.D,Keys.Q);
        }
開發者ID:Vergilreborn,項目名稱:ACM_Projects,代碼行數:38,代碼來源:Player.cs

示例11: AtlasGraphics

        public AtlasGraphics(AtlasGlobal atlas, GraphicsDeviceManager _graphicsDeviceManager)
            : base(atlas)
        {
            _currentMode = AtlasGraphicsMode.None;

            _graphicsDevice = atlas.Game.GraphicsDevice;
            this._graphicsDeviceManager = _graphicsDeviceManager;

            _graphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color;

            #if XNA
            _graphicsDeviceManager.PreferredBackBufferHeight = 768;
            _graphicsDeviceManager.PreferredBackBufferWidth = 1024;
            #endif
            ////_graphicsDeviceManager.IsFullScreen = true;
            _graphicsDeviceManager.ApplyChanges();

            _spriteBatch = new SpriteBatch(_graphicsDevice);

            _basicEffect = new BasicEffect(_graphicsDeviceManager.GraphicsDevice);

            batch = new VertexPositionColorTexture[32][];
            batchPrimitiveCount = new int[batch.Length];

            _viewPort = new Viewport(0, 0,
                _graphicsDeviceManager.PreferredBackBufferWidth,
                _graphicsDeviceManager.PreferredBackBufferHeight);
        }
開發者ID:Racura,項目名稱:AtlasEngine,代碼行數:28,代碼來源:AtlasGraphics.cs

示例12: TreeController

        public TreeController(Viewport vp, ContentManager content)
        {
            Trees = new List<Tree>();

            baseTreeTxtr = content.Load<Texture2D>(@"Tree/Base");
            sides[0] = content.Load<Texture2D>(@"Tree/LogLeft");
            sides[1] = content.Load<Texture2D>(@"Tree/LogRight");
            sides[2] = content.Load<Texture2D>(@"Tree/LogNEU");

            viewport = vp;
            float xSize = viewport.Width * 0.5f;
            size = new Vector2(xSize, xSize * 0.7407f);
            StandardX = Convert.ToInt32(viewport.Width / 2);

            DownRate = size.Y;
            float sizeX = viewport.Width * 0.25f;

            Vector2 baseSize = new Vector2(sizeX, sizeX * 0.1125f);
            Vector2 baseLocation = new Vector2(StandardX, viewport.Height - (baseSize.Y * 7));
            Tree baseLog = new Tree(baseLocation, baseSize, baseTreeTxtr);

            locations[0] = xSize / 4;
            locations[1] = StandardX - (xSize / 4);
            Trees.Add(baseLog);

            for (int i = 1; i < 12; i++)
            {
                Tree prevT = Trees[i - 1];
                Tree t = new Tree(new Vector2(locations[i % 2], prevT.location.Y - size.Y), size, sides[i % 2]);
                Trees.Add(t);
            }
        }
開發者ID:jayhxmo,項目名稱:lumberjack,代碼行數:32,代碼來源:TreeController.cs

示例13: Initialize

        protected override void Initialize()
        {
            viewport = GraphicsDevice.Viewport;
            TileEngine.InitializeEngine();
            AudioManager.Initialize();

            //Later replace with something else.
            IsMouseVisible = true;

            //Load the tileset here so the map can be properly loaded.
            new Tileset(Content.Load<Texture2D>("levelTileset"));

            //Let the audio manager load all relevant assets itself
            AudioManager.LoadContent(Content);

            // If you want to make changes to the game map, uncomment the following line and then comment out the
            // two lines that follow it.  Make any changes you like to the map, and then click the save button to
            // automatically write to map.gtd.  Afterwards, swap the commented lines once more.

            //currentScene = new MapEditorScene();

            currentScene = new OpeningMovieScene();
            currentScene.LoadContent(Content);

            base.Initialize();
        }
開發者ID:cmark89,項目名稱:GarrettTowerDefense,代碼行數:26,代碼來源:GarrettTowerDefense.cs

示例14: Camera

        public Camera(Viewport pViewPort)
        {
            _viewport = pViewPort;

            UpdateViewMatrix();
            UpdateProjectionMatrix();
        }
開發者ID:saschaarthur,項目名稱:sandstorm,代碼行數:7,代碼來源:Camera.cs

示例15: Camera

 /// <summary>
 /// Constructs a camera object.
 /// </summary>
 /// <param name="viewport">Current viewport for the game</param>
 public Camera(Viewport viewport)
 {
     mPosition = new Vector3(300.0f, 200.0f, 0.0f);
     mZoom = 0.75f;
     mHeight = viewport.Height;
     mWidth = viewport.Width;
 }
開發者ID:grodranlorth,項目名稱:tctk,代碼行數:11,代碼來源:Camera.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Viewport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。