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


C# RenderWindow.GetView方法代码示例

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


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

示例1: GameScreen

        public GameScreen(RenderWindow window)
        {
            Window = window;
            GuiView = new View(Window.GetView());
            GameGuiView = new View(Window.GetView());
            Gui = new EditorBaseWidget(Window, GuiView);
            Gui.Dimension = GuiView.Size;

            PlayerHdl.Instance.Init("");

            MapHandler.Instance.SetGameRoot(Window);
            MapMan.Instance.InitMap(GameData.INIT_MAP);

            Gui.AddWindow(MiscWidget.Instance, true);
            Gui.AddWindow(MapHandler.Instance, true);
            Gui.AddWindow(MapMan.Instance, true);
            Gui.AddWindow(PointCreator.Instance);
            Gui.AddWindow(WarpPointCreator.Instance);
            Gui.AddWindow(MapCreator.Instance);
            Gui.AddWindow(ObjectMan.Instance);
            Gui.AddWindow(ObjectCreator.Instance);
            Gui.AddWindow(TextureMan.Instance);
            Gui.AddWindow(TextureCreator.Instance);
            Gui.AddWindow(TextureRemover.Instance);
            Gui.AddWindow(InformationDialogBox.Instance);
            Gui.AddWindow(ConfirmationDialogBox.Instance);
            Gui.AddWindow(BoundingBoxCreator.Instance);
            Gui.AddWindow(TextureRectDrawer.Instance);
            Gui.AddWindow(TileMan.Instance);
            Gui.AddWindow(TileSetMan.Instance);
            Gui.AddWindow(TileSetCreator.Instance);
            Gui.AddWindow(TileCreator.Instance);
            Gui.AddWindow(EventCreator.Instance);
            Gui.AddWindow(ActionCreator.Instance);

            Gui.AddKeyWindowBind(Keyboard.Key.M, MapMan.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.G, MiscWidget.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.O, ObjectMan.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.T, TextureMan.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.H, MapHandler.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.I, TileMan.Instance);
            Gui.AddKeyWindowBind(Keyboard.Key.L, TileSetMan.Instance);

            PlayerHdl.Vlad.ToScript();
        }
开发者ID:eickegao,项目名称:Blazera,代码行数:45,代码来源:GameScreen.cs

示例2: BlazeraProgram

        BlazeraProgram()
        {
            // GameEngine init
            ScriptEngine.Instance.Init("ProgramData");

            TextureManager.Instance.Init();
            SoundManager.Instance.Init();

            // GraphicsEngine init
            Window = new RenderWindow(new VideoMode(GameData.WINDOW_WIDTH, GameData.WINDOW_HEIGHT), "Blazera program", GameData.WINDOW_STYLE);
            Window.Closed += new System.EventHandler(Window_Closed);
            WindowEvents.Instance.Init(Window);

            GuiView = new View(Window.GetView());
            Gui = new EditorBaseWidget(Window, GuiView);
            Gui.Dimension = GuiView.Size;

            Border.Init();

            Gui.AddWindow(ConfirmationDialogBox.Instance);
            Gui.AddWindow(InformationDialogBox.Instance);

            CallOnInit();
        }
开发者ID:eickegao,项目名称:Blazera,代码行数:24,代码来源:BlazeraProgram.cs

示例3: Run


//.........这里部分代码省略.........

            contextMenu = new ContextMenu();
            contextMenu.Add(() =>
            {
                selected.BodyType = BodyType.Dynamic;
            }, "Set Dynamic");
            contextMenu.Add(() =>
            {
                selected.BodyType = BodyType.Static;
            }, "Set Static");
            contextMenu.Add(() =>
            {
                world.FindBody(selected).GameDimension = Dimension.None;
            }, "Set No Dimension");
            contextMenu.Add(() =>
            {
                world.FindBody(selected).GameDimension = world.FindBody(selected).GameDimension == Dimension.OneO ? Dimension.TwoX : Dimension.OneO;
            }, "Switch Dimension");
            contextMenu.Add(() =>
            {
                selected.Rotation += 0.0872664626f;
            }, "+5 Rotation");
            contextMenu.Add(() =>
            {
                selected.Rotation += 0.785398163f;
            }, "+45 Rotation");
            contextMenu.Add(() =>
            {
                selected.Rotation -= 0.0872664626f;
            }, "-5 Rotation");
            contextMenu.Add(() =>
            {
                selected.Rotation -= 0.785398163f;
            }, "-45 Rotation");
            contextMenu.Add(() =>
            {
                world.Copy(selected, new Vector2(offset.X, offset.Y) * -0.1f);
            }, "Duplicate");
            contextMenu.Add(() =>
            {
                world.Remove(selected);
            }, "Remove");

            messageScene = new Scene(ScrollInputs.None);

            Stopwatch sw = new Stopwatch();
            TimeSpan elapsed = TimeSpan.Zero;
            TimeSpan secondCounter = TimeSpan.Zero;
            int frames = 0;
            world.Step(0);

            View v;
            Console.WriteLine(window.GetView().Center);

            while (window.IsOpen())
            {
                sw.Start();
                window.DispatchEvents();
                window.Clear();

                if (enabled)
                    world.Step((float)elapsed.TotalSeconds);

                v = window.GetView();
                v.Zoom(zoom);
                v.Center = (world.CamLock == null ? -offset : new Vector2f(world.CamLock.Position.X * 10, world.CamLock.Position.Y * 10));
                if (world.CamLock != null) v.Rotation = world.CamLock.Rotation * 57.2957795f;
                else v.Rotation = 0;
                window.SetView(v);

                window.Draw(grid);

                world.Render(window);

                v = window.GetView();
                v.Size = new Vector2f(1280, 720);
                v.Rotation = 0;
                v.Center = new Vector2f(640, 360);
                window.SetView(v);

                ui.Render(window);
                ui.CurrentScene = messageScene;
                ui.Render(window);
                ui.CurrentScene = scene;
                contextMenu.Render(window);

                window.Display();
                sw.Stop();
                elapsed = sw.Elapsed;
                secondCounter += elapsed;
                frames++;
                if (secondCounter >= TimeSpan.FromSeconds(1))
                {
                    Console.WriteLine(frames / secondCounter.TotalSeconds);
                    secondCounter -= TimeSpan.FromSeconds(1);
                    frames = 0;
                }
                sw.Reset();
            }
        }
开发者ID:WebFreak001,项目名称:LD-30,代码行数:101,代码来源:LevelEditor.cs

示例4: input

        public override void input(RenderWindow _window)
        {
            if (Keyboard.IsKeyPressed(Keyboard.Key.A))
            {
                if (mPosition.X > 0)
                    mBody.ApplyLinearImpulse(new Vector2(-0.3f * Delta.mDelta, 0f));
                else
                    mBody.ApplyLinearImpulse(new Vector2(0.3f * Delta.mDelta, 0f));
            }
            else if (Keyboard.IsKeyPressed(Keyboard.Key.D))
            {
                if(mPosition.Y < 1280)
                    mBody.ApplyLinearImpulse(new Vector2( 0.3f * Delta.mDelta, 0f));
                else
                    mBody.ApplyLinearImpulse(new Vector2(-0.3f * Delta.mDelta, 0f));
            }

            if(Keyboard.IsKeyPressed(Keyboard.Key.Return))
            {
                if(!mOnce)
                    invincible();
            }

            if (Keyboard.IsKeyPressed(Keyboard.Key.Space))
            {
                if (mPosition.X > 0 && mPosition.X < 1280)
                    mBody.ApplyLinearImpulse(new Vector2(0f, -0.9f * Delta.mDelta));
            }

            if (Mouse.IsButtonPressed(Mouse.Button.Left))
            {
                if (mShoot.ElapsedMilliseconds > 250)
                {
                    Vector2i mousePos   = Mouse.GetPosition(_window);
                    Vector2f translated = _window.MapPixelToCoords(mousePos, _window.GetView());
                    Vector2f aim        = new Vector2f(translated.X - mPosition.X, translated.Y - mPosition.Y);
                    double   angle      = Math.Atan2(aim.Y, aim.X);

                    mWorld.createBullet(mPosition, this, "resources/bullet.png", angle);
                    mShoot.Restart();
                }
            }
        }
开发者ID:Jamsterx1,项目名称:Titan,代码行数:43,代码来源:Player.cs

示例5: InitWindow

        public static bool InitWindow(Styles style)
        {
            int width, height;
            if (!_game.TryGetData("screen_width", out width))
            {
                Console.WriteLine("No screen width set in game.sgm.");
                return false;
            }
            if (!_game.TryGetData("screen_height", out height))
            {
                Console.WriteLine("No screen height set in game.sgm.");
                return false;
            }

            if (width <= 0 || height <= 0)
            {
                Console.WriteLine("Invalid width and height in game.sgm.");
                return false;
            }

            GlobalProps.Width = width;
            GlobalProps.Height = height;

            if (Scaled)
            {
                width *= 2;
                height *= 2;
            }
            _clipper.Width = width;
            _clipper.Height = height;

            GlobalProps.BasePath = Path.GetDirectoryName(_game.FileName);

            if (!_game.TryGetData("name", out GlobalProps.GameName))
            {
                Console.WriteLine("No name set in game.sgm.");
                return false;
            }

            if (style == Styles.Fullscreen && (width < 640 || height < 480))
            {
                width = 640;
                height = 480;
            }

            _window = new RenderWindow(new VideoMode((uint)width, (uint)height), GlobalProps.GameName, style);

            if (Scaled)
            {
                View v = _window.GetView();
                v.Size = new Vector2f(GlobalProps.Width, GlobalProps.Height);
                v.Center = new Vector2f(GlobalProps.Width / 2, GlobalProps.Height / 2);
                _window.SetView(v);
            }

            _window.SetMouseCursorVisible(false);
            GlobalInput.AddWindowHandlers(_window);
            Program._window.SetFramerateLimit((uint)_internal_fps);
            Program._window.SetMouseCursorVisible(false);

            GlobalPrimitives.Target = _window;
            Batch = new SpriteBatch(_window);

            FindIcon();
            return true;
        }
开发者ID:Radnen,项目名称:sphere-sfml,代码行数:66,代码来源:Program.cs


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