Warning, /education/gcompris/external/qml-box2d/examples/motorjoint/boat.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.2 0002 import Box2D 2.0 0003 import "../shared" 0004 0005 Rectangle { 0006 width: 800 0007 height: 600 0008 0009 World { 0010 id: physicsWorld 0011 0012 onStepped: { 0013 joint.step += 0.2; 0014 if (joint.step > width - 150) 0015 joint.step = 0; 0016 joint.linearOffset = Qt.point(joint.step + 100, Math.sin(joint.step * 6.0)); 0017 joint.angularOffset = Math.sin(joint.step / 8.0) * 10.0; 0018 } 0019 } 0020 0021 Rectangle { 0022 id:waves 0023 height:30 0024 y: 260 0025 anchors { 0026 left: parent.left 0027 right: parent.right 0028 } 0029 Image { 0030 id: waveImg 0031 source: "images/wave.png" 0032 fillMode: Image.Tile 0033 anchors.fill: parent 0034 } 0035 } 0036 0037 Rectangle { 0038 id: water 0039 y: 290 0040 height: parent.height - 290 0041 anchors { 0042 left: parent.left 0043 right: parent.right 0044 } 0045 color: "#74c2e6" 0046 } 0047 0048 PhysicsItem { 0049 id: berth 0050 height: 30 0051 width: 100 0052 x: 0 0053 y: 260 0054 fixtures: Box { 0055 width: berth.width 0056 height: berth.height 0057 } 0058 Rectangle { 0059 anchors.fill: parent 0060 color: "brown" 0061 } 0062 } 0063 0064 PhysicsItem { 0065 id: boat 0066 width: 32 0067 height: 32 0068 x: 100 0069 y: 250 0070 bodyType: Body.Dynamic 0071 fixtures: Box { 0072 width: boat.width 0073 height: boat.height 0074 friction: 0.6 0075 density: 2 0076 0077 } 0078 Image { 0079 id: boatImg 0080 source: "images/boat.png" 0081 anchors.fill: parent 0082 } 0083 } 0084 0085 MotorJoint { 0086 id: joint 0087 bodyA: berth.body 0088 bodyB: boat.body 0089 maxForce: 1000 0090 maxTorque: 1000 0091 property double step: 0.0 0092 angularOffset: 0 0093 } 0094 0095 Rectangle { 0096 id: button 0097 x: 10 0098 y: 10 0099 width: 100 0100 height: 40 0101 color: "#DEDEDE" 0102 border.color: "#999" 0103 radius: 5 0104 Text { 0105 id: title 0106 text: debugDraw.visible ? "Debug view: on" : "Debug view: off" 0107 anchors.centerIn: parent 0108 anchors.margins: 5 0109 } 0110 MouseArea { 0111 anchors.fill: parent 0112 onClicked: debugDraw.visible = !debugDraw.visible; 0113 } 0114 } 0115 0116 DebugDraw { 0117 id: debugDraw 0118 world: physicsWorld 0119 visible: false 0120 } 0121 }