How to use a runtime trigger?

0 favourites
  • 1 posts
  • 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:

    AddCondition(0, cf_trigger, "addisplayed", "My category", "ad_displayed", "Description for my condition!", "addisplayed");[/code:2k0zagp5]
    in runtime.js:
    [code:2k0zagp5]Cnds.prototype.addisplayed = function (state)
    	{
    	    return true;
    };[/code:2k0zagp5]
    
    Now:
    Case 1:
    if I put this code 
    [code:2k0zagp5]var self=this;
     self.runtime.trigger(cr.plugins_.GoogleIMA.prototype.cnds.addisplayed,self);[/code:2k0zagp5]
    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:2k0zagp5]instanceProto.addisplayed= function()
    	{
    	var self=this;
     self.runtime.trigger(cr.plugins_.GoogleIMA.prototype.cnds.addisplayed,self);}[/code:2k0zagp5]
    
    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
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)