topical media & game development

talk show tell print

mobile-graphic-enchant-dev-src-ParallelAction.js / js



  
@scope enchant.ParallelAction.prototype

  
  enchant.ParallelAction = enchant.Class.create(enchant.Action, {
      
@name enchant.ParallelAction @class [lang:ja] アクションを並列で実行するためのアクション。 子アクションを複数持つことができる。 [/lang] @constructs @extends enchant.Action

  
      initialize: function(param) {
          enchant.Action.call(this, param);
          var timeline = this.timeline;
          var node = this.node;
          
[lang:ja] 子アクション [/lang] [lang:en] Children Actions [/lang]

  
          this.actions = [];
          
[lang:ja] 実行が終了したアクション [/lang] [lang:en] Removed actions [/lang]

  
          this.endedActions = [];
          var that = this;
  
          this.addEventListener(enchant.Event.ACTION_START, function(evt) {
              for (var i = 0, len = that.actions.length; i < len; i++) {
                  that.actions[i].dispatchEvent(evt);
              }
          });
  
          this.addEventListener(enchant.Event.ACTION_TICK, function(evt) {
              var i, len, timeline = {
                  next: function(remaining) {
                      var action = that.actions[i];
                      that.actions.splice(i--, 1);
                      len = that.actions.length;
                      that.endedActions.push(action);
  
                      var e = new enchant.Event("actionend");
                      e.timeline = this;
                      action.dispatchEvent(e);
  
                      e = new enchant.Event("removedfromtimeline");
                      e.timeline = this;
                      action.dispatchEvent(e);
                  }
              };
  
              var e = new enchant.Event("actiontick");
              e.timeline = timeline;
              e.elapsed = evt.elapsed;
              for (i = 0, len = that.actions.length; i < len; i++) {
                  that.actions[i].dispatchEvent(e);
              }
  
              if (that.actions.length === 0) {
                  evt.timeline.next();
              }
          });
  
          this.addEventListener(enchant.Event.ADDED_TO_TIMELINE, function(evt) {
              for (var i = 0, len = that.actions.length; i < len; i++) {
                  that.actions[i].dispatchEvent(evt);
              }
          });
  
          this.addEventListener(enchant.Event.REMOVED_FROM_TIMELINE, function() {
              this.actions = this.endedActions;
              this.endedActions = [];
          });
  
      }
  });
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.