本文整理汇总了C#中Camera.GlobalToCameraPos方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.GlobalToCameraPos方法的具体用法?C# Camera.GlobalToCameraPos怎么用?C# Camera.GlobalToCameraPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.GlobalToCameraPos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public void Draw(SpriteBatch sb, Camera camera, MouseState state)
{
Vector2 topLeft = camera.GlobalToCameraPos(Bounds.Left, Bounds.Top);
Vector2 dimensions = camera.GlobalToCameraPos(Bounds.Right, Bounds.Bottom);
Rectangle r = new Rectangle((int)topLeft.X, (int)topLeft.Y, (int)dimensions.X - (int)topLeft.X, (int)dimensions.Y - (int)topLeft.Y);
Editor.DrawRectangleOutline(sb, r, Color.GreenYellow);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Left - 2, r.Top - 2, 4, 4), Color.GreenYellow);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Right - 2, r.Top - 2, 4, 4), Color.GreenYellow);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Left - 2, r.Bottom - 2, 4, 4), Color.GreenYellow);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Right - 2, r.Bottom - 2, 4, 4), Color.GreenYellow);
if (Bounds.Contains((int)camera.CameraToGlobalPos(state.X, state.Y).X, (int)camera.CameraToGlobalPos(state.X, state.Y).Y))
sb.DrawString(Editor.Font, Name, topLeft + Vector2.One, Color.Black);
}
示例2: Draw
public void Draw(SpriteBatch sb, Camera camera)
{
if (points.Count > 1)
{
for (int i = 0; i < points.Count - 1; i++)
{
Editor.DrawRectangleOutline(sb, new Rectangle((int)camera.GlobalToCameraPos(points[i]).X - 2, (int)camera.GlobalToCameraPos(points[i]).Y - 2, 4, 4), Color.Red);
Editor.DrawLine(sb, camera.GlobalToCameraPos(points[i]), camera.GlobalToCameraPos(points[i + 1]), Color.Red);
}
Editor.DrawRectangleOutline(sb, new Rectangle((int)camera.GlobalToCameraPos(points[points.Count - 1]).X - 2, (int)camera.GlobalToCameraPos(points[points.Count - 1]).Y - 2, 4, 4), Color.Red);
Editor.DrawLine(sb, camera.GlobalToCameraPos(points[points.Count - 1]), camera.GlobalToCameraPos(points[0]), Color.Red);
}
}
示例3: Draw
public void Draw(SpriteBatch sb, Camera camera, Color c)
{
sb.Draw(Editor.ObjectTextures[this.Texture],
camera.GlobalToCameraPos((int)Position.X, (int)Position.Y),
null,
c,
ParameterNames != null && ParameterNames.Contains("Rotation") ? float.Parse(ValueFromName("Rotation")) : 0f,
new Vector2(Editor.ObjectTextures[this.Texture].Width / 2, Editor.ObjectTextures[this.Texture].Height / 2),
camera.TotalScale * ((ParameterNames != null && ParameterNames.Contains("Width") ? float.Parse(ValueFromName("Width")) / Editor.ObjectTextures[this.Texture].Width : 1f) * Vector2.UnitX +
(ParameterNames != null && ParameterNames.Contains("Height") ? float.Parse(ValueFromName("Height")) / Editor.ObjectTextures[this.Texture].Height : 1f) * Vector2.UnitY),
SpriteEffects.None,
0.5555556f);
}
示例4: Draw
public void Draw(SpriteBatch sb, Camera camera)
{
Vector2 topLeft = camera.GlobalToCameraPos(Bounds.Left, Bounds.Top);
Vector2 dimensions = camera.GlobalToCameraPos(Bounds.Right, Bounds.Bottom);
Rectangle r = new Rectangle((int)topLeft.X, (int)topLeft.Y, (int)dimensions.X - (int)topLeft.X, (int)dimensions.Y - (int)topLeft.Y);
Editor.DrawRectangleOutline(sb, r, Color.Blue);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Left - 2, r.Top - 2, 4, 4), Color.Blue);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Right - 2, r.Top - 2, 4, 4), Color.Blue);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Left - 2, r.Bottom - 2, 4, 4), Color.Blue);
Editor.DrawRectangleOutline(sb, new Rectangle(r.Right - 2, r.Bottom - 2, 4, 4), Color.Blue);
Editor.DrawLine(sb, camera.GlobalToCameraPos(Target - Vector2.One * 2), camera.GlobalToCameraPos(Target + Vector2.One * 2), Color.Blue);
Editor.DrawLine(sb, camera.GlobalToCameraPos(Target + Vector2.UnitX * 2 - Vector2.UnitY * 2), camera.GlobalToCameraPos(Target - Vector2.UnitX * 2 + Vector2.UnitY * 2), Color.Blue);
}