查看: 3705|回复: 0

[已经过期] 找到一个状态动画插件,求教怎么让动画循环

[复制链接]
梦石
0
星屑
75
在线时间
231 小时
注册时间
2014-10-5
回帖
226
发表于 2016-1-24 17:21:53 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
外站上找到一个插件,作用是在战斗场景,
如果附加了某个状态,会播放一个动画,
在这个状态消失的时候,播放另外一个动画,
我感觉这个插件是一个很大的启发,
如果,
在这个插件的基础上,
把播放的这个动画设置成无限循环播放,
然后在状态消失,播放另一个动画的时候停止,
这样不就可以做出来累死大话梦话那样的状态动画了吗?
求大神来帮忙看看插件,怎么设置动画循环我不会写,
插件指令
在状态的注释里面写:
<state add animation: 125 />  在附加这个状态时候,播放125号动画
<state remove animation: 126 /> 在状态消失的时候,播放126号动画
[pre lang="javascript"]var Imported = Imported || {} ;
var TH = TH || {};
Imported.StateChangeAnimations = 1;
TH.StateChangeAnimations = TH.StateChangeAnimations || {};

(function ($) {

  $.stateAddRegex = /<state[-_ ]add[-_ ]animation:\s*(\d+)\s*\/>/im
  $.stateRemoveRegex = /<state[-_ ]remove[-_ ]animation:\s*(\d+)\s*\/>/im
  
  $.stateAddAnimation = function(state) {
    if (state.stateAddAnimation === undefined) {
      data = {id: 0, mirror: false, delay: 0};
      var res = $.stateAddRegex.exec(state.note);
      if (res) {
        data.id = Math.floor(res[1]);
      }
      state.stateAddAnimation = data;
    }
    return state.stateAddAnimation;
  };
  
  $.stateRemoveAnimation = function(state) {
    if (state.stateRemoveAnimation === undefined) {
      data = {id: 0, mirror: false, delay: 0};
      var res = $.stateRemoveRegex.exec(state.note);
      if (res) {
        data.id = Math.floor(res[1]);
      }
      state.stateRemoveAnimation = data;
    }
    return state.stateRemoveAnimation;
  };

  var TH_GameBattlerBase_addNewState = Game_BattlerBase.prototype.addNewState;
  Game_BattlerBase.prototype.addNewState = function(stateId) {
    TH_GameBattlerBase_addNewState.call(this, stateId);
    this.playStateAddAnimation(stateId);
  };
  
  var TH_GameBattlerBase_eraseState = Game_BattlerBase.prototype.eraseState;
  Game_BattlerBase.prototype.eraseState = function(stateId) {
    if (this.isStateAffected(stateId)) {
      this.playEraseStateAnimation(stateId);
    }
    TH_GameBattlerBase_eraseState.call(this, stateId);   
  };
  
  Game_BattlerBase.prototype.playStateAddAnimation = function(stateId) {
    var state = $dataStates[stateId];
    var data = $.stateAddAnimation(state);
    if (data.id > 0) {
      this.startAnimation(data.id, data.mirror, data.delay);
    }
  };
  
  Game_BattlerBase.prototype.playEraseStateAnimation = function(stateId) {
    var state = $dataStates[stateId];
    var data = $.stateRemoveAnimation(state);
    if (data.id > 0) {
      this.startAnimation(data.id, data.mirror, data.delay);
    }
  };
})(TH.StateChangeAnimations);[/pre]
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部