[Experiment] Construct2 with Ejecta and GameCenter

Discussion and feedback on Construct 2

Post » Wed Feb 27, 2013 1:30 am

I created a plugin for Ejecta (impactjs.com/ejecta/overview) and successfully exported Space Blaster to an XCode project that runs it on Ejecta. I had to do some tweaks to the generated c2runtime.js file but the game works well. Actually, most of it, because ejecta does not support tiled backgrounds, so the health bar does not draw very well. The YouTube video of space blaster running on Ejecta in my iPad with GameCenter is here:

http://www.youtube.com/watch?v=0DMn5qg88KY

The steps I did are the following:
1. exported as Html5 game
2. Modified runtime.js in the following places
a. set this.isDomFree = true and this.isiOS = true in function Runtime(canvas)
b. set this.ctx = global_ctx; in function Runtime(canvas). global_ctx is just an arbitrary global var that holds the 2d context obtained in the index.js script (see Ejecta documentation). That was the only way I could make it work, not sure why.
c. In areAllTexturesLoaded, I replaced the end of the function with the following:

this.progress++;
return (this.progress > 250);//got 250 through trial and error

and replaced the following line in Runtime.prototype.go:
this.progress = 0;

with:

this.progress = (typeof this.progress === 'undefined') ? 0 : this.progress ; //jpt

to allow the progress variable to keep track of my arbitrary progress (maximum is 250).

This is caused by Ejecta not supporting the filesize info that C2 polls in areAllTexturesLoaded. A fix is needed for this, I will try to find a way of just using chained onloadimages to detet if all images are loaded, or something like that. Smarter suggestions are very welcome.

3. Created a index.js file for ejecta with the following contents:
var global_canvas = document.getElementById('canvas');
var global_ctx = canvas.getContext('2d');
ejecta.require('c2runtime.js');
// Create new runtime using the c2canvas
cr.createRuntime('canvas');

I marked my changes to c2runtime with "//jpt" so you can see in the source what I changed. The Xcode source, with the capx and the Ejecta plugin are in:

https://www.dropbox.com/sh/wp9wzw1yxd6pz9a/NODC9JCZMr

The Ejecta plugin so far only has the actions and conditions to authenticate into GameCenter and to post scores and achievements.See http://impactjs.com/ejecta/game-center for info on what Ejecta supports in GameCenter.

Please understand that you will not be able to just run the Xcode project in your Mac. You will have to:

1. Get an Apple dev account
2. Create all your certificates and app IDs (this is not C2 specific, you have to do that with any IOS app you want to develop in any tool)
3. Setup GameCenter for your app ID. See http://www.cocos2d-iphone.org/forum/topic/20998 (ignore the cocos part and just follow the iTunes Connect tuturial)
4. change the bundle identifier of the Xcode project to your own bundle identifier.
5. GameCenter will work 24 hurs after you set it up.
6. Scores will not show until more than one GameCenter Account pots a score. I ahd to create an extra account and play SpaceBlaster with it to make the scores visible.

Disadvantages of using Ejecta:
1. Tiled backgrounds dont work properly
2. No file size support, need to find fix. For now I just have the loader wait an arbritary number of seconds.
3. Not all HTML5 is supported. I know for sure XMLParser does not work (tried to use the TMX imported from RexRainbow in another experiment). Please see http://impactjs.com/ejecta/supported-apis-methods to see what part of HTML5 ejecta supports.
4. You have to know XCode. Make sure you try follwoing a tutorial on the web on how to do a Native Hello World IOS app in Xcode so that you can learn how to work with certificates and app IDs.
5. You have to have a Mac; but you need one anyways to publish to the app store. I got my 2009 macbook for about $250 at http://www.cedarpc.com/ plus 4GB at $35 from crucial. The screen has some white spots but they are no big deal.
6. You need to understand JavaScript in order to make the chnages to the c2runtime.js file. Please dont try this experiment unless you know some javascript programming and are comfortable with XCode.

Advantages of using Ejecta:

1. Current GameCenter support. I know CocoonJS has now an API for that but I think it involves contacting them or something like that.
2. Is open source so it is free. No monthly fees or sharing revenue.
3. It has ways to allow your JS to communicate with Objectitve C code if you need to implement something natively (http://impactjs.com/ejecta/extending-ejecta)
4. Performance wise, I will say it is good. But CocoonJS is also fast, so there is not much difference. In my iPhone 5 it ran really well, in my iPad2 it ran smooth but it did drop sometimes to ~35 fps at some points in the game.
5. Their GitHub page says they are working on implementing WebGL (https://github.com/phoboslab/Ejecta)juantar2013-02-27 01:34:06
B
26
S
7
G
3
Posts: 118
Reputation: 4,264

Post » Wed Feb 27, 2013 2:31 am

This is great news, seriously! This is what we need!
OpenSource like PhoneGap but hardware accelerated! Thank you very very much for you work, I start experimenting right away!

Please @Ashley get on top of this because this is the way to go!
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Wed Feb 27, 2013 2:57 am

I doubt Ashley will not help anything if it requires a mac to compile a game with Xcode, anyways it should have optional exporter would be awesome

EDIT: We have 2 optional exporters may require with mac:

-Ejecta (Only iOS)
-GameClosure (iOS and Android)Joannesalfa2013-02-27 03:16:04
B
96
S
25
G
20
Posts: 3,053
Reputation: 22,640

Post » Wed Feb 27, 2013 9:20 am

Ejecta is good, and the guy who made EjectaGL is helping backporting is work inside Ejecta (so we'll get WebGL via OpenGLES).
For those who don't want to buy a Mac, you can always rent one over the web, since your dev account won't be attached to a machine but to your banking account. You can always rent one for the month or week where you build the archive and send it to Apple, and follow online only after that (and rent the month or the wek you wan when you release a new build).
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Feb 28, 2013 12:19 am

I'm testing. So far I discovered that (surprisingly) spritefonts doesn't work.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Feb 28, 2013 1:18 am

I'm impressed. I was interested in Ejecta last month. I was planning if no option showed up for the Ouya to port Ejecta to Android/Java with the Canvas using OpenGL ES and just layer faking the Canvas calls to OGL.

However Game Closure showed up and I would rather build on top of that. As for Game Closure. You don't need a Mac. You can get working on Windows with some hacks. Also the GC team is working on preparing it for Windows. So it's just a matter of time for viability for those who don't want the hacking headache.

To the OP. I appreciate some of the work you have there. Currently I injected some cr_createRuntime with a cr_createGCRuntime(<canvas>). A customized. Your looks easier to just set the car global_ctx = .... I'll probably look into that instead of the way I did it :)

I can't specifically say for SpriteFont, but I'm aware that a number of community plugins use jQuery. It could be that we will just have to do plugin work around until the fateful day jQuery is phased out..... a long time coming.jayderyu2013-02-28 01:19:25
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Feb 28, 2013 6:51 am

@juantar I made some experiments and I don't understand why you fiddled with areAllTexturesLoaded. I was able to make it work without touching that function.

@jayderyu Game Closure looks interesting, but it doesn't support Game Center and having access to xCode gives you the freedom to add some very nice features like cloud saves that can really boost the sales of your game.

I'm now testing True Type Fonts in Ejecta, I'll keep you posted. Please update this thread with all your experiments because this product is the way to go for iOS currently.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Feb 28, 2013 7:19 am

@jayderyu Game Closure looks interesting, but it doesn't support Game Center and having access to xCode gives you the freedom to add some very nice features like cloud saves that can really boost the sales of your game.

I'm now testing True Type Fonts in Ejecta, I'll keep you posted. Please update this thread with all your experiments because this product is the way to go for iOS currently.[/QUOTE]

Well I do agree that there is no Game Center support, but I'm a pretty adamant supporter that such aspect should be 100% cross platform. Though i like the robustness I would rather use Clay.io(http://clay.io/) or Hydra(https://hydra.agoragames.com/) if it ever comes with HTML5/JS support. Clay.io supports data saving to the Clay servers. So it also supports saving games to a cloud network :)

I however do agree do to extension capability it seems like more opportunity than CJS. Also as support seems to be lost in some kind of confusion it might be more reliable as it's expected as only community support.jayderyu2013-02-28 07:20:23
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Feb 28, 2013 9:59 am

@jayderyu

The problem with clay.io is that is rather buggy at the moment (especially under accelerated canvases), it also requires a (constant) internet connection which might result in a reject by Apple, it's also another closed source library that could close tomorrow for all we know.

Cross platform I would go with openFeint at the moment.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Feb 28, 2013 1:57 pm

@0plus1 I modified areAllTexturesLoaded because on my intial tests, the function would get call indefinitely becuase the filesize always returned zero. That initial test was done a few versions before, I will try without the modification and do some logging on the filezise and see what happens.

Also, please note that if you start your layout without the images being loaded, you will not see the sprites on the screen unless the change position (if they change position, that forces a redraw).juantar2013-02-28 13:59:11
B
26
S
7
G
3
Posts: 118
Reputation: 4,264

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Eisenhans, Mirlas, Zebbi and 12 guests