PixelRebirth's Recent Forum Activity

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

  • Try Construct 3

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

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

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

PixelRebirth's avatar

PixelRebirth

Member since 26 Mar, 2008

Twitter
PixelRebirth has 1 followers

Trophy Case

  • 16-Year Club
  • Entrepreneur Sold something in the asset store
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

23/44
How to earn trophies