本文整理汇总了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;
}
示例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;
}
示例3: GraphicsDevice
public GraphicsDevice(DrawQueue drawQueue)
{
// TODO: Complete member initialization
this.drawQueue = drawQueue;
viewport = new Viewport(0,0,UnityEngine.Screen.width, UnityEngine.Screen.height);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例8: Camera
public Camera()
{
Viewport = new Viewport();
Viewport.Width = Engine.Instance.Screen.Width;
Viewport.Height = Engine.Instance.Screen.Height;
UpdateMatrices();
}
示例9: Initialize
public void Initialize(Viewport viewport, Texture2D texture)
{
Texture = texture;
this.viewport = viewport;
Active = false;
AnimationTime = 4f;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}
示例14: Camera
public Camera(Viewport pViewPort)
{
_viewport = pViewPort;
UpdateViewMatrix();
UpdateProjectionMatrix();
}
示例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;
}