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


C# RenderWindow.SetKeyRepeatEnabled方法代码示例

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


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

示例1: Main

        internal static void Main(string[] args)
        {
            shapes = new List<Shape>();

            window = new RenderWindow(new VideoMode(WINDOW_SIZE.X, WINDOW_SIZE.Y), "Physics Playground", Styles.Titlebar | Styles.Close);
            window.SetVerticalSyncEnabled(true);
            window.SetKeyRepeatEnabled(false);
            SetupEvents();

            Time lastTime = clock.ElapsedTime;

            while(window.IsOpen)
            {
                Time now = clock.ElapsedTime;
                Time frame = now - lastTime;
                lastTime = now;
                lag += frame;

                while(lag >= dt)
                {
                    window.DispatchEvents();

                    if(!paused)
                    {
                        Update();
                    }

                    lag -= dt;
                }

                Draw();
            }
        }
开发者ID:dabbertorres,项目名称:PhysicsPlayground,代码行数:33,代码来源:Game.cs

示例2: Init

        public static void Init()
        {
            ContextSettings settings = new ContextSettings (32, 8, 4, 3, 3);
              Styles windowStyle = Styles.Close;

              if (FULLSCREEN) {
            windowStyle = Styles.Fullscreen;
            Game.Width = FULLSCREEN_WIDTH;
            Game.Height = FULLSCREEN_HEIGHT;
            Game.CameraWidth = FULLSCREEN_WIDTH;
            Game.CameraHeight = FULLSCREEN_HEIGHT;
              }

              Context = new RenderWindow (new VideoMode ((uint)Game.Width, (uint)Game.Height), WindowTitleText, windowStyle, settings);

              Context.Closed += OnClose;
              Context.KeyPressed += KeyPressed;
              Context.KeyReleased += KeyReleased;
              Context.SetKeyRepeatEnabled (true);

              Rand = new Random ();
              EventMgr = new EventManager ();
              World = new GameWorld ();

              Camera = new View ();
              Camera.Center = new Vector2f (CameraWidth / 2, CameraHeight / 2);
              Camera.Size = new Vector2f (CameraWidth, CameraHeight); // Half Size
              Context.SetView (Camera);
        }
开发者ID:colincapurso,项目名称:GlobalGameJam2013,代码行数:29,代码来源:Game.cs

示例3: Game

        public Game(uint width = 1365, uint height = 768)
        {
            if (!File.Exists(IniFileName))
            {
                MessageBox.Show(string.Format("Brak pliku {0}!", IniFileName));
                Environment.Exit(1);
            }

            ReadIniFile(IniFileName);

            Players = new Dictionary<int, PlayerInstance>();

            Width = width;
            Height = height;

            var settings = new ContextSettings { AntialiasingLevel = 8 };
            Window = new RenderWindow(new VideoMode(Width, Height), "Nano War", Styles.Close, settings);

            Window.Closed += (s, a) =>
                {
                    GameClient.GameClient.Dispose();
                    Window.Close();
                };
            Window.SetVerticalSyncEnabled(true);
            Window.SetKeyRepeatEnabled(false);

            StateMachine = new StateMachine();
            AudioManager = new AudioManager();
        }
开发者ID:Yozer,项目名称:NanoWar,代码行数:29,代码来源:Game.cs

示例4: GameApplication

        public GameApplication()
        {
            mWindow = new RenderWindow(new VideoMode(640, 480), "SFML App", Styles.Close);
            mWindow.SetKeyRepeatEnabled(false);

            mPlayer = new Player();

            mTextures = new ResourceHolder<Texture, ResourceID>();
            mTextures.load(ResourceID.TitleScreen, "Media/Textures/TitleScreen.png");
            mTextures.load(ResourceID.ButtonNormal, "Media/Textures/ButtonNormal.png");
            mTextures.load(ResourceID.ButtonSelected, "Media/Textures/ButtonSelected.png");
            mTextures.load(ResourceID.ButtonPressed,"Media/Textures/ButtonPressed.png");

            mFonts = new ResourceHolder<Font, FontID>();
            mFonts.load(FontID.Main, "Media/Sansation.ttf");

            mStateStack = new StateStack(new State.Context(mWindow,mTextures,mFonts,mPlayer));
            eventqueue = new Queue<Event>();

            registerStates();
            mStateStack.pushState(StateID.Title);

            mWindow.Closed += onClosed;
            mWindow.GainedFocus += gainedFocus;
            mWindow.LostFocus += lostFocus;
            mWindow.KeyPressed += keyPressed;
        }
开发者ID:pixeltasim,项目名称:SFML.NET_Gamedev,代码行数:27,代码来源:Application.cs

示例5: GameApplication

        public GameApplication()
        {
            mWindow = new RenderWindow(new VideoMode(640, 480), "SFML App", Styles.Close);
            mWindow.SetKeyRepeatEnabled(false);

            mPlayer = new Player();

            mTextures = new ResourceHolder<Texture, TextureID>();

            mFonts = new ResourceHolder<Font, FontID>();
            mFonts.load(FontID.Title, "Assets/KarmaFuture.ttf");

            mStateStack = new StateStack(new Context(mWindow, mTextures, mFonts, mPlayer));
            eventqueue = new Queue<Input.Event>();

            registerStates();
            mStateStack.pushState(StateID.Title);

            mWindow.Closed += onClosed;
            mWindow.GainedFocus += gainedFocus;
            mWindow.LostFocus += lostFocus;
            mWindow.KeyPressed += keyPressed;
        }
开发者ID:pixeltasim,项目名称:Conform,代码行数:23,代码来源:Application.cs

示例6: Main

        static void Main()
        {
            Console.Title = "Tetraquark Console";
            Running = true;

            const string ConfigFile = "cfg.yaml";
            if (File.Exists(ConfigFile)) {
                Console.WriteLine("Loading config file {0}", ConfigFile);
                Settings.Load(File.ReadAllText(ConfigFile));
            }

            GameWatch = new Stopwatch();
            GameWatch.Start();
            PackMgr.Mount("Default.zip");

            string[] Files = PackMgr.GetFiles();
            for (int i = 0; i < Files.Length; i++) {
                if (Files[i].StartsWith("resources/fonts/"))
                    ResourceMgr.Register<Font>(PackMgr.OpenFile(Files[i]), Path.GetFileNameWithoutExtension(Files[i]));
                else if (Files[i].StartsWith("resources/textures/"))
                    ResourceMgr.Register<Texture>(PackMgr.OpenFile(Files[i]), Path.GetFileNameWithoutExtension(Files[i]));
            }

            Scales.Init(new Vector2f(ResX, ResY));

            // OpenTK
            ToolkitOptions TOpt = ToolkitOptions.Default;
            TOpt.Backend = PlatformBackend.PreferNative;
            TOpt.EnableHighResolution = true;
            Toolkit.Init(TOpt);
            // SFML
            VideoMode VMode = new VideoMode((uint)Scales.XRes, (uint)Scales.YRes, (uint)BitsPerPixel);
            ContextSettings CSet = new ContextSettings((uint)DepthBits, (uint)StencilBits);
            CSet.MajorVersion = 4;
            CSet.MinorVersion = 2;
            CSet.AntialiasingLevel = (uint)Samples;
            Styles S = Styles.None;
            if (Border)
                S |= Styles.Titlebar | Styles.Close;
            RenderWindow RWind = new RenderWindow(VMode, "Tetraquark", S, CSet);
            RWind.Closed += (Snd, E) => Running = false;
            RWind.SetKeyRepeatEnabled(false);
            // OpenTK
            IWindowInfo WindInfo = Utilities.CreateWindowsWindowInfo(RWind.SystemHandle);
            var GfxMode = new GraphicsMode(new ColorFormat(BitsPerPixel), DepthBits, StencilBits, Samples, new ColorFormat(0));
            var GfxCtx = new GraphicsContext(GfxMode, WindInfo, (int)CSet.MajorVersion, (int)CSet.MinorVersion,
                GfxCtxFlags.Default);
            GfxCtx.MakeCurrent(WindInfo);
            GfxCtx.LoadAll();
            RWind.ResetGLStates();

            //GL.Enable(EnableCap.FramebufferSrgb);

            Renderer.Init(RWind);
            Stopwatch Clock = new Stopwatch();
            Clock.Start();

            while (Running) {
                RWind.DispatchEvents();
                while (Clock.ElapsedMilliseconds < 10)
                    ;
                float Dt = (float)Clock.ElapsedMilliseconds / 1000;
                Clock.Restart();
                Renderer.Update(Dt);
                Renderer.Draw(RWind);
                RWind.Display();
            }

            RWind.Close();
            RWind.Dispose();
            Console.WriteLine("Flushing configs");
            File.WriteAllText(ConfigFile, Settings.Save());
            Environment.Exit(0);
        }
开发者ID:cartman300,项目名称:Tetraquark,代码行数:74,代码来源:Program.cs

示例7: InitializeWindow

 public static void InitializeWindow(RenderWindow win)
 {
     win.KeyPressed +=  KeyPressed;
     win.KeyReleased += KeyReleased;
     win.SetKeyRepeatEnabled(false);
 }
开发者ID:Phyxius,项目名称:SomeZombieGame,代码行数:6,代码来源:EntityManager.cs

示例8: Main

        static void Main(string[] args)
        {
            Texture textureBack = new Texture(File.ReadAllBytes(@"assets/back.png"));

            textureBack.Smooth = true;

            Sprite spriteBack = new Sprite(textureBack, new IntRect(0, 0, 800, 500));

            Texture textureLock = new Texture(File.ReadAllBytes(@"assets/lock.png"));

            textureLock.Smooth = true;

            Sprite spriteLock = new Sprite(textureLock, new IntRect(0, 0, 80, 80));

            spriteLock.Position = new Vector2f(76, 68);

            icons = new List<Sprite>();

            for (int index = 0; index < 15; index++)
            {
                int col = index % 5;

                int row = (index - col) / 5;

                Texture textureIcon = new Texture(File.ReadAllBytes(String.Format(@"assets/buttons/{0:00}.png", index + 1)));

                textureIcon.Smooth = true;

                Sprite spriteIcon = new Sprite(textureIcon, new IntRect(0, 0, 72, 72));

                spriteIcon.Position = new Vector2f(80 + col * 72 + col * 70, 72 + row * 72 + row * 70);

                icons.Add(spriteIcon);
            }

            ContextSettings context = new ContextSettings();

            context.DepthBits = 32;

            RenderWindow window = new RenderWindow(new VideoMode(800, 500), String.Empty, Styles.Default, context);

            window.SetActive();

            window.SetVisible(true);

            window.SetKeyRepeatEnabled(true);

            window.SetMouseCursorVisible(true);

            window.SetVerticalSyncEnabled(false);

            window.Closed += new EventHandler(
                delegate(object sender, EventArgs e)
                {
                    window.Close();

                    window.Dispose();
                }
            );

            window.GainedFocus += new EventHandler(
                delegate(object sender, EventArgs e)
                {

                }
            );

            window.LostFocus += new EventHandler(
                delegate(object sender, EventArgs e)
                {

                }
            );

            window.KeyPressed += new EventHandler<KeyEventArgs>(
                delegate(object sender, KeyEventArgs e)
                {
                    if (e.Code == Keyboard.Key.Escape)
                    {
                        /*
                        sound.Stop();

                        sound.Dispose();

                        buffer.Dispose();
                        */

                        window.Close();

                        window.Dispose();
                    }

                    if (e.Code == Keyboard.Key.Right)
                    {
                        if (col < 4)
                        {
                            col += 1;
                        }
                    }

//.........这里部分代码省略.........
开发者ID:erinus,项目名称:SFML,代码行数:101,代码来源:Program.cs

示例9: WindowConfig

		public static void WindowConfig()
		{
			ContextSettings settings = new ContextSettings();
			settings.AntialiasingLevel = 4;

			myWindow = new RenderWindow(
				new VideoMode(1600, 900),
				"SFML Application (SFML.netV2.2 + Optimized Multithread)",
				Styles.Fullscreen,
				settings);

			aspectRatio = myWindow.Size.X / (double)myWindow.Size.Y;
			myWindow.SetVerticalSyncEnabled(true);
			myWindow.SetKeyRepeatEnabled(false);
			EventLinking(myWindow);
			MyShapes.SetShapes();
		}
开发者ID:RSF-Deus,项目名称:SFML.Net-V2.2-Template,代码行数:17,代码来源:SFMLConfig.cs


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