MV상에서는 툴을통해 이동속도를 조절하여 저장하면,
data폴더에 json 파일로 저장이되는데 가장 느린속도를 지정해도 1로지정되게 되더군요.
이를 임의적으로 수정하거나 아니면 코드상에서 수정할수 있을까요?
흐름 자체가 initialize -> ... -> update로 들어가게되는데
update에서 체크하기에는 약간 성향이 다른것같고,
init 에서 수정해도 json에 적힌 값이 덮어씌워지더군요.
조언부탁드립니다.
※ 현재 오프라인 상에 없기에... 우선 플레이어만 다룹니다. ※
웹 브라우저로 실행해서 개발자 도구에서 _moveSpeed의 값을
변경하면 그대로 적용이 됩니다.
툴에서 권장하는 최소 속도가 1인듯하니 스크립트로 처리를 하시면
제대로 원하는 연출을 가능하게 할 것으로 생각됩니다.
어떤 상황일 때에 속도가 느려져야 하는지는 모르겠지만
(세부적인 사항은 모르고 방법만 기재합니다.)
저라면 따로 함수를 만들어 두고서 기본 값과 토글되는
방식으로 처리를 해보겠습니다.
rpg_object.js 의 6222줄부터 있는 함수를 복사해서 편집합니다.
다음과 같이 원래의 변수는 남겨두고 새로
this._moveSpeed_에 원래의 이동 값을 저장합니다.
그리고 새로 플러그인으로 작성해서 꽂아주시면 됩니다.
Game_CharacterBase.prototype.initMembers = function() {
this._x = 0;
this._y = 0;
this._realX = 0;
this._realY = 0;
this._moveSpeed_ = 4;
this._moveSpeed = this._moveSpeed_;
this._moveFrequency = 6;
this._opacity = 255;
this._blendMode = 0;
this._direction = 2;
this._pattern = 1;
this._priorityType = 1;
this._tileId = 0;
this._characterName = '';
this._characterIndex = 0;
this._isObjectCharacter = false;
this._walkAnime = true;
this._stepAnime = false;
this._directionFix = false;
this._through = false;
this._transparent = false;
this._bushDepth = 0;
this._animationId = 0;
this._balloonId = 0;
this._animationPlaying = false;
this._balloonPlaying = false;
this._animationCount = 0;
this._stopCount = 0;
this._jumpCount = 0;
this._jumpPeak = 0;
this._movementSuccess = true;
};
Game_Character 객체는 Game_CharacterBase의 인스턴스로
Game_CharacterBase객체의 모든 것을 사용할 수 있습니다.
아래의 부분도 만드시는 플러그인에 꽂아넣어주시고 사용하면 됩니다.
※ 아래 2개의 함수는 새로 추가하실 함수입니다. ※
[ 아래의 .changeSpeed()는 단순하게 작성한 예입니다. ]
Game_Character.prototype.changeSpeed = function(moveSpeed){
this._moveSpeed = moveSpeed;
};
Game_Character.prototype.initSpeed = function(){
this._moveSpeed = this._moveSpeed_;
};
사용하실 이동값을 배열에 저장해서 쓴다면
.changeSpeed()를 위와는 다르게 해야 됩니다.
//플러그인 설명문 시작
//직접 하실 줄 아실테니 수도코드로만
//플러그인 설명문 끝
//플러그인 매니저에 해당 플러그인 로딩시키기
//직접 하실 줄 아실테니 수도코드로만
//change speed array : csa
//특정 상황에 연동시키시려면 ._moveSpeed값만
//있으면 안됩니다. 추가적으로 생각을 하셔서
//적용을 하시지 않으면 원하실 때에 작동하지 않습니다.
//맵상에 표시된 플레이어 파티의 리더 Actor의 상태를
//기준으로 가정하여 작성해보겠습니다.
//csa[ 상태번호 ] = [ 상태번호 , 이동속도 ];
var csa = new Array();
csa[0] = [0,0.1];
Game_Character.prototype.changeSpeed = function(){
var cs,cs2;
switch(typeof csa === "undefined"){
case true:
return false;
}
for(cs = 0;cs < $gameActors._data.length;cs++){
switch($gameActors._data[cs]._characterIndex === $gamePlayer._characterIndex){
case true:
for(cs2 = 0;cs2 < $gameActors._data[cs]._states.length;cs2++){
switch($gameActors._data[cs]._states[cs2] === Number(csa[$gameActors._data[cs]._states[cs2]][0])){
case true:
this._moveSpeed = Number(csa[$gameActors._data[cs]._states[cs2]][1]);
return true;
}
}
break;
}
}
};
위의 스크립트가 에러가 나면 .changeSpeed()를 다음과 같이
Game_Character.prototype.changeSpeed = function(){
var cs,cs2;
switch(typeof csa === "undefined"){
case true:
return false;
}
for(cs = 0;cs < $gameActors._data.length;cs++){
switch($gameActors._data[cs] instanceof Object
&& $gameActors._data[cs]._characterIndex === $gamePlayer._characterIndex){
case true:
for(cs2 = 0;cs2 < $gameActors._data[cs]._states.length;cs2++){
switch(csa[$gameActors._data[cs]._states[cs2]] instanceof Array
&& csa[$gameActors._data[cs]._states[cs2]].length === 2
&& $gameActors._data[cs]._states[cs2] === Number(csa[$gameActors._data[cs]._states[cs2]][0])){
case true:
this._moveSpeed = Number(csa[$gameActors._data[cs]._states[cs2]][1]);
return true;
}
}
break;
}
}
};
이 스크립트는 에러 발생시 2중 for문만 실행하고 나옵니다.
※ 실제 사용 방법 ※
속도 값 변화시 $gamePlayer.changeSpeed();
원래로 되돌릴 때는 $gamePlayer.initSpeed();
2중 for문을 사용했기에 속도가 저하되는 관계로
switch문으로 보완하려고 했습니다.
if문으로도 속도가 떨어지지 않는다면 if문을 쓰시길...
제가 작성해드린 방식은 속도 최적화 방식이 아닙니다.