Warning, /education/gcompris/external/qml-box2d/examples/movingBox/movingBox.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.0
0002 import Box2D 2.0
0003 import "../shared"
0004 
0005 Item {
0006     id: screen
0007     width: 800
0008     height: 600
0009     focus: true
0010 
0011     Keys.onPressed: {
0012         if (event.key === Qt.Key_Left) {
0013             movableBox.moveBackward();
0014         }
0015         else if (event.key === Qt.Key_Right) {
0016             movableBox.moveForward();
0017         }
0018         else if (event.key === Qt.Key_Up) {
0019             movableBox.jump();
0020         }
0021     }
0022 
0023     Keys.onReleased: {
0024         if (event.isAutoRepeat)
0025             return ;
0026 
0027         if (event.key === Qt.Key_Left ||
0028             event.key === Qt.Key_Right) {
0029             movableBox.stopMoving();
0030         }
0031     }
0032 
0033     World { id: physicsWorld; }
0034 
0035     Repeater {
0036         model: 4
0037         delegate: WoodenBox {
0038             x: Math.random() * (screen.width - 100);
0039             y: Math.random() * (screen.height / 3);
0040             rotation: Math.random() * 90;
0041         }
0042     }
0043 
0044     MovableBox {
0045         id: movableBox
0046         width: 40
0047         height: width
0048     }
0049 
0050     ScreenBoundaries {}
0051 }