Implement Spilgames API

Get help using Construct 2

Post » Wed Jan 08, 2014 1:33 pm

[QUOTE=bilgekaan] 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.



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.
[/QUOTE]

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.
B
23
S
6
G
10
Posts: 1,041
Reputation: 7,553

Post » Wed Jan 08, 2014 4:20 pm

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.skyhunter932014-01-08 16:21:10
B
35
S
4
G
5
Posts: 84
Reputation: 4,860

Post » Wed Jan 08, 2014 8:12 pm

[QUOTE=skyhunter93] 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.[/QUOTE]

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. PixelRebirth2014-01-08 20:24:50
B
23
S
6
G
10
Posts: 1,041
Reputation: 7,553

Post » Thu Jan 09, 2014 6:52 pm

@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.
Image
B
67
S
31
G
39
Posts: 430
Reputation: 24,587

Post » Fri Jan 10, 2014 3:58 pm

@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.
B
23
S
6
G
10
Posts: 1,041
Reputation: 7,553

Post » Tue Jan 28, 2014 9:30 pm

I do not understand how install that package...
i am rather new to the use of api's and i need to add it to my game just this one you are saying.. so..
can someone explain the steps to do so?

for example you talked that you need to use the one in the page of the splitgames...how do i do that or the other..

do i have to manually touch the html once its ready?

and what did you mean about do it when its all loaded.

please answer me or send a pm...
B
5
S
1
Posts: 23
Reputation: 421

Post » Wed Jan 29, 2014 12:05 am

Finally managed to install the package of this link.

[QUOTE=skyhunter93] I'm making a example capx right now but in the meantime:
Here's a little plugin I made: (i didn ot have permisions but is the same that skyhunter93 set).
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.[/QUOTE]

but still not sure of what it does or how to use it..
will it also make the functions needed to stop and resume?

and if so what are the names of the variables?

if i have to do that part what file do i have to open to add it?
do i have to open after presenting and making all the game?

(ignore my first request as its obsolete but could not remove it)
B
5
S
1
Posts: 23
Reputation: 421

Post » Thu Jan 30, 2014 4:49 am

@PixelRebirth @skyhunter93 @bilgekaan Have any of you managed to get this working and have it successfully submitted to them? I am in contact with them, but before I submit I want to make sure that it actually works :)
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Thu Jan 30, 2014 9:53 pm

I think skyhunter93 should have the proper feedback from Spilgames by now, but he doesn't seem to be around.

Unfortunately I will also have to submit my game without knowing if the implementation will work properly and be accepted.

@stelarfox Actually all the information is available in this thread if you read the posts carefully.
B
23
S
6
G
10
Posts: 1,041
Reputation: 7,553

Post » Fri Jan 31, 2014 7:15 am

Hey guys my game is at QA right now.

After the QA I will tell you how it goes.
Image
B
67
S
31
G
39
Posts: 430
Reputation: 24,587

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests