forked from qml-box2d/qml-box2d
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…d#109 qrc & icons. qml-box2d#110 qmlscence optinal. qml-box2d#111 , qml-box2d#112 qt's example dir in prep for docs
- Loading branch information
JosephMillsAtWork
committed
Sep 25, 2016
1 parent
1b37be7
commit 43cf466
Showing
203 changed files
with
5,159 additions
and
3,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## QML Box2D plugin | ||
---------------- | ||
|
||
This plugin is meant to be installed to your Qt/imports directory, or shipped | ||
in a directory of which the parent is added as import path. | ||
|
||
The goal is to expose the functionality of Box2D as QML components, in order | ||
to make it easy to write physics based games in QML. | ||
|
||
|
||
#### INSTALLING | ||
----------- | ||
|
||
If running into permissions issues please use sudo with sudo if necessary | ||
|
||
By default everything gets insalled to your qt examples and plugin directory's | ||
|
||
```bash | ||
qmake | ||
make | ||
make install | ||
``` | ||
|
||
|
||
#### RUNNING THE EXAMPLES | ||
----------- | ||
|
||
After building all the examples will be located in your $$[QT_INSTALL_EXAMPLE] | ||
directory. But one can also use qtcreator to pick which example they would like | ||
to run. See the section below [using qt creator](#USING-QT-CREATOR) | ||
|
||
|
||
#### DEPLOYMENT | ||
----------- | ||
|
||
Support for deployment to mobile devices like the N900 and N8 is being worked | ||
on. | ||
|
||
|
||
#### USING QT CREATOR | ||
----------- | ||
|
||
Open the box2d pro file and selcet which example project you would like to run | ||
note there is a all-examples example applicaiton that allows one to view all | ||
the examples. | ||
|
||
When you have write permissions to Qt's import path, it can be convenient to | ||
add a deployment step to your run settings: | ||
|
||
* Go to Projects -> box2d -> Run Settings | ||
* Choose Add Deploy Step -> Make | ||
* Enter "install" under "Make arguments" | ||
|
||
This will make sure that before running, the version of the plugin is updated | ||
in Qt's import path. | ||
|
||
|
||
#### OPTIONAL QML TOOLING | ||
----------- | ||
|
||
If you would like to get Syntax highlighting for the Qml Elements/Objects | ||
|
||
* Go to Projects -> box2d -> Run Settings | ||
* Choose Add Deploy Step -> Make | ||
* Enter "qmltypes" under "Make arguments" | ||
|
||
|
||
#### DOCS | ||
----------- | ||
Coming soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,17 @@ | ||
TEMPLATE = lib | ||
CONFIG += plugin | ||
QT += quick | ||
TARGET = $$qtLibraryTarget(Box2D) | ||
TARGETPATH = Box2D | ||
API_VER=2.0 | ||
MOC_DIR = .moc | ||
OBJECTS_DIR = .obj | ||
|
||
contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols | ||
|
||
# Uncomment the line below to compile qml-box2d plugin with Box2D library, installed in OS | ||
# or pass the variable to qmake in command line: | ||
# qmake DEFINES+=BOX2D_SYSTEM | ||
# Warning: Box2D library must be already installed in system, for example in Debian it could be done with: | ||
# sudo apt-get install libbox2d-dev | ||
|
||
#DEFINES += BOX2D_SYSTEM | ||
|
||
include(box2d_lib.pri) | ||
include(examples/examples.pri) | ||
|
||
importPath = $$[QT_INSTALL_QML]/$$replace(TARGETPATH, \\., /).$$API_VER | ||
target.path = $${importPath} | ||
|
||
qmldir.path = $${importPath} | ||
qmldir.files += $$PWD/qmldir | ||
|
||
|
||
INSTALLS += target qmldir | ||
|
||
|
||
TEMPLATE = subdirs | ||
CONFIG += ordered | ||
SUBDIRS += \ | ||
$$PWD/src/box2d.pro \ | ||
$$PWD/src/Components \ | ||
$$PWD/examples/examples.pro | ||
|
||
OTHER_FILES += \ | ||
$$PWD/box2d_lib.pri \ | ||
$$PWD/box2d.qbs \ | ||
$$PWD/box2d-static.pri \ | ||
$$PWD/COPYING \ | ||
$$PWD/README.md \ | ||
$$PWD/debian/changelog \ | ||
$$PWD/debian/compat \ | ||
$$PWD/debian/control \ | ||
$$PWD/debian/rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
TEMPLATE = app | ||
|
||
QT += qml quick | ||
CONFIG += c++11 | ||
|
||
SOURCES += main.cpp | ||
|
||
RESOURCES += qml.qrc \ | ||
$$PWD/../images/example-images.qrc | ||
|
||
# Additional import path used to resolve QML modules in Qt Creator's code model | ||
QML_IMPORT_PATH = | ||
|
||
target.path = $$[QT_INSTALL_EXAMPLES]/Box2D/$${TARGET}/ | ||
export(target.path) | ||
INSTALLS += target | ||
export(INSTALLS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,53 @@ | ||
import QtQuick 2.0 | ||
import Box2D 2.0 | ||
import QtQuick.Window 2.0 | ||
import QtSensors 5.0 | ||
import "../shared" | ||
|
||
Image { | ||
id: screen | ||
import Box2D 2.0 | ||
import Box2D.Components 1.0 | ||
|
||
Window{ | ||
visible: true | ||
width: 640 | ||
height: 480 | ||
|
||
source: "background.png" | ||
|
||
World { id: physicsWorld } | ||
|
||
Repeater { | ||
model: 3 | ||
delegate: WoodenBox { | ||
x: Math.random() * (screen.width - 100); | ||
y: Math.random() * (screen.height / 3); | ||
rotation: Math.random() * 90; | ||
title: "Accelerometer Example" | ||
Image { | ||
id: screen | ||
width: parent.width | ||
height: parent.height | ||
|
||
source: "qrc:/images/background.png" | ||
|
||
World { id: physicsWorld } | ||
|
||
Repeater { | ||
model: 3 | ||
delegate: WoodenBox { | ||
x: Math.random() * (screen.width - 100); | ||
y: Math.random() * (screen.height / 3); | ||
rotation: Math.random() * 90; | ||
} | ||
} | ||
} | ||
|
||
ScreenBoundaries {} | ||
ScreenBoundaries {} | ||
|
||
DebugDraw { | ||
id: debugDraw | ||
world: physicsWorld | ||
opacity: 0.75 | ||
visible: false | ||
} | ||
MouseArea { | ||
id: debugMouseArea | ||
anchors.fill: screen | ||
onPressed: debugDraw.visible = !debugDraw.visible | ||
} | ||
DebugDraw { | ||
id: debugDraw | ||
world: physicsWorld | ||
opacity: 0.75 | ||
visible: false | ||
} | ||
MouseArea { | ||
id: debugMouseArea | ||
anchors.fill: screen | ||
onPressed: debugDraw.visible = !debugDraw.visible | ||
} | ||
|
||
Accelerometer { | ||
Component.onCompleted: start() | ||
onReadingChanged: { | ||
var r = reading; | ||
physicsWorld.gravity = Qt.point(r.x, r.y); | ||
Accelerometer { | ||
Component.onCompleted: start() | ||
onReadingChanged: { | ||
var r = reading; | ||
physicsWorld.gravity = Qt.point(r.x, r.y); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
#include <QGuiApplication> | ||
#include <QQmlApplicationEngine> | ||
#include <QDebug> | ||
#include <QtQml> | ||
#include <box2dplugin.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QGuiApplication app(argc, argv); | ||
|
||
Box2DPlugin plugin; | ||
plugin.registerTypes("Box2D"); | ||
|
||
QQmlApplicationEngine engine; | ||
engine.load(QUrl("qrc:/ui.qml")); | ||
engine.load(QUrl(QStringLiteral("qrc:/accelerometer.qml"))); | ||
|
||
return app.exec(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>WoodenBox.qml</file> | ||
<file>accelerometer.qml</file> | ||
</qresource> | ||
</RCC> |
Oops, something went wrong.