Project1

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

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

[pre lang="javascript"]Game_CharacterBase.prototype.updateMove = function() {
        //移动速度为0时不移动
        if (this._moveSpeed === 0) {
                this.setPosition(this._realX,this._realY);
                }
    if (this._x < this._realX) {
        this._realX = Math.max(this._realX - this.distancePerFrame(), this._x);
    }
    if (this._x > this._realX) {
        this._realX = Math.min(this._realX + this.distancePerFrame(), this._x);
    }
    if (this._y < this._realY) {
        this._realY = Math.max(this._realY - this.distancePerFrame(), this._y);
    }
    if (this._y > this._realY) {
        this._realY = Math.min(this._realY + this.distancePerFrame(), this._y);
    }
    if (!this.isMoving()) {
        this.refreshBushDepth();
    }
};
[/pre]


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

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

[pre lang="javascript"]Game_CharacterBase.prototype.setDirection = function(d) {
    if (!this.isDirectionFixed() && d) {
         if (this._moveSpeed === 0) {return}
        this._direction = d;
    }
    this.resetStopCount();
};
[/pre]

作者: 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! X5.0