Forums

OverviewV-Play 2 Support (Qt 5)How to set the scale for sprites in sequence › Reply To: How to set the scale for sprites in sequence

OverviewV-Play 2 Support (Qt 5)How to set the scale for sprites in sequence › Reply To: How to set the scale for sprites in sequence
#9640

Günther
V-Play Team

Hi, I tried your example and fixed it this way:
– The Flow component is responsible for the positioning of the elements in your code, so it is required that the actual width and height can be accessed. It seems the scale-property tampers with the calculations and the elements then get wrong positions.

A specific width and height for the delegate (Sprite Sequence) should fix that problem:

import VPlay 2.0
import QtQuick 2.0     

 Flow {
        anchors.fill: parent
        anchors.margins: 1
        spacing: 4

        Repeater {
          id: treesRepeater
          model: 0
          delegate: SpriteSequenceVPlay {
            width: 1024 * 0.1
            height: 512 * 0.1

            SpriteVPlay {
              source: "../assets/img/Tree.png"
              frameCount: 4
              frameWidth: 1024
              frameHeight: 512
              frameRate: 4
            }
          }
        }
      }

 

As for the image: If the Sprite image is set up correctly, the animation should work fine. In your case, the image “Tree.png” should be 4096 x 512 px.
All the frames of the animation should have the same width and should be aligned next to each other within the image. If you use four frames, they should each use 1/4 of the total width = 1024 px.

 

Hope this helps you!

Best,
GT

 

 

 

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