Advertisement
jerry2810

AnimatedActorsWindow

Dec 17th, 2015
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var COLD = COLD || {};
  2.  
  3. (function(){
  4.     COLD.animatedWindow = {
  5.         windowBaseUpdate : Window_Base.prototype.update,
  6.         windowBaseInitialize : Window_Base.prototype.initialize,
  7.         originalSetBattler : Sprite_Actor.prototype.setBattler,
  8.         originalInitialize : Sprite_Actor.prototype.initialize,
  9.  
  10.         newSetBattler : function(battler){
  11.             Sprite_Battler.prototype.setBattler.call(this, battler);
  12.             var changed = (battler !== this._actor);
  13.             if (changed) {
  14.                 this._actor = battler;
  15.                 this._stateSprite.setup(battler);
  16.             };
  17.         },
  18.                
  19.         newInitialize : function(battler) {Sprite_Battler.prototype.initialize.call(this, battler);},
  20.            
  21.         modifyActorSprite : function(value){
  22.             if(value == 'new'){
  23.                 Sprite_Actor.prototype.initialize = COLD.animatedWindow.newInitialize
  24.                 Sprite_Actor.prototype.setBattler = COLD.animatedWindow.newSetBattler;
  25.             }else{
  26.                 Sprite_Actor.prototype.initialize = COLD.animatedWindow.originalInitialize;
  27.                 Sprite_Actor.prototype.setBattler = COLD.animatedWindow.originalSetBattler;
  28.             };
  29.         }
  30.     };
  31.    
  32. })();
  33.  
  34. (function($){
  35.        
  36.     $.prototype.drawAnimatedActor = function(actor, x, y, motion){
  37.         if(x <= this.width && y <= this.height){
  38.             COLD.animatedWindow.modifyActorSprite('new');
  39.             this._actorSprite = new Sprite_Actor();
  40.             this._actorSprites.addChild(this._actorSprite);
  41.             this._actorSprite.setBattler(actor);   
  42.             this._actorSprite.setHome(x, y);
  43.             this.actorMotions.push(motion);
  44.             COLD.animatedWindow.modifyActorSprite('original');
  45.         };
  46.     };
  47.    
  48.     $.prototype.update = function(){
  49.         COLD.animatedWindow.windowBaseUpdate.call(this);
  50.         if(this._actorSprites.children.length > 0){
  51.             this.updateActors();
  52.         };
  53.     };
  54.    
  55.     $.prototype.initialize = function(x, y, width, height){
  56.         COLD.animatedWindow.windowBaseInitialize.call(this,x,y,width,height);
  57.         this._actorSprites = new Sprite();
  58.         this.addChild(this._actorSprites);
  59.         this.actorMotions = [];
  60.     };
  61.  
  62.     $.prototype.updateActors = function(){
  63.         var childs = this._actorSprites.children;
  64.         for (var i = 0; i < childs.length; i++){
  65.             if(childs[i]._motionCount == 0){
  66.                 childs[i].startMotion(this.actorMotions[i]);
  67.             };
  68.         };
  69.     };
  70.    
  71. })(Window_Base);
Advertisement
RAW Paste Data Copied
Advertisement