Box2D Examples
import QtQuick 2.0
import Felgo 4.0
GameWindow {
id: screen
activeScene: scene
Scene {
id: scene
PhysicsWorld {
id: world
debugDrawVisible: true
gravity.y: 10
}
Ball {
id: ball1
x: 200
y: 30
radius: 15
bodyType: Body.Static
}
Square {
id: square2
x: 250
y: 30
width: 20
height: 20
}
Ball {
id: ball3
x: 330
y: 30
radius: 10
}
RopeJoint {
id: ropeJoint1
maxLength: 70
bodyA: ball1.body
bodyB: square2.body
localAnchorA: Qt.point(ball1.width/2, ball1.height/2)
localAnchorB: Qt.point(square2.width/2, square2.height/2)
}
RopeJoint {
id: ropeJoint2
maxLength: 100
bodyA: square2.body
bodyB: ball3.body
localAnchorA: Qt.point(square2.width/2, square2.height/2)
localAnchorB: Qt.point(ball3.width/2, ball3.height/2)
}
Text {
z: 1
color: "blue"
text: "Click to apply an impulse to the right on the green square in the middle"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
square2.body.applyLinearImpulse(Qt.point(100, 0), square2.body.getWorldCenter())
}
}
EntityManager {
id: entityManager