[tutorial] Hook Layer For Android/ios, The First Brick For Advanced Customizations

Discussion in 'Buildbox General Discussion' started by EZKad, Aug 22, 2016.

  1. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    Hello community,

    This is a new tutorial of my serie, buildbox like a boss.
    [​IMG]

    Link to the tutorial : http://ezelia.com/2016/buildbox-hook-android-ios

    This one is a little more advanced than the first ones, but it's very important : since it make it possible to detect some game events not allowed by the default export.
    Events are very important when it comes to integration of 3rd party services, for example if you want to add game analytics that log when the player start and end playing, you need to know when those events occure.
    if you want to handle custom leaderboards, you need to detect when the score is submitted to the main leaderboard so you can also send it to your custom one ...etc.

    In this tutorial, you'll setup a hook layer to allow you detect some important game events from the code.
    this is the first brick which will allow different customizations and integrations.

    At the end of the tutorial you'll be able to show toast messages for custom events : game start, game over , button click ...etc
    if you are familiar with code, you can already implement many interesting services.
    if not, the next tutorials will show you how to setup those services using the hook layer.

    as usual, your comments and suggestions are welcome.
     
  2. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Hey man, this is hardcore. Very cool!

    One question: what is a Toast message?
    And what do you think will be the coolest thing we can do with this?
     
  3. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    A Toast message is a small unobstructive message used to notify about something
    here is an image illustrating a Toast message (the one saying "Your text has been sent")

    [​IMG]



    With the current tutorial without anything else you can .... show toast messages when the game start and on game over :D
    I wanted to isolate this first part from the rest because writing a single tutorial for, let's say, Everyplay integration, will make it very difficult to follow.
    so this tutorial will be the base for the following ones : Achievement integration, Multiple leaderboards, Game analytics integration and Everyplay integration.

    those tutorial will all refer to the hook layer.
    if you implement the hook layer and understand how it work, it allow you to implement all the above features if you have some developement knowledge and have time to read and understand the tutorials/documentation for each of those services .

    otherwise you have to wait for the next tutorials :D
     
    Benfont, DMONGS and Christoph like this.
  4. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Common! Bring them already! I can't write a single line of code that's why I use Buildbox. :p

    Nah, seriously, this is some of the most amazing shares since I'm part of this community. Thank you very much!
     
  5. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    they're coming :) it take some time because every tutorial even the simplest ones require time to test, on both android and iOS .... and I think you already know how much time it take :D
    I'm also preparing the release of my game, and working on other stuff.
    actually the most difficult task in those tutorials, is to make them simple and usable by non-developers :D it's really hard, because they require advanced code and hacks, and I need to find the way and words to simplify all the stuff .... also english is not my native laguage, which add some complexity for me :D
     
  6. VectologyGames

    VectologyGames Serious Boxer

    Joined:
    Oct 5, 2015
    Messages:
    529
    Likes Received:
    473
    @EZKad Could we add youtube videos?
     
  7. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    if there is an API that play them on Android or iOS apps then I suppose yes.
    the code I made allow calling custom code when the events trigger, so it can virtually call any SDK/API developed for android/iOS.

    but the code don't provide interactions with the gameplay (for example it cannot trigger an event when the player enters a scene or collect a specific object)
     
  8. trudnai

    trudnai Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,235
    Likes Received:
    701
    @EZKad This is pure awesomness! Why I did not think about URL buttons?!
    Thanks dude, you are da man!
     
  9. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    you're welcome :) actually I tried many hacks before finding the damn simple solution of URL button, but it was still not that simple to hook on iOS.
    I come from C/C++/C# environment so Objective-C is obscure to me.
    I discovered method swizzling feature by pure coincidence, which is a very dirty feature IMO, but did the trick to allow hooking the url button on iOS :D
     
    Gregory Storm and trudnai like this.
  10. trudnai

    trudnai Miniboss Boxer

    Joined:
    Sep 25, 2015
    Messages:
    1,235
    Likes Received:
    701
    I feel your pain, I was doing the same, but forced myself to learn ObjC few years back. Still not my favorite but can live with that. Now here is Swift (which you could use btw as you have a nice ObjC connector built in). Problem is that Swift slowly becomes a true functional programming language, which means they are dropping traditional for looping and indexing with integers... Takes a while to get used to do everything with iterators and lambdas and such but I guess we have to just move with the crowd...

    Do you have ideas how to add custom character controller buttons or how to interact with the Cocos2D-x objects created by BuildBox? I have not explored these things yet but now you have just opened Pandora's BuildBox :)
     
  11. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    I did lot of experiments with cocos2d-x to try to add custom stuff, but it's not possible. Buildbox actually have a custom high level layer on top of cocos2d-x and this layer is compiled.
    you can still have access to the low level cocos2d objects but you can't do anyhing interesting with that. I think that some hacks would be possible if the export include buildbox runtime .h files but it only include few of them (the minimum required to compile the export).
    also, those manipulations are only possible on iOS, because you can import cocos2d-x source code to bb project and it will compile just fine, on android everything is shipped in a static library ... so you can't recompile cocos2d-x.

    anyway, I think that interacting with buildbox specific stuff won't be possible if BB team don't provide an official API (or open source a part of runtime binaries)
     
    Gregory Storm, trudnai and Christoph like this.
  12. Gregory Storm

    Gregory Storm Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    130
    I just looked at your tutorial. Very nice job laying it out. In your iOS portion I think you mean AppController.mm instead of Application.mm.
     
    Christoph likes this.
  13. EZKad

    EZKad Avid Boxer

    Joined:
    Apr 26, 2016
    Messages:
    157
    Likes Received:
    155
    you're right it's AppController.mm :) ==> fixed

    thank you
     
    Christoph and Gregory Storm like this.
  14. Rainyday

    Rainyday Avid Boxer

    Joined:
    Nov 21, 2016
    Messages:
    116
    Likes Received:
    41
    thumbs up for what you did ... its amazing

    is there a way to add a code instead of toast msg which is reset the score to zero ( i mean when ever the player press START which is typically triggers the url button the score get resets to zero )

    any idea what is the right code ??
     
  15. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Does this still work now that the export files from Buildbox are password protected and zipped?

    Edit:
    Oh yeah, baby, it does. I just implemented it for iOS. That's the most awesome feature I had played with in a while. Now I can track a lot of user behavior for my game. Thanks a lot @EZKad. Sad you are not around in the forum anymore. But your hack is very very appreciated. Cheers!
     
    Last edited: Aug 23, 2017
    Jumpingu likes this.

Share This Page