vairen's Recent Forum Activity

  • Hi,

    I am looking for a Construct 2 expert that can help me on fixing some specific Android related issues (game crashes almost at start).

    The game works perfectly on the Web, so I think it is something related to the relation between C2 and Apache Cordova.

    The game starts with no problem at a main menu level, but when you start the level itself sometimes it crashes and other times works perfect.

    It is a Tower Defense kind of game, but with many variations and original concepts on it.

    The game as of now is near completion.

    I can pay by the hour if we agree a fair fee.

    If you are interested PM me and I will share pictures, and/or videos of the game as well.

    Thanks in advance!

  • Hello C2 community!!

    Please apologize if my question is misplaced.

    I have a working C2 game and I want to add it the In Ap purchase feature.

    I have set up all with Google Play and I have my billing key already.

    The problem is that I can not seem to run the IAP plugin. Here is what I have done so far:

    Related to the game itself:

    • Added the IAP plugin in the game.
    • IAP plugin is set to test mode.
    • Added the "add product IDs" (with mi product id of course), and the "request store listing" actions to the "On start of layout" event.
    • Added the "On store listing success" event with a few alerts showing product name, product price, etc.
    • Added the "On store listing failed" event with an alert showing the "IAP.ErrorMessage"
    • Exported as "cordova" project from C2.

    Related to the export to android via apache cordova:

    • Added the "cc.fovea.plugins.inapppurchase" plugin to the cordova project.
    • Added the "com.mcm.plugins.androidinappbilling" plugin to the cordova project, with the --variable BILLING_KEY="MY_KEY" parameter
    • Compile the project (generate APK file) manually via command line with Apache Cordova, signed and zip aligned it.

    The problem is that the "On store listing success" event is firing ok, but there is not data retrieved from the store. All alerts shows empty strings.

    Can please anyone tell me what am I doing wrong?

    I appreciate all the help you can provide.

    Thanks in advance!!

  • vairen

    Looking forward for that plugin...

    I have one question... how does app handles recieved notifications if its minimised?

    thanx!

    I have tested only on Android OS, and is the OS itself that gets the notification from Google AGCM Service.

    You need to register with Google in order to be authorized to send AGCM messages, and you need to implement your own server side application that gets tue registration and using the sender ID that google provides you, sneds the message trough google AGCM service.

    For that you need to have apache cordova with this plugin installed: https://github.com/phonegap-build/PushPlugin

    And then my plugin register an event listener that talks with it. Once the device gets a push notification message, the OS sends it to the app and my plugin captures that and fire a C2 condition. And then you can do whatever you want with it.

    I can also provide you with my PHP code, so the only thing you need to do is register with google and put all pieces in place.

    I hope I can solve this soon and I will share it with you. I think there is a timing problem. when the plugin initializes. If I wait a few seconds to fire the conditions it works fine.

    I hope Ashley could be able to clarify that.

    Cheers

  • vairen

    Hi, are you willing to share your latest version?

    tnx!

    Of course Inina, I have no problem sharing it.

    The thing is that I updated C2 to r200 and my plugin stop working!!!

    It is driving me crazy, I can not fire conditions with: this.runtime.trigger(cr.plugins_.pushNotifications.prototype.cnds.OnPushMessageReceived, this);

    My condition is defined in edittime.js like this:

    AddCondition(0, cf_trigger, "On Push Message received", "Events API", "On push notification received", "Triggered when a push notification message is received.", "OnPushMessageReceived");

    And in runtime.js like this:

    Cnds.prototype.OnPushMessageReceived = function()

    {

    return true;

    };

    I do not know if there is something wrong with my code (I haven't change anything), or if there is some compatibility issue with the latest version.

    I just put the trigger code line at the top of "instanceProto.onCreate" function and nothing happen. I even commented all the rest of my code.

    Maybe Ashley could help on clarify if there was some change on this.

  • No, you should not define self as a global variable.

    Construct 2 uses Google Closure Compiler to compile JS code, which is separately documented by Google.

    Thank you very much for your help Ashley. Your information indeed solved my issue.

    Now I have a proper self contained and fully functional C2 plugin for push notifications.

    Thank you very much!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is really just a normal JS programming question, and this isn't really the place to ask that kind of thing. You just need to define the function in a scope where you can access the variables you want via a closure. Typically you have something like "var self = this" in the enclosing scope and then you refer to "self" instead of "this" in the function body. If you have other general JS programming questions best head to a site like StackOverflow.

    Thank you for your reply Ashley.

    I asked that, because I already try what you mentioned. I am not familiarized on how Construct 2 compiles the JS, so I am finding hard to debug the code. But I am indeed familiarized with JS.

    If you say that should work, then I will look for another error. Because I defined "self" as a global variable, and asigned self = this inside instanceProto.onCreate. And inside window["onNotification"] = function (e) {} "self" is null.

    I apologize if my question was misplaced. I will try to find my answer elsewhere.

    Kind regards

  • [attachment=0:1wx0ps4l][/attachment:1wx0ps4l]

    To add a global function that won't be renamed by closure compiler, just use:

    window["myGlobalFunction"] = function () { ... };

    Hello Ashley, thanks for your reply.

    I am testing your solution, and it seems to work. the problem I have now is to access the plugin properties from within the global function.

    I mean, how can I do this:

    window["onNotification"] = function (e) {

    this.lastMessageReceived = e.payload.message;

    this.runtime.trigger(cr.plugins_.pushNotifications.prototype.cnds.OnPushMessageReceived, this);

    }

    Of course I have defines lastMessageReceived and OnPushMessageReceived properly. But the error says "this is not defined".

    I guess that this is related to the global status of the function. But how can I get the "self" object or access its properties from inside that function.

    The process in general works fine. But I want to be able to catch the Push Messages from construct itself, and so stuff with it.

    Thanks!!

  • Thank you very much for your quick answers.

    I will test both options as soon as possible.

    Thanks!!

  • Hello all, I am new to construct and I am developing a plugin to solve a problem I have.

    I am implementing a Push Notifications Plugin for android HTML5 games. In fact, I have it working using google push notifications service. But not the way I think a plugIn must be done.

    I wrote the plugin using the JS SDK provided by scirra. But I hit a wall when I needed a javascript function that can be call from outside the application, via the Cordova Push Notifications Plugin (https://github.com/phonegap-build/PushPlugin.git).

    That (and all push services) requires that the applications needs to be accessible (via a JS function) from the Device OS (Android).

    In my implementation I had to include an external JS file into the index.html, where the "onNotification" function is defined. If I define that same function inside the plugin, it does not work.

    In order to be a proper plugin, it must be autonomous and self contained. Or at least it must be Construct 2 itself who includes that file.

    So my question is:

    Plan A - How or where (inside the plugin) do I define a javascript function that has the same scope that the ones defined in the index.html file?

    Plan B - How do I define a plugin that once the game is exported to Cordova or Phonegap, Construct 2 itself imports the needed JS files and writes the <script> tag including it in the index.html file.

    Thank you very much for your help!

vairen's avatar

vairen

Member since 20 Oct, 2014

None one is following vairen yet!

Trophy Case

  • 9-Year Club
  • Email Verified

Progress

10/44
How to earn trophies