赞 | 8 |
VIP | 50 |
好人卡 | 9 |
积分 | 7 |
经验 | 25417 |
最后登录 | 2023-1-15 |
在线时间 | 224 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 676
- 在线时间
- 224 小时
- 注册时间
- 2006-12-7
- 帖子
- 839
|
没看这个rar不过八向和analog是不冲突的
唯一要改的核心代码就是analog里面这段 注释掉之后analog插件就不会强制把人物八向专为四向
- // 内部4方向を更新
- Game_AnalogMove.prototype.updateDir4 = function(thisCharacter) {
- this._dir4 = thisCharacter.direction();
- //doranikofu edit for 8dir this._dir4 = this.dir8ToDir4(this.radianToDir8(this._directionRadian));
- this._dir4 = this.radianToDir8(this._directionRadian);
- };
复制代码
然后要注意一下行走图的素材规格,analog的方向是
789
456
123
跟八向的默认好像不太一样
自己做的时候加了点别的增强触发事件判定/朝向的,其实也不太好用,仅供参考
- //===========================char direction for diagonal
- Game_Character.prototype.turnTowardCharacter = function(character) {
- var sx = this.deltaXFrom(character._realX);
- var sy = this.deltaYFrom(character._realY);
- var radian = Math.atan2(sx,sy) + Math.PI;
- this.setDirection(
- radian < Math.PI / 8.0 * 1.0 ? 2 :
- radian < Math.PI / 8.0 * 3.0 ? 3 :
- radian < Math.PI / 8.0 * 5.0 ? 6 :
- radian < Math.PI / 8.0 * 7.0 ? 9 :
- radian < Math.PI / 8.0 * 9.0 ? 8 :
- radian < Math.PI / 8.0 * 11.0 ? 7 :
- radian < Math.PI / 8.0 * 13.0 ? 4 :
- radian < Math.PI / 8.0 * 15.0 ? 1 : 2
- );
- };
- Game_Character.prototype.turnAwayFromCharacter = function(character) {
- var sx = this.deltaXFrom(character._realX);
- var sy = this.deltaYFrom(character._realY);
- var radian = Math.atan2(sx,sy) + Math.PI;
- this.setDirection(
- radian < Math.PI / 8.0 * 1.0 ? 8 :
- radian < Math.PI / 8.0 * 3.0 ? 7 :
- radian < Math.PI / 8.0 * 5.0 ? 4 :
- radian < Math.PI / 8.0 * 7.0 ? 1 :
- radian < Math.PI / 8.0 * 9.0 ? 2 :
- radian < Math.PI / 8.0 * 11.0 ? 3 :
- radian < Math.PI / 8.0 * 13.0 ? 6 :
- radian < Math.PI / 8.0 * 15.0 ? 9 : 8
- );
- };
- Game_Map.prototype.roundXWithDirection = function(x, d) {
- return this.roundX(x + (d%3 == 0 ? 1 : (d+2)%3 == 0 ? -1 : 0));
- };
- Game_Map.prototype.roundYWithDirection = function(y, d) {
- return this.roundY(y + (d < 4 ? 1 : d > 6 ? -1 : 0));
- };
- //expand trigger region, look to left
- Game_Map.prototype.roundXWithDirectionL = function(x, d) {
- switch(d) {
- case 1:
- return this.roundX(x+1);
- break;
- case 2:
- return this.roundX(x+1);
- break;
- case 8:
- return this.roundX(x-1);
- break;
- case 9:
- return this.roundX(x-1);
- break;
- default :
- return this.roundX(x);
- };
- };
- Game_Map.prototype.roundYWithDirectionL = function(y, d) {
- switch(d) {
- case 3:
- return this.roundY(y-1);
- break;
- case 4:
- return this.roundY(y+1);
- break;
- case 6:
- return this.roundY(y-1);
- break;
- case 7:
- return this.roundY(y+1);
- break;
- default :
- return this.roundY(y);
- };
- };
- //look to right
- Game_Map.prototype.roundXWithDirectionR = function(x, d) {
- switch(d) {
- case 2:
- return this.roundX(x-1);
- break;
- case 3:
- return this.roundX(x-1);
- break;
- case 7:
- return this.roundX(x+1);
- break;
- case 8:
- return this.roundX(x+1);
- break;
- default :
- return this.roundX(x);
- };
- };
- Game_Map.prototype.roundYWithDirectionR = function(y, d) {
- switch(d) {
- case 1:
- return this.roundY(y-1);
- break;
- case 4:
- return this.roundY(y-1);
- break;
- case 6:
- return this.roundY(y+1);
- break;
- case 9:
- return this.roundY(y+1);
- break;
- default :
- return this.roundY(y);
- };
- };
- //set 1/2 scroll for reduced map size --doranikofu
- Game_Map.prototype.parallaxOx = function() {
- if (this._parallaxZero) {
- return Math.floor(this._parallaxX * this.tileWidth());
- } else if (this._parallaxLoopX) {
- return this._parallaxX * this.tileWidth() / 2;
- } else {
- return 0;
- }
- };
- Game_Map.prototype.parallaxOy = function() {
- if (this._parallaxZero) {
- return Math.floor(this._parallaxY * this.tileHeight());
- } else if (this._parallaxLoopY) {
- return this._parallaxY * this.tileHeight() / 2;
- } else {
- return 0;
- }
- };
- Game_Player.prototype.checkEventTriggerHere = function(triggers) {
- if (this.canStartLocalEvents()) {
- this.startMapEvent(Math.round(this._realX), Math.round(this._realY), triggers, false);
- }
- };
- Game_Player.prototype.checkEventTriggerThere = function(triggers) {
- if (this.canStartLocalEvents()) {
- var direction = this.direction();
- var x1 = Math.round(this._realX);
- var y1 = Math.round(this._realY);
- var x2 = Math.floor($gameMap.roundXWithDirection(x1, direction));
- var y2 = Math.floor($gameMap.roundYWithDirection(y1, direction));
- this.startMapEvent(x2, y2, triggers, true);
- if (!$gameMap.isAnyEventStarting() && $gameMap.isCounter(x2, y2)) {
- var x3 = Math.floor($gameMap.roundXWithDirectionL(x2, direction));
- var y3 = Math.floor($gameMap.roundYWithDirectionL(y2, direction));
- this.startMapEvent(x3, y3, triggers, true);
- if (!$gameMap.isAnyEventStarting() && $gameMap.isCounter(x3, y3)) {
- var x4 = Math.floor($gameMap.roundXWithDirectionR(x2, direction));
- var y4 = Math.floor($gameMap.roundYWithDirectionR(y2, direction));
- this.startMapEvent(x4, y4, triggers, true);
- }
- }
- }
- };
- Game_Player.prototype.triggerTouchAction = function() {
- if ($gameTemp.isDestinationValid()){
- var direction = this.direction();
- var x1 = this.x;
- var y1 = this.y;
- var x2 = $gameMap.roundXWithDirection(x1, direction);
- var y2 = $gameMap.roundYWithDirection(y1, direction);
- var x3 = $gameMap.roundXWithDirectionL(x2, direction);
- var y3 = $gameMap.roundYWithDirectionL(y2, direction);
- var x4 = $gameMap.roundXWithDirectionR(x2, direction);
- var y4 = $gameMap.roundYWithDirectionR(y2, direction);
- var destX = $gameTemp.destinationX();
- var destY = $gameTemp.destinationY();
- if (destX === x1 && destY === y1) {
- return this.triggerTouchActionD1(x1, y1);
- } else if (destX === x2 && destY === y2) {
- return this.triggerTouchActionD2(x2, y2);
- } else if (destX === x3 && destY === y3) {
- return this.triggerTouchActionD3(x2, y2);
- } else if (destX === x4 && destY === y4) {
- return this.triggerTouchActionD3(x2, y2);
- }
- }
- return false;
- };
复制代码
再一个问题就是斜向行动的时候地图上事件可能会抖动,浮点数计算的问题感觉不太好处理,试了一些办法都没彻底解决 |
|