do-disciplinary-committee-m.../www/js/plugins/SZ_KeyWait.js
2025-05-04 14:43:03 -05:00

56 lines
No EOL
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//=============================================================================
// SZ_KeyWait
//=============================================================================
/*:
* @plugindesc キーの入力を待機できるようにするプラグイン
* @author suzu
*
* @help
* e.g. this.setWaitMode('key_ok');
*/
//20221114 timer変数追記あまり要らないクリックでも反応するように41・42行目を追加 24行目の条件を追記 銀河
(function(){
var _Game_Interpreter_updateWaitMode = Game_Interpreter.prototype.updateWaitMode;
var timer = 6;
Game_Interpreter.prototype.updateWaitMode = function(){
if(this.isWaitKey()){
if(this.isWaitKeyTransition()){
this.setWaitMode('');
return true;
}
var waiting = this.waitKey(this._waitMode.slice(4));
if(Input.isPressed('ok') || Input.isPressed('cancel') || TouchInput.isPressed()){
this.wait(timer/2)
}else if(Input.isPressed('control')){
this.wait(timer/3)
}else{
this.wait(timer);
}
if (!waiting) {
this.setWaitMode('key__');
return true;
}
return waiting;
}else{
timer = 6;
}
return _Game_Interpreter_updateWaitMode.call(this);
}
Game_Interpreter.prototype.waitKey = function(key){
var result = !key ? !Input.isPressed('ok') : !Input.isPressed(key);
if(result){result = !Input.isPressed('cancel')}
if(result){result = !Input.isPressed('control')}
if(result){result = !TouchInput.isPressed()}
return result;
}
Game_Interpreter.prototype.isWaitKey = function(){
return this._waitMode.indexOf('key_') >= 0;
}
Game_Interpreter.prototype.isWaitKeyTransition = function(){
return this._waitMode === 'key__'
}
})();