Implement Spilgames API

0 favourites
  • Hi, I need to implement Spilgames API but I'm having a lot of trouble making it work.

    Here's the API: dropbox.com/s/l0wpiz2v2q0y690/spilgames_game_api%5B1%5D.pdf

    It's just two functions.

    I add the script tag to my exported index.html but I can't make the functions work with Execute Javascript.

    I'm not minifying the project.

    Can any of you guys help me with this?

  • i have the same question. Hope someone did it.

  • Same here, please let me know if you guys find a way to make this.

  • Have received a PM about this API.

    From briefly looking at the documentation I think this should be indeed possible with execute javascript and a little editing of the index.html file.

    Will look further into it as soon as possible and let you know.

  • PixelRebirth You are great! Thanks for helping.

    I have tried execute javascript and adding script in index.html but since I am noob at programming I couldn't make it.

    I guess we all need just in-game-ads part of the api.

    I will keep trying and if I manage to do it, I will let you know guys.

  • Holy cow, I was actually already contacted earlier by skyhunter93, but I kind of forgot all about it. <img src="smileys/smiley9.gif" border="0" align="middle" />

    We had a brief exchange over Skype and he said he was about to realize the implementation himself. I hope he succeeded in the meantime and would be so kind to share his approach.

    I think the problem was with the request(fnPause, fnResume) method. You need to define the functions fnPause and fnResume yourself and have them pause and resume the C2 game.

    A way to do this would be to create these functions in an additional js file or in a script tag in the index.html itself. Make them simple functions that change a variable, also defined in the same js file/script.

    Now in Construct you can actually compare the value of this variable with the Browser.ExecJS() expression. Just put "variablename" there. And obviously use it in a Compare two values condition of the System object.

    I imagine that should work, keep asking if there's anything yet unclear.

    I do believe skyhunter93 was creating a plugin btw, which could be ready by now. Don't see him on Skype right now, but maybe he will come back to this thread.

  • Hi! I My game is passing Spilgames Q&A right now so I'm not sure if it is working perfectly, but I found a method to do it. I'm at my ipod right now, so I'll post the implementation when I get home!

  • Hey PixelRebirth

    I have tried something like that >

    I added those in index.html

    <script type="text/javascript"

    src="http://cdn.gameplayer.io/api/js/game.js"></script> ( before </head>)

    and

    <script>

         //Spil Api

         GameAPI.loadAPI(function(API) {

    GameAPI.GameBreak.request(fnPause, fnResume);

    });

    var apiTry= 2;

    function fnPause()

    {

    var apiTry = 0;

    }

    function fnResume()

    {

    var apiTry = 1;

    }

    </script> (after <script src="c2runtime.js"></script> )

    Also I have added those in capx.

    <img src="http://new.tinygrab.com/bd08b53d3f72a32d77a05e99619f2c09321047a8e2.png" border="0" />

    After all there is no error in console and when I tried apiTry = 0 and apiTry=1 it works. But there is no ads or anything.

  • skyhunter93 Great news! Thanks a lot :D

  • yahooo!

  • Hey PixelRebirth

    I have tried something like that >

    I added those in index.html

    <script type="text/javascript"

    src="http://cdn.gameplayer.io/api/js/game.js"></script> ( before </head>)

    and

    <script>

         //Spil Api

         GameAPI.loadAPI(function(API) {

    GameAPI.GameBreak.request(fnPause, fnResume);

    });

    var apiTry= 2;

    function fnPause()

    {

    var apiTry = 0;

    }

    function fnResume()

    {

    var apiTry = 1;

    }

    </script> (after <script src="c2runtime.js"></script> )

    Also I have added those in capx.

    <img src="http://new.tinygrab.com/bd08b53d3f72a32d77a05e99619f2c09321047a8e2.png" border="0" />

    After all there is no error in console and when I tried apiTry = 0 and apiTry=1 it works. But there is no ads or anything.

    Just wanted to mention that in your script you keep declaring the variable apiTry every time. Actually it should just say "apiTry=value;" when you want to change it again. You only have to put "var apiTry=value;" one time.

    Also I'm not sure if you just did this for testing purposes, but I noticed you put "GameAPI.GameBreak.request(fnPause, fnResume);" in the loadAPI method. Normally you should call this from within C2 whenever you want to show an ad and not when the API is readily loaded.

    I also made a similar test on my localhost and didn't get any javascript errors either. And no ad either. I observed that you only ever get the fnResume callback, never fnPause, but this might be because it was on localhost. Also the branding thing seems to return "0" every time.

    This might be because the game has to be on their platform servers to work. I've used a couple of APIs before and usually they have some sort of online testing environment, it wouldn't work locally. Some do have a special script for testing locally too, which is nice.

    I really don't know about spilgames. Registering with them as a developer just gives you access to flash related stuff. Including such an online tester.

    Probably just wait for what skyhunter93 will report. <img src="smileys/smiley4.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
  • I'm making a example capx right now but in the meantime:

    Here's a little plugin I made:

    dropbox.com/s/nuf5zq2dv3jwtgt/spilgames.zip

    The only thing it does is adding the spilgames API to the index.html so you don't have to add it manually each time you export your project. It's a huge time saver.

    I talked with spilgames and they said that the ads are not showing right now because their API isn't complete right now and are testing things. So there is no way for us to test it right now. I suppose they use a local environment on their side to test the ads.

    Actually my implementation is pretty similar to the one bilgekaan did. but you are now seeing the ads because of what I said.

  • I'm making a example capx right now but in the meantime:

    Here's a little plugin I made:

    https://www.dropbox.com/s/nuf5zq2dv3jwtgt/spilgames.zip

    The only thing it does is adding the spilgames API to the index.html so you don't have to add it manually each time you export your project. It's a huge time saver.

    I talked with spilgames and they said that the ads are not showing right now because their API isn't complete right now and are testing things. So there is no way for us to test it right now. I suppose they use a local environment on their side to test the ads.

    Actually my implementation is pretty similar to the one bilgekaan did. but you are now seeing the ads because of what I said.

    Ah, so the ads don't show on localhost as I suspected. This leads me to believe that bilgekaan's implementation and mine would also work fine.

    If you're worried about having to alter the index.html each time, you could simply keep a second already altered index file around, called index2.html so it won't get overwritten.

    Just don't forget to use the altered one and rename it back to index.html when you're submitting your game.

    If that's still too inconvenient I believe the CallJS plugin has a property to set an external javascript file. So that could likely be used to include any script and you wouldn't need a custom plugin just to include a specific one.

    EDIT: If you use a plugin dependency to include a javascript file, the tag to include the file will not be placed in the head of the index.html file.

    This can become relevant, because some APIs demand that the script be included in the head tag of the html document. I had the case that my implementation got rejected simply because the reference to the script wasn't within the head tag.

    However the spilgames API documentation just recommends to put it in the head, so you should be fine in this case. I still thought I'd mention this odd thing. <img src="smileys/smiley12.gif" border="0" align="middle" />

  • PixelRebirth thanks for helping. Can you post your implementation example please ? I think you made more proper implementation than mine.

    skyhunter93 thanks for the plugin! I will wait your example and please let me know Spil's QA result.

  • bilgekaan Basically there isn't really much difference between my version and yours.

    Apart from the things I mentioned I did also only allow the game itself to load when the API was ready. However this isn't even a requirement for this particular API, so you can neglect that part.

    I almost overlooked earlier that skyhunter93 used a local version of the API script file to go with the plugin. This might work fine, however in the API documentation it states that you should include the script from the provided URL.

    Technically this does not comply with the requirements of the API anymore. Maybe it won't matter after all. Skyhunter93 should know soon. <img src="smileys/smiley17.gif" border="0" align="middle" />

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