Open rishavs opened 4 years ago
i think is ok to use Love.Timer.GetDelta
in KeyPressed callback .
if you want move a ball , i think the best way to do is use Keyboard.IsDown
in update phase. which just like:
class MoveBall : Scene
{
const float speed = 40;
Vector2 center = new Vector2(Graphics.GetWidth(), Graphics.GetHeight()) / 2f;
public override void Draw()
{
Graphics.Circle(DrawMode.Fill, center, 10);
}
public override void Update(float dt)
{
if (Keyboard.IsDown(KeyConstant.Left)) center.X -= dt * speed;
if (Keyboard.IsDown(KeyConstant.Right)) center.X += dt * speed;
if (Keyboard.IsDown(KeyConstant.Down)) center.Y += dt * speed;
if (Keyboard.IsDown(KeyConstant.Up)) center.Y -= dt * speed;
}
}
Keyboard.Pressed
only trigger one when you pressd your key or repate triggered in interval after you set Keyboard.SetKeyRepeat(true)
. it's not continuous.
And, if you want to join, i just create discord channel here (or email me directly if i lost your message :satisfied:) : https://discord.gg/nF9wMkK
And https://love2d.org/forums/ for offical forums
I usually have a global DeltaTime
that I set once per frame before everything else, and everything that needs a delta time simply reads this value. So I never pass a delta time in specific functions. Very simple.
the callback for love.KeyPressed takes only 3 args: key, scancode and isRepeat. It doesnt takes takes dt as an argument.
Should I use
Love.Timer.GetDelta()
in my KeyPressed callback?Also, do you have a short snippet of using isRepeat in love.KeyPressed callback? For example, I am not sure how should I use the isRepeat value to move a ball with x and y position.
Finally, is there any chat channel where the community can be active in? some of these questions are not really issues and I hope I am not polluting the repo with them.