Including Platform Specific Settings In A GameBuilder Plugin

Prerequisite: Setting Up The Plugin Descriptor


Favorite This Post!
0 Votes
Posted by Lavon on July 1, 2015

As you know by now GameBuilder Studio (GBs) can be extended with additional features utilizing our plugin SDK. Now your plugins can specify platform specific settings and include JS files for games deployed for the web via the PluginConfig.xml file included with every plugin. I will cover the newly available xml nodes below.

Communicating With External Javascript Code

Communicating With External Javascript Code

You may be wondering how GBs can communicate with javascript (JS) if GBs exports web games to a SWF file. There is a well known class available in ActionScript 3 (AS3) called the ExternalInterface class which allows a swf to communicate with the javascript in the browser on the host web page that holds the swf. This api allows you to register external methods that javascript functions can call directly on the embedded swf object which will then call the mapped AS3 method inside the flash runtime. For details on how the ExternalInterface class works please refer to this article: Using the ExternalInterface class.

Including Javascript Files For Web Publishing

Including Javascript Files For Web Publishing

GBs needs to know what js files to include in the final html page hosting the game swf. Specify the location of the js files by adding xml node entries inside of your plugins' PluginConfig.xml file. The js files need to be embedded in the plugin SWC at the location you specify. The new xml node section for these js file inclusions is called <jsIncludes> with a capital "I". A sub <javascriptLibs> xml node entry needs to be added for each individual js file include. The url="" property on this node is the only thing that needs to be added when specifying remote js files.

Embedding Files In Your Plugin SWC

Embedding Files In Your Plugin SWC

When creating your plugin SWC file using FlashBuilder there is an Assets tab that allows you to specify which files get compiled into your final swc at compile time. Just right click on your project and open the properties window. Your plugin SWC file can also be compiled using an ant script or any other IDE that allows you to compile ActionScript library files.

Including Platform Specific Adobe Native Extensions

Some plugins require the inclusion of native code depending on the targeted platform. This native Objective-C code for iOS or Java code for Android can be packaged with a GBs game using Adobe Native Extensions (ANE). If you are not familiar with how to create an ANE there are plenty of resources online. Check out some of the free tutorials on RIADraw.com

There is an <extensions> xml node that can be added to the PluginConfig.xml file for including extensions. To include the ANE file you need to add a <extensionID> xml node that matches the id in your compiled ANE and a <extlocation> xml node to tell GBs where the extension file is included in your compiled plugin. Remember that your plugin is just a compiled ActionScript library known as a SWC which is pretty much a zip file container.

You also have to include which platforms the extension supports. If it is only Android or only iOS then there should only be one <platform> xml entry. If your plugin does not require an ANE to be included in the target platform still include the platforms section and just remove the <extensionID> and <extlocation> xml nodes. If the <platform> xml node is not specified then GBs will not use the settings specified in this section when exporting to the target platform.

Specific Mobile Platform Settings

Specific Mobile Platform Settings

This "extensions" section of the config file can also be used to specify Android and iOS specific configuration settings. These platform specific settings can be included with or without an ANE present. For Android some plugins require certain permissions to function correctly on the device. Or your plugin may require the target Android device to have a certain feature to be present. These settings can be included in the <extension> xml node section under the <android> xml node entry. For iOS sometimes you need to include key value pairs that get included in the final build's plist files. This is where you include all those different settings for each platform.

**Note: Some users have asked for the ability to specify some of these platform specific features and entries through the publish window in the editor. That will be something adding in the future.

Dynamic Search / Replace Config Parameters

Dynamic Search / Replace Config Parameters In GameBuilder Plugin

Some of the platform specific entries may require the inclusion of an app id or key value that gets compiled into the final binary which your plugin may not know ahead of time. This would be a value that the end user will enter when creating their game. There is a section in the PluginConfig.xml file called <staticParameters> which you can include searchable key strings surrounded by curly braces "{}" and GBs will search and replace those static keywords with user input values when the end user of your plugin publishes a build of their game. This search and replace only happens on the <activityEntry> xml nodes for Android and the <infoEntry> xml node for iOS.

%STEP_TITLE%

The value for the static parameter is set at runtime by including a public static property in your plugin's class list file and setting that when a user inputs a value in your plugin's properties panel. Whether its a custom components properties panel or a custom action properties window.

%STEP_TITLE%

When the end user opens the custom action's properties window and enters the appId value and saves it. The value is populated on the static parameter of the plugin class list. This value is then used to perform the search and replace during publishing.


Congratulations on finishing this tutorial! Found it helpful? Spread the word...


Comments

Pages: 1 All
Said:
your policies in engine development are excellent(especially particle system and spine2d runtime).I just got familiar with this engine by a simple search in google and i must say the engine features are very good.First of all I want to say it is better to change your game engine logo(that is very simple and clumsy) and then make a modern website(like gamesalad website) surely it will increase the game developers confidence in choose the engine because the website is the first thing that we can know the new engine by .then change the name of game engine(gamebuilder studio!!!?).At last please evaluate other popular drag n drop game engines like gamesalad or construct 2 or buildbox(Amazingly easy to use + very good editor) and then develop engine.see what are the pros of that game engines.for example ad integration is very
2 years ago
+1
Pages: 1 All

Anyone can leave a comment!


You just need to signup for an account or log-in before you can comment.