파렌하이트 MYPI

파렌하이트
접속 : 3822   Lv. 55

Category

Profile

Counter

  • 오늘 : 6 명
  • 전체 : 112373 명
  • Mypi Ver. 0.3.1 β
[RPG MV] (0) 2017/05/29 PM 05:55

/*:

* @help SceneManager.goto(SelectScene)

* @plugindesc 목록을 선택할 새 씬과 윈도우를 출력한다. V2

* @author 파렌하이트

*/


// --scene--

// 씬 생성

    function SelectScene() {

        this.initialize.apply(this, arguments);

    }


    SelectScene.prototype = Object.create(Scene_MenuBase.prototype);

    SelectScene.prototype.constructor = Scene_Menu;


    SelectScene.prototype.initialize = function() {

        Scene_MenuBase.prototype.initialize.call(this);

    };


    SelectScene.prototype.create = function() {

        Scene_MenuBase.prototype.create.call(this);

        this.createWindow();

    };


    SelectScene.prototype.start = function() {

        Scene_MenuBase.prototype.start.call(this);

        this.Connect();

    };


    SelectScene.prototype.createWindow = function(){

        this._newWindow = new SelectWindow(0, 0);

        this.addWindow(this._newWindow);

    }

    

    SelectScene.prototype.update = function(){

        Scene_MenuBase.prototype.update.call(this);

        

        if(Input.isTriggered('cancel')){    // out

            this.DisConnect();

        }

    }

    

    // Scene 실행시

    SelectScene.prototype.Connect = function(){

        console.log('connect');

    }

    // Scene 종료시

    SelectScene.prototype.DisConnect = function(){

        SceneManager.goto(Scene_Map);

        SoundManager.playCancel();

        console.log('disconnect');

    }

    

// --variables

// 변수들

        var length = 15;

        var list = new Array(length);

        for(var i = 0; i < list.length; i++)

        {

            list[i] = 'slot ' + i;

        }



// ---Selectable window---

// 선택박스를 출력하는 윈도우를 구현한다.

    function SelectWindow() {

        this.initialize.apply(this, arguments);

    }


    SelectWindow.prototype = Object.create(Window_Selectable.prototype);

    SelectWindow.prototype.constructor = SelectWindow;


    SelectWindow.prototype.initialize = function(x, y, width, height) {

        Window_Selectable.prototype.initialize.call(this, x, y, 200, 500);

        this.select(0); // 초기 커서의 위치

        this.maxItems();

        this.drawAllItems();

    }

    

    // 아이템 배열의 최대값을 지정한다.

    SelectWindow.prototype.maxItems = function() {

        return length;

    };


    // 지정된 아이템 배열의 수 만큼 반복한다.

    SelectWindow.prototype.drawAllItems = function() {

    var topIndex = this.topIndex();

    for (var i = 0; i < this.maxPageItems(); i++) {

        var index = topIndex + i;

        if (index < this.maxItems()) {

            this.drawItem(index);

            }

        }

    };


    // 지정된 아이템 배열 값을 출력한다.

    SelectWindow.prototype.drawItem = function(index) {

        var rect = this.itemRectForText(index);

        // var align = this.itemTextAlign();

        // this.resetTextColor();

        // this.changePaintOpacity(this.isCommandEnabled(index));

        this.drawText(list[index], rect.x, rect.y, rect.width, 0);

    };

    

    SelectWindow.prototype.update = function(){

        Window_Selectable.prototype.update.call(this);

        this.cursorMove();

        this.scrollingKey();

        this.scrollingWheel();

    }

    

    // 커서를 움직인다.

    SelectWindow.prototype.cursorMove = function(){

        if (Input.isRepeated('up')) {

            this.cursorUp(Input.isTriggered('up'));

        }

        else if (Input.isRepeated('down')) {

            this.cursorDown(Input.isTriggered('down'));

        //  console.log(this._index);

        }

    }

    

    // 키보드의 페이지업/다운키로 스크롤을 움직인다.

    SelectWindow.prototype.scrollingKey = function(){

        if (!this.isHandled('pagedown') && Input.isTriggered('pagedown')) {

            this.cursorPagedown();

        }

        if (!this.isHandled('pageup') && Input.isTriggered('pageup')) {

            this.cursorPageup();

        }

    }

    

    // 마우스 휠로 스크롤을 움직인다.

    SelectWindow.prototype.scrollingWheel = function(){

        if (TouchInput.wheelY >= 20) {

            this.scrollDown();

        }

        if (TouchInput.wheelY <= -20) {

            this.scrollUp();

        }

    }

 

과거 단순히 씬과 윈도우를 만들어 출력하는 것에서 살짝 더 발전하여, 선택이 가능한 목록을 구현하였다.

유니티에서 써먹었던 꼼수로도 구현이 가능하나, 효율이 엄청나게 나빠지기 때문에 어쩔수없이 기본으로 지원하는 함수들을 이리저리 찾아가며 구현하였다. 뭐 이렇게 표현을 했지만 대부분 복사, 붙여넣기 신공이고 몇몇 변수를 살짝 바꾸어주니 운좋게 작동하는 것 뿐이지.

 

신고

 
[RPG MV] (0) 2017/05/25 PM 06:06

/*:

* @help SceneManager.goto(NewScene)

* @plugindesc 새로운 씬을 생성하고 씬 안에 새로운 윈도우를 생성, 출력한다.

* @author 파렌하이트

*/


    function NewScene() {

        this.initialize.apply(this, arguments);

    }


    NewScene.prototype = Object.create(Scene_MenuBase.prototype);

    NewScene.prototype.constructor = Scene_Menu;


    NewScene.prototype.initialize = function() {

        Scene_MenuBase.prototype.initialize.call(this);

    };


    NewScene.prototype.create = function() {

        Scene_MenuBase.prototype.create.call(this);

        this.createWindow();

    };


    NewScene.prototype.start = function() {

        Scene_MenuBase.prototype.start.call(this);

    };



    NewScene.prototype.createWindow = function(){

        this._newWindow = new NewWindow(0, 0);

        this.addWindow(this._newWindow);

    }


    function NewWindow() {

        this.initialize.apply(this, arguments);

    }


    NewWindow.prototype = Object.create(Window_Base.prototype);

    NewWindow.prototype.constructor = NewWindow;


    NewWindow.prototype.initialize = function(x, y) {

        Window_Base.prototype.initialize.call(this, x, y, Graphics.width * 0.5, Graphics.height);

    };

 

여전히 RMMV JS에 대한 이해도는 부족하다.

새로운 창을 만들기 위해서는 창의 정보를 갖는 씬을 새롭게 만들어야하는듯하다.

씬과 윈도우의 차이는 뭐랄까.

씬은 인게임 중 메뉴화면을 펼치면 나오는 것들을 담는 무엇이라고 할까.

윈도우는 말 그대로 출력되서 나타내는 창이고.

유투브에 강좌가 제법 여럿되지만 역시나 한글은 없다. 뭐, 당연하겠지.

몇몇 강좌를 보고있노라니 도무지 이해가 가지 않아, 결국엔 직접 스크립트들을 봐가며 눈치껏 노력해보는 중이다.

 

본문은 빈 윈도우를 출력하는 신으로서 메뉴를 만드는데 기본적인 것이라고 하면 좋을듯하다.

뭔가 말에 일관성이 없고 주구난방하다-_-

 

SceneManager.goto(NewScene)는 위의 구문을 인게임에서 불러들이는 명령어다.

 

사실 씬이 아니라 윈도우만 만들수도 있지만, 윈도우는 어디까지나 출력을 위한 것으로서 윈도우만 띄우면 윈도우가 띄어진 상태로 다른 조작도 가능하게 된다. 그러니까 아이템, 스킬 등 추가적인 조작이 필요한 메뉴에서 방향키를 눌렀더니 아이템이나 스킬을 선택하는게 아니라 필드에 있는 캐릭터가 움직이는 상황이 나타난다는 것이지. 반대로 윈도우만 만들면 HUD등 상시 출력되는 정보창 따위를 만들수있으니 각각 장단점이 있다.

신고

 
[작업2] (0) 2017/05/25 AM 09:44

본 글은 비공개 게시물이며, 본인만 볼 수 있습니다.

신고

 
[작업2] (0) 2017/05/19 AM 11:07

본 글은 비공개 게시물이며, 본인만 볼 수 있습니다.

신고

 
[작업] (0) 2017/05/17 PM 05:54

본 글은 비공개 게시물이며, 본인만 볼 수 있습니다.

신고

 
이전 6 7 8 현재페이지9 10 다음
X