Box2D Examples
import QtQuick 2.0
import Felgo 4.0
import QtQuick.Controls
import QtQuick.Dialogs
GameWindowApplicationWindow {
color: "white"
Loader {
id: loader
source: "boxes/Boxes.qml"
asynchronous: true
onLoaded: item.shutdownAppWithEscapeKeyEnabled = false
Connections {
target: loader.item
function onClosing() {
switchSource("")
}
}
}
Flow {
spacing: 10
width: parent.width
Button {
text: "Select Box2D Example"
onClicked: {
fileDialog.open()
}
}
Button {
text: "Unload"
onClicked: {
switchSource("")
}
}
Button {
text: "Boxes"
onClicked: {
switchSource("boxes/Boxes.qml")
}
}
Button {
text: "Demolition"
onClicked: {
switchSource("demolition/Demolition.qml")
}
}
Button {
text: "Distance"
onClicked: {
switchSource("distance/Distance.qml")
}
}
Button {
text: "Filtering"
onClicked: {
switchSource("filtering/Filtering.qml")
}
}
Button {
text: "Impulse"
onClicked: {
switchSource("impulse/Impulse.qml")
}
}
Button {
text: "Monera"
onClicked: {
switchSource("monera/Monera.qml")
}
}
Button {
text: "MovingBox"
onClicked: {
switchSource("movingBox/MovingBox.qml")
}
}
Button {
text: "Polygons"
onClicked: {
switchSource("polygons/Polygons.qml")
}
}
Button {
text: "Prismatic"
onClicked: {
switchSource("prismatic/Prismatic.qml")
}
}
Button {
text: "Raycast"
onClicked: {
switchSource("raycast/Raycast.qml")
}
}
Button {
text: "Revolute"
onClicked: {
switchSource("revolute/Revolute.qml")
}
}
Button {
text: "Rope"
onClicked: {
switchSource("rope/Rope.qml")
}
}
Button {
text: "TwoWorlds"
onClicked: {
switchSource("twoWorlds/TwoWorlds.qml")
}
}
}
FileDialog {
id: fileDialog
title: "Please choose a qml file from a subfolder of the Box2D Examples"
onAccepted: {
console.log("You chose: " + fileDialog.fileUrl)
switchSource(fileDialog.fileUrl)
}
currentFolder: "."
}
function switchSource(newSource) {
Box2D.defaultWorld = null
loader.source = newSource