Leadbolt – ShiVa Engine

Leadbolt

by straybullet and dbladez

Resources

All project resources can be downloaded here: http://www.padxtek.com/PADXTEKLeadBoltIntegrationAndroid.zip
PADXTEK LeadBolt Integration.doc
PADXTEK_LeadBoltAI.ste
padxtekleadboltc.c
PADXTEKLeadBoltjava.java

SDK/c/java Setup

AndroidManifest.xml

Open AndroidManifest.xml and Overwrite the current 3 default permissions with. (Or select ones you need or don’t need if you are not using the full LeadBolt Ads)


    
    
    
    
    
    
    
    
    
    
    
    
    

Under the permissions, Insert:

If your application is a landscape application and you wish to use FullPage Ads or BannerSlot Ads, Insert:

If your application is a landscape application and you wish to use FullPage Ads or BannerSlot Ads, Set:

android:screenOrientation="landscape"

If your application is a landscape application and you will not be using FullPage Ads or BannerSlot Ads. You can otherwise keep portrait and you can set this up in shiva and continue to use as you are most likely already using. If you wish to use BannerSlot Ads with portrait settings and don’t care if they are turned sideways for whatever reason.

application.setOption ( application.kOptionViewportRotation, 3 ) --Inside Shiva Editor

However if you are using screenOrientation portrait and application.setOption ( application.kOptionViewportRotation, 3 ), you will need to edit the functions inside PADXTEK_LeadBoltAI to not auto set landscape after a full page ad is made.
As the way it works, the full page Ad looks horrible in a landscape setting, therefor the AI will send and event to turn the screen

oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ) ;

Then, when the Ad is complete, fails, closed etc, an Event will trigger to let Shiva know and the AI will then send an event to turn the screen back to

oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ) ;

If your app is already full portrait then you have nothing to worry about.
If using notifications Ads, Under , Insert:

//This is so the notifications Ads will survive a system reboot.


      

Before < /application>, Insert:

LeadBolt SDK

– If you haven’t setup an account yet, you can do so here. http://leadbolt.com/developers_signup.php?ref=10038489
– Download and extract the LeadBolt SDK from your LeadBolt Account Manager Page.
– Create a new folder “libs” in your project directory
– Import from file LeadBoltController.jar into the new libs folder.
– Right click project, goto properties. Menu Item: Java Build Path, Tab: Libraries, Button: Add JARs /libs/LeadBoltController.jar, Click OK

PADXTEKLeadBoltjava.java

Import From File PADXTEKLeadBoltjava.java into your ProjectName/src/com.companyname.gamename/ folder. Open File PADXTEKLeadBoltjava.java, edit: Around Line 1 to match your project path.

package com.companyname.gamename; //Example:  package com.padxtek.hostiletdfree

Edit: Around Line 23 to match your project path. Located from your ProjectName/gen/com.companyname.gamename Example:

HostileTDFree/gen/com.padxtek.hostiletdfree
import com.companyname.gamename.R; //Example:  import com.padxtek.hostiletdfree.R

If using Notifications Ads, also Import From File BootReceiver.java into your ProjectName/src/com.companyname.gamename/ folder and change the SectionID# to your notifications SectionID#, which is given to you from your LeadBolt Account Manager Page after you Add a Notification SDK Setup.

padxtekleadboltc.c

Import From File padxtekleadboltc.c into your ProjectName/jni/ folder
If not using UAT 1.4.3 Import From File into your project’s jni folder your StonetripShiva Authoring ToolDataWindowsAndroidBuildS3DX all files, select all and import, if using 1.4.3 these are already imported.
Open file padxtekleadboltc.c
Edit: Around Line 33 to match your project path. Example:

//static char sGamePath [255] = "com/padxtek/hostiletdfree/PADXTEKLeadBoltjava" ;
static char sGamePath [255] = "com/companyname/gamename/PADXTEKLeadBoltjava" ;

Edit: Around Line 25, Change GameName to your GameName, the line should be the same as line 22 inside S3DClient.cpp, Example:

define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "HostileTDFree", __VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "GameName", __VA_ARGS__)

Edit: Around line 200 // Or around the end of the file, If I have made changes, Example:

Java_com_padxtek_hostiletdfree_PADXTEKLeadBoltjava_onAdListenerUpdateNative( JNIEnv* env, jobject thiz, jstring AdType )
JNIEXPORT void JNICALL Java_com_companyname_gamename_PADXTEKLeadBoltjava_onAdListenerUpdateNative( JNIEnv* env, jobject thiz, jstring AdType )

S3DClient.cpp

With the other includes at the top above

//----------------------------------------------------------------------
// @@END_JNI_INCLUDES@@
//----------------------------------------------------------------------
Insert: Around line 17
#include "padxtekleadboltc.c"
Above
//----------------------------------------------------------------------
// @@END_JNI_INSTALL_EVENT_HOOKS@@
//---------------------------------------------------------------------- 

Insert: Around Line 697

padxtek_leadbolt_registerCallbacks( pJavaVM );

YourGameName.java

Editing YourGameName.java inside ProjectName/src/com.companyname.gamename/, Example: HostileTDFree.java inside HostileTDFree/src/com.padxtek.hostiletdfree
Open File YourGameName.java, Insert: Around line 86.

import com.companyname.gamename.PADXTEKLeadBoltjava;
//Example: import com.padxtek.hostiletdfree.PADXTEKLeadBoltjava;

At the end of the function

/------------------------------------------------------------------
@Override
protected void onCreate ( Bundle savedInstanceState )
Insert AFTER createAsync ( ) ; Around line 190
PADXTEKLeadBoltjava.getInstance().init(this, GameName.this);
//Example: PADXTEKLeadBoltjava.getInstance().init(this, HostileTDFree.this);

Replace GameName with your main game name’s Java file without the .java The file you currently have loaded…
Found inside src/com/companyname/gamename/GameName.java
If your application is a landscape application and you wish to use FullPage Ads or BannerSlot Ads:
Inside the function private static boolean onPlayOverlayMovie ( String sURI ) , comment out:

// If your game plays in Landscape and/or you don’t use ShivaOverlay Movies, Around Line 963 :
//oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ) ;

If its not there and the UAT has updated, just do a find for setRequestedOrientation.
Inside the function private static void onStopOverlayMovie ( ), Around Line 993, Comment Out:

// If your game plays in Landscape and/or you don’t use ShivaOverlay Movies.
//oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ) ;

If your application is a landscape application and you wish to use FullPage Ads or BannerSlot Ads: If you previously were using application.setOption ( application.kOptionViewportRotation, 3 ) –Inside Shiva Editor, and now using , 0.
With android:screenOrientation=”portrait” , and your splash screen is turned sideways, you can either fix the splash screen graphic. Or do the following. Basically turning the splash screen, then turning back after. Inside YourGameName.java, around Line 143, inside the function onCreate AFTER, comment Out:

// If your game plays in Landscape and/or you don’t use ShivaOverlay Movies.
// Get singleton
//
oThis = this ;

Insert:

oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ) ;

Then. Around line 379 AFTER

// Remove splash view
//oViewGroup.removeView ( oSplashView ) ;

Insert:

oThis.setRequestedOrientation ( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ) ;

build.xml

If your using UAT 1.4.Beta3) and getting the –preserve build error: Open build.xml and Find/Replace “–preserve” with “” essentially replacing it with nothing

Shiva Setup

The shiva code is extensively documented if you wish to see how it all works or want to see further descriptions of steps given below.

PADXTEK_LeadBoltAI

Import the Shiva Archive .ste
Add PADXTEK_LeadBoltHUD from the HUD folder into the Game Resources.
Add PADXTEK_LeadBoltAI into your User Main AI’s.
In your main AI call:

user.sendEvent ( application.getCurrentUser ( ), "PADXTEK_LeadBoltAI", "onSetup_DeveiceInfo_LeadBolt" )

Check out the PADXTEK_LeadBoltAI Handler onInit for a descriptions of all the ad types I compiled from researching into it to decide what you would like to go with.

Setup_DeviceInfo ( )

Load function PADXTEK_LeadBoltAI.Setup_DeviceInfo ( ). If you want to use your own HUD, you could change this.sHUDTemplate_AdDelay ( “PADXTEK_LeadBoltHUD” ), otherwise leave it.

Setup_Device_sSectionIDs ( )

Register and login to your Account Management Page on the LeadBolt website. Select the Apps Tab, create your new app. Click Add Ad.
Alt tab back to Shiva. Goto function PADXTEK_LeadBoltAI.Setup_Device_sSectionIDs ( )
Highlight and Copy sSectionID_AdvancedOverlay_2AdsWide_468x60.
Alt tab back to your Internet Browser with your Lead Account Management loaded after clicking the Add Ap: Button.
Into the Ad Name *: Paste the above, sSectionID_AdvancedOverlay_2AdsWide_468x60
Click From Library: Choose.
Click Advanced Overlay 2 Ads Wide.
Setup Close Button to Show so the user isn’t held prisoner by an ad and can close if he wishes.
Click Add Now.
Make sure the items selected in the Website UI match the member variable values your copying and pasting as the names of those Ad types with the example like.
sSectionID_AdvancedOverlay_2AdsWide_468x60 being Advanced Overlay 2 Ads Wide.

Setup_Device_ScreenViewportRotation ( )

Load function PADXTEK_LeadBoltAI.Setup_Device_ScreenViewportRotation ( ) and Set

this.sDevice_ViewportRotation ( "landscape")

to your game type. This AI has vast comments going into detail for using landscape or portrait and how this AI communicates to make it work with Banner Slot Ads or Full Page Ad Types.

Triggering an Ad

You can do this whenever you want. Example: When the user clicks new game, or if you want it to appear right away Or whenever you want. I just went with when they click new game. This lets the app also know if it was completed, and if failed it will set the Boolean that there is no internet. So future calls will just be stopped before they even try so it doesn’t use up system resources.
Insert: Wherever you want. Best used when first load the app or if they click New game.

local hUser = application.getCurrentUser ( )
user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_OfferWall" )

This will cause the app to load up an Offer Wall. Done. That’s it. Just call the Handler. Or don’t use onStart_OfferWall, use any of the PADXTEK_LeadboltAI Handlers, maybe you want to do

user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", " onStart_AdvancedOverlay " )

Then. What I went with is as I click New Game, Which starts a new menu before they really start the scene. Once they click Start. Then while the Scene is loading I run.

user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_AppIcon" )
user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_Notifications" )

Then after each level I run.

local L_bAdFailed_PossibleNoInternet = application.getCurrentUserAIVariable ( "PADXTEK_LeadBoltAI", "bAdFailed_PossibleNoInternet" )
if (L_bAdFailed_PossibleNoInternet == false) then
    if (math.mod ( this.nLevel ( ), 4 ) == 0) then
        user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_BannerSlot", 45 )
    end
end

This causes the Banner Slot to load up for 45 seconds, then it will destroy itself, or send nil to have it up forever. Setup certain types at certain levels. Example:

if (this.nLevel ( ) == 6) then
    user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_AdvancedOverlay" )
elseif (this.nLevel ( ) == 14) then
    user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_RichMediaOverlay" )
elseif (this.nLevel ( ) == 19) then
    user.sendEvent ( hUser, "PADXTEK_LeadBoltAI", "onStart_CaptureForm" )
end

Videos

Watch the tutorial videos on the Warhead Games Youtube channel!
Leadbolt Introduction
Link to video #1
Link to video #2

FAQs

Q: How do I build an unsigned app?
A: By default dragging and dropping the build.xml on antbuild.cmd creates debug apps. Just edit the build.xml and change the top default=”Build debug apk” to default=”Build release apk” and save the build.xml. Then drag and drop again and you will get a unsigned release app, then use jarsigner (located in the bin folder of your jdk directory) to sign with your keystore.
Q: How much does Leadbolt make over Admob?
A: It’s not set in stone formular but my most popular apps make over 10 times more with Leadbolt and my lesser popular APPs make about 3 times more on average. I have multiple Google developer accounts. Depending on the niche I am creating apps for. I just started with Shiva and Leadbolt so those numbers aren’t there, but considering Leadbolt’s advertising I actually expect them to be better on average for the gaming niche!
Q: Will this work with all Shiva apps?
A: Yes it should work with any Shiva app and does not require any coding inside your Shiva app to work, unlike Admob.
Q: What wasn’t clear in the video (and is perhaps beyond it’s remit) is how might I choose how the ads appear from the App in ShiVa (like in a component?) or if I used a different .jar library in a similar way, how could I call a command from Shiva and maybe recieve results back. Would I need to create a plugin to sit inbetween the APIs?
A: This is kind of a repeat of above, but I guess I need to make it clearer. Nothing in Shiva is required, it is all taken care of by the code I provided outside of Shiva. Shiva doesn’t even care about the ads.




Need more answers?

  • slackBanner