[Experiment] Construct2 with Ejecta and GameCenter

0 favourites
  • 14 posts
  • 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:

    youtube.com/watch

    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:

    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 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 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 don?t 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 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 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 don?t 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)

  • 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!

  • 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)

  • 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).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm testing. So far I discovered that (surprisingly) spritefonts doesn't work.

  • 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.

  • 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.

  • 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.

    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.

  • 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.

  • 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).

  • 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.

    OpenFeint is now out of buisness. I won't disagree about the bugginess. However Austin is always keen on getting "required' features and bug fixes rolled out quickly. Though I agree that the hack to get CJS working is annoying :| Clay.io does not require constant internet connection. I have a game that works off line fine. However the Clay.io services I do agree seem to be online only for now, but talks have been done to getting Clay.io to be off line as well. But Again I do not disagree that Game Centre is more robust at this time. It's just Clay.io at the moment is the only alternative to cross platform for JS gaming features :).

    en.wikipedia.org/wiki/OpenFeint

    Shutdown as Dec 4 2012

    Jauntar

    Do you think it could be something to do with the first frame rendering. Because it seems weird that an object has to move first before it's rendered.

  • Regarding the offline capabilities of clay.io, Austin confirmed it was very hi on the to-do list. scirra.com/forum/plugin-clayio-leaderboards-achievements_topic54357_page31.html

    It is mentioned a number of times

  • jayderyu wow didn't know about openfeint, it's just sad.

    The issue I have with clay.io is the non-compliance with Apple requirements. They are all fixable with a little bit of work on our part, but why do this when there is Game Center and its awesome functions that work offline? Also Game Center on iOS is a very very big factor in sales, putting a game without GC support is almost sure to be a failure. It has become a REQUIRMENT for iOS games.

  • Offline support is a work in progress :) I'll crank out some more work on it tonight, but can't say for sure when it will be 100% ready to go.

    I haven't played around with Ejecta yet, but from my understanding it doesn't currently support a webview for overlaying the UI elements (like DirectCanvas and CocoonJS do), so it would have to rely completely on the DOMless version of the API (http://clay.io/api/api-domless.js)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)