I hope my question will not always be the same question. I have a QGraphicsScene. Its elements are some QGraphicsPixmaps. I move them with a timer that does SetX +10 every second. I set +10 because the window is large 100. With this solution, my animations are not smooth. I thought I could make them smoother by setting +10 +1 + 10 instead. But that didn't work.
Can you suggest me a way to do this, please? Thank you very much.
void GameGui::updateScene() { for (int y = 0; y < game->getHeight(); ++y) { for (int x = 0; x < game->getWidth(); ++x) { Actor* a = game->get(y, x); if (sceneItems[a] != 0) { sceneItems[a]->setX(x*SIZE); sceneItems[a]->setY(y*SIZE); } } } }
Each actor is my game character (in his functions, for example, moving ecc) in my main part of the program. sceneItems is a map in which I associate each actor with his pixmap. x, y are the positions in the abstract scene, and x * SIZE is the position in the graph. Positions are updated in an abstract scene, and I represent them in a graph.
source share