Results 1 to 5 of 5

Thread: Display several AnimatedSprite at different speed?

  1. #1
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Display several AnimatedSprite at different speed?

    Hi,

    I have 3 different AnimatedSprite that I want to display, in parallel, at different "speeds".

    title
    testA
    testB

    Here is the behavior I try to obtain:

    title is set on "pause" and display only the first sprite

    testA loops once > when loop is finished:
    - change testA opacity to 0
    - display title NEXT frame
    - change testB opacity to 1
    testB loops once > when loop is finished:
    - change testB opacity to 0
    - display title NEXT frame
    - change testA opacity to 1

    It seems fairly simple but I can't do it, my QT / coding experience is non-existent even though I did a lot of scripting and macros work.



    Qt Code:
    1. AnimatedSprite {
    2. id: title
    3.  
    4. z: 5
    5.  
    6. running: true
    7. paused: true
    8. opacity: 1
    9.  
    10. width: 300
    11. height: 10
    12.  
    13. x: 100
    14. y: 100
    15.  
    16. source: "qrc:/images/Titles/Y_titles___board___118-59___522-77.png"
    17.  
    18. frameCount: 2
    19.  
    20. frameWidth: 300
    21. frameHeight: 10
    22.  
    23. frameDuration: 1000
    24. interpolate: false
    25. }
    26.  
    27. AnimatedSprite {
    28. id: testA
    29.  
    30. z: 5
    31.  
    32. running: true
    33.  
    34. width: 10
    35. height: 10
    36.  
    37. x: 100
    38. y: 110
    39.  
    40. source: "qrc:/images/Titles/Y_titles___board___118-59___522-77.png"
    41.  
    42. frameCount: 50
    43.  
    44. frameWidth: 10
    45. frameHeight: 10
    46.  
    47. frameDuration: 1000
    48. interpolate: false
    49. }
    50.  
    51. AnimatedSprite {
    52. id: testA
    53.  
    54. z: 5
    55.  
    56. running: true
    57.  
    58. width: 10
    59. height: 10
    60.  
    61. x: 100
    62. y: 110
    63.  
    64. source: "qrc:/images/Titles/Y_titles___board___118-59___522-77.png"
    65.  
    66. frameCount: 50
    67.  
    68. frameWidth: 10
    69. frameHeight: 10
    70.  
    71. frameDuration: 1000
    72. interpolate: false
    73. }
    To copy to clipboard, switch view to plain text mode 



    Cheers,
    --Jay

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Display several AnimatedSprite at different speed?

    I guess you could try using states on the parent element

    Qt Code:
    1. Item {
    2. AnimatedSprite {
    3. id: title
    4. }
    5. AnimatedSprite {
    6. id: testA
    7.  
    8. onRunningChanged: if (!running) parent.state = "END1"
    9. }
    10. AnimatedSprite {
    11. id: testB
    12.  
    13. onRunningChanged: if (!running) parent.state = "END2"
    14. }
    15.  
    16. state: "START"
    17.  
    18. states: [
    19. State {
    20. name: "START"
    21.  
    22. PropertyChanges { target: title; currentFrame: 0 }
    23. PropertyChanges { target: testA; running: true; opacity: 1 }
    24. PropertyChanges { target: testB; running: false; opacity: 0 }
    25. },
    26.  
    27. State {
    28. name: "END1"
    29.  
    30. PropertyChanges { target: title; currentFrame: 1 }
    31. PropertyChanges { target: testA; running: false; opacity: 0 }
    32. PropertyChanges { target: testB; running: true; opacity: 1 }
    33. },
    34.  
    35. State {
    36. name: "END2"
    37.  
    38. PropertyChanges { target: title; currentFrame: 2 }
    39. PropertyChanges { target: testA; running: false; opacity: 1 }
    40. PropertyChanges { target: testB; running: false; opacity: 0 }
    41. }
    42. ]
    43. }
    To copy to clipboard, switch view to plain text mode 


    Cheers,
    _

  3. #3
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Display several AnimatedSprite at different speed?

    Cheers again for help.

    Here is the error I get:
    "QML StateGroup: Can't apply a state change as part of a state definition."

    I tried to apply the code you wrote to mine.
    Then I just copy/pasted it raw.

    In both cases I get the same error : /.


    this is the ressources I found on the subject:

    1)
    "No part of a state definition should trigger an additional state change (for that particular stategroup),
    as the state machine can't handle changing from one state to another until it has completely entered the
    first state. You might be able to get some useful debug information using the environmental variable
    STATECHANGE_DEBUG (set to 1) -- it should be able to at least tell you the second state that is being triggered.

    Regards,
    Michael"

    2)
    "This happens when you try to set a state in an element that is already
    changing its state."

    However even if I understand what it means, my experience is too weak to solve the issue


    Yours,
    --Jay

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Display several AnimatedSprite at different speed?

    Hmm, try this:

    remove the properties, that are set by the PropertyChanges line, from the element definitions.
    I.e none of the AnimatiedSprite elements should have a opacity or running line.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    JaySDC (15th September 2015)

  6. #5
    Join Date
    Sep 2015
    Posts
    32
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Display several AnimatedSprite at different speed?

    Hi,

    Quick word to let you know that a friend of mine helped me use your solution with PropertyChanges and everything works now!


    Thanks again for the great help : D

    --Jay

Similar Threads

  1. How to speed up the Qt GUI apps launch speed?
    By wshn13 in forum Qt Programming
    Replies: 3
    Last Post: 14th March 2012, 08:37
  2. speed of the gif
    By KillGabio in forum Newbie
    Replies: 2
    Last Post: 12th February 2012, 23:41
  3. Different speed when debug
    By SteM in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th June 2011, 09:53
  4. Speed Up TreeView
    By abbapatris in forum Qt Programming
    Replies: 6
    Last Post: 14th June 2010, 19:42
  5. QScrollBar + setToolTip speed on display ... to slow
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 26th February 2007, 13:27

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.