Juanito-cnstrct2's Recent Forum Activity

  • vikerman : very nice video. Did you add a comment to the lines you changed in c2runtime.js so that we can find them, or should I just do a diff on them?

    Thanks!

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

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have looked into that before, trying to use the C2 behaviours in Unity.

    Unity's javascript is not the web's javascript. One of the main differences are prototypes, Unity's javascript does not support them.

    So, yes, like Ashley said, it would require some major rewrite.

  • I read Ashley's really good article at m.netmagazine.com/tutorials/make-your-javascript-apps-smoother . He suggested avoiding creating objects too often in Javascript.

    My question is, at a higher level, in Construct2, should we also be avoiding creating/destroying too many sprites on the fly and instead have a "pool" of them that we can re-use?

    A good example are bullets, which get created and destroyed very often.

    Obviously the answer might be "depends", I just wanted to make sure there is nothing in the Construct2 engine already doing the "pooling" of sprites and objects for us.

    Thanks!

  • I have an ARM surface tablet (WinRT)

  • shreedharcva thank you! that helped me fix my Win8 game that also uses the TMX importer.

  • dusoft : probably not because it uses the same techniques as the official plugin.

  • I have not tested windows 8 rt, but it works on chrome on win 8 desktop version

  • I ran the space blaster game at bestbuy on a vivo rt tablet. It did not go above 8 fps. However the yoga tablet (x86) had absolutely no problem staying at 60 fps.

  • I am working on making Construct2 work with Ejecta. So far a was able to get a primitve C2 game that displays text, moves a box with 8-dir behaviour and touch input (http://www.scirra.com/forum/topic60309.html). The nice thing with Ejecta is that it is open source and has some GameCenter support already, so in theory you could add your own JS bindings/plugins using Objective-C.

    Performance-wise is about the same as directcanvas.

    Best of all, vikerman is working on adding webgl support to Ejecta. If people help him, he might be able to complete the webgl implementation.

  • Never mind, I was able to make a simple C2 game work in Ejecta.

    I had to do the following:

    1. export as Html5 game

    2. Modify 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. always return true in areAllTexturesLoaded. The loading progress logic did not work for me in Ejecta. As a ugly work aorund I just set it to return true. Obviously, this could create problems for games that load a lot of textures.

    3. Create 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');

    Please see Ejecta documentation for additional steps required for ejecta to work in Xcode.

    As Ashley said, you need a mac to use Ejecta, but then again, you need a mac anyways when uploading the final version for publishing in the app store.

    For me the biggest advantage of Ejecta over Cocoon or AppMobi is the already available integration with GameCenter. other than that, I think they perform the same. The other biggest possible advantage would be WebGL if vikerman is able to complete his amazing Ejecta webgl bindings.

Juanito-cnstrct2's avatar

Juanito-cnstrct2

Member since 26 Apr, 2010

Twitter
Juanito-cnstrct2 has 1 followers

Trophy Case

  • 14-Year Club
  • Email Verified

Progress

15/44
How to earn trophies