当前位置: 首页>>代码示例>>C#>>正文


C# Camera.GlobalToCameraPos方法代码示例

本文整理汇总了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);
 }
开发者ID:TadCordle,项目名称:MrGuyXNA,代码行数:13,代码来源:TriggerInfo.cs

示例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);
     }
 }
开发者ID:TadCordle,项目名称:MrGuyXNA,代码行数:13,代码来源:StaticBodyInformation.cs

示例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);
 }
开发者ID:TadCordle,项目名称:MrGuyXNA,代码行数:13,代码来源:ObjectInformation.cs

示例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);
 }
开发者ID:TadCordle,项目名称:MrGuyXNA,代码行数:13,代码来源:CameraBoxInformation.cs


注:本文中的Camera.GlobalToCameraPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。