Skip to content

Instantly share code, notes, and snippets.

@karlwestin
Created March 15, 2012 16:17
Show Gist options
  • Save karlwestin/2045042 to your computer and use it in GitHub Desktop.
Save karlwestin/2045042 to your computer and use it in GitHub Desktop.
m.OnceBehavior
(function(m) {
m.OnceBehavior = function() {
m.OnceBehavior.superclass.constructor.call(this);
};
m.OnceBehavior.prototype = {
setForTime : function(time, actor) {
if(this.oldtime && this.oldtime > time)
this.callback();
this.oldtime = time;
}
};
extend(m.OnceBehavior, CAAT.GenericBehavior);
})(MOVE);
@karlwestin
Copy link
Author

(function(m) {

m.OnceBehavior = function() {
    m.OnceBehavior.superclass.constructor.call(this);
};

m.OnceBehavior.prototype = {
        setForTime : function(time, actor) {
                if(this.oldtime && this.oldtime > time)
                        this.callback();

                this.oldtime = time;
        },

        setCallback: function(callback) {
            this.callback = callback;
            return this;
        }
    };

    extend(m.OnceBehavior, CAAT.Behavior);

})(MOVE);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment