Implement Spilgames API

Get help using Construct 2

Post » Tue Feb 11, 2014 7:08 pm

@PixelRebirth,

Is there an api call to check to see if the API has loaded? That way we can check to see if the api loaded before doing the other calls?

Thanks for all the work.
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Tue Feb 11, 2014 7:32 pm

Ok, I got all three greens. Here is what I did.

I used Pixel's plugin, but didn't load the api from it, did that in the index.html file



Then used the plugin to call Get Logo on the start of layout for my title screen.

After the user hits play, my game has a window with instructions. At this point I requested Ads (on start of layout). Since my game is already paused and waiting for use input it was a good spot to call the ad. I could also call it when the level is over.



I'll contact spillgames now and see if any of my games fit in with their network.

Thanks for all the hard work on this thread!!!ArcadEd2014-02-11 19:33:09
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Mon Feb 17, 2014 8:25 am

@ArcadEd: Thanx dude.. thanx for the image tutorial. it made my game turn green the API Loaded and In-Game Ads call. However, I am not getting when to call the branding logo event. Can you please tell me where and on which event you called the GetLogo call ??
B
6
S
2
G
1
Posts: 77
Reputation: 708

Post » Mon Feb 17, 2014 1:42 pm

On the Start of Layout for my title screen.
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Mon Feb 17, 2014 5:39 pm

SPIL gave me a GGG.com logo image and wanna implement it to the game using their API. So I wonder I if just only used the Get Logo action of PixelRebirth's plugin or had to do any other steps for showing the clickable logo?

I think that we could use both of the plugin for a well testing result and placing the logo to the game manually. But I don't sure about it.. :(Iris2014-02-17 17:51:08
B
6
S
1
G
1
Posts: 39
Reputation: 828

Post » Mon Feb 17, 2014 6:58 pm

[QUOTE=ArcadEd] @PixelRebirth,

Is there an api call to check to see if the API has loaded? That way we can check to see if the api loaded before doing the other calls?
[/QUOTE]
There isn't yet. But I plan to have at least an expression covering this in version 1.0 of the plugin.

[QUOTE=Iris] SPIL gave me a GGG.com logo image and wanna implement it to the game using their API. So I wonder I if just only used the Get Logo action of PixelRebirth's plugin or had to do any other steps for showing the clickable logo?

I think that we could use both of the plugin for a well testing result and placing the logo to the game manually. But I don't sure about it.. :([/QUOTE]
The "Get logo"-action is in place to dynamically get logo data (image url and link). Likely used for having one version of the same game on their various portals (different logos)and in case they change the logo.

Anyway - if Spil provided the logo just go ahead and add it manually in C2 I guess. I hope I understood your issue correctly.
B
23
S
6
G
11
Posts: 1,047
Reputation: 8,065

Post » Mon Feb 17, 2014 8:14 pm

Hmmm, seems like an intersting topic, so allow me to barge in (:

@PixelRebirth
To me the way you use the GameAPI.loadAPI() is wrong, the aim of this function is to provide a "trigger" for when the API is loaded
So you should probably create an OnLoaded trigger instead of having a function that just call the loading.
It's like saying "Send this AJAX request and.... blah"

The way you should be able to do that is:
[code]     instanceProto.onCreate = function(){
          this.API = null;
          this.gamePaused = false;
          GameAPI["loadAPI"](function(API) {
              this.API = API;
              this.runtime.trigger(cr.plugins_.pix_spilgames.prototype.cnds.OnLoadAPI, this);
          });
     };[/code]
with the corresponding condition just returning true
[code]     Cnds.prototype.OnLoadAPI = function () {
          return true;
     };
        // and because we can:
     Cnds.prototype.isAPILoaded = function () {
          return this.API != null;
     };[/code]
This way the C2 user can start doing things here.

The same way, you should probably provide triggers for OnGamePaused, OnGameResumed
[code]     Acts.prototype.RequestAd = function ()
     {
          // alert the message
          //GameAPI.GameBreak.request(fnPause, fnResume);
          GameAPI["GameBreak"]["request"](
              function() {
                    // pause
                    this.gamePaused = true;
                    this.runtime.trigger(cr.plugins_.pix_spilgames.prototype.cnds.OnGamePaused, this);     
              },
              function() {
                    // resume
                    this.gamePaused = false;
                    this.runtime.trigger(cr.plugins_.pix_spilgames.prototype.cnds.OnGameResumed, this);     
              }
          );
     };[/code]
With the corresponding

[code]     Cnds.prototype.OnGamePaused = function () {
          return true;
     };
     Cnds.prototype.OnGameResumed = function () {
          return true;
     };
        // why not
     Cnds.prototype.isPaused = function () {
          return this.gamePaused ;
     };[/code]

With all that you shouldn't need to put anything in typeProto.onCreate

And please, note that it's on the top of my head and that I dunno too much about how spilgames works, but It should work :DYann2014-02-17 20:17:04
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Post » Mon Feb 17, 2014 11:10 pm

@Yann
Great! I knew I had to start using proper triggers where appropriate, but to be frank I would have had to yet look into it. My actual coding skills are still... in development :)

Seems you laid it all out for me here. This is obviously much better and I shall adapt it right away in the next version. So thank you for that!

One thing I did intentionally was making the GameAPI.loadAPI() an action and not be executed at "onCreate". The idea was to keep full control and load the API at a later point if necessary. But I realize that case might not be very realistic anyway. If you add the plugin you probably want to load the API asap...

Anyway, thanks for your detailed post! Will help to improve the plugin a lot.PixelRebirth2014-02-17 23:11:24
B
23
S
6
G
11
Posts: 1,047
Reputation: 8,065

Post » Tue Feb 18, 2014 10:17 am

@PixelRebirth
Actually you could still implement your idea.
For example you could have an autoload property in edittime you could set to yes or no
You can get this property on create, if it's true you load the plugin and the trigger will be... triggered (as I did it)
If it's false the user can still call the load action (as you did) and there you would provide a callback that will call the trigger (instead of an empty function)

However, doing that you give the possibility to the user to load the API more than once... And I'm not sure that in the end it would be a good design choice (not sure what would happen either)

So yeah, in the end I would stick with auto loading it. (Yeah I'm thinking while typing)
B
68
S
22
G
14
Posts: 1,485
Reputation: 16,561

Post » Thu Feb 20, 2014 11:32 pm

Wow. This is great work. Has there been any updates to this @PixelRebirth?
B
44
S
5
G
5
Posts: 412
Reputation: 5,771

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests