animation timings and key-repeat issues

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tperry2x
Posts: 22
Joined: Wed Apr 22, 2020 9:58 pm

animation timings and key-repeat issues

Post by tperry2x » Thu Apr 23, 2020 9:45 pm

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.

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: animation timings and key-repeat issues

Post by jiml » Wed Apr 29, 2020 12:35 am

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

tperry2x
Posts: 22
Joined: Wed Apr 22, 2020 9:58 pm

Re: animation timings and key-repeat issues

Post by tperry2x » Thu Apr 30, 2020 11:23 pm

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

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: animation timings and key-repeat issues

Post by jiml » Fri May 01, 2020 8:48 pm

Here I don't notice a slowdown of the rectangle when the oval is moving.
Mac OSX, LC 9.6.9 dp4

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: animation timings and key-repeat issues

Post by jiml » Fri May 01, 2020 10:05 pm

I mean LC 9.6.0 dp4

keliko
Posts: 85
Joined: Thu Aug 01, 2019 8:15 am

Re: animation timings and key-repeat issues

Post by keliko » Fri Aug 14, 2020 3:25 pm

I am interested in what is shown in this video. can you share the code. for me to learn. thanks

Klaus
Posts: 13793
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: animation timings and key-repeat issues

Post by Klaus » Fri Aug 14, 2020 3:31 pm

Click the link above the screenshot! 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9250
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: animation timings and key-repeat issues

Post by richmond62 » Fri Aug 14, 2020 4:58 pm

without waiting

should help a bit.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: animation timings and key-repeat issues

Post by jmburnod » Fri Aug 14, 2020 5:13 pm

Hi All,
Works fine with LC 9.6.0 stable
Jean-Marc
https://alternatic.ch

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: animation timings and key-repeat issues

Post by PaulDaMacMan » Wed Feb 17, 2021 5:53 pm

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.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: animation timings and key-repeat issues

Post by PaulDaMacMan » Wed Feb 17, 2021 6:02 pm

I just realized this thread is like like 6 months old, hah.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: animation timings and key-repeat issues

Post by FourthWorld » 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?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: animation timings and key-repeat issues

Post by PaulDaMacMan » Wed Feb 17, 2021 10:10 pm

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
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “Games”