Juanito-cnstrct2's Forum Posts

  • Hello all! long time not posting <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> . Has anybody already tried to create typescript definitions for parts of the construct2 sdk, like the shared properties of the instances (like the ones documented in https://www.scirra.com/manual/25/sdk-reference)?

    I am just asking because I have been working on a new plugin using typescript and before I do my own type definitions I wanted to see if somebody has already done some work in that area.

    I heard rumors that C3 was built using TypeScript but this question is for C2.

    Thank you!

  • I don't have the exact version with me, ( I think I uninstalled it). It was the version back in mid 2012. So about 2 years ago.

  • The Q3D plugin is probably better written than this one. The freeze you are experiencing might be due to a lot of vectors being created. Out of ignorance at tge time, I did not apply some javacsript best practices on memory management.

    Reken : yes, I created the scene using coppecube (the version from 2013 I think). I don't have the latest version of coppercube (expensive) but I would guess the problems you are seeing are due to the copperlich.js library used in the plugin being too old for your scene. If you know javascript, You could try replacing the copperlicht library in the plugin with the library that gets exported in your coppercube scene (i think the file is called copperlicht.js)

  • Did you try the examples from the official tutorial or some other 3rd party example?

  • Fersis , the transparency setting should be in your layer properties (https://www.scirra.com/manual/85/layers). I only had one layer, so I only had to set one layer to "transparent".

  • irina : nope, But the plugin should work in its current functionality. You are more than welcome to fork the plugin and develop more stuff with it. One think I think it needs is a rewrite of some of the functions that create too many vector objects on the fly.

  • Wow, Ejecta is getting better and better every day. 0plus1 has done a great job on the unofficial exporter . Too bad I had to cancel my apple dev account ( had a second kid, no time for hobby programming) . Great work everybody! Hopefully this will become an official exporter when I come back to the apple dev program.

  • dunkin Chery : there is now an official websocket plugin, so I don't work on this plugin anymore. However, to answer your question in theoretical terms:

    1. Use the official websocket to send the position of the platform player every so often (15 times a second maybe?)

    2. You can choose the format of sending that data. I would use a letter representing the command (P for position) followed by a comma separated value pair representing X and Y (e.g.: "P",10","302").

    3. Code your node server (you will need non-c2 coding skills for this) to receive the position ("P","10","302") and then sends it to all the other connected clients (other players) with an extra parameter appended that represents the internal ID of the player (e.g.: "P",10","302","1").

    4. On the client side (C2 game) have a OnReceive event when you determine the type of command by spliting the string on commas. So if the first part of the string is P then you know is to update position so pick the sprite with the id of 1 and set its x,y to 10,302.

  • JonathanCastro : I don't know I have not test it wioth those. I no longer work in this plugin. I left it here in case another plugin developer wanted to get the source.

  • I made this app using C2 for the Windows App Store:

    apps.microsoft.com/windows/en-us/app/babysee/c15e9773-bd70-4949-bf39-7d63f6181b6c

    I really like how easy it was to export to Windows 8 compared to iOS.

  • Thanks to vikerman, I was able to get Space Blaster running on webgl in ios using Ejecta (latest build from GitHub). It feels faster than the ejecta canvas version I did before. The TileBackground plugin now works perfectly. I was also able to use the radial blur effect when one of the enemies hit. Hopefully, it is clear in the video when the effect takes place. The youtube video is at

    Subscribe to Construct videos now

    To make it work, I did a diff on Vikerman's work and was able to identify where in the c2runtime.js file you need to make changes for webgl to work on ios with ejecta (no need to do the changes shown in the 1st post of this thread, that is for canvas):

    1. In GLWrap_.prototype.loadTexture remove the last parameter in hte function declaration, so that it reads:

         function (img, tiling, linearsampling, pixelformat) //jpt

    2. In GLWrap_.prototype.loadTexture after gl.texImage2D(gl.TEXTURE_2D, 0, internalformat, format, type, img);

    the following if condition needs to be removed:

    if (tiling)

              {

                  ?if (tiletype === "repeat-x")

                  ?{

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

                  ?}

                  ?else if (tiletype === "repeat-y")

                  ?{

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);

                  ?}

                  ?else

                  ?{

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);

                        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);

                  ?}

              }

              else

              {

                  ?gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);

                  ?gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

              }

              

    and replaced with:

              

              

              gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, tiling ? gl.REPEAT : gl.CLAMP_TO_EDGE); //jpt tiling restructured

              gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, tiling ? gl.REPEAT : gl.CLAMP_TO_EDGE);//jpt tiling restructured, replaces the if(tiling) part

    4. In function Runtime(canvas) add

         this.isEjecta = !!window["ejecta"]; //jpt

              

    after this line

         this.isCocoonJs = !!window["c2cocoonjs"];

    5. Replace

              this.isDomFree = this.isDirectCanvas || this.isCocoonJs;

    with

              this.isDomFree = this.isDirectCanvas || this.isCocoonJs || this.isEjecta; //jpt

    6. also in same function, replace the following:

         if (typeof jQuery !== "undefined" && this.fullscreen_mode > 0)

                  ?this["setSize"](jQuery(window).width(), jQuery(window).height());

                  ?

    with

              if (typeof jQuery !== "undefined" && this.fullscreen_mode > 0 && !this.isEjecta)

                  ?this["setSize"](jQuery(window).width(), jQuery(window).height());

                  ?

    7. In the next "if", replace it with:

         if (this.enableWebGL && (!this.isDomFree || this.isEjecta)) //jpt

    8. Surround the following code with an if for ejecta:

                  ?jQuery(this.overlay_canvas).appendTo(this.canvas.parentNode);

                  ?this.overlay_canvas.oncontextmenu = function (e) { return false; };

                  ?this.overlay_canvas.onselectstart = function (e) { return false; };

                  ?this.overlay_canvas.width = canvas.width;

                  ?this.overlay_canvas.height = canvas.height;

                  ?this.positionOverlayCanvas();

                  ?

    so it should read:

                  ?if (!this.isEjecta)

                  ?{

                  ?jQuery(this.overlay_canvas).appendTo(this.canvas.parentNode);

                  ?this.overlay_canvas.oncontextmenu = function (e) { return false; };

                  ?this.overlay_canvas.onselectstart = function (e) { return false; };

                  ?this.overlay_canvas.width = canvas.width;

                  ?this.overlay_canvas.height = canvas.height;

                  ?this.positionOverlayCanvas();

                  ?}

    9. Add the check in Runtime.prototype.go:

    replace:

         if (this.overlay_canvas)

    with:

         if (!this.isEjecta && this.overlay_canvas) //jpt

              

    10. In Runtime.prototype.go_textures_done:

    add a check around this.canvas.parentNode.removeChild(this.overlay_canvas) :

                  ?if (!this.isEjecta)//jpt

                  ?{

                        this.canvas.parentNode.removeChild(this.overlay_canvas);

                  ?}

    11. also, in the same function, add check to

         if (this.fullscreen_mode >= 2) :

    So it should read:

         if (!this.isEjecta && this.fullscreen_mode >= 2)

         

    The XCode project for the Space Blasters using WebGL with the modified c2runtime.js file is at http://sites.google.com/site/jptarqu/downloads/SpaceBlastersWebGL-ejecta-xcode.zip?attredirects=0&d=1

    By the way, I only wanted to test WebGL in this space blaster version so I left out the GameCenter actions/events I did for my previous experiment. The GameCenter should work even if you use webgl. Also, note that in order to keep good performance on your mobile game, you need to still follow the general guidelines for mobile that have been floating around in this forum, i.e.: not drawing more than 3 times into a pixel, keep physics object count low, use tiled backgrounds instead of sprites when possible, etc.

  • Incompatible plugins:

    • "TMX importer" by Rexrainbow
    • Any other plugin that relies on an XML parser
    • Tiled Backgrounds render as black
  • 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).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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)