Forums

OverviewV-Play 1 SupportRepeating background › Reply To: Repeating background

OverviewV-Play 1 SupportRepeating background › Reply To: Repeating background
#5947

Alex
V-Play Team

Hi Chrisu,

the correct way of using clip in this case would be applying it to the Item, unfortunately this is not fully supported at the moment.

A workaround that comes to my mind would be this:

    Item {
      id: item
      property int rows : 1
      property int cols : 1
      property string imgSource
      property double tileWidth: width/cols
      property double tileHeight: height/rows

      Repeater {

        id: repeater
        model: item.rows * item.cols

        Image {
          property int col: index % item.cols
          property int row: Math.floor(index / item.cols)
          x: item.tileWidth * col
          y: item.tileHeight * row
          width: item.tileWidth//col < repeater.cols - 1 ? item.tileWidth : (item.width % item.tileWidth)
          height: item.tileHeight//row < repeater.rows - 1 ? item.tileHeight : (item.height % item.tileHeight)
          source: item.imgSource
          z: -1
        }
      }
    }

This is of course not fully flexible, as you will have to determine the number of rows and cols yourself, and maybe it will stretch/collapse your tiles. But if this is no problem, maybe it’s good enough for your use case?

Cheers,
Alex

 

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