-
Hello
I've problem my problem is I want when player pressed the left button of mouse my game detect one clic not 3600 clic
Thanks for your help ;)
-
Hi!
Take a look at the tutorial about events:
https://www.sfml-dev.org/tutorials/2.5/window-events.php
Take particular note of the mouse button pressed events section:
https://www.sfml-dev.org/tutorials/2.5/window-events.php#the-mousebuttonpressed-and-mousebuttonreleased-events
-
Hi
I've see that in internet but I don't understand where i initialize the Event in my main class i just this Window.DispatchEvents();
For the event
-
I apologise; I didn't notice that this was in the DotNet category.
I have little experience with C# so I'm unsure as the correct way to approach this situation and how it may be different from the C++ approach.
-
Hello
I've surrend this idea but this week i take my revenche but i don't know how I can do this
I want detect just once the input for detect the input always is pressed i use
_window
.KeyPressed += new EventHandler
<KeyEventArgs
>(OnKeyPressed
); private static void OnKeyPressed(object sender, KeyEventArgs e)
{
Window window = (Window)sender;
if (e.Code == Keyboard.Key.A)
Console.WriteLine("Hola");
}
But i don't find for detect the input once
I'm french sorry for my english ;)
Thanks for your help ;)
-
The Window class has a function to disable repeated keyboard events.
-
Ok but if i want detected the repeat i can't
Because i wan't to detected once for the attack but for the move i want detected always :/
-
Moves should use real-time inputs (Keyboard and Mouse classes), not events.
-
You can keep read repeatedly your key strokes and implement your "attack" with toggling a boolean on key down and key up event.
-
Hello
I write the window.SetKeyRepeatEnabled(false);
But this don't work i try to write in the Update, in the constructor of my main class, in my function OnKeyPressed and in my function for create my window but this line don't work :/
Where i write i don't find.
Thanks and sorry :/
-
Can you provide a minimal example (https://stackoverflow.com/help/mcve)?
-
Sure sorry
OnKeyPressed function
private void OnKeyPressed(object sender, KeyEventArgs e)
{
Window window = (Window)sender;
window.SetKeyRepeatEnabled(false);
if (e.Code == Keyboard.Key.A)
{
Console.WriteLine("Bou");
}
}
Update function
private void Update
(){ _window
.Closed += new EventHandler
(OnClosed
); _window
.KeyPressed += new EventHandler
<KeyEventArgs
>(OnKeyPressed
); _window
.SetFramerateLimit(60);}
The Update function is call when i do the while window.isOpen
Thanks
-
People usually put a link under "minimal example", please click and read it...
Your Update() function does stuff that should be done just once, I hope you don't call it every frame (and if you don't, then you should rename it). Also don't call SetKeyRepeatEnabled every time, do it just once.