Project1

标题: 问一个关于VisualStateFX显示状态动作的问题 [打印本页]

作者: yihe74    时间: 2018-11-26 12:35
标题: 问一个关于VisualStateFX显示状态动作的问题
不才最近在研究VisualStateFX和龙骨插件的结合
发现一个问题:
对于主角角色,会用设置好的骨骼动画显示状态动画
但是对于敌人的话就无法以骨骼动画显示状态动画 但是技能序列没有问题
所以我想问一下是我自己的脚本发生冲突还是说VisualStateFX无法显示敌人的骨骼动画呢
十分感谢!
作者: wq627100    时间: 2018-11-26 14:22
                     
作者: yihe74    时间: 2018-11-28 16:15
本帖最后由 yihe74 于 2018-11-28 17:54 编辑

最终问题解决了
原因比较简单 因为在原版中敌人没有动作,所以在VisualFX中沿用用了另一插件AnimatedSVEnmemies里边对于敌人动作的定义
那么在这里我们首先要让VisualFX承认他是一个动态有动画的敌人,删去了if (!this._svBattlerEnabled) return;
之后 我在龙骨插件的脚本中仿照对于Actor动作的定义把Enemy.startMotion定义了一遍。问题就解决了。
dragonBonesIntegration.Sprite_Enemy_prototype_startMotion =
  Sprite_Enemy.prototype.startMotion;
Sprite_Enemy.prototype.startMotion = function(motionType) {
  //only play dragonbone animation if dragonboneIndex variable is valid
  if (this._enemy.hasDragonBone === true) {
    if (this._enemy.lastMotionType !== motionType) {       
      dragonBonesIntegration.PlayAnimationOnBattler(this._enemy, motionType);
      this._enemy.lastMotionType = motionType;
    }
  } else {
    //console.log("Vanilla startMotion: " + this._actor._name + " motion = " +
    //motionType);
    dragonBonesIntegration.Sprite_Enemy_prototype_startMotion.call(this,
      motionType);
  }
};
不过有一个小问题 就是角色受到攻击以后动画会消失掉
那么就牵扯到龙骨插件里有一小段代码是说敌人完成动作后恢复walk动作的
我目前没什么太好的办法 就一个一个把他们分情况if进去了:
switch (event.type) {
            case dragonBones.EventObject.COMPLETE:
              //if actor is not knocked out
              if (this._states.contains(1) === false) {
                                  if (this._states.contains(11) ) {dragonBonesIntegration.PlayAnimationOnBattler(this, "Idle2");
                                  } else if (this._states.contains(12) ) {dragonBonesIntegration.PlayAnimationOnBattler(this, "Injury");
                                  } else{dragonBonesIntegration.PlayAnimationOnBattler(this, "walk");                                          
                                  }
                //var idleAnimation = this.dragonboneAnimation['walk'];
                //dragonBonesIntegration.ArmatureDatabaseEnemy
                //[this.dragonboneIndex].animation.play(idleAnimation);
               
              } else {
                dragonBonesIntegration.Game_Enemy_prototype_performCollapse.call(this);
              };
              break;
            default:
              //nothing
          }        
这就是说在敌人存活的情况下
11号状态显示Idle2 12号injury 其他 walk。
最后,这只是一点抛砖引玉 肯定有许多不足之处,欢迎指教




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1