解説/初級編

ワークエリアの利用

new Theater({
  img: [
    "img/sample1.gif",
    "img/sample2.gif",
    "img/sample3.gif"
  ],
  scenario:[
    function(){
      this.work.count = 0;
      this.act({
        img: "img/sample1.gif",
        msg: "カウント:" + this.work.count
      });
    },
    function(){
      this.work.count++;
      this.act({
        img: "img/sample2.gif",
        msg: "カウント:" + this.work.count
      });
    },
    function(){
      this.work.count++;
      this.act({
        img: "img/sample3.gif",
        msg: "カウント:" + this.work.count
      });
    }
  ]
});

シナリオ関数の返却値と引数

new Theater({
  img: [
    "img/sample1.gif",
    "img/sample2.gif",
    "img/sample3.gif"
  ],
  scenario:[
    function(){
      this.act({
        img: "img/sample1.gif",
        msg: "trueを返却・・・"
      });
      return true;
    },
    function(result){
      this.act({
        img: "img/sample2.gif",
        msg: "前のシナリオ関数の返却値:" + result
             + "。falseを返却・・・"
      });
      return false;
    },
    function(result){
      this.act({
        img: "img/sample3.gif",
        msg: "前のシナリオ関数の返却値:" + result
      });
    }
  ]
});

サブシナリオの設定と実行

var subScenario = [
  function(){
    this.act({
      img: "img/sample2.gif",
      msg: "サブシナリオ1"
    });
  },
  function(){
    this.act({
      img: "img/sample3.gif",
      msg: "サブシナリオ2"
    });
  }
];

new Theater({
  img: [
    "img/sample1.gif",
    "img/sample2.gif",
    "img/sample3.gif",
    "img/sample4.gif"
  ],
  scenario:[
    function(){
      this.act({
        img: "img/sample1.gif",
        msg: "メインシナリオ1"
      });
    },
    function(){
      this.push(subScenario);
      this.keep();
    },
    function(){
      this.act({
        img: "img/sample4.gif",
        msg: "メインシナリオ2"
      });
    }
  ]
});

基本メニュー表示とユーザ入力取得

new Theater({
  img: [
    "img/sample1.gif",
    "img/sample2.gif",
    "img/sample3.gif"
  ],
  scenario:[
    function(){
      this.alert("alertメソッド。");
    },
    function(){
      this.confirm("confirmメソッド。");
    },
    function(result){
      this.act({
        img: "img/sample1.gif",
        msg: "confirmの結果:" + result
      });
    },
    function(){
      this.prompt("promptメソッド。", "初期値です。");
    },
    function(result){
      this.act({
        img: "img/sample2.gif",
        msg: "promptの結果:" + result
      });
    },
    function(){
      this.choice(["choice1", "choice2", "choice3"]);
    },
    function(result){
      this.act({
        img: "img/sample3.gif",
        msg: "choiceの結果:" + result
      });
    }
  ]
});

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS