How to use the events.trigger function in events

To help you get started, we’ve selected a few events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CarnegieLearning / MathFluency / src / html5 / racecar / src / ModifyOverTime.js View on Github external
// Check the case that the tick is longer than our remaining time
            var edt = Math.min(dt, dur);
            this.set('duration', dur - edt);
            
            var rate = this.get('rate');
            this.set('value', this.get('value') + rate * edt);
            
            if(this.func) {
                this.func.apply(this.obj, [this.get('value') + rate * edt]);
            }
        }
        
        // Otherwise change is complete
        else {
            // Let anyone who wants to know that this change has finished
            events.trigger(this, 'Completed', this);
            
            // Then kill it
            this.kill();
        }
    },
github CarnegieLearning / MathFluency / src / html5 / numberline / src / QuestionSet.js View on Github external
nextQuestion: function() {
        if(this.current < this.questions.length - 1) {
            // Advance to next question
            events.trigger(this, 'beforeNextQuestion');
            
            // Remove the current question only if this is not a first question
            if(this.current > -1) {
                this.removeChild({child: this.questions[this.current]});
            }
            this.current += 1;
            
            setTimeout(this.nextQuestionCallback.bind(this), QuestionSet.QDelay);
        }
        else {
            var that = this;
            setTimeout(function() {events.trigger(that, 'endOfSet')}, QuestionSet.QDelay);
        }
    },
github CarnegieLearning / MathFluency / src / html5 / racecar / src / ScriptingSystem.js View on Github external
exec: function() {
        events.trigger(eventRelay, 'CallFunctionEvent', this.func, this.params);
    }
});
github CarnegieLearning / MathFluency / src / html5 / src / Intermission.js View on Github external
update: function(dt) {
        if(PNode.cameraZ >= this.get('zCoordinate') && !this.fired) {
            this.fired = true;
            events.trigger(this, 'changeSelector', this.selector);
        }
        
        Intermission.superclass.update.call(this, dt);
    },
});
github CarnegieLearning / MathFluency / src / html5 / racecar / src / ScriptingSystem.js View on Github external
exec: function() {
        events.trigger(eventRelay, 'CombineVarsEvent', this.name, this.other1, this.other2, this.op);
    }
});
github CarnegieLearning / MathFluency / src / html5 / numberline / src / QuestionSet.js View on Github external
onQuestionTimeout: function () {
        events.trigger(this, 'questionTimeout');
        events.trigger(this, 'scoreChange', this.questions[this.current].pointsEarned);
        this.set('lineColor', '#220000');
        
        this.nextQuestion();
    },
});
github CarnegieLearning / MathFluency / src / html5 / mathattack / src / EndOfGameDisplay.js View on Github external
next: function() {
        var step = this.get('step');
        
        if(step == 0)
            this.slideLabelIn(this.get('name'), 0.75);
        else if(step == 1) {
            this.totalLabelUp(this.get('amount'), 'amountLink', this.get('amountT'), 0.5);
        }
        else if(step == 2) {
            events.trigger(this, 'animationCompleted');
        }
        
        this.set('step', step + 1);
    }
});
github CarnegieLearning / MathFluency / src / html5 / ghosts / src / Level.js View on Github external
boot: function() {
        this.player.teleport(this.startR, this.startC);
        
        for(var i=0; i=0; i-=1) {
            list.push(TextBox.create({}, this.introText[i], 250, 200, '/resources/green.png', ((i