Jump to content

How to start with CocoonJS


totallybueno
 Share

Recommended Posts

Hi there,

I have my game working perfectly on web, everything goes perfectly good... but I´m trying to try it as an app using CocoonJS and all I have is a black screen and the fps counter.

 

I have a .html and two folders, one with the .js files and another one with all the assets. I tried with all the .js files in the root of the zip but I have the same result.

 

Can anyone tell me how to pack a proper zip for use with Cocoon?

Link to comment
Share on other sites

Hi

 

there is no "magic" solution for all issues with CocoonJS :)

 

but here are some directives to help you debug your problem.

1 - try to compil your application on a webview/webview+ container, this should work since it has the same behaviour as a mobile browser. if the game performance is good then you're done .... but webview/webview+ are not as performant as canvas+ ....

2 - if (1) didn't work or didn't satisfy your need, then download or build a cocoon launcher, put your zip package on a server, and open it from cocoon launcher, tap the FPS button, you'll get a screen with a JS console where errors/warnings are displayed. resolve them and your game should work.

 

3 - if your resolved your errors, in step (2) the game worked on launcher but the compiled version don't work, your final option is : adb logcat .... here you'll need to put some console.log in your code to identify when the game starts and the potential errors it throws .

 

 

most of the time, the black screen issue is related to a resource (image, sound, json ...etc) you are trying to use while it's not yet loaded.

browsers are more tolerant to this in some cases while CocoonJS will just fail.

 

try this and tell me if it help :)




 

Link to comment
Share on other sites

really strange !
both Webview+ and Canvas+ should have better performace thant webview ...

are you using a specific engine ? or from scratch ?

what size are your images ?

are you using requestanimationframe ?


btw : from the CocoonJS debug screen you can profile CPU and Memory usage, so you'll know what's slowing down your code ;)

Link to comment
Share on other sites

do you mean a custom render function ? or the native Phaser render function ?

 

 

The native one, without that function commented the game is running at 60fps in Canvas+, with that function at  1/2fps, and dude, this is the code... soooooo weird:

render:function() {        this.game.debug.body(this.hero);        this.game.debug.body(this.background);    },
Link to comment
Share on other sites

 

The native one, without that function commented the game is running at 60fps in Canvas+, with that function at  1/2fps, and dude, this is the code... soooooo weird:

render:function() {        this.game.debug.body(this.hero);        this.game.debug.body(this.background);    },

 

To answer why using render is so much slower, it's because it is making extra drawing calls per frame. Instead of caching the visual data and updating sections, game.debug makes new calls every single render call. That's a huge number of wasted drawing calls that would drop the frame rate tremendously on any platform and especially on mobile devices.

 

As well, to backup @Ezelia's comments, upgrading to Phaser 2.0.7 is recommended. There have been a number of CocoonJS-related patches between 2.0.2 and 2.0.7 -- and more to come in 2.1 too.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...