Commit 34fbc562 authored by Holger Kaelberer's avatar Holger Kaelberer
Browse files

balancebox, reconfigure scene on window resize

parent c35cc388
......@@ -38,6 +38,16 @@ ActivityBase {
property string levelSet: "builtin" // "builtin" or "user"
property var testLevel
onWidthChanged: {
Activity.reconfigureScene();
Activity.initLevel();
}
onHeightChanged: {
Activity.reconfigureScene();
Activity.initLevel();
}
onStart: {
console.log("XXX BalanceBox onStart");
focus = true;
......@@ -91,7 +101,7 @@ ActivityBase {
onStart: Activity.start(items)
onStop: { Activity.stop() }
onStop: Activity.stop()
QtObject {
id: items
......
......@@ -22,10 +22,8 @@
/* ToDo:
- levels, levels, levels
- make sensitivity configurable?
- visualize when in test-mode in Balancebox
- catch case of user levelset without or empty levels file
- editor: detect and warn invalid levels (no start, no goal)
- handle resize events
*/
.pragma library
.import QtQuick 2.0 as Quick
......@@ -81,21 +79,8 @@ function start(items_) {
items = items_;
currentLevel = 0;
// set up dynamic variables for movement:
pixelsPerMeter = boardSizePix / boardSizeM / (items.dpi / dpiBase);
//pixelsPerMeter = (items.mapWrapper.length / 760) * boardSizePix / boardSizeM;
vFactor = pixelsPerMeter / box2dPpm;
console.log("Starting: mode=" + items.mode
+ " pixelsPerM=" + items.world.pixelsPerMeter
+ " timeStep=" + items.world.timeStep
+ " posIterations=" + items.world.positionIterations
+ " velIterations=" + items.world.velocityIterations
+ " boardSizePix=" + boardSizePix + " (real " + items.mapWrapper.length + ")"
+ " pixelsPerMeter=" + pixelsPerMeter
+ " vFactor=" + vFactor
+ " dpi=" + items.dpi
+ " nativeOrientation=" + GCompris.ApplicationInfo.getNativeOrientation());
reconfigureScene();
if (items.mode === "play") {
if (GCompris.ApplicationInfo.isMobile) {
......@@ -131,6 +116,25 @@ function start(items_) {
initLevel();
}
function reconfigureScene()
{
// set up dynamic variables for movement:
pixelsPerMeter = boardSizePix / boardSizeM / (items.dpi / dpiBase);
//pixelsPerMeter = (items.mapWrapper.length / 760) * boardSizePix / boardSizeM;
vFactor = pixelsPerMeter / box2dPpm;
console.log("Starting: mode=" + items.mode
+ " pixelsPerM=" + items.world.pixelsPerMeter
+ " timeStep=" + items.world.timeStep
+ " posIterations=" + items.world.positionIterations
+ " velIterations=" + items.world.velocityIterations
+ " boardSizePix" + boardSizePix + " (real " + items.mapWrapper.length + ")"
+ " pixelsPerMeter=" + pixelsPerMeter
+ " vFactor=" + vFactor
+ " dpi=" + items.dpi
+ " nativeOrientation=" + GCompris.ApplicationInfo.getNativeOrientation());
}
function sinDeg(num)
{
return Math.sin(num/180*Math.PI);
......@@ -336,6 +340,7 @@ function removeBallContact(item)
function tearDown()
{
items.ball.body.linearVelocity = Qt.point(0, 0);
items.timer.stop();
items.keyboardTimer.stop();
if (holes.length > 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment