Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Interactive content fixed in/on view while it scrolls over scene?

Interactive content fixed in/on view while it scrolls over scene?

Scheduled Pinned Locked Moved Game Development
10 Posts 4 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m_p_wilcox
    wrote on 3 Dec 2010, 16:40 last edited by
    #1

    Hi,

    If I want to make maximum use of the screen on a mobile device then I'd like to put some buttons around the edge of my scrolling game such that they don't take out the entire width or height of the lines they're on. I assume I can put non-interactive content like the score in place by implementing QGraphicsView::drawForeground() but what about buttons I can click?

    I'm guessing that putting them in the scene and moving them at the same time as the view is going to be bad for performance (and a fairly crazy looking design). Maybe a standard QWidget (z-ordered above the QGraphicsView with raise() and a transparent background)?

    Any suggestions on the best approach?

    Thanks,
    Mark

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xsacha
      wrote on 3 Dec 2010, 17:01 last edited by
      #2

      [quote author="m_p_wilcox" date="1291394410"]I want to make maximum use of the screen on a mobile device[/quote]
      [quote author="m_p_wilcox" date="1291394410"]I'd like to put some buttons around the edge of my scrolling game[/quote]
      [quote author="m_p_wilcox" date="1291394410"]what about buttons I can click?[/quote]
      [quote author="m_p_wilcox" date="1291394410"]putting them in the scene and moving them at the same time as the view is going to be bad for performance (and a fairly crazy looking design)[/quote]

      I know you're looking at Qt C++ GUI approach, but all these issues are much easier to tackle and solved quicker by using..
      [quote author="m_p_wilcox" date="1291394410"]Any suggestions on the best approach?[/quote]
      QtQuick? Don't shoot me!

      You can still use normal Qt C++ for all the game logic and the main screen. QtQuick is just used for the UI and layout.

      • Sacha
      1 Reply Last reply
      0
      • M Offline
        M Offline
        m_p_wilcox
        wrote on 3 Dec 2010, 17:09 last edited by
        #3

        Thanks - I originally looked at doing this in QML - I don't see how it helps at all with this particular issue. Indeed the trolls that responded to my original questions suggested that QML was not yet really suited to the type of game I'm trying to write.

        Frankly if this has any chance of running well on an S60 5th Edition device I'm going to have to do everything native! (Well, maybe the intro screens could be in QML but I'd rather not make N8 users upgrade for something so trivial to do anway).

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xsacha
          wrote on 3 Dec 2010, 17:14 last edited by
          #4

          Oh, well that is the only drawback really. QML isn't available yet without including a 13MB package for N8 users. And isn't allowed on Ovi Store for anyone yet.

          However, I'm not suggesting to use QML for the whole game. Only a few lines to do the buttons/animations of the UI like you described in your post. Would make life much easier.
          The actual game can all be done inside an item in the centre, controlled entirely from the QML Wrapper (in native Qt C++).

          You can just do this in Qt C++ instead if you want (just use Objects over the top of your main scene). Especially if you need to release soon.

          • Sacha
          1 Reply Last reply
          0
          • M Offline
            M Offline
            m_p_wilcox
            wrote on 3 Dec 2010, 17:29 last edited by
            #5

            I want the buttons to overlap the rectangle of QGraphicsView that's running the game.

            bq. You can just do this in Qt C++ instead if you want (just use Objects over the top of your main scene). Especially if you need to release soon.

            When you say Objects do you mean QGraphicsObjects? How do I put them over the top of my main scene (which will be scrolling past in the view at a significant speed!) - that's really what I'm asking?

            1 Reply Last reply
            0
            • B Offline
              B Offline
              blex
              wrote on 3 Dec 2010, 18:28 last edited by
              #6

              [quote author="m_p_wilcox" date="1291394410"]Maybe a standard QWidget (z-ordered above the QGraphicsView with raise() and a transparent background)?[/quote]

              I think "Yes", it is a possible solution.

              If you need nothing more complex than click-able button then QGraphicsView::drawForeground() also works with special mouse handling.

              Definitely do not move them on scene.

              I am not sure but maybe it will be better to create your own widget class and re-implement paint() instead of using scene.


              Oleksiy Balabay

              1 Reply Last reply
              0
              • B Offline
                B Offline
                baysmith
                wrote on 4 Dec 2010, 02:25 last edited by
                #7

                Another option would be to add items to the scene with the QGraphicsItem::ItemIgnoresTransformations flag set and a z-value set to maximum.

                Nokia Certified Qt Specialist.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  blex
                  wrote on 4 Dec 2010, 05:00 last edited by
                  #8

                  [quote author="Bradley" date="1291429529"]Another option would be to add items to the scene with the QGraphicsItem::ItemIgnoresTransformations flag set and a z-value set to maximum.[/quote]

                  Maybe, I do not understand the idea, but Qt doc states something different:

                  This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately.

                  So, it will be moved with scene, but not rotated.


                  Oleksiy Balabay

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    baysmith
                    wrote on 4 Dec 2010, 05:50 last edited by
                    #9

                    Yes, if view is moved around the scene, the items positions must also be updated to hold them in a constant location in the view.

                    Nokia Certified Qt Specialist.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      blex
                      wrote on 4 Dec 2010, 05:53 last edited by
                      #10

                      [quote author="Bradley" date="1291441829"]Yes, if view is moved around the scene, the items positions must also be updated to hold them in a constant location in the view.[/quote]

                      I think it may be a performance problem. But only prototype may show does performance problem really exist.


                      Oleksiy Balabay

                      1 Reply Last reply
                      0

                      10/10

                      4 Dec 2010, 05:53

                      • Login

                      • Login or register to search.
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved