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


C# RectangleShape.Draw方法代码示例

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


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

示例1: Draw

        public override void Draw()
        {
            //blue sky
            MainGame.window.SetView(MainGame.window.DefaultView);
            shader.Shader.SetParameter("offsetY", MainGame.Camera.Center.Y);
            RectangleShape rs = new RectangleShape
            {
                Size = new Vector2f(800, 600)
            };
            MainGame.window.Draw(rs, shader);
            MainGame.window.SetView(MainGame.Camera);

            //background
            Render.Draw(Content.GetTexture("background1Far.png"), new Vector2f(-200, -100), Color.White, new Vector2f(0, 0), 1, 0f);
            Render.Draw(Content.GetTexture("background1Far.png"), new Vector2f(145, -100), Color.White, new Vector2f(0, 0), 1, 0f);
            Render.Draw(Content.GetTexture("background1.png"), new Vector2f(-200, -150), Color.White, new Vector2f(0, 0), 1, 0f);

            //tracks
            RectangleShape tracks = new RectangleShape(new Vector2f(800, .5f));
            tracks.Position = new Vector2f(-400, -49);
            tracks.FillColor = new Color(10, 10, 10, 50);
            tracks.Draw(MainGame.window, RenderStates.Default);

            //train
            Render.Draw(Content.GetTexture("mapDecor.png"), new Vector2f(trainPosX, -55), new Color(255, 255, 255, 200), new Vector2f(0, 0), 1, 0f, .03f);

            //title
            Render.Draw(Content.GetTexture("title.png"), new Vector2f(-50, -190), new Color(255, 255, 255, 240), new Vector2f(0, 0), 1, 0f, .4f);

            if (stage == 0)
            {
                //menubox
                RectangleShape rectBG = new RectangleShape(new Vector2f(200, 110));
                rectBG.Position = new Vector2f(-50, 0);
                rectBG.FillColor = new Color(10, 10, 10, 100);
                rectBG.Draw(MainGame.window, RenderStates.Default);

                if (!submitted)
                {
                    //menu username
                    rectUsername.FillColor = new Color(10, 10, 10, (byte)(composingUsername ? 150 : 50));
                    rectUsername.Draw(MainGame.window, RenderStates.Default);

                    //menu ip
                    rectIP.FillColor = new Color(10, 10, 10, (byte)(composingIP ? 150 : 50));
                    rectIP.Draw(MainGame.window, RenderStates.Default);

                    //menu connect button
                    rectConnect.FillColor = new Color(10, 255, 10,
                        (byte)(rectConnect.GetGlobalBounds().Contains(
                        (int)MainGame.worldMousePos.X, (int)MainGame.worldMousePos.Y) ? 150 : 70));
                    rectConnect.Draw(MainGame.window, RenderStates.Default);

                    //text: username, ip, connect button
                    Render.DrawString(Content.GetFont("OldNewspaperTypes.ttf"), usernameField, new Vector2f(50, 15), Color.White, .3f, true, 1);
                    Render.DrawString(Content.GetFont("OldNewspaperTypes.ttf"), ipField, new Vector2f(50, 45), Color.White, .3f, true, 1);
                    Render.DrawString(Content.GetFont("OldNewspaperTypes.ttf"), "Connect", new Vector2f(50, 77), Color.White, .4f, true, 1);
                }
                else
                {
                    Render.DrawString(Content.GetFont("OldNewspaperTypes.ttf"), "Connecting...", new Vector2f(50, 15), Color.White, .3f, true, 1);
                    submitTimer++;
                    if (submitTimer > 300)
                    {
                        submitted = false;
                        submitTimer = 0;
                        ipField = "Failed to Connect";
                    }
                }
            }
            if (stage == 1)
            {
                RectangleShape rectBG = new RectangleShape(new Vector2f(200, 110));
                rectBG.Position = new Vector2f(-50, 0);
                rectBG.FillColor = new Color(10, 10, 10, 100);
                rectBG.Draw(MainGame.window, RenderStates.Default);

                //char1.Update();
                //char2.Update();

                Render.DrawAnimation(char1.Texture, new Vector2f(-0, 5), Color.White, new Vector2f(0, 0), 1, char1.Count, char1.Frame);
                Render.DrawAnimation(char2.Texture, new Vector2f(100, 5), Color.White, new Vector2f(0, 0), -1, char2.Count, char2.Frame);

                //Render.Draw(Content.GetTexture("gibHead.png"), new Vector2f(40, 10), Color.White, new Vector2f(0, 0), 1, 0, 2);
                //Render.Draw(Content.GetTexture("char2_gibHead.png"), new Vector2f(0, 10), Color.White, new Vector2f(0, 0), 1, 0, 2);

                FloatRect leftRect = new FloatRect(new Vector2f(0, 5), new Vector2f(20, 55));
                FloatRect rightRect = new FloatRect(new Vector2f(75, 5), new Vector2f(20, 55));

                if (leftRect.Contains(MainGame.worldMousePos.X, MainGame.worldMousePos.Y))
                {
                    currentCursor = hoverCursor;
                    if (Input.isMouseButtonTap(Mouse.Button.Left))
                    {
                        stage = 2;
                        MainGame.dm.player.model = MainGame.Char1Model;
                        MainGame.dm.player.UpdateToCurrentModel();
                        return;
                    }
                }
//.........这里部分代码省略.........
开发者ID:libjared,项目名称:iris,代码行数:101,代码来源:Menu.cs


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