Forums

OverviewV-Play 1 SupportShow only a section of a level › Reply To: Show only a section of a level

OverviewV-Play 1 SupportShow only a section of a level › Reply To: Show only a section of a level
#4322

Christian
V-Play Team

Hi,

the easiest way to do this, is by moving the Level inside the scene. The level would be of a bigger size and is a child of the Scene, and it contains all game entities. By moving the Level then, you adjust the visible portion of the Scene. This is the same approach we are using for our Chicken Outbreak demo, where we move the level endlessly to the top, which has the visual effect of all objects going down. You can test that with the following example code:

GameWindow {
    Scene {
      width: 480
      height: 320
       
      Level {
        // make the Level any size, only the 480x320 section will be visible though
        width: 4000
        height: 3000
        
        Rectangle {
          width: 50; height: 30
        }
        
        Rectangle {
          x: 300
          width: 50; height: 30
        }
        
        Rectangle {
          x: 600
          width: 50; height: 30
        }
        
        // this will move the level from its original x position 0 to -800, which will have the effect of the Rectangles moving right
        // instead of this NumberAnimation, you can set the position of your level to whatever you want your visible part to be
        NumberAnimation on x {
          from: 0
          to: -800
          duration: 3000          
        }
        
      }// Level
    }// Scene
  }// GameWindow

 

The Level item is just a normal QML Item element, but if you design multiple levels you will probably put that file into an own qml file and name it Level01, Level02, etc.

Cheers, Chris

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