Page 1 of 1

animation timings and key-repeat issues

Posted: Thu Apr 23, 2020 9:45 pm
by tperry2x
Hi everyone.
Having a few real issues with animation speeds not being consistent across different platforms.
For example:
https://www.tsites.co.uk/downloads/anim ... prites.mp4
This seems to run fine and is a simple load of PNGs being loaded into a button, while the button is being moved across the card.
This is the same on both platforms (ignore the audio test button in the screenshot). The reason it's the same is because it uses no keyboard input for movement.

https://www.tsites.co.uk/downloads/anim ... vement.mp4
This shows a comparison between OSX and Windows when not only are pngs loaded in as sprites, but when the horizontal and vertical movement is changed dynamically. Windows does it almost instantly - the animation is too fast. OSX is a bit too laggy with the png frames and the movement sideways.

https://www.tsites.co.uk/downloads/anim ... c-test.mp4
Again, here you can see how fast the animation plays in Windows, and notice after the figure starts moving on Windows it stops because I have no native way I can figure out to control the key repeat rate.

https://www.tsites.co.uk/downloads/anim ... xample.mp4
You can see how much of an effect key repeat rate can be, so how is this controlled in Livecode and set back. Is there a 'get' and 'set' option?

Unfortunately, the more I try to use Livecode for games, the more it feels like it's fighting me every step of the way and being made to do something it really doesn't want to do in the first place. I do feel that there needs to be big improvements made on this front.

Re: animation timings and key-repeat issues

Posted: Wed Apr 29, 2020 12:35 am
by jiml
Perhaps instead of depending on the machine's rate of key events, you might base the animation rate on time.
Maybe use keydown simply to start the animation, which would be handled in the script of the object you are animating.

on keyDown theKey
switch theKey
case "A"
send "animateLeft" to control "animatedFigure"
break
case "D"
send "animateRight" to control "animatedFigure"
break
default
pass keyDown
end switch
end keyDown

Then put "animateLeft" and "animateRight" handlers in the script of control "animatedFigure".
Use send in time to advance to the next 'frame' of the animation.

Use keyUp to send "stopAnimation" to control "animatedFigure"

Jim Lambert

Re: animation timings and key-repeat issues

Posted: Thu Apr 30, 2020 11:23 pm
by tperry2x
Hmmm, I think I know what you mean.
I've found that when I move the red dot with A and D keys, it drastically slows down any animations currently looping (the green square).
Can you see what I'm doing wrong?

https://www.tsites.co.uk/downloads/key- ... vecode.zip
Image

Re: animation timings and key-repeat issues

Posted: Fri May 01, 2020 8:48 pm
by jiml
Here I don't notice a slowdown of the rectangle when the oval is moving.
Mac OSX, LC 9.6.9 dp4

Re: animation timings and key-repeat issues

Posted: Fri May 01, 2020 10:05 pm
by jiml
I mean LC 9.6.0 dp4

Re: animation timings and key-repeat issues

Posted: Fri Aug 14, 2020 3:25 pm
by keliko
I am interested in what is shown in this video. can you share the code. for me to learn. thanks

Re: animation timings and key-repeat issues

Posted: Fri Aug 14, 2020 3:31 pm
by Klaus
Click the link above the screenshot! 8)

Re: animation timings and key-repeat issues

Posted: Fri Aug 14, 2020 4:58 pm
by richmond62
without waiting

should help a bit.

Re: animation timings and key-repeat issues

Posted: Fri Aug 14, 2020 5:13 pm
by jmburnod
Hi All,
Works fine with LC 9.6.0 stable
Jean-Marc

Re: animation timings and key-repeat issues

Posted: Wed Feb 17, 2021 5:53 pm
by PaulDaMacMan
You cannot set the key repeat rate from LiveCode. I know on macOS this is a system level user setting. I'm not sure that this would even be possible to do this with an external or extension.

You could try using lock messages, flushEvents["autoKey"] and flushEvents["keyDown"] in your animation handler.

Probably the best thing to do is use the on keyDown (or on rawKeyDown) message to start a "send doMyStuff to me in tTimerLength milliseconds" style loop. In that doMyStuff loop you store the key or keyCode that was pressed in a myKeysThatAreDown variable list or array, and you can check the contents of that variable to see if one (or more) of the keys you were looking for are currently down. You would then use the on keyUp (or on rawKeyUp) message you remove any key that is released from your myKeysThatAreDown variable list or array.
I've used this technique a lot. I recommend using an array (a bit faster than using a comma delimited list) to store the keys down information. Also if you're using rawKey key-codes in a comma-delimited text list, make sure that you 'set the wholeMatches to true' so that you don't get any false positives.

Re: animation timings and key-repeat issues

Posted: Wed Feb 17, 2021 6:02 pm
by PaulDaMacMan
I just realized this thread is like like 6 months old, hah.

Re: animation timings and key-repeat issues

Posted: Wed Feb 17, 2021 6:40 pm
by FourthWorld
PaulDaMacMan wrote:
Wed Feb 17, 2021 6:02 pm
I just realized this thread is like like 6 months old, hah.
How did you find this thread?

Re: animation timings and key-repeat issues

Posted: Wed Feb 17, 2021 10:10 pm
by PaulDaMacMan
FourthWorld wrote:
Wed Feb 17, 2021 6:40 pm
PaulDaMacMan wrote:
Wed Feb 17, 2021 6:02 pm
I just realized this thread is like like 6 months old, hah.
How did you find this thread?
I was just looking though the "last post" column on the right-hand side of each sub-forum listing