Forums

OverviewV-Play 1 Support › MultiResolutionImage: up/down button art problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6264

    Michael

    Hi

    I’m experimenting & learning the basics. I am trying the following code to swap the up button art with down button art. The following 2 sections show a method with MultiResolutionImage which doesn’t alternate the art (shows only up art regardless of press) but using Image works. What did I do wrong? I suppose I should use a sprite sheet, so maybe that might work better in my case.

            MultiResolutionImage {
                source: ma.pressed ? "btn/buttondown.png" : "btn/buttonup.png"
                anchors.centerIn: parent
    
                Text {
                    text: "Test MIR"
                    font.pointSize: 14
                    anchors.centerIn: parent
                }
    
                MouseArea {
                    id: ma
                    anchors.fill: parent
                    onClicked: console.log("MIR button was clicked")
                }
            }
    
            Image {
                source: ma2.pressed ? "btn/buttondown-sd.png" : "btn/buttonup-sd.png"
                anchors.bottom: parent.bottom
    
                Text {
                    text: "Test Img"
                    font.pointSize: 14
                    anchors.centerIn: parent
                }
    
                MouseArea {
                    id: ma2
                    anchors.fill: parent
                    onClicked: console.log("Regular button was clicked")
                }
            }

    Cheers,

    Michael.

    #6265

    David

    Hi Michael,

    currently it is not possible to exchange the source of the MultiResolutionImage. The best solution would be to use a MultiResolutionImage for each image and set them visible/invisible according to your needs.

    Cheers,

    David

    #6266

    Michael

    Thanks David. I think it’s a worthwhile addition (future update) to MultiResolutionImage to make this kind of art swapping an easy implementation & consistent with what’s possible with Image.

    Cheers,

    Michael.

    #6270

    Christian
    V-Play Team

    Hi Michael,

    you are right. However, I would suggest not using MultiResolutionImage in any live game, but instead use SingleSpriteFromFile as it has a better performance because only a single draw call is needed because a sprite sheet is used. Also, switching sources for SingleSpriteFromFile components is fully supported.

    Cheers, Chris

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support