Implement Spilgames API

Get help using Construct 2

Post » Mon Dec 16, 2013 10:09 pm

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

Here's the API: https://www.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?skyhunter932013-12-16 22:10:16
B
35
S
4
G
5
Posts: 84
Reputation: 4,860

Post » Thu Dec 19, 2013 9:34 pm

i have the same question. Hope someone did it.
B
7
S
2
Posts: 15
Reputation: 634

Post » Mon Jan 06, 2014 6:56 pm

Same here, please let me know if you guys find a way to make this.
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,185

Post » Tue Jan 07, 2014 9:03 am

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.
B
22
S
6
G
10
Posts: 1,036
Reputation: 7,518

Post » Tue Jan 07, 2014 9:30 am

@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.
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,185

Post » Tue Jan 07, 2014 3:11 pm

Holy cow, I was actually already contacted earlier by skyhunter93, but I kind of forgot all about it.

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.PixelRebirth2014-01-07 16:01:08
B
22
S
6
G
10
Posts: 1,036
Reputation: 7,518

Post » Tue Jan 07, 2014 6:04 pm

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!
B
35
S
4
G
5
Posts: 84
Reputation: 4,860

Post » Tue Jan 07, 2014 6:13 pm

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.
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,185

Post » Tue Jan 07, 2014 6:15 pm

@skyhunter93 Great news! Thanks a lot :D
Image
B
63
S
28
G
39
Posts: 459
Reputation: 24,185

Post » Tue Jan 07, 2014 6:16 pm

yahooo!
B
7
S
2
Posts: 15
Reputation: 634

Next

Return to How do I....?

Who is online

Users browsing this forum: DharmaOne, Yahoo [Bot] and 6 guests