Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 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
    Felgo 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.