モジュールを作っていく過程で問題が発生していったので書き換えた。
!!novel.setText
novel.setText("");
::("")内に文字を書き込むことによって文字を出力。
!!novel.setPageBreak
novel.setPageBreak();
::ページを新たに読み込む
!!novel.setChoice
novel.setChoice(1,
::"",
::"",
::"",
::"",
::"",
::core.selectChoice);
::最初の引数でidを設定し上から""内の文字を出力し、その文字を選択することによって上から1から4までのselect番号をあたえ、core.selectChoiceでその返答を出力する関数に遷移する。
!!core.selectChoice
core.selectChoice = function(id, select) {
::switch (id) {
::case 1:
::switch (select) {
::case 1:
::・・・・・・・・
::break;
::case 2:
::・・・・・・・・・
::break;
::case 3:
::・・・・・・・・・
::break;
::case 4:
::・・・・・・・・・
::break;
::default:
::break;
::}
break;
::}
渡されたid、selectに応じた条件分岐
::
!!core.currentScene.ontouchstart
core.currentScene.ontouchstart = function() {
::novel.next();
::}
::画面タッチで次へ行くように読み込んでいる。
!!!novel.enchant.jsの変更・追加プログラム
!!text5の追加
/**
::* 選択肢の設定.
::* @param {Number} id
::* @param {String} text1
::* @param {String} text2
::* @param {String} text3
::* @param {String} text4
::* @param {String} text5
::* @param {Function} callback 選択時のコールバック関数.
::*/
::setChoice: function( id, text1, text2, text3, text4, text5, callback ) {
::this.action.push( this.ACTION_CHOICE );
::this.action.push( [ 1, text1 ] );
::this.action.push( [ 2, text2 ] );
::this.action.push( [ 3, text3 ] );
::this.action.push( [ 4, text4 ] );
::this.action.push( [ 5, text5 ] );
::this.action.push( this.ACTION_SELECT );
::this.action.push( [ id, callback ] );
::}
::text5を追加することにより今までより多くの条件分岐を可能とした。
!!+540
for ( var i = 0 ; i < this.parentNode.lineMax ; i++ ) { ::// 何行目をタッチされたか.
::if ( this.parentNode.lines[ i ].y + 540 > evt.y ) {
::lineTouch=i;
::// タッチされた行数.
::break;
::}
::}
::文字を表示するときにy座標が540の位置からスタートするため条件分岐を選択するときの選択肢のy座標に540を加えなければならないためそれを加えた。
!!novel.setIMG();
::this.ACTION_IMG= "ACTION CODE : Img !!!";
::・・・・・・・・・・・・・
::setIMG: function( IMG ) {
::this.action.push( this.ACTION_IMG );
::this.action.push( [ IMG ] );
::},
::・・・・・・・・・・・・・
::if ( this.ACTION_IMG == action ) {
::this.actionNow = this.ACTION_IMG;
::action = this.action.shift(); ::// アクションの取出し
::Others.Background.create(action[0]);
:://入れ替え
::return;
::}
::novel.setIMG("A");
Aの中に画像を入れることで別ファイルから関数を呼び出し画像をセットする関数をnovel.enchant.jsで定義した。こうすることにより