Hello and welcome to my first ever post on here! Defold is a very clean machine and I look forward to learning it after I master Lua and Love2d. Although master is a strong word, I do intend to use frameworks as ‘ankle weights’ so to speak.
I am a little pedantic about something that I can fix in most other engines and frameworks I’ve tried, and I am confident that there is a quick fix to my issue.
The movement code that this site provides works as is, however I am concerned about when I press left and right at the same time. The behavior is not symmetrical, pressing left and right at the same time makes the character jerk around a bit, and it’ll just straight up ignore the other key being pressed but not the other way around.
Whereas in a framework like Love2d, it can be fixed to where if you press left and right at the same time the player will just stop and maintain the direction of the first key pressed, no extra variables.
This asymmetrical type of glitch, if I can call it that, does not break the game for most, but it does however, mildly irks me because I cannot fix this in the same way as I can on Love2d.
if love.keyboard.isDown(“left”) and not love.keyboard.isDown(“right”) then
(Movement code)
end
If I use the ‘and’ and ‘not’ logical operators in Defold for its movement code, the player ceases to move at all, or they only go in one direction not the other depending on how I try to tweak it.
If action_id == hash(“left”) and not action_id == hash(“right”) then
(Movement code)
I’ve tried this variant and a few others, at one point I accidentally made the main spaceman character from the tutorial sink into the earth! Poor guy
Thank you for your time, I apologize on my formatting I am doing this from mobile and not sure how to put that code in a code format for better viewing.