PDA

View Full Version : Right approach for moving animated objects



AndyQT
3rd November 2012, 12:59
Hi everybody!

I am working on my first QT project in my free time. I want to create a simple game. I would like to have a static image as the background and I want to let objects appear on the screen from different sides of the window, the objects would move around and the user has to click all of them.

So far I got this to work with QGraphicsScene and QGraphicsView. At this moment the moving objects are simple PNG images. Now I want to switch the PNG images to something more spectacular like GIF animations or even better would be some video loops. However, now I wonder if I have chosen the wrong base to build on, as for example QMovie I can only use through QLabel and QGraphicsProxyWidget. Anyway, although I got the animated GIF to run this way, it's a mess to handle the transparency of the animated GIF's background, as one has to set mask and update the picture for every frame of the animation.

Now I wonder, what would be the "state of the art" way to get photorealistic objects move around the screen in QT(for example let a video recorded dog run across the screen), yet I need to be able to track mouse clicks on every object. I even don't know if there is something like transparency in video files...

I hope you could catch the idea and someone could enlighten me.

Andy

alizadeh91
3rd November 2012, 13:58
Can you use qml?? it has better performance for game and easier. Especially if use QT5, because it renders with openGL

AndyQT
3rd November 2012, 16:00
Thanks for your suggestion. In fact, I am not restricted by anything, except by myself. I have never before heard about QML(in fact QT Creator offers a project template, I never thought about what it was), I will have a look into it.
Just for information, my plan is to have a program running on a Windows PC.

AndyQT
6th November 2012, 07:18
Please, someone! What would be the best approach to let running video objects fly around the screen? Give me at least some Qt classnames to look at.

wagmare
6th November 2012, 07:34
small suggestion ..
what about QPropertyAnimation on Graphicsitem ..? will it be useful ..

check animation/easing example ..

AndyQT
6th November 2012, 09:39
Thank you for this hint. The QPropertyAnimation class might help and thanks to you I just looked up Google for a QGraphicsItem video, which I somehow did not even consider before(looked for something more specific) and found the example multimedia/videographicsitem. Haveing a look at it, I think the example has the key to my needs, although it seems like videos there are getting handeled on a frame by frame basis.

Yet, I wonder if this is the way to go to get good performance. I remember a QT example which shows a comparison of Qt to Qt with OpenGL, which somehow happen to look much better in Qt, whereas OpenGL seems to be the higher performance choice.