Biggerplay Posted February 27, 2014 Share Posted February 27, 2014 Anyone know how to do that? I've got this... GameAPI.loadAPI(function(API) { // The API is ready for use. // It can be accessed by using the "API" variable. // For example, the following call requests a branding logo: GameAPI.GameBreak.request(fnPause, fnResume);});var apiTry= 2;function fnPause(){ var apiTry = 0;}function fnResume(){ var apiTry = 1; // Create your Phaser game and inject it into the gameContainer div. // We did it in a window.onload event, but you can do it anywhere (requireJS load, anonymous function, jQuery dom ready, - whatever floats your boat) var game = new Phaser.Game(700, 600, Phaser.AUTO, 'gameContainer'); API.Branding.getLogo(); // Add the States your game has. // You don't have to do this in the html, it could be done in your Boot state too, but for simplicity I'll keep it here. game.state.add('Boot', BasicGame.Boot); // Now start the Boot state. game.state.start('Boot');}The ad test shows, but then nothing, just a black screen. Link to comment Share on other sites More sharing options...
Hsaka Posted February 27, 2014 Share Posted February 27, 2014 Hi, I put it in my index.html page, but I suppose you could put it anywhere as long as you do something like this: window.onload = function () { GameAPI.loadAPI(function (API) { var myGame = new Phaser.Game(1024, 672, Phaser.AUTO, 'game'); myGame.state.add('boot', Screen.Boot, true); myGame.state.add('preloader', Screen.Preloader); myGame.state.add('gamescreen', Screen.GameScreen); }); }Then you can call GameAPI.GameBreak whenever you want to show an ad. Biggerplay 1 Link to comment Share on other sites More sharing options...
Biggerplay Posted February 27, 2014 Author Share Posted February 27, 2014 Hi, I put it in my index.html page, but I suppose you could put it anywhere as long as you do something like this: window.onload = function () { GameAPI.loadAPI(function (API) { var myGame = new Phaser.Game(1024, 672, Phaser.AUTO, 'game'); myGame.state.add('boot', Screen.Boot, true); myGame.state.add('preloader', Screen.Preloader); myGame.state.add('gamescreen', Screen.GameScreen); }); }Then you can call GameAPI.GameBreak whenever you want to show an ad. Thanks, where did you put..GameAPI.GameBreak.request(this.fnPause, this.fnResume);? Link to comment Share on other sites More sharing options...
Hsaka Posted February 27, 2014 Share Posted February 27, 2014 I put it in the create() function of my gamescreen state, so the ad shows when the game starts (it gets paused while the ad is shown). Link to comment Share on other sites More sharing options...
Biggerplay Posted February 27, 2014 Author Share Posted February 27, 2014 I've got some strange behavior going on. I've got this in the preloaderfnResume:function() { this.apiTry = true; },And I've got this as the update function in the preloader.js update: function () { if (this.cache.isSoundDecoded('titleMusic') && this.ready == false && this.apiTry == true) { this.ready = true; this.game.state.start('MainMenu'); }}I know for a fact that fnResume is called because I've put in an alert, and that is displayed correct when the ad is closed, but for some strange reason apiTry never gets seen as true by the if statement in the update function, it's almost as if the fnResume turns off the update function, any ideas? Even when I put this.ready = true; this.game.state.start('MainMenu');inside the fnResume function it still doesn't start the main menu....very weird. Link to comment Share on other sites More sharing options...
Hsaka Posted February 27, 2014 Share Posted February 27, 2014 Try this:GameAPI.GameBreak.request(this.fnPause.bind(this), this.fnResume.bind(this)); Biggerplay and delta9 2 Link to comment Share on other sites More sharing options...
Biggerplay Posted February 27, 2014 Author Share Posted February 27, 2014 Try this:GameAPI.GameBreak.request(this.fnPause.bind(this), this.fnResume.bind(this)); Yay it worked , what does bind do? Also how do you useAPI.Branding.getLogo();To display their logo? is that meant to automatically put their logo on the screen ? or am I meant use the data included in the returned object somehow? This is the object it's meant to return{height: 50image : "http://www.url-link-pointing-to-default-image-logo.com/default-logo.png",link : "http://www.url-link-pointing-to-default-Spil-Games-portal.com",type : "png",mime : "image/png",scale : 1style : "margin-left:10%;margin-bottom: 25%;height: 10%;"width : 202}But how do I use that with Phaser, to create a clickable logo? Link to comment Share on other sites More sharing options...
Biggerplay Posted February 28, 2014 Author Share Posted February 28, 2014 Anyone? just need to know how to use that object data to create a clickable logo in Phaser. Link to comment Share on other sites More sharing options...
Hsaka Posted February 28, 2014 Share Posted February 28, 2014 See here for an explanation of bind(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind I did not use that function at all. I used the branding image they provided and displayed it using a sprite. Link to comment Share on other sites More sharing options...
Biggerplay Posted February 28, 2014 Author Share Posted February 28, 2014 See here for an explanation of bind(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind I did not use that function at all. I used the branding image they provided and displayed it using a sprite. Where's there branding? couldn't find it anywhere. Link to comment Share on other sites More sharing options...
Hsaka Posted February 28, 2014 Share Posted February 28, 2014 They sent me an email with the branding package. It was for their Zibbo.com brand. You could try sending them a message if you haven't yet received it. Link to comment Share on other sites More sharing options...
LuckieLordie Posted March 4, 2014 Share Posted March 4, 2014 Anyone? just need to know how to use that object data to create a clickable logo in Phaser. If in the preloader you get the logo object and store it somewhere you can get at it. You can use the .url property to get where you need it to link to. On the subject of the API, in the docs there is this paragraph. InfoBranding is controlled at API level: the appropriate branding data is retrieved from the API, depending on the game requirements and based on the contractual agreement between the game developer and Spil Games.This means that as a game developer you don't need to worry about setting these links: the API provides the appropriate URL values for the necessary branding images and the clickable links.Therefore, it is important that you don't hardcode any links in your code. At the minute I'm getting the Zibbo branding but A10 is what I need to get. Does the paragraph above mean that it'll be sorted by them on the API level when I deliver? Link to comment Share on other sites More sharing options...
gerb Posted March 19, 2014 Share Posted March 19, 2014 At the minute I'm getting the Zibbo branding but A10 is what I need to get. Does the paragraph above mean that it'll be sorted by them on the API level when I deliver? That's correct, the branding is delivered at run-time. You can test your integration using the Spil test environment which is available at http://cdn.gameplayer.io/testtool/index.html#!/tester. Insert your game endpoint URL (can also be localhost if you prefer) and you're good to go. If you want to test with the proper branding, you should contact your Licensing contact person, or the Tech support team at http://developers.spilgames.com/contact (use the Support Tab, not the form please!). For reference, the fully updated documentation is available on http://developer.spilgames.com/wiki/Developer_Platform_-_Learning_center_-_HTML5_API_overview Link to comment Share on other sites More sharing options...
qdrj Posted April 5, 2014 Share Posted April 5, 2014 I have a problem with Spil API too. API is loaded correctly, isReady === true, but all methods aren't working correctly. Logo loading for example:console.log("SpilAPI: ", Main.spilAPI);var logoData = Main.spilAPI.Branding.getLogo();console.log("Logo data: ", logoData);We can see in console that api is loaded, Branding object available. But getLogo() return strange result - http://imgur.com/Acu4mRl HTML5 test tool shows that everything is ok too. I tested from localhost and from my server. It is not working. Can anyone help please ? Link to comment Share on other sites More sharing options...
gerb Posted April 5, 2014 Share Posted April 5, 2014 Hi qdrj, Are you sure the API has been loaded correctly? Was the loadAPI function called and did you pass a function into it, as shown in our tutorial? http://developers.spilgames.com/wiki/Developer_Platform_-_Learning_center_-_HTML5_API_-_%28Tutorial%29_Inclusion This error always occurs when the API is not loaded correctly. If you're in doubt, can you share a code snippet? Thanks. Link to comment Share on other sites More sharing options...
qdrj Posted April 5, 2014 Share Posted April 5, 2014 Hi qdrj, Are you sure the API has been loaded correctly? Was the loadAPI function called and did you pass a function into it, as shown in our tutorial? http://developers.spilgames.com/wiki/Developer_Platform_-_Learning_center_-_HTML5_API_-_%28Tutorial%29_Inclusion This error always occurs when the API is not loaded correctly. If you're in doubt, can you share a code snippet? Thanks.Thanks a lot for helping me. I would like to share code but I don't want to show my game in public. So I sent you PM. Hope you don't mind! Link to comment Share on other sites More sharing options...
Recommended Posts