How to use a runtime trigger?

For developers using the Construct 2 Javascript SDK

Post » Wed Aug 17, 2016 11:35 am

My goal is to trigger an event from javascript into construct 2.
I think I should use a runtime trigger.
My code:
in edittime.js:
Code: Select all
AddCondition(0, cf_trigger, "addisplayed", "My category", "ad_displayed", "Description for my condition!", "addisplayed");

in runtime.js:
Code: Select all
Cnds.prototype.addisplayed = function (state)
   {
       return true;
};


Now:
Case 1:
if I put this code
Code: Select all
var self=this;
 self.runtime.trigger(cr.plugins_.GoogleIMA.prototype.cnds.addisplayed,self);

under instanceProto.onCreate = function()
it works

Case 2 : if I put the same code under an action, it doesn't work: Acts.prototype.MyAction = function (myparam)
{

I tried to make :
Code: Select all
instanceProto.addisplayed= function()
   {
   var self=this;
 self.runtime.trigger(cr.plugins_.GoogleIMA.prototype.cnds.addisplayed,self);}


and call from action: this.addisplayed(); but doens't work.

So how do I trigger the event from actions?

Thanks

EDIT:
It seams that calling this.addisplayed(); from actions works but :
if I wrap it inside a function it doesn't
B
34
S
8
G
4
Posts: 157
Reputation: 3,781

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest