【解決済み】斜め向きの歩行グラフィックを想定した上下左右移動を行いたい

フタツギ
記事: 9
登録日時: 2016年7月29日(金) 18:14

【解決済み】斜め向きの歩行グラフィックを想定した上下左右移動を行いたい

投稿記事by フタツギ » 2021年6月23日(水) 22:10

リクエストをさせて頂きます。よろしくおねがいします。

斜め向きの歩行グラフィックを使用し主人公やイベントを移動させたいです。
もう少し具体的に内容を書きたかったのですが、自分の文章力だと伝わる気がしなかったのでサンプル画像を用意しました。確認をお願いします。

精一杯の具体的内容:現在の向きを考慮した上で移動時に歩行グラフィックの向きが切り替わるようにしたい
移動のイメージ例:スーパーファミコンソフト、ライブ・ア・ライブの戦闘時の移動処理

歩行グラフィックが右上を向いていた場合、右や上への移動で向きは切り替わらず、
左や下への移動の際は左上や右下といった、右上+移動先の向きになってほしいです。

イベント上で処理させれば似たような動作は可能ですが、歩行グラフィック用意とプラグインで自動処理させたいです。
歩行グラフィックは斜め向きですが斜め移動は今のところ想定していません。

プラグインでそのように動作させることは可能でしょうか。
お手数おかけしますが、どうかよろしくお願いいたします。
添付ファイル
イラスト.png
最後に編集したユーザー フタツギ on 2021年6月25日(金) 00:01 [ 編集 1 回目 ]

アバター
WTR
記事: 558
登録日時: 2015年12月22日(火) 19:14

Re: 斜め向きの歩行グラフィックを想定した上下左右移動を行いたい

投稿記事by WTR » 2021年6月24日(木) 17:14

作ってみました。あってるかな…
歩行グラフィックを決まった並びというか方向というかで作る必要があります。
↘↘↘
↙↙↙
↗↗↗
↖ ↖ ↖
内部的なキャラクターの向きと画像のパターンが一致しないので
若干キモチワルイ場面もあるかもしれません。イベントコマンドで向き変更した場合とか…
画像のパターンを直接変更するには

コード: 全て選択

$gamePlayer.setSpriteDirection(2) // プレイヤーを↘向きに
$gameMap.event(id).setSpriteDirection(4) // イベントを↙向きに

とかで出来ます。ただし向き固定されている場合は効きません。
2 : ↘
4 : ↙
6 : ↗
8 : ↖

画像は素材ではないですが…
必要なら動作確認用にのみお使いください。

コード: 全て選択

(() => {
   "use strict";
   //=============================================================================
   // Game_CharacterBase
   //=============================================================================
   // this._spriteDirection = 2 : ↘
   // this._spriteDirection = 4 : ↙
   // this._spriteDirection = 6 : ↗
   // this._spriteDirection = 8 : ↖
   const _Game_CharacterBase_initMembers = Game_CharacterBase.prototype.initMembers;
   Game_CharacterBase.prototype.initMembers = function() {
      _Game_CharacterBase_initMembers.call(this);
      this._spriteDirection = 2;
   };

   Game_CharacterBase.prototype.spriteDirection = function() {
      return this._spriteDirection;
   };

   Game_CharacterBase.prototype.setSpriteDirection = function(d, auto) {
      if (this.isDirectionFixed()) {
         return;
      }
      if (auto) {
         if (this._spriteDirection === 2) {
            if (d === 4) this._spriteDirection = 4;
            if (d === 8) this._spriteDirection = 6;
         }
         if (this._spriteDirection === 4) {
            if (d === 6) this._spriteDirection = 2;
            if (d === 8) this._spriteDirection = 8;
         }
         if (this._spriteDirection === 6) {
            if (d === 4) this._spriteDirection = 8;
            if (d === 2) this._spriteDirection = 2;
         }
         if (this._spriteDirection === 8) {
            if (d === 6) this._spriteDirection = 6;
            if (d === 2) this._spriteDirection = 4;
         }
      } else {
         this._spriteDirection = d;
      }
   };

   const _Game_CharacterBase_setDirection = Game_CharacterBase.prototype.setDirection;
   Game_CharacterBase.prototype.setDirection = function(d) {
      this.setSpriteDirection(d, true);
      _Game_CharacterBase_setDirection.call(this, d);
   };

   //=============================================================================
   // Sprite_Character
   //=============================================================================
   // override
   Sprite_Character.prototype.characterPatternY = function() {
   //   return (this._character.direction() - 2) / 2;
      return (this._character.spriteDirection() - 2) / 2;
   };
})();
最後に編集したユーザー WTR on 2021年6月25日(金) 01:38 [ 編集 1 回目 ]
Twitter、はじめました。
https://twitter.com/wtr_in_reverie/
フタツギ
記事: 9
登録日時: 2016年7月29日(金) 18:14

Re: 斜め向きの歩行グラフィックを想定した上下左右移動を行いたい

投稿記事by フタツギ » 2021年6月25日(金) 00:01

WTRさん

素早い御対応ありがとうございます。
用意していただいたグラフィックとプラグインで動作確認してみました。
思ったとおりの動作です、とても助かりました!

やりたい意図読み取って頂いた上、わざわざ動作確認用のグラフィックも準備いただきありがとうございます!
歩行グラフィックは向きしっかり確認して作成していきます。
この度は本当にありがとうございました!

“MV:プラグイン素材のリクエスト” へ戻る