Forums

OverviewV-Play 2 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
    V-Play 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 V-Play 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 V-Play 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 V-Play?

     

    #8633

    Christian
    V-Play 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 V-Play 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
    V-Play Team

    Hi Martin,

    we added support that the correct image is detected automatically in V-Play 2.3.1 (see the Note in V-Play 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 3 years, 9 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.

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