本文整理汇总了C#中Microsoft.Xna.Framework.Vector2.ToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.ToPoint方法的具体用法?C# Vector2.ToPoint怎么用?C# Vector2.ToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Vector2
的用法示例。
在下文中一共展示了Vector2.ToPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringRectangle
public Rectangle GetStringRectangle(string text, Vector2 position)
{
var width = 0;
var height = 0;
foreach (var c in text)
{
BitmapFontRegion fontRegion;
if (_characterMap.TryGetValue(c, out fontRegion))
{
width += fontRegion.XAdvance;
if (fontRegion.Height + fontRegion.YOffset > height)
height = fontRegion.Height + fontRegion.YOffset;
}
}
var p = position.ToPoint();
return new Rectangle(p.X, p.Y, width, height);
}
示例2: GetStringRectangle
public Rectangle GetStringRectangle(string text, Vector2 position)
{
var size = GetSize(text);
var p = position.ToPoint();
return new Rectangle(p.X, p.Y, size.Width, size.Height);
}
示例3: Update
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
if (ballRect.Right >= screen.Width)
ballDirection.X = -1;
if (ballRect.Left <= 0)
ballDirection.X = 1;
ballLocation += speed * ballDirection * (float)gameTime.ElapsedGameTime.TotalSeconds;
ballRect.Location = ballLocation.ToPoint();
ballRect.X += ballRect.Width / 2;
ballRect.Y += ballRect.Height / 2;
base.Update(gameTime);
}