PixelRebirth's Forum Posts

  • If I understand this correctly, using the execute javascript action of the browser object should do the trick. Have you tried that already?

  • PixelRebirth

    But wouldn't you just be linking the player to this URL if not edited?

    "http://moregames.differencegames.com"

    But then again I guess FGL would decline the game if we did edit the file.

    Yes, sure. I don't know if that's a placeholder URL and FGL will replace it, in which case it probably wouldn't matter if you edited it first.

    It should end up linking to their crosspromotion system somehow, so editing the URL doesn't make sense anyway, because this function is not for linking to your own site or a site of your choice. As I understand it of course. <img src="smileys/smiley2.gif" border="0" align="middle" />

    Also it might not be such a good idea to send your direct html5 export to fgl. I'm not claiming that they steal or anything but I think it might be best to have your scripts obfuscated so sponsors or companies would have a harder time to steal and edit the game. Since minify doesn't work I guess i'll have to manually edit my scripts so they look like a bunch of jargon. Unless someone can fix the minifying issue with the fgl plugin.

    Any takers?

    Why use the plugin at all? You can minify just fine with the way I described earlier (use the execute javascript action of the browser object). Any problems for you with that method?

  • Also for the "more games" option you'll have to edit the link on the fgl.js file to change the url into your URL otherwise you'll link to some useless annonymous site. But once again the showAd is the only thing you really need.

    I don't think you are supposed to edit anything there. This is from the documentation:

    When tapped, this button will display an overlay which will cross

    promote other games in our network. By implementing the

    cross promotion system, you will also take advantage of this

    free traffic.

    The button should invoke the following code:

    f g l . s h o w M o r e G a m e s ( ) ;

    So it is my understanding that by editing the URL you'll break the cross promotion and won't be compliant with the API anymore.

  • I have come to the conclusion that a plugin isn't really needed if you're just going to use the ads, show more games and maybe send the score.

    You can do all this simply with the execute javascript action of the browser object. You'll just put "fgl.showAd();" or "fgl.showMoreGames();".

    Of course you need to exchange the index.html for the exported game (which you also would need to do when using the plugin). And also put the fgl.js file in the game folder (one thing the plugin would do for you). You can download a working index.html file that uses the onReady function by clicking here.

  • Just tried it for myself and the game does load with the onReady function. It looks like this:

    <script>
         var element = document.getElementById('c2canvas');
            
            fgl.create(element, 'com.fgl.mygame');
            
            fgl.onReady(function(){
                loadGame();
                   
            });
         
         var loadGame = function() {
              // Size the canvas to fill the browser viewport.
              jQuery(window).resize(function() {
                   cr_sizeCanvas(jQuery(window).width(), jQuery(window).height());
              });
              
              // Start the Construct 2 project running on window load.
              jQuery(document).ready(function ()
              {               
                   // Create new runtime using the c2canvas
                   cr_createRuntime("c2canvas");
              });
              
              // Pause and resume on page becoming visible/invisible
              function onVisibilityChanged() {
                   if (document.hidden || document.mozHidden || document.webkitHidden || document.msHidden)
                        cr_setSuspended(true);
                   else
                        cr_setSuspended(false);
              };
              
              document.addEventListener("visibilitychange", onVisibilityChanged, false);
              document.addEventListener("mozvisibilitychange", onVisibilityChanged, false);
              document.addEventListener("webkitvisibilitychange", onVisibilityChanged, false);
              document.addEventListener("msvisibilitychange", onVisibilityChanged, false);
         };
              
        </script>
    

    You may have some typo in your version.

  • Seems you're missing a semicolon at the end of each script block. Or did you paste it incorrectly?

    <!-- The runtime script. You can rename it, but don't forget to rename the reference here as well.
        This file will have been minified and obfuscated if you enabled "Minify script" during export. -->
         <script src="c2runtime.js"></script>
         <script>
           var element = document.getElementById('c2canvas');
           fgl.create(element, 'com.fgl.gamename');
            //fgl.onReady(function(){loadGame();}<font color=red>;</font>
         </script>
          
        <script>
              // Size the canvas to fill the browser viewport.
              //var loadGame = function() {
              jQuery(window).resize(function() {
                   cr_sizeCanvas(jQuery(window).width(), jQuery(window).height());
              });
              
              // Start the Construct 2 project running on window load.
              
              jQuery(document).ready(function ()
              {               
                   // Create new runtime using the c2canvas
                   cr_createRuntime("c2canvas");
              });
              
              // Pause and resume on page becoming visible/invisible
              function onVisibilityChanged() {
                   if (document.hidden || document.mozHidden || document.webkitHidden || document.msHidden)
                        cr_setSuspended(true);
                   else
                        cr_setSuspended(false);
              };
              
              document.addEventListener("visibilitychange", onVisibilityChanged, false);
              document.addEventListener("mozvisibilitychange", onVisibilityChanged, false);
              document.addEventListener("webkitvisibilitychange", onVisibilityChanged, false);
              document.addEventListener("msvisibilitychange", onVisibilityChanged, false);
              //}<font color=red>;</font>
        </script>
         
    </body> 
    </html> 
    
  • PixelRebirth I don't know how to make the game start.

    In the example provided, in index.html:

    fgl.onReady(function(){

                new FGLNinja(element).boot();

    }

    Now in construct 2 I didn't found an equivalent of boot function to start the whole game.

    At the bottom of the exported index.html file there is the script which starts the game.

    You can enclose that script in a function

    var loadGame = function() { SCRIPT HERE };

    then it should work:

    fgl.onReady(function(){

                loadGame();

    }

    Let me know how it goes.

  • I hope you can figure it out how to do it.

    EDIT: I think I made it:

    ht*ps://w*w.scirra.com/tutorials/790/implement-fgl-html-5-api-in-construct-2

    That looks good!

    I'm just not sure you took care of the fgl.OnReady function. The game should only be started via the callback there. FGL might reject the game if that part doesn't work like described in the documentation.

    So just add that to what you already have in the index.html and you should be good.

  • I started looking into the plugin today. I don't think you can include the create function in the plugin itself, because according to the documentation that stuff is supposed to happen before the actual game is being started.

    This requires manipulation of the index.html file. I did something similar when I adjusted a game for the softgames API, which also required to initialize before the actual game is started.

    Will get further into this now and tell you guys more in the next few days. I think it should work out fine. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • PixelRebirth Ah-oh teach me nao! Jk:)

    Actually, I'd really appreciate if you could point me in a right direction:

    1)Do you have a single Array? Is it 2d or 3d?

    And if it's 3d.. how "deep" is your array? (ouch this might sound wrong:P)

    2)Do you use recursion? Functions or just events&loops?

    Thanks in advance^^

    1) I do have a couple of arrays. One for the playfield which is 3d with a depth of 2. It has an additional layer for marking blocks to be destroyed so to speak.

    The second array is 1D and being used dynamically. Sort of a queue or tasklist. Basically the game checks this array for entries, calls that function and removes the entry afterwards. If theres nothing left to do the player may interact again.

    2) Functions of course. I would argue they are essential for any serious game made in C2. Without them you will end up getting clunky and overcomplicated events for sure.

    There are also loops and recursive functions, so yeah. You'll end up using all of that naturally. <img src="smileys/smiley2.gif" border="0" align="middle" />

  • PixelRebirth I totally agree:)

    It's just me, as a novice in C2 and general programming, always trying to "roll my own" solution instead of using examples:P

    Sometimes useful, mostly- complete waste of time^^

    Understandable! <img src="smileys/smiley1.gif" border="0" align="middle" />

    I still prefer to use my own array-based Match-3 engine as well.

  • Hey Joannesalfa,

    would you mind sharing your plugin with me so I can have a closer look?

  • You really should either go with arrays or use rexrainbows set of plugins (which come with capx examples btw).

  • I found this tutorial about Yepi API:

    ht*ps://w*w.scirra.com/tutorials/727/implementation-of-the-yepi-mobile-api#h2a3

    Maybe you can PM the developer of this plugin to do the same for FGL SDK.

    I can't PM.

    Hey, someone did send me a mail about the creation of a FGL plugin (I made the Yepi plugin). <img src="smileys/smiley1.gif" border="0" align="middle" />

    Don't know if this has been resolved already, but without having really looked into it yet, it seems to me you are missing a js file dependency here.

    I will take a closer look in the next few days though for sure.

  • This year there has been a flood of affordable game bundles and sales, which is a great thing if you are a pc gamer.

    On the downside you will end up with duplicate copies of games eventually. I usually distribute them among my friends, but in the spirit of christmas I want to make my current giveaways available to the cool community here at scirra.

    I'm giving away the following steam redeemable games via steamgifts.com:

    Sanctum 2

    Serious Sam 3: BFE

    Trine 2: Complete Story

    Alan Wake Franchise

    Br?tal Legend

    Fear 3

    All you have to do to enter is join my steam group. If you join please leave a comment in the group with your nickname here on the scirra forum. And please do not make a new forum account just to join in. <img src="smileys/smiley9.gif" border="0" align="middle">

    Also be aware that these are steam games and you will need a steam account to enter the giveaways, redeem the game key and play the game.

    Thank you all, merry christmas and good luck!