ページ 22

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年10月30日(水) 08:53
by ジャングル
> 思った動作になったようです。

それなら良かったです
クリックによる表示非表示よりも、プラグインコマンドで消せる方が良いとのことでしたね...

また何か問題があれば言ってください
あと、このコードは一例なので、より良い方法があれば他の方も回答してあげてください

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年10月30日(水) 10:11
by MEIKOI
丁寧にご回答いただき感謝です。
解決方法が、ちょっとイメージできないと感じていた所だったのでとても助かりました。
未解決リストがまた1行少なくなりました^^ がんばって制作に励みます(^^)

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年10月31日(木) 09:23
by ジャングル
いくつか修正を行いました

A グローバルのプロパティ名の変更
B プラグインコマンド無しで消せる
※Bは、キャラ画像が表示されていたら「ピクチャの消去」で自動で消えるようにしたという意味です

コード: 全て選択

(function() {
	var appearFlg = false;
	var erasePict = function() {
		SceneManager._scene.removeChild($gameScreen._charSpriteJM);
	  	appearFlg = false;
	  	var spriteset = SceneManager.getSpriteset();
	  	spriteset.removeChild(spriteset._pictureContainer);
	};
	var _Game_Interpreter_command235 = Game_Interpreter.prototype.command235;
	Game_Interpreter.prototype.command235 = function() {
	    	if (appearFlg) { erasePict(); }
    		return _Game_Interpreter_command235.call(this);
	};
	var _Game_Screen_setDTextPicture = Game_Screen.prototype.setDTextPicture;
	Game_Screen.prototype.setDTextPicture = function(value, size) {
	   if (TouchInput.isPressed()) {
	   		if (!appearFlg) {
		   	appearFlg = true;
		      	var x = 10, y = 10, scale = 5; // ★
		       var bitmap = ImageManager.loadCharacter(this._characterNameJM);
		       var big = ImageManager.isBigCharacter(this._characterNameJM);
		       var pw = bitmap.width / (big ? 3 : 12);
		       var ph = bitmap.height / (big ? 4 : 8);
		       if (!big) {
		          var n = this._characterIndexJM;
		          var sx = (n % 4 * 3 + 1) * pw;
		          var sy = (Math.floor(n / 4) * 4) * ph;
		       } else {
		          var n = {2:2, 4:5, 6:8, 8:12}[this._originalDirectionJM];
		          var sx = n % 3 * Math.floor(bitmap.width / 3);
		          var sy = Math.floor(n / 4) * Math.floor(bitmap.height / 4);
		       }
		       bitmap.addLoadListener(function() {
		          this._charSpriteJM = new Sprite(bitmap);
		          this._charSpriteJM.setFrame(sx, sy, pw, ph);
		          this._charSpriteJM.scale.x = this._charSpriteJM.scale.y = scale;
		          this._charSpriteJM.x = x;
		          this._charSpriteJM.y = y;
		           SceneManager._scene.addChild(this._charSpriteJM);
		           this.clear();
		           var spriteset = SceneManager.getSpriteset();
		      		spriteset.addChild(spriteset._pictureContainer);
		      }.bind(this));   
	      }
	   	_Game_Screen_setDTextPicture.apply(this, arguments);
	     } 
	};
	var _Game_Event_lock = Game_Event.prototype.lock;
	Game_Event.prototype.lock = function() {
	   if (!this._locked) {
	      $gameScreen._characterNameJM = this._characterName;
	      $gameScreen._characterIndexJM = this._characterIndex;
	      $gameScreen._originalDirectionJM = this._originalDirection;
	   }
	   _Game_Event_lock.call(this);
	};
})();
もし、何か問題があれば言ってください

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年11月01日(金) 20:19
by MEIKOI
ジャングル様

修正ありがとうございます!
たった今、差し替えさせていただきまして動かしてみました。
細かいところまで配慮いただき感謝です。
そしてプラグインコマンドを無くしても消えるようになっています。

1つ質問なのですが、
Chronusと言う、時間帯を導入するプラグインを入れてまして
https://triacontane.blogspot.com/2015/1 ... or-mi.html

私のゲームの中は現実の時間と同じ時間で動いているので
夜になると画面が暗くなり、昼になると明るくなります。

「そこで夜の暗い状態で イベントをクリックして イベントの画像を表示させて 消す」
の処理をすると、暗かった画面がなぜか昼間の明るい状態になります。


マップを移動したら、また暗くなるのですが、これはどういった現象なのかよかったらまた教えてくださいm(_ _)m

色々聞いてすみません。

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年11月01日(金) 21:11
by ジャングル
明るくなる問題を修正したコードです
済みません

コード: 全て選択

(function() {
	var appearFlg = false;
	var erasePict = function() {
		SceneManager._scene.removeChild($gameScreen._charSpriteJM);
	  	appearFlg = false;
	};
	var _Game_Interpreter_command235 = Game_Interpreter.prototype.command235;
	Game_Interpreter.prototype.command235 = function() {
    	if (appearFlg) { erasePict(); }
    	return _Game_Interpreter_command235.call(this);
	};
	var _Game_Screen_setDTextPicture = Game_Screen.prototype.setDTextPicture;
	Game_Screen.prototype.setDTextPicture = function(value, size) {
	   if (TouchInput.isPressed()) {
	   		if (!appearFlg) {
		   		appearFlg = true;
		      	var x = 10, y = 10, scale = 5; // ★
		       var bitmap = ImageManager.loadCharacter(this._characterNameJM);
		       var big = ImageManager.isBigCharacter(this._characterNameJM);
		       var pw = bitmap.width / (big ? 3 : 12);
		       var ph = bitmap.height / (big ? 4 : 8);
		       if (!big) {
		          var n = this._characterIndexJM;
		          var sx = (n % 4 * 3 + 1) * pw;
		          var sy = (Math.floor(n / 4) * 4) * ph;
		       } else {
		          var n = {2:2, 4:5, 6:8, 8:12}[this._originalDirectionJM];
		          var sx = n % 3 * Math.floor(bitmap.width / 3);
		          var sy = Math.floor(n / 4) * Math.floor(bitmap.height / 4);
		       }
		       bitmap.addLoadListener(function() {
		          this._charSpriteJM = new Sprite(bitmap);
		          this._charSpriteJM.setFrame(sx, sy, pw, ph);
		          this._charSpriteJM.scale.x = this._charSpriteJM.scale.y = scale;
		          this._charSpriteJM.x = x;
		          this._charSpriteJM.y = y;
		           SceneManager._scene.addChild(this._charSpriteJM);
		      }.bind(this));   
	      }
	   	_Game_Screen_setDTextPicture.apply(this, arguments);
	     } 
	};
	var _Game_Event_lock = Game_Event.prototype.lock;
	Game_Event.prototype.lock = function() {
	   if (!this._locked) {
	      $gameScreen._characterNameJM = this._characterName;
	      $gameScreen._characterIndexJM = this._characterIndex;
	      $gameScreen._originalDirectionJM = this._originalDirection;
	   }
	   _Game_Event_lock.call(this);
	};
})();
これで明るくなることはないと思います

Re: 動的文字列プラグインでクリックしたイベントの歩行画像を表示させる方法

Posted: 2019年11月02日(土) 19:47
by MEIKOI
ジャングル様

こんばんは!
コードの修正ありがとうございます。
今、差し替えて動かしてみました。
イベントをクリックして表示して消した後も、夜のままです。
希望の動作になっております。
まだコードを見ていないのですが、前のコードと並べて変わった所を
見比べて少しでも理解してみたいと思います。
ありがとうございます!!