Project1

标题: 移动速度为0时禁止移动 [打印本页]

作者: yang1zhi    时间: 2017-11-5 21:01
标题: 移动速度为0时禁止移动
本帖最后由 yang1zhi 于 2017-11-5 21:02 编辑

JAVASCRIPT 代码复制
  1. Game_CharacterBase.prototype.updateMove = function() {
  2.         //移动速度为0时不移动
  3.         if (this._moveSpeed === 0) {
  4.                 this.setPosition(this._realX,this._realY);
  5.                 }
  6.     if (this._x < this._realX) {
  7.         this._realX = Math.max(this._realX - this.distancePerFrame(), this._x);
  8.     }
  9.     if (this._x > this._realX) {
  10.         this._realX = Math.min(this._realX + this.distancePerFrame(), this._x);
  11.     }
  12.     if (this._y < this._realY) {
  13.         this._realY = Math.max(this._realY - this.distancePerFrame(), this._y);
  14.     }
  15.     if (this._y > this._realY) {
  16.         this._realY = Math.min(this._realY + this.distancePerFrame(), this._y);
  17.     }
  18.     if (!this.isMoving()) {
  19.         this.refreshBushDepth();
  20.     }
  21. };



//然后这个是控制移动速度的
$gamePlayer.setMoveSpeed(0);

作者: fangqing9    时间: 2017-12-16 18:26
我正需要这个   感谢~   要是顺带连无法更改朝向效果也有就更好了(这个人已经懒死了
作者: yang1zhi    时间: 2017-12-17 10:27
fangqing9 发表于 2017-12-16 18:26
我正需要这个   感谢~   要是顺带连无法更改朝向效果也有就更好了(这个人已经懒死了  ...

JAVASCRIPT 代码复制
  1. Game_CharacterBase.prototype.setDirection = function(d) {
  2.     if (!this.isDirectionFixed() && d) {
  3.          if (this._moveSpeed === 0) {return}
  4.         this._direction = d;
  5.     }
  6.     this.resetStopCount();
  7. };


作者: fangqing9    时间: 2017-12-17 18:44
yang1zhi 发表于 2017-12-17 10:27
Game_CharacterBase.prototype.setDirection = function(d) {
    if (!this.isDirectionFixed() && d) { ...

膜拜下
话说大佬有兴趣收费帮忙写插件吗?
作者: pandeng421    时间: 2023-1-8 20:59
这个太有用了!!十分感谢大大分享!!
作者: 三哈哈    时间: 2023-7-26 08:21
不知道大佬是否还在,在一些判断里不算禁止移动还是在走 只是速度为0,比如increaseSteps之类还是会判断玩家走了一步,这种有什么办法禁止移动吗




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