QTimer and QThread?
-
What different between QTimer and QThread?
When we use QTimer instead of QThread?I made a shooting game and i have a class bullet.
each bullet is a pointer . It changes position every 2s.(I used QTimer for it)
a player shot lots of bullets so my game got lagging so much.
Is that caused by Timer variables?
any ideas to solve this issue?
Thanks alot! -
What different between QTimer and QThread?
When we use QTimer instead of QThread?I made a shooting game and i have a class bullet.
each bullet is a pointer . It changes position every 2s.(I used QTimer for it)
a player shot lots of bullets so my game got lagging so much.
Is that caused by Timer variables?
any ideas to solve this issue?
Thanks alot!@CongVo
short:
A timer fires every interval and executes some code (all executed on the same thread).
A separate thread supports "concurrent" execution.So actually they have nothing in common.
-
What different between QTimer and QThread?
When we use QTimer instead of QThread?I made a shooting game and i have a class bullet.
each bullet is a pointer . It changes position every 2s.(I used QTimer for it)
a player shot lots of bullets so my game got lagging so much.
Is that caused by Timer variables?
any ideas to solve this issue?
Thanks alot!@CongVo Do you use one timer for each bullet or one for all? Without knowing your implementation it is not possible to say why it is slow with many bullets. But I doubt using more threads will solve it as it looks more like an inefficient implementation. It should be enough to use one timer for all bullets.
-
If you want to use threads, I am sure there are elements of your graphics display which are not dependent on the states of the bullets. You could move that to its own thread, so that the updating of the bullet states does not adversely affect your ability to update your graphics. If there is a delay, it should only be on updating the bullets themselves