1

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);
Dean
  • 301
  • 4
  • 11

1 Answers1

1

Primary deploy target for no-dom branch was Ejecta. Because community showed interest in CocoonJS and it was 99% similar, the code was also tested with the CocoonJS launcher. I've never tried it more than running the demo games. Lot of other people have reported that they have successfully ran their games.

There are some edge cases that are not finished (for example font loading). Also, I haven't merged it into master because I have no real production code that uses this. So I'm not confident I can provide support to that code. At the moment all of the code is public but usage is on the game author's responsibility.

I ran the demo games again today in the launcher(on iPhone not Android). There was a small timing API issue that is fixed now(does not seem to be same error you have) https://github.com/digitalfruit/limejs/commit/5ad9eb67a but other than that they worked fine.

The error you have posted seems like a legitimate bug but I have nothing to do with your code sample. Launcher requires a compiled game inside a zip container. If you have problems making the container then look at the sample in the Makefile.

Also, if you have a bug report(with a testcase) I would prefer if you opened up an issue in Github instead of StackOverflow.

Tõnis Tiigi
  • 104
  • 2
  • _Lot of other people have reported that they have successfully ran their games._ --This is kind of why I posted here. I'm kind of assuming I'm doing something wrong rather than having a bug to report. I'm happy to use Github if I think it's a bug. Thank you for your response. Also, if you would prefer this kind of post else where (e.g. Google Groups) I'd be happy to use that too. – Dean Mar 15 '14 at 03:39
  • _Launcher requires a compiled game inside a zip container_ Are you talking about a requirement for LimeJS based games? Because I tested it with demo source code and assets from Ludei and it works either with a zipped file or with fully deployed application on the demo code. – Dean Mar 15 '14 at 03:49