Forums

OverviewV-Play 1 Support › MultiResolutionImage issue (maybe)

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

    Michael

    Hi

    I have a bunch of SimpleButtons that I’m converting over to MultiResolutionImage buttons. With the SimpleButtons, I had some logic to change the colour of the button (if the button was a vowel it would change the colour to distinguish from a consonant). It worked well. However when converting the code to use my button based on MIR, it’s not working, and I can’t see why.

    Here’s the part that changes the colour (for the case of SimpleButton) & how I’m doing it by swapping an image of one colour for another of a different colour.

    //SimpleButton { id: btnLetter1; width: 50; height: 50; color: LetterLogic.ifVowel(text) ? "#65A8DB" : "#C9A582"; onClicked: postpendLetter(text) }
    MyButton { id: btnLetter1; buttonName: LetterLogic.ifVowel(text) ? "btnVowel" : "btnConsonant"; onClicked: postpendLetter(text) }

    Here’s the MyButton qml

    import QtQuick 1.1
    import VPlay 1.0
    
    Item {
        id: button
    
        width: btnUpImg.width
        height: btnUpImg.height
    
        property alias text: buttonText.text
        property alias textColor: buttonText.color
        property alias textSize: buttonText.font.pixelSize
        property string buttonName
    
        signal clicked
    
        MultiResolutionImage {
          id: btnUpImg
          source: "img/" + buttonName + "-up.png"
          anchors.centerIn: parent
          visible: !ma.pressed
        }
    
        MultiResolutionImage {
          id: btnDownImg
          source: "img/" + buttonName + "-down.png"
          anchors.centerIn: parent
          visible: ma.pressed
        }
    
        Text {
            id: buttonText
            anchors.centerIn: btnUpImg
            font.pixelSize: 14
            color: "white"
        }
    
        MouseArea {
            id: ma
            anchors.fill: btnUpImg
            onClicked: button.clicked()
        }
    }

    My JS tester function worked well in the SimpleButton case to change the colour dynamically, but this same logic is failing to achieve the same outcome in the MIR image case. BTW this is why I asked before if tinting was working, as if it was, I may be able to apply the same SimpleButton colour-changing concept to the image version.

    This issue is kinda driving me crazy, so any tips are gratefully welcome. I’m kinda guessing the source: in MIR can’t be updated after it’s established, like a color can be for SimpleButton.

    Thanks.

    Cheers, Michael.

    #6353

    Christian
    V-Play Team

    Hi Michael,

    you are right, a MRI cannot change its source once established, and tinting is not supported currently.

    One workaround would be to create one MRI for each color you need, and then use the state property to make the correctly-colored MRI visible.

    Would this work for your game?

    Cheers, Chris

    #6356

    Michael

    Thanks Chris for your suggestion, I think it will work. I will look-up how to do it.

    Cheers, Michael.

    #6359

    Michael

    Thanks Chris, your idea of visibility solved the issue, and I could set that via a property, which was a bit more convenient than states.

    I suppose in the future, it would be really nice to have “source:” as updateable in MRI in the future. That is, when the source is changed, the image is reloaded/reevaluated for scale.

    Cheers, Michael.

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