本文整理汇总了C#中Camera.TrackBody方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.TrackBody方法的具体用法?C# Camera.TrackBody怎么用?C# Camera.TrackBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Camera
的用法示例。
在下文中一共展示了Camera.TrackBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public override void Initialize()
{
screenCursorPos = Vector2.Zero;
worldCursorPos = Vector2.Zero;
world = new World(Vector2.Zero);
map = LoadMapFromFile("map1");
mapBodies = new List<Body>();
for (int i = 0; i < map.Count - 1; i++)
{
Vector2 difference = map[i] - map[(i + 1) % map.Count];
float distance = Vector2.Distance(map[i], map[(i + 1) % map.Count]);
Vector2 centre = (map[i] + map[(i + 1) % map.Count]) / 2f;
float angle = (float)Math.Atan2(difference.Y, difference.X) + MathHelper.PiOver2;
Body temp = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(3f), distance, 1f, centre);
temp.CollisionCategories = Category.Cat2;
temp.CollidesWith = Category.Cat1;
temp.Rotation = angle;
temp.BodyType = BodyType.Static;
mapBodies.Add(temp);
}
player1 = new Player(this, ConvertUnits.ToSimUnits(0, 0), world, Color.Yellow);
player2 = new Player(this, ConvertUnits.ToSimUnits(500, 500), world, Color.Aquamarine);
camera = new Camera(owner.Graphics.GraphicsDevice);
camera.TrackBody(player1.Body);
}