Loop Run
-
How do loop run 60FPS on qml?
-
Hi,
Pretty well when you have the right hardware.
More seriously, what exactly are you looking for ?
-
I'm looking this way
// Qml javascript
item{// init object
Component.onCompled: {
// here being a parallel thread While (runningGame) { Update () ... Sleep SPF 60 } // end while
} // end event onCompled
} // end Item
This is possible to do, do you have any example of a game in the qml that does it?
-
No, I don't have any example doing it like that and I don't think it's a good idea either.
What would you do in that loop ?
-
Update all objects
-
@Everton-Fonseca
But any object will update/draw itself is its state changes? -
That same design change status, how do I do that?
-
It sounds like you are thinking in the traditional way (the way people think of real time operating systems).
QML wasn't designed with this idea in mind. It goes design and objects first. The framework will then get you the FPS your hardware can handle (probably 60, or whatever your graphics card usually outputs to your monitor).
Of course QML provides timers, but they also work automatically, you do not need to "sleep" them. -
thanks = D
-
i'm using timer for updating game state
30 mks give 33FPS and this working on mobileTimer { id: tMain; interval: 30; running: false; repeat: true onTriggered: { var diff = Qt.core.move(); if (diff > 0) { CTL.checkGameState(diff); } } }
my game with main loop in timer
https://play.google.com/store/apps/details?id=net.is.games.CatchTheGhost -
well very good, thanks = D brother
-
@Everton-Fonseca
I would suggest moving your main game loop from qml to C++ code. It's only my suggestion.
I think you've already checked this but one more time here is good explanation how you can get 60 FPS.
Use Qt Quick module only for rendering. Ideally logic should be written in C++ IMHO. -
From my experience, QML timer is all but accurate betwen plataforms.
I have experienced significant speed diferencies between linux and windows, wich makes the game characters move with very diferent speeds on diferent plataforms. This can be a problem and make the game unplayable.Iinitially I tought that Timer was just a QTimer exposed to QML, but has AFAIK thet are not related at all.
QTimer seems to provide a much better accuracy, so what I did was to created a new c++ class that uses QTimer, and expose it to QML. In the end, I got a MyTimer qml entity with similar Timer sintaxe, but with much better results.