I have an application written in QT that uses QTimer. This is basically a game, and all actions are controlled by a timer. The game includes the ability to increase / decrease the speed of the game. Code to increase speed:
timerValue -= speedUpValue; if (timerValue < maxSpeed) { timerValue = maxSpeed; } timer -> setInterval(timerValue);
speedUpValueand maxSpeedare constants. Almost the same code is used to reduce speed. The problem is that it setIntervalresets the internal timer, and therefore, if you constantly increase or decrease the speed, the game will never continue as a result, because the remainingTimereset is constantly on. Is there a way to set remainingTimemanually or change the interval without restarting it?
speedUpValue
maxSpeed
setInterval
remainingTime
QTimer::singleShot(...) timerValue. , timerValue, .
QTimer::singleShot(...)
timerValue
RA, , , setInterval() , , , , - .
setInterval()
, , , . , , , , , .
, , . , , . , , , , , , , .
Source: https://habr.com/ru/post/1610056/More articles:tableview, change tvos focus font color - objective-cHaskell `Data.Vector.Mutable.unsafeNew` zero memory? - vectorError while working with image from gcr.io - google-container-engineHow to use php commands, compiler, artisan ... (Laravel) manually - phpRestructuring CSV data with Notepad ++, Regex - regexsqlalchemy: displaying a schema for finding / using a custom type for all instances - pythonQt4: unresolved timer events - eventsAutoIt (AutoItX) on C # Windows 7 App System.DllNotFoundException - c #How to find common rows between two data frames in R? - rНе удается сохранить обработанное изображение отпечатка пальца с помощью VeriFinger - c++All Articles