设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1378|回复: 2
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2540
在线时间
361 小时
注册时间
2021-9-20
帖子
109
跳转到指定楼层
1
发表于 2023-1-3 21:56:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
请教:当我显示满屏的一张图片时,点击图片任何位置,角色实际上仍然可以行走,有什么方法屏蔽吗?打开图片停止行走,关掉图片恢复行走。

Lv3.寻梦者

梦石
0
星屑
3111
在线时间
238 小时
注册时间
2021-4-22
帖子
217
2
发表于 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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-28 07:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表