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


C# Camera2D.Jump2Target方法代码示例

本文整理汇总了C#中Camera2D.Jump2Target方法的典型用法代码示例。如果您正苦于以下问题:C# Camera2D.Jump2Target方法的具体用法?C# Camera2D.Jump2Target怎么用?C# Camera2D.Jump2Target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Camera2D的用法示例。


在下文中一共展示了Camera2D.Jump2Target方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadContent

        public override void LoadContent()
        {
            base.LoadContent();

            string json = System.IO.File.ReadAllText("Levels\\" + mLevelID + ".txt");

            List<object> output = JsonParser.Parse(json);
            Hashtable level = (Hashtable)output[0];

            //Level Name
            mLevelName = (string)level["name"];

            //Gravity
            mGravity = new Vector2((float)((List<object>)level["Gravity"])[0], (float)((List<object>)level["Gravity"])[1]);

            //Starting Positions
            foreach(List<object> pos in (List<object>)level["starting_positions"])
            {
                mStartingPositions.Add(mStartingPositions.Count, new Vector2((float)pos[0], (float)pos[1]));
            }

            //Create the camera
            mCamera = new Camera2D(ScreenManager.GraphicsDevice);

            //Create the world
            mWorld = new World(mGravity);

            //Save starting poition index
            mStartingPositionIndex = 0;

            //Save starting position
            mStartingPosition = mStartingPositions[mStartingPositionIndex];

            //Get the content manager
            mContentManager = new ContentManager(ScreenManager.Game.Services, "Content");

            //Create the player
            mPlayer = new Player(mWorld, this, mContentManager, Color.White, mStartingPosition);
            mCamera.EnableTracking = true;
            mCamera.EnablePositionTracking = true;
            mCamera.TrackingBody = mPlayer.CamBody;
            mCamera.Jump2Target();

            //Create a test PC
            mTestPC = new PC(mWorld, this, mContentManager, Color.White, mStartingPosition);

            //Create level objects
            foreach(object dobj in (List<object>)level["Objects"])
            {
                Hashtable dict = (Hashtable)dobj;

                if (dict["Type"].Equals("Body"))
                {
                    Body nBody;

                    Hashtable properties = (Hashtable)dict["Properties"];

                    string SpriteClass = (string)properties["SpriteClass"];

                    if (SpriteClass != "" && SpriteClass != null)
                    {
                        nBody = BodyFactory.CreateBody(mWorld, new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]));
                    }
                    else
                    {
                        nBody = BodyFactory.CreateBody(mWorld, new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]));
                    }

                    string nTextureName = (string)properties["SpriteTexture"];
                    MaterialType nMaterialType = (MaterialType)Enum.Parse(typeof(MaterialType), (string)properties["MaterialType"]);
                    Color nColor = (Color)Color.White.GetType().GetProperty((string)properties["Color"]).GetValue(null, null);

                    nBody.Position = new Vector2((float)((List<object>)properties["Position"])[0], (float)((List<object>)properties["Position"])[1]);
                    nBody.Rotation = (float)properties["Rotation"];
                    nBody.BodyType = (BodyType)Enum.Parse(typeof(BodyType), (string)properties["BodyType"]);
                    nBody.IsBullet = (bool)properties["IsBullet"];
                    nBody.IsSensor = (bool)properties["IsSensor"];
                    nBody.IsStatic = (bool)properties["IsStatic"];

                    nBody.Mass = (float)properties["Mass"];

                    nBody.Inertia = (float)properties["Inertia"];
                    nBody.Friction = (float)properties["Friction"];
                    nBody.Restitution = (float)properties["Restitution"];
                    nBody.LinearDamping = (float)properties["LinearDamping"];
                    nBody.AngularDamping = (float)properties["AngularDamping"];
                    nBody.FixedRotation = (bool)properties["FixedRotation"];

                    nBody.Awake = (bool)properties["Awake"];
                    nBody.Enabled = (bool)properties["Enabled"];
                    nBody.IgnoreCCD = (bool)properties["IgnoreCCD"];
                    nBody.IgnoreGravity = (bool)properties["IgnoreGravity"];
                    nBody.SleepingAllowed = (bool)properties["SleepingAllowed"];

                    foreach(object fobj in (List<object>)dict["Fixtures"])
                    {
                        Hashtable fixture = (Hashtable)fobj;

                        if(fixture["Shape"].Equals("Rectangle"))
                        {
//.........这里部分代码省略.........
开发者ID:WilHall,项目名称:hakyn-client,代码行数:101,代码来源:Level.cs


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