Results 1 to 4 of 4

Thread: Had a Conceptual doubts on QGraphicsItemAnimation ?

  1. #1
    Join Date
    Apr 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Post Had a Conceptual doubts on QGraphicsItemAnimation ?

    Hi,

    I am implementing a small game. I am using QGraphicsItemAnimation class for this. I had a background for the game as a qgraphicsitem and a plane which is also a qgraphicsitem is moving slowly on it.
    My requirement is that :

    If i mouse press on the plane its speed should increase for example double of previous speed and i do something on this. And I had to repeat this for 10 times. So I am keeping my loop count as 10.

    On Start of the every loop the plane should move slowly from left to right. It will move fast only when mouse is pressed on it else it moves with a normal speed.

    I am able to move the plane with a normal speed for 10 times. But when I change the speed it on mouse pressed it moves fast for first mouse press ... Its behavior is non recognizable.

    I am changing the speed by changing the time duration of the QTimeLine on the mouse pressed event to 2 secs.
    Time duration for normal speed is 8 sec.

    I have connected the framechange(int ) signal to slotFrameChanged(int) of object of the QTimeLine. There I am checking The end of the frame for each Loop. I had kept 72 frames for each loop. I always compare frame count in this slot to 72. If it is 72 I change the Time Duration back to 8 secs.

    But This is not working...

    If anyone can help ...
    Please help.

    Thanks & Regards
    PunitK

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Had a Conceptual doubts on QGraphicsItemAnimation ?

    I would rather use QTimer and QGraphicsScene::advance() than QGraphicsItemAnimation for this particular purpose. You will need some kind of a game loop anyway.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2010
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Had a Conceptual doubts on QGraphicsItemAnimation ?

    As I mention that My Background for the game is QGraphicsItem that is game is designed on QGraphicsItem , so that it can move on the scene and there is no any alternation on the game running on it. Is it Possible to use QTimer and QGraphicsScene::advance.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Had a Conceptual doubts on QGraphicsItemAnimation ?

    Quote Originally Posted by punitk View Post
    As I mention that My Background for the game is QGraphicsItem that is game is designed on QGraphicsItem , so that it can move on the scene and there is no any alternation on the game running on it.
    I have no idea what this sentence means.
    Is it Possible to use QTimer and QGraphicsScene::advance.
    If the method is there then obviously you can use it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Conceptual Question; QLabel as Banner?
    By SneakyPeterson in forum Newbie
    Replies: 5
    Last Post: 28th June 2010, 09:18
  2. Conceptual MVC problem in Qt
    By Daniel Dekkers in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2010, 17:26
  3. doubts regarding QT
    By sudheer168 in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2009, 10:02
  4. some doubts qtablewidget
    By mmm286 in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2009, 21:36
  5. QGraphicsItemAnimation and QTimeLine
    By babu198649 in forum Newbie
    Replies: 13
    Last Post: 31st December 2007, 12:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.