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


C# Screen.Initialize方法代码示例

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


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

示例1: Initialize

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //graphics.IsFullScreen = true;
            graphics.IsFullScreen = false;

            graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            data.screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            data.screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            this.IsMouseVisible = true;
            graphics.ApplyChanges();
            Window.Title = "Dinosaurs Game";

            currentScreen = new WelcomeScreen(data);
            currentScreen.Initialize();

            base.Initialize();
        }
开发者ID:brittany2e,项目名称:DinosaursGame,代码行数:25,代码来源:Game1.cs

示例2: Initialize

            /// <summary>
            /// Allows the game to perform any initialization it needs to before starting to run.
            /// This is where it can query for any required services and load any non-graphic
            /// related content.  Calling base.Initialize will enumerate through any components
            /// and initialize them as well.
            /// </summary>
            protected override void Initialize()
            {
                Components.Add(new GamerServicesComponent(this));
                Sprites = new SpriteBatch(Graphics.GraphicsDevice);
                Primitives.Initialize();
                Viewport = Graphics.GraphicsDevice.Viewport;

                sizex = Viewport.Width;
                sizey = Viewport.Height;

                splash = new Screen(sizex, sizey);
                mainscreen = new Screen(sizex, sizey);

                menu = new Menu(3);
                difficulty = new Menu(3);
                yesno = new Menu(2);
                okay = new Menu(1);

                splash.Initialize();
                mainscreen.Initialize();

                Input.Initialize();
                FontEngine.Initialize(64, 16, 32);

                menu.Initialize();
                difficulty.Initialize();
                yesno.Initialize();
                okay.Initialize();

                menu.SetSpacing(10);
                menu.SetSize(347, 97);
                menu.SetText(0, "Start");
                menu.SetText(1, "Level");
                menu.SetText(2, "Quit");

                difficulty.SetSpacing(10);
                difficulty.SetSize(347, 97);
                difficulty.SetText(0, "Easy");
                difficulty.SetText(1, "Medium");
                difficulty.SetText(2, "Hard");

                yesno.SetSpacing(8);
                yesno.SetSize(247, 47);
                yesno.SetText(0, "Yes");
                yesno.SetText(1, "No");

                okay.SetSpacing(8);
                okay.SetSize(247, 47);
                okay.SetText(0, "OK");

                cancel.Iniitialize();
                cancel.text = "Quit game?";
                cancel.SetSize(32 * cancel.text.Length, 48);

                replay.Iniitialize();
                replay.text = "Play again?";
                replay.SetSize(32 * replay.text.Length, 48);

                winner.Iniitialize();
                winner.text = "Winner!";
                winner.SetSize(48 * winner.text.Length, 64);

                score.Iniitialize();
                score.text = "Score: ";
                score.SetSize(48 * score.text.Length, 64);

                box.Initialize();
                box.SetSize(304);
                box.SetPosition(398, 88);

                laser.Initialize();

                hud.Initialize();
                hud.SetSize(175, 350);
                hud.SetPosition(145, 65);

                gametime = 0;

                base.Initialize();
            }
开发者ID:spdemille,项目名称:Baffled,代码行数:86,代码来源:Baffled.cs

示例3: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // If the game is paused, don't update anything.
            if (Paused())
            {
                return;
            }

            /* State Machine */
            if (currentState == State.Welcome &&
                data.welcome2main)
            {
                currentState = State.Main;
                currentScreen = new MainScreen(data);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.welcome2main = false;

                this.IsMouseVisible = false;
            }

            if (currentState == State.Main
                && data.main2bonus)
            {
                currentState = State.Bonus;
                currentScreen = new BonusScreen(data);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.main2bonus = false;

                this.IsMouseVisible = true;
            }

            if (currentState == State.Main
                && data.main2playagain)
            {
                currentState = State.PlayAgain;
                currentScreen = new PlayAgainScreen(data);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.main2playagain = false;

                this.IsMouseVisible = true;
            }

            if (currentState == State.Bonus
                && data.bonus2main)
            {
                currentState = State.Main;
                currentScreen = new MainScreen(data, false);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.bonus2main = false;

                this.IsMouseVisible = false;
            }

            if (currentState == State.Bonus
                && data.bonus2playagain)
            {
                currentState = State.PlayAgain;
                currentScreen = new PlayAgainScreen(data);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.bonus2playagain = false;

                this.IsMouseVisible = true;
            }

            if (currentState == State.PlayAgain
                && data.playagain2welcome)
            {
                currentState = State.Welcome;
                currentScreen = new WelcomeScreen(data);
                currentScreen.Initialize();
                currentScreen.LoadContent(Content);

                data.playagain2welcome = false;

                this.IsMouseVisible = true;
            }

            if (currentState == State.PlayAgain
                && data.playagain2exit)
            {
                this.Exit();
            }

            // In case we want to exit from anywhere in the game,
            // Emergency exit is E+<Esc>
//.........这里部分代码省略.........
开发者ID:brittany2e,项目名称:DinosaursGame,代码行数:101,代码来源:Game1.cs


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