Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › SpriteVPlay frameWidth scaling?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #8594

    Martin

    I have a spritesheet of 8 sprites that are each 28 wide by 43 pixels high.

    I am finding that I have to specify:

     

                SpriteVPlay {
                       name: "walkright"
                       source:  "../../assets/img/Ninja.png"
                       frameWidth: 7
                       frameHeight: 43
                       frameCount: 2
                       frameRate: 2
               }

     

    to get the first two sprites animated.  See how frameWidth here is 7 instead of 28.   What could be causing this?

     

    #8595

    Martin

    There’s an associated mystery, which is that when I instantiate the image of this entity in this way (using SpriteSequenceVPlay) it is getting scaled very small.   Perhaps 1/4 the size I’m expecting to see.

    When I do this:

    EntityBase {
            entityId: "theDude"
            entityType: "Ninja"
    
            SpriteSequenceVPlay {
                id: ninja_sprite
    
                SpriteVPlay {
                       name: "walkright"
                       source:  "../../assets/img/Ninjas.png"
                       frameWidth: 7
                       frameHeight: 43
                       frameCount: 2
                       frameRate: 2
                }
            }
           

    The Ninja image is tiny.

    When I do this:

    EntityBase {
            entityId: "theDude"
            entityType: "Ninja"
    
            Image {
                source: "../../assets/img/Ninja.png"
            }
    

    It’s the right size.

     

    #8624

    Martin

    I’m bumping this because it’s my most pressing issue, and also because there’s a typo in the original code posted above.

    I have found out that if I do:

        // first pair
        frameWidth: 7
        frameHeight: 11
        
        // second pair
        height: 43
        width:28

    then the ninja is animated at the correct size.

    If I comment out either pair of specifiers, it gets it wrong.   I think that the second pair should not be needed.

     

    #8626

    Christian
    Felgo Team

    Hi Martin,

    what you are experiencing is the Content Scaling and Dynamic Image Switching Support.

    Please provide your images in 3 different resolutions and put it into the default assets, +hd and +hd2 folder. You can also have a look at the Felgo demos & sprite example how it is done there.

    Cheers, Chris

    #8627

    Martin

    Thanks Chris.

     

    I have felt like I understand Content Scaling up till now.  I have been able to have my images appear at the “correct” resolution on different screens, and configure scaling etc for the effect that I want.

     

    I was hoping I didn’t have to worry about Dynamic Image Switching Support so soon.   It hasn’t affected normal images, so I thought I would get away without worrying till much later.

     

    Are you saying that for SpriteVPlay, it is mandatory?   And that since I have a high DPI screen Felgo thinks that the image is x4 size, so it scales it down?    This “makes sense” … it explains what I am seeing.    But it is not what I hoped for 🙂

     

    Can I say “please don’t do that” to Felgo?

     

    #8633

    Christian
    Felgo Team

    Hi Martin,

    yes you can disable the automatic dynamic image switching, and only provide your images in 1 reslolution.

    To do that, call

    vplay.setContentScaleAndFileSelectors(1);

    in your main.cpp file. This would only enable the sd graphics. If you want hd-only, you could change the parameter from 1 to 2.

    In one of the next Felgo updates, we will detect manually if there are sd/hd/hd2 graphics and if you don’t provide them we won’t use them internally for the Sprite.

    Cheers, Chris

    #8819

    Martin

    It seems like something changed about how this works in release 2.3.1?

    It broke my app – the code that I posted above as “working” no longer works on the phone, though it does work on the android simulator.

    To “fix” it I had to use the code Christian gave in main.cpp.

    #8823

    Christian
    Felgo Team

    Hi Martin,

    we added support that the correct image is detected automatically in Felgo 2.3.1 (see the Note in Felgo File Selectors in the new 2.3.1 doc here)- this allows that you do not need to specifiy a hd2 or hd version of every image. It is taken if it is there, but if it isn’t, the default sd image is used.

    So you do not need the

    vplay.setContentScaleAndFileSelectors(1);

    any more since 2.3.1.

    Could you post the code that does not work now, but did work before?

    Cheers, Chris

    • This reply was modified 9 years, 2 months ago by  Christian.
Viewing 8 posts - 1 through 8 (of 8 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded