As a prelude to moving my LimeJS game from PC to Android, I'm trying to get the Android CocoonJS Launcher to work with a basic LimeJS application. Am I doing something wrong here?
I have some questions some of which may be only known to Tõnis Tiigi so I'll ask him as well:
Is LimeJS known to be functional on CocoonJS Android Launcher or are there issues with LimeJS that have not been resolved for this platform?
If there are issues, is support for this platform planned or under development? If not, I will have to consider rewriting to use a game engine known to work with CocoonJS.
I downloaded and installed the limejs-no-dom package and have it working on my Windows machine. I adapted the basic \limejs-no-dom\lime\demos\tests\anim1 and run_canvasonly.htm to my own test project. This works fine with no console errors. I did a lime.py build to create a test which I uploaded to my remote server. When I access it from my browser it works fine with no console errors. When I connect my android phone to the site using the CocoonJS Launcher app, I get a black screen. There is a JavaScript Exception: TypeError: Cannot read property parentNode of undefined at Object goog.style.installStyles
<!DOCTYPE HTML>
<html>
<head>
<title>Run MBTest</title>
<script type="text/javascript" src="mbt.js"></script>
</head>
<body onload="mbtest.start(document.getElementById('mycanvas'))">
<canvas id="mycanvas" width="500" height="500" style="border: 3px solid #c00"></canvas>
</body>
</html>
goog.provide('mbtest');
goog.require('lime');
goog.require('lime.Button');
goog.require('lime.Circle');
goog.require('lime.CoverNode');
goog.require('lime.Director');
goog.require('lime.Label');
goog.require('lime.Layer');
goog.require('lime.Scene');
goog.require('lime.Sprite');
goog.require('lime.animation.Loop');
goog.require('lime.animation.MoveBy');
goog.require('lime.animation.RotateBy');
goog.require('lime.animation.ScaleBy');
goog.require('lime.animation.Sequence');
goog.require('lime.animation.Spawn');
goog.require('lime.animation.ColorTo');
mbtest.WIDTH = 600;
mbtest.HEIGHT = 400;
mbtest.start = function(parent) {
mbtest.director = new lime.Director(parent || document.body, mbtest.WIDTH, mbtest.HEIGHT);
mbtest.director.makeMobileWebAppCapable();
var menuscene = new lime.Scene;
var layer = (new lime.Layer).setPosition(100, 100);
menuscene.appendChild(layer);
var sprite = new lime.Sprite().setFill(100,0,0).setSize(50, 50).setRenderer(lime.Renderer.CANVAS);
layer.appendChild(sprite);
var anim = new lime.animation.Sequence(new lime.animation.Spawn(
new lime.animation.MoveBy(200, 0).setDuration(1.5),
new lime.animation.ScaleBy(2),
new lime.animation.ColorTo(0,200,0)
), new lime.animation.Spawn(
new lime.animation.MoveBy(-200, 0).setDuration(1.5),
new lime.animation.ScaleBy(.5),
new lime.animation.ColorTo(200,0,0)
));
sprite.runAction(new lime.animation.Loop(anim).setLimit(5));
var sprite = new lime.Sprite().setFill('#0c0').setSize(50, 50).setPosition(0, 100).setRenderer(lime.Renderer.CANVAS);
layer.appendChild(sprite);
var anim = new lime.animation.Spawn(
new lime.animation.RotateBy(-90).setDuration(3).enableOptimizations(),
new lime.animation.MoveBy(300, 0).setDuration(3).enableOptimizations()
);
var a2 = new lime.animation.Sequence(anim, anim.reverse());
sprite.runAction(new lime.animation.Loop(a2).setLimit(5));
mbtest.director.replaceScene(menuscene);
};
goog.exportSymbol('mbtest.start', mbtest.start);