Advertisement
Fehu

PictureAnimations

Mar 13th, 2017
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2. /*:
  3. @plugindesc Este plugin permite que você mostre
  4. animações em imagens no mapa.
  5.  
  6. @author Alisson
  7.  
  8. @help Para mostrar uma animação, use o seguinte
  9. comando: Prism.SpriteAnim(n1, n2, wait)
  10.  
  11. n1: O número da imagem no mapa.
  12. n2: O número da animação no database.
  13. wait: true ou false, faz com que ele espere a animação terminar.
  14.  
  15. @param Ajuste X
  16. @desc Ajusta a posição da animação horizontalmente.
  17. Valores negativos ajustam para a esquerda.
  18. @default 0.0
  19.  
  20. @param Ajuste Y
  21. @desc Ajusta a posição da animação verticalmente.
  22. Valores negativos ajustam para cima.
  23. @default 0.0
  24.  
  25. */
  26.  
  27. Prism.makeAlias("spInit", Sprite_Picture.prototype.initialize);
  28. Sprite_Picture.prototype.initialize = function () {
  29.     Prism.getAlias("spInit").apply(this, arguments);
  30.     this._animationSprite = new Sprite_Base ();
  31.     this.addChild(this._animationSprite);
  32. };
  33.  
  34. Prism.makeAlias("spUp", Sprite_Picture.prototype.update);
  35. Sprite_Picture.prototype.update = function () {
  36.     Prism.getAlias("spUp").apply(this, arguments);
  37.     var pic = this.picture(this._pictureId);
  38.     if (pic && pic._reservedAnimation) {
  39.         this._executeAnimation();
  40.     }
  41.     if (pic && this._animationSprite) {
  42.         if (this.bitmap.isReady()) {
  43.             var pa = PluginManager.parameters("PictureAnimations");
  44.             var numX = Number(pa["Ajuste X"] || 0.0);
  45.             var numY = Number(pa["Ajuste Y"] || 0.0);
  46.             if (this._animationSprite.x != this.bitmap.width * (0.5 + numX)) {
  47.                 this._animationSprite.x = this.bitmap.width * (0.5 + numX);
  48.             }
  49.             if (this._animationSprite.y != this.bitmap.height * (0.5 + numY)) {
  50.                 this._animationSprite.y = this.bitmap.height * (0.5 + numY);
  51.             }
  52.         }
  53.         if (this._animationSprite.isAnimationPlaying()) {
  54.             $gameScreen._pictures[this._pictureId]._waitingAnimation = true;
  55.         } else if (!this._animationSprite.isAnimationPlaying()) {
  56.             $gameScreen._pictures[this._pictureId]._waitingAnimation = false;
  57.         }
  58.     }
  59. }
  60.  
  61. Sprite_Picture.prototype._executeAnimation = function () {
  62.     var anim = this.picture(this._pictureId)._reservedAnimation;
  63.     this._animationSprite.startAnimation(anim);
  64.     $gameScreen._pictures[this._pictureId]._reservedAnimation = null;
  65. }
  66.  
  67. Game_Picture.prototype._requestAnimation = function (anim, wait) {
  68.     this._reservedAnimation = anim;
  69.     if (wait) {
  70.         this._waitingAnimation = true;
  71.     }
  72. }
  73.  
  74. Prism.makeAlias("giUWM", Game_Interpreter.prototype.updateWaitMode);
  75. Game_Interpreter.prototype.updateWaitMode = function () {
  76.     if (this._waitMode === 'imageAnimation') {
  77.         return $gameScreen._pictures[this._spAnimId]._waitingAnimation;
  78.     } else {
  79.         return Prism.getAlias("giUWM").call(this);
  80.     }
  81. }
  82.  
  83. Prism.SpriteAnim = function (id, anid, wait) {
  84.     $gameMap._interpreter._showSpriteAnimation(id, anid, wait);
  85. }
  86.  
  87. Game_Interpreter.prototype._showSpriteAnimation = function (id, anid, wait) {
  88.     var anim = $dataAnimations[anid];
  89.     var img = $gameScreen._pictures[id];
  90.     this._spAnimId = id;
  91.     if (img) {
  92.         $gameScreen._pictures[id]._requestAnimation(anim, wait);
  93.         this.setWaitMode('imageAnimation');
  94.     }
  95.     return true;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement