mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-27 05:01:38 +00:00
android attempt fixes
This commit is contained in:
parent
609c5dc1b7
commit
df5f1f0743
7 changed files with 95 additions and 33 deletions
|
|
@ -717,7 +717,7 @@ class Marble extends GameObject {
|
||||||
var soFar = 0.0;
|
var soFar = 0.0;
|
||||||
for (k in 0...contacts.length) {
|
for (k in 0...contacts.length) {
|
||||||
var dist = this._radius - contacts[k].contactDistance;
|
var dist = this._radius - contacts[k].contactDistance;
|
||||||
var timeToSeparate = 0.1;
|
var timeToSeparate = 0.016;
|
||||||
var vel = this.velocity.sub(contacts[k].velocity);
|
var vel = this.velocity.sub(contacts[k].velocity);
|
||||||
var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal);
|
var outVel = vel.add(dir.multiply(soFar)).dot(contacts[k].normal);
|
||||||
if (dist > timeToSeparate * outVel) {
|
if (dist > timeToSeparate * outVel) {
|
||||||
|
|
@ -1508,7 +1508,7 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == Start) {
|
if (mode == Start && startPad != null) {
|
||||||
var upVec = this.level.currentUp;
|
var upVec = this.level.currentUp;
|
||||||
var startpadNormal = startPad.getAbsPos().up();
|
var startpadNormal = startPad.getAbsPos().up();
|
||||||
this.velocity = upVec.multiply(this.velocity.dot(upVec));
|
this.velocity = upVec.multiply(this.velocity.dot(upVec));
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import gui.MessageBoxOkDlg;
|
||||||
import src.Replay;
|
import src.Replay;
|
||||||
import touch.TouchInput;
|
import touch.TouchInput;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import gui.MessageBoxOkDlg;
|
||||||
import collision.Collision;
|
import collision.Collision;
|
||||||
import shapes.MegaMarble;
|
import shapes.MegaMarble;
|
||||||
import shapes.Blast;
|
import shapes.Blast;
|
||||||
|
|
@ -198,7 +199,7 @@ class MarbleWorld extends Scheduler {
|
||||||
|
|
||||||
public function initLoading() {
|
public function initLoading() {
|
||||||
this.loadingGui = new LoadingGui(this.mission.title, this.mission.game);
|
this.loadingGui = new LoadingGui(this.mission.title, this.mission.game);
|
||||||
MarbleGame.canvas.setContent(this.loadingGui);
|
// MarbleGame.canvas.setContent(this.loadingGui);
|
||||||
|
|
||||||
function scanMission(simGroup:MissionElementSimGroup) {
|
function scanMission(simGroup:MissionElementSimGroup) {
|
||||||
for (element in simGroup.elements) {
|
for (element in simGroup.elements) {
|
||||||
|
|
@ -231,11 +232,11 @@ class MarbleWorld extends Scheduler {
|
||||||
scanMission(this.mission.root);
|
scanMission(this.mission.root);
|
||||||
this.resourceLoadFuncs.push(fwd -> this.initScene(fwd));
|
this.resourceLoadFuncs.push(fwd -> this.initScene(fwd));
|
||||||
this.resourceLoadFuncs.push(fwd -> this.initMarble(fwd));
|
this.resourceLoadFuncs.push(fwd -> this.initMarble(fwd));
|
||||||
this.resourceLoadFuncs.push(fwd -> {
|
// this.resourceLoadFuncs.push(fwd -> {
|
||||||
this.addSimGroup(this.mission.root);
|
// this.addSimGroup(this.mission.root);
|
||||||
this._loadingLength = resourceLoadFuncs.length;
|
// this._loadingLength = resourceLoadFuncs.length;
|
||||||
fwd();
|
// fwd();
|
||||||
});
|
// });
|
||||||
this.resourceLoadFuncs.push(fwd -> this.loadMusic(fwd));
|
this.resourceLoadFuncs.push(fwd -> this.loadMusic(fwd));
|
||||||
this._loadingLength = resourceLoadFuncs.length;
|
this._loadingLength = resourceLoadFuncs.length;
|
||||||
}
|
}
|
||||||
|
|
@ -253,7 +254,8 @@ class MarbleWorld extends Scheduler {
|
||||||
var musicFileName = 'data/sound/music/' + this.mission.missionInfo.music;
|
var musicFileName = 'data/sound/music/' + this.mission.missionInfo.music;
|
||||||
AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources), this.mission.missionInfo.music);
|
AudioManager.playMusic(ResourceLoader.getResource(musicFileName, ResourceLoader.getAudio, this.soundResources), this.mission.missionInfo.music);
|
||||||
MarbleGame.canvas.clearContent();
|
MarbleGame.canvas.clearContent();
|
||||||
this.endPad.generateCollider();
|
if (this.endPad != null)
|
||||||
|
this.endPad.generateCollider();
|
||||||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
@ -1249,11 +1251,21 @@ class MarbleWorld extends Scheduler {
|
||||||
var func = this.resourceLoadFuncs.shift();
|
var func = this.resourceLoadFuncs.shift();
|
||||||
lock = true;
|
lock = true;
|
||||||
#if hl
|
#if hl
|
||||||
func(() -> {
|
try {
|
||||||
|
func(() -> {
|
||||||
|
lock = false;
|
||||||
|
this._resourcesLoaded++;
|
||||||
|
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
lock = false;
|
lock = false;
|
||||||
this._resourcesLoaded++;
|
this._resourcesLoaded++;
|
||||||
this.loadingGui.setProgress((1 - resourceLoadFuncs.length / _loadingLength));
|
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
});
|
errorTxt.setPosition(20, 20);
|
||||||
|
errorTxt.text = e.toString();
|
||||||
|
errorTxt.textColor = 0xFFFFFF;
|
||||||
|
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||||
|
}
|
||||||
#end
|
#end
|
||||||
#if js
|
#if js
|
||||||
func(() -> {
|
func(() -> {
|
||||||
|
|
@ -1516,7 +1528,7 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.finishTime == null) {
|
if (this.finishTime == null && this.endPad != null) {
|
||||||
if (spherebounds.collide(this.endPad.finishBounds)) {
|
if (spherebounds.collide(this.endPad.finishBounds)) {
|
||||||
var padUp = this.endPad.getAbsPos().up();
|
var padUp = this.endPad.getAbsPos().up();
|
||||||
padUp = padUp.multiply(10);
|
padUp = padUp.multiply(10);
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ import src.Settings;
|
||||||
|
|
||||||
class ResourceLoader {
|
class ResourceLoader {
|
||||||
#if (hl && !android)
|
#if (hl && !android)
|
||||||
#if MACOS_BUNDLE
|
#if MACOS_BUNDLE
|
||||||
public static var fileSystem:FileSystem = new TorqueFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "..", ".."])), null);
|
public static var fileSystem:FileSystem = new TorqueFileSystem(Path.normalize(Path.join([Path.directory(Sys.programPath()), "..", "..", ".."])), null);
|
||||||
#else
|
#else
|
||||||
public static var fileSystem:FileSystem = new TorqueFileSystem(".", null);
|
public static var fileSystem:FileSystem = new TorqueFileSystem(".", null);
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
public static var fileSystem:FileSystem = null;
|
public static var fileSystem:FileSystem = null;
|
||||||
|
|
@ -53,12 +53,12 @@ class ResourceLoader {
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
var mfileSystem = ManifestBuilder.create("data");
|
var mfileSystem = ManifestBuilder.create("data");
|
||||||
var mloader:ManifestLoader = new ManifestLoader(mfileSystem);
|
var mloader:ManifestLoader = new ManifestLoader(mfileSystem);
|
||||||
|
|
||||||
var preloader = new ManifestProgress(mloader, () -> {
|
var preloader = new ManifestProgress(mloader, () -> {
|
||||||
loader = mloader;
|
loader = mloader;
|
||||||
fileSystem = mfileSystem;
|
fileSystem = mfileSystem;
|
||||||
onLoadedFunc();
|
onLoadedFunc();
|
||||||
}, scene2d);
|
}, scene2d);
|
||||||
|
#if js
|
||||||
loader = mloader;
|
loader = mloader;
|
||||||
fileSystem = mfileSystem;
|
fileSystem = mfileSystem;
|
||||||
var loadg = new h2d.Text(hxd.res.DefaultFont.get());
|
var loadg = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
|
|
@ -100,7 +100,10 @@ class ResourceLoader {
|
||||||
fwd();
|
fwd();
|
||||||
});
|
});
|
||||||
worker.run();
|
worker.run();
|
||||||
// preloader.start();
|
#end
|
||||||
|
#if android
|
||||||
|
preloader.start();
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
#if (hl && !android)
|
#if (hl && !android)
|
||||||
onLoadedFunc();
|
onLoadedFunc();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import gui.MessageBoxOkDlg;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
|
import src.MarbleGame;
|
||||||
|
|
||||||
class ResourceLoaderWorker {
|
class ResourceLoaderWorker {
|
||||||
var tasks:Array<(() -> Void)->Void> = [];
|
var tasks:Array<(() -> Void)->Void> = [];
|
||||||
|
|
@ -20,7 +22,11 @@ class ResourceLoaderWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTaskParallel(task:(() -> Void)->Void) {
|
public function addTaskParallel(task:(() -> Void)->Void) {
|
||||||
|
#if (!android)
|
||||||
paralleltasks.push(task);
|
paralleltasks.push(task);
|
||||||
|
#else
|
||||||
|
tasks.push(task);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
|
|
@ -41,19 +47,59 @@ class ResourceLoaderWorker {
|
||||||
|
|
||||||
if (tasks.length > 0) {
|
if (tasks.length > 0) {
|
||||||
var task = tasks.shift();
|
var task = tasks.shift();
|
||||||
task(() -> {
|
try {
|
||||||
if (tasks.length > 0) {
|
task(() -> {
|
||||||
run();
|
if (tasks.length > 0) {
|
||||||
} else {
|
run();
|
||||||
onFinish();
|
} else {
|
||||||
}
|
onFinish();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
|
errorTxt.setPosition(20, 20);
|
||||||
|
errorTxt.text = e.toString();
|
||||||
|
errorTxt.textColor = 0xFFFFFF;
|
||||||
|
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
onFinish();
|
try {
|
||||||
|
onFinish();
|
||||||
|
} catch (e) {
|
||||||
|
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
|
errorTxt.setPosition(20, 20);
|
||||||
|
errorTxt.text = e.toString();
|
||||||
|
errorTxt.textColor = 0xFFFFFF;
|
||||||
|
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadFile(path:String) {
|
public function loadFile(path:String) {
|
||||||
paralleltasks.push(fwd -> ResourceLoader.load(path).entry.load(fwd));
|
#if (!android)
|
||||||
|
paralleltasks.push(fwd -> {
|
||||||
|
try {
|
||||||
|
ResourceLoader.load(path).entry.load(fwd);
|
||||||
|
} catch (e) {
|
||||||
|
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
|
errorTxt.setPosition(20, 20);
|
||||||
|
errorTxt.text = e.toString();
|
||||||
|
errorTxt.textColor = 0xFFFFFF;
|
||||||
|
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#else
|
||||||
|
tasks.push(fwd -> {
|
||||||
|
try {
|
||||||
|
ResourceLoader.load(path).entry.load(fwd);
|
||||||
|
} catch (e) {
|
||||||
|
var errorTxt = new h2d.Text(hxd.res.DefaultFont.get());
|
||||||
|
errorTxt.setPosition(20, 20);
|
||||||
|
errorTxt.text = e.toString();
|
||||||
|
errorTxt.textColor = 0xFFFFFF;
|
||||||
|
MarbleGame.canvas.scene2d.addChild(errorTxt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,13 @@ class ManifestBuilder {
|
||||||
// try later with another fs
|
// try later with another fs
|
||||||
if (!StringTools.startsWith(file.fullPath, basePath))
|
if (!StringTools.startsWith(file.fullPath, basePath))
|
||||||
continue;
|
continue;
|
||||||
var info = {path: file.relPath.toLowerCase(), original: file.relPath};
|
var info = {path: file.relPath, original: file.relPath};
|
||||||
out.push(info);
|
out.push(info);
|
||||||
var f = fs.get(file.relPath); // convert
|
var f = fs.get(file.relPath); // convert
|
||||||
if (f.originalFile != null && f.originalFile != f.file) {
|
if (f.originalFile != null && f.originalFile != f.file) {
|
||||||
info.original = f.relPath;
|
info.original = f.relPath;
|
||||||
info.path = StringTools.startsWith(f.file, fs.baseDir) ? f.file.substr(fs.baseDir.length) : f.file;
|
info.path = StringTools.startsWith(f.file, fs.baseDir) ? f.file.substr(fs.baseDir.length) : f.file;
|
||||||
info.path = info.path.toLowerCase();
|
info.path = info.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class ManifestFileSystem implements FileSystem {
|
||||||
}
|
}
|
||||||
var entry:ManifestEntry = new ManifestEntry(this, Path.withoutDirectory(original), original, file, original);
|
var entry:ManifestEntry = new ManifestEntry(this, Path.withoutDirectory(original), original, file, original);
|
||||||
r.contents.push(entry);
|
r.contents.push(entry);
|
||||||
manifest.set(path.toLowerCase(), entry);
|
manifest.set(path, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_manifest.get(0)) {
|
switch (_manifest.get(0)) {
|
||||||
|
|
@ -298,7 +298,7 @@ class ManifestFileSystem implements FileSystem {
|
||||||
// JSON
|
// JSON
|
||||||
var json:Array<{path:String, original:String}> = haxe.Json.parse(_manifest.toString());
|
var json:Array<{path:String, original:String}> = haxe.Json.parse(_manifest.toString());
|
||||||
for (entry in json) {
|
for (entry in json) {
|
||||||
insert(entry.path.toLowerCase(), baseDir + entry.path, entry.original);
|
insert(entry.path, baseDir + entry.path, entry.original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -322,11 +322,11 @@ class ManifestFileSystem implements FileSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exists(path:String) {
|
public function exists(path:String) {
|
||||||
return find(path.toLowerCase()) != null;
|
return find(path) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get(path:String) {
|
public function get(path:String) {
|
||||||
var entry:ManifestEntry = find(path.toLowerCase());
|
var entry:ManifestEntry = find(path);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
throw new NotFound(path);
|
throw new NotFound(path);
|
||||||
return entry;
|
return entry;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue