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


C# Platform.getMidPoint方法代码示例

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


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

示例1: Initialize

        public override void Initialize()
        {
            childComponents = new List<GameObject>();
            ioManager = new IOManager();
            font = gameRef.Content.Load<SpriteFont>("SpriteFont1");

            platform = new Platform(new Rectangle(18, 40, 445, 650), gameRef.Content);
            guage = new Guage(new Rectangle(platform.Position.X + platform.Position.Width + 2, 40, 100, 650), gameRef.Content);
            Vector2 startingPos = platform.getMidPoint();
            player = new Munchlit(new Rectangle((int)startingPos.X, (int)startingPos.Y, 20, 20), gameRef.Content);

            childComponents.Add(platform);
            childComponents.Add(guage);
            childComponents.Add(player);

            for (int i = platform.Position.X + 12; i <= platform.Position.X + platform.Position.Width - 24; i += 30)
            {

                childComponents.Add(new Meteor(new Rectangle(i, platform.Position.Y + platform.Position.Height - 45, 30, 30), gameRef.Content, 0));
                childComponents.Add(new Meteor(new Rectangle(i, platform.Position.Y + platform.Position.Height - 75, 30, 30), gameRef.Content, 0));
                childComponents.Add(new Meteor(new Rectangle(i, platform.Position.Y + platform.Position.Height - 105, 30, 30), gameRef.Content, 0));
            }

            guiManager.AddLabel("HighScore", font, "Highscore: " + 0);
            guiManager["HighScore"].Position = new Vector2(guage.Position.X + guage.Position.Width + 10, 40.0f);
            guiManager["HighScore"].Size = new Vector2(200.0f, 75.0f);
            guiManager["HighScore"].Color = Color.Black;

            guiManager.AddLabel("level", font, "Level: " + level);
            guiManager["level"].Position = new Vector2(platform.Position.X + platform.Position.Width / 3 + 20, 10.0f);
            guiManager["level"].Size = new Vector2(150, 20.0f);
            guiManager["level"].Color = Color.Black;

            guiManager.AddLabel("time", font, "Timer: " + timer);
            guiManager["time"].Position = new Vector2(guage.Position.X + guage.Position.Width + 10, 70.0f);
            guiManager["time"].Size = new Vector2(200.0f, 75.0f);
            guiManager["time"].Color = Color.Black;

            guiManager.AddLabel("lives", font, "Lives: " + player.Lives);
            guiManager["lives"].Position = new Vector2(guage.Position.X + guage.Position.Width + 10, 100.0f);
            guiManager["lives"].Size = new Vector2(150.0f, 20.0f);
            guiManager["lives"].Color = Color.Black;

            guiManager.AddLabel("points", font, "Points: " + player.Point);
            guiManager["points"].Position = new Vector2(guage.Position.X + guage.Position.Width + 10, 130.0f);
            guiManager["points"].Size = new Vector2(150.0f, 20.0f);
            guiManager["points"].Color = Color.Black;

            guiManager.AddPicture("tmp", gameRef.Content.Load<Texture2D>("Freezling"));
            guiManager["tmp"].Position = new Vector2(guage.Position.X + guage.Position.Width + 30, 200.0f);
            guiManager["tmp"].Size = new Vector2(200.0f, 200.0f);

            guiManager.AddButton("pause", "PAUSE", guage.Position.X + guage.Position.Width + 10, 400, 200.0f, 75.0f);

            guiManager.AddButton("btnMainMenu", "Menu", guage.Position.X + guage.Position.Width + 10, 500, 200.0f, 75.0f);

            guiManager.AddButton("btnExit", "Exit", guage.Position.X + guage.Position.Width + 10, 600, 200.0f, 75.0f);

            btnMainMenu = guiManager["btnMainMenu"] as Button;
            btnMainMenu.Click += (control, button) =>
            {
                GameState MainMenu = this.parent[GameStateType.Playing];
                if (MainMenu != null)
                {
                    this.parent.PushState(MainMenu);

                    MainMenu MainMenuState = new MainMenu(this.gameRef, this.renderer, this.parent);
                    MainMenu.Initialize();
                    this.parent.PushState(MainMenuState);

                }
            };

            btnExit = guiManager["btnExit"] as Button;
            btnExit.Click += (control, button) =>
            {
                gameRef.Exit();
            };

            try
            {
                highScore = ioManager.LoadHighScore();
            }
            catch (Exception)
            {
                ioManager.SaveHighScore(0);
                highScore = 0;
            }
        }
开发者ID:jl4312,项目名称:Meteor-Freeze,代码行数:89,代码来源:Play.cs


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