Warning, /education/gcompris/external/qml-box2d/examples/movingBox/MovableBox.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 PhysicsItem { 0006 id: box 0007 0008 sleepingAllowed: false 0009 bullet: true 0010 fixedRotation: true 0011 bodyType: Body.Dynamic 0012 0013 function moveForward() { 0014 body.linearVelocity.x = 10; 0015 } 0016 0017 function moveBackward() { 0018 body.linearVelocity.x = -10; 0019 } 0020 0021 function stopMoving() { 0022 body.linearVelocity.x = 0; 0023 } 0024 0025 function jump() { 0026 var impulse = Qt.point(0, -10); 0027 body.applyLinearImpulse(impulse, body.getWorldCenter()); 0028 } 0029 0030 fixtures: Box { 0031 width: box.width 0032 height: box.height 0033 0034 density: 1 0035 friction: 0.3 0036 restitution: 0.2 0037 groupIndex: 1 0038 } 0039 0040 Rectangle { 0041 anchors.fill: parent 0042 color: "red" 0043 } 0044 }