Question

I have searched everywhere, whether it be forums, blogs, Google, and even documentation but could not figure out how to do Android specific things for CocoonJS. I want to start developing a javascript game and build it with CocoonJS and I know CocoonJS is fullscreen on Android, but how do I know what canvas size to use? For example:

I am creating the game and testing locally via Google Chrome. If I develop a whole game with canvas size = innerWidth / innerHeight then it will be fullscreen but how will I know what this scales to on mobile. I am also unaware on how to handle touch events.

The best (current) example would be the game 2048. This game is written in javascript and runs in your browser, but is also a native android app.

Let me simplify:

Creating a javascript game is simple on the desktop, but I have no idea what to set my canvas size to etc to ensure this works on Android. By the way, I am developing this game because I am a web developer so am more efficient in HTML / JS compared to other languages, but do not necessarily need this game to run on browsers at all. I want Android to be my target platform, but still be able to test the game on my laptop.

This question is kind of a mess at the moment but I will go through and organize it better to help others who possibly have this same problem.

If I could rephrase the question in just one sentence it would be this:

Where do I start when creating an Android game with CocoonJS?

Was it helpful?

Solution

I would recommend downloading the cocoon launcher from the app/play store. In this app you can open DEMO apps where you can actually see what you can do with cocoonjs and how fast it is.

In addition you can download the source code of each app here: https://cocoonjsservice.ludei.com/cocoonjslaunchersvr/demo-list/

You can set the scale mode of your app in the launcher or later in your compiled app. Just take a look at the options. The rest of your questions like scales/size will be answered by looking at the source code of the demo apps where you can see how they handle it :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top