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

Project1

 找回密码
 注册会员
搜索
查看: 2914|回复: 1

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7693
在线时间
1342 小时
注册时间
2012-6-6
帖子
345
发表于 2020-12-31 14:54:44 | 显示全部楼层 |阅读模式

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

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

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






JAVASCRIPT 代码复制
  1. (() => {
  2.     //设置角色阵型的哈希,键为阵型ID,值为角色坐标
  3.     let Actor_Pos = {
  4.         //散开阵
  5.     0: [[595, 172],
  6.         [615, 228],
  7.         [635, 284],
  8.         [655, 340],
  9.         [675, 396]],
  10.  
  11.         //鹤翼阵
  12.     1: [[675, 172],
  13.         [675, 228],
  14.         [721, 284],
  15.         [675, 340],
  16.         [675, 396]],
  17.  
  18.     };
  19.  
  20.  
  21. //初始化阵型id
  22. const UncleJay_Formation_initialize = Game_Party.prototype.initialize
  23.     Game_Party.prototype.initialize = function() {
  24.         UncleJay_Formation_initialize.call(this);
  25.         this._formation = 0;
  26.     };
  27.  
  28.  
  29.  
  30. //获取阵型id
  31.     Game_Party.prototype.formation = function() {
  32.         return this._formation;
  33.     };
  34.  
  35.  
  36. //设置阵型id
  37.     Game_Party.prototype.setFormationID = function(num) {
  38.         this._formation = num;
  39.     };
  40.  
  41. //战斗画面下角色坐标的设置
  42.     Sprite_Actor.prototype.setActorHome = function(index) {
  43.         const id = $gameParty.formation();
  44.         const x = Actor_Pos[id][index][0];
  45.         const y = Actor_Pos[id][index][1];
  46.         this.setHome(x, y);
  47.     };
  48.  
  49. })();

Lv4.逐梦者

梦石
0
星屑
7693
在线时间
1342 小时
注册时间
2012-6-6
帖子
345
 楼主| 发表于 2021-1-3 11:07:52 | 显示全部楼层
本帖最后由 流浪杰哥 于 2021-1-3 12:31 编辑

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

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 10:04

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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