查看: 2240|回复: 2

[有事请教] 怎么让角色原地不动?

[复制链接]
梦石
0
星屑
2617
在线时间
375 小时
注册时间
2021-9-20
回帖
71
发表于 2023-1-3 21:56:15 | 显示全部楼层 |阅读模式

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

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

×
请教:当我显示满屏的一张图片时,点击图片任何位置,角色实际上仍然可以行走,有什么方法屏蔽吗?打开图片停止行走,关掉图片恢复行走。
梦石
0
星屑
3081
在线时间
236 小时
注册时间
2021-4-22
回帖
203
发表于 2023-1-3 23:38:16 | 显示全部楼层
本帖最后由 dabaxhei 于 2023-1-3 23:40 编辑

打开图片的事件里加这个
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();
    }
};

然后在再加移动速度为0
$gamePlayer.setMoveSpeed(0);
最后清楚图片的时候恢复移动速度
$gamePlayer.setMoveSpeed(4);

点评

哇哇哇 厉害,谢谢!  发表于 2023-1-4 00:46
回复 1 0

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部