XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
setInterval Function https://www.bbs.xwidget.com/viewtopic.php?f=10&t=2112 |
Page 1 of 1 |
Author: | vlad [ September 10th, 2012, 11:16 pm ] |
Post subject: | setInterval Function |
i can't get the function work. Could somebody show me an working example of the setInterval(name,time); function? |
Author: | qiancang [ September 11th, 2012, 3:00 am ] |
Post subject: | Re: setInterval Function |
hi , vlad setInterval function is not available in XWidget , you can use a timerCore to replace it |
Author: | vlad [ September 11th, 2012, 4:34 am ] |
Post subject: | Re: setInterval Function |
It's cool man, i had figured it out. Just use setTimeout function like this Code: // ms = 1000 / fps // 1000 / 40(fps) = 25(ms) var timeMs = 25; setTimeout("moveButton",timeMs); function moveButton() { displayAnimation(); setTimeout("moveButton",timeMs); } And i even managed to play / stop animation on click. ![]() Code: var timeMs = 25; start(); function moveButton() { if ( ! looping ) return; displayAnimation(); setTimeout("moveButton",timeMs); } function start() { if ( looping ) return; setTimeout("moveButton",timeMs); looping = true; } function stop() { if ( ! looping ) return; looping = false; } |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |