查看: 4168|回复: 1

[有事请教] 怎么实时更新角色坐标位置,新人求教

[复制链接]
梦石
0
星屑
9968
在线时间
1649 小时
注册时间
2012-6-6
回帖
306
发表于 2020-12-31 14:54:44 | 显示全部楼层 |阅读模式

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

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

×
战斗的时候使用$gameParty.setFormationID改变坐标时,不能及时刷新角色位置,有什么办法能及时刷新一下变更后的位置么?还请大佬们指点一下
新人刚刚学习一点点js,下面代码写的可能很粗糙。。。。






[pre lang="javascript"](() => {
    //设置角色阵型的哈希,键为阵型ID,值为角色坐标
    let Actor_Pos = {
        //散开阵
    0: [[595, 172],
        [615, 228],
        [635, 284],
        [655, 340],
        [675, 396]],

        //鹤翼阵
    1: [[675, 172],
        [675, 228],
        [721, 284],
        [675, 340],
        [675, 396]],

    };


//初始化阵型id
const UncleJay_Formation_initialize = Game_Party.prototype.initialize
    Game_Party.prototype.initialize = function() {
        UncleJay_Formation_initialize.call(this);
        this._formation = 0;
    };



//获取阵型id
    Game_Party.prototype.formation = function() {
        return this._formation;
    };


//设置阵型id
    Game_Party.prototype.setFormationID = function(num) {
        this._formation = num;
    };

//战斗画面下角色坐标的设置
    Sprite_Actor.prototype.setActorHome = function(index) {
        const id = $gameParty.formation();
        const x = Actor_Pos[id][index][0];
        const y = Actor_Pos[id][index][1];
        this.setHome(x, y);
    };

})();[/pre]
梦石
0
星屑
9968
在线时间
1649 小时
注册时间
2012-6-6
回帖
306
 楼主| 发表于 2021-1-3 11:07:52 | 显示全部楼层
本帖最后由 流浪杰哥 于 2021-1-3 12:31 编辑

有没有老哥来指点一下,精灵的位置怎么刷新,折腾了很久没有什么好办法,我想到呼叫一个空的场景然后再删除,SceneManager.push(null);  SceneManager.pop(); 这个办法总感觉太不友好了,虽然的确能够更新一下坐标位置,但这似乎不科学,也不知道这样做合不合理
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部