OverviewV-Play 1 SupportAnchor wall to bottom of screen not working. › Reply To: Anchor wall to bottom of screen not working.

OverviewV-Play 1 SupportAnchor wall to bottom of screen not working. › Reply To: Anchor wall to bottom of screen not working.

V-Play Team

Hi Edi,

here is the code that solves your problem and I added an explanation of the exact issue below it:

import VPlay 1.0
import QtQuick 1.1

GameWindow {

  activeScene: scene

  width: 640/2
  height: 1136/2

  EntityManager {
    id: entityManager
    entityContainer: scene.entityContainer //!!!

  Scene {

    id: scene
    width: 320
    height: 480

    PhysicsWorld {
      id: physicsWorld
      z: 10
      updatesPerSecondForPhysics: 60
      gravity.y: -10
      velocityIterations: 5
      positionIterations: 5
      anchors.fill: entityContainer //!!!

    property alias entityContainer: entityContainer
    Item {
      id: entityContainer
      anchors.fill: scene.gameWindowAnchorItem //!!!

      Rectangle {

        id: loader
        anchors.fill: parent


          id: level
          color: "lightblue"
          anchors.fill: parent


            id: ground
            height: 20

              left: parent.left
              right: parent.right
              bottom: parent.bottom

            Rectangle {
              anchors.fill: parent
              color: "orange"

            BoxCollider {
              bodyType: Body.Static




        x: scene.gameWindowAnchorItem.width/2
        y: scene.gameWindowAnchorItem.height/2

        Rectangle {
          width: 40
          height: 40
          x: -width/2
          y: -height/2
          color: "red"

          id: collider
          radius: 20
          bodyType: Body.Dynamic
          restitution: 1

The problem is that you are using 2 different container items with 2 different coordinate systems where you put your colliders (entities) into.

First you are having the scene where you put your ball in. This scene is centered in the screen by default, meaning it’s 0|0 origin is also not always the left upper edge of the screen. Your PhysicsWorld is also put into that scene, so the 0|0 origin is the same like the one of the scene.

Your second container is your level, which has the same size as the gameWindowAnchorItem (the whole screen), so it’s 0|0 origin is always the top left corner of the screen.

Now imagine the screen is e.g. 320 x 580 pixel. Your scene is 320 x 480 pixel. The screen is 100 pixels higher than the scene, therefore the scene is put 50 pixel below the top of the screen to be centered. Then you put your ball into the scene at e.g. x:100 and y:100. It will be put 100 pixel right and 100 pixels below the 0|0 origin of both the scene and the PhysicsWorld, because they share the same origin.
Then you place your ground wall, which is 20 pixels high, on the bottom of your level which is 580 pixels high. This means you give the ground wall a y value of 560 pixels. BUT since the origin of the PhysicsWorld is not the upper left corner but 50 pixels below it, the ground wall collider is effectively placed at 560 + 50 pixels, resulting in being outside of the screen.

So the solution is to give all your entities and the PhysicsWorld a container that they share, so they all use the same coordinate system.

I hope this explanation is comprehensible, let me know if you have any further questions!


  • This reply was modified 4 years, 4 months ago by  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
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support