Yukiの変更
Yukiに関して、以前はマクロ言語として別ファイル扱いでしたが、これを廃して、DSL形式(Rubyスクリプトとして実行します)に変更しました。
また、Yukiを使うときは、Sceneモジュール(Miyako 1.5では、Sceneはクラスからモジュールに変更になりました)と一緒にmixinする必要があります。
#! /usr/bin/ruby require 'Miyako/miyako' require 'Miyako/idaten_miyako' include Miyako class Storys include Story end class MainScene include Story::Scene # Yukiを使うときはSceneモジュールのmixin必須 include Yuki def init # シーンの初期化 wc = Sprite.new({:file=>'img/wait_cursor.png',:type=>:ac}) wc.oh = wc.w wa = SpriteAnimation.new({:sprite=>wc, :wait=>0.1}) sc = Sprite.new({:file=>'img/cursor.png',:type=>:ac}) sc.oh = sc.w sa = SpriteAnimation.new({:sprite=>sc, :wait=>0.1}) @box = TextBox.new({:wc => wa, :sc => sa}) init_yuki(@box) # Yukiを使うときはテキストボックスとinit_yuki呼び出し必須 @v = 0 @com1 = [Command.new("こたえ1", nil, "a1"), # コマンドは、Command構造体のインスタンス Command.new("こたえ2", condition{ @v == 100 }, "a2"), # 要素は、左から「表示するコマンド名」、「表示(選択可能)条件」、「結果」 Command.new("こたえ3", nil, SubScene)] # 表示条件がnilのとは、無条件で表示する(condition{ true }と同じ) @img = Sprite.new({:file=>"scene1.png", :type=>:ac}) # Spriteインスタンスの作成は、ハッシュ引数に変更 @img.center @img.top end def setup @img.show end def plot # Yukiスクリプト本体(メソッド名は必ずplot) text "今日はいい天気ですね。こういう日は、ぱーっとどっかへ遊びに行きませんか?" # 文字の表示はtextメソッドで(自動折り返し機能あり) cr text "とりあえず、" color(:red){"どこ"} # 文字の色付けや、文字サイズの変更は、ブロックを使って対象文字を指定する text "へ行きましょうか。" pause clear text "じゃあ、駅へ行きましょうか。" cr command @com1 # シーンを移動する際は、異動先シーンクラスを返す #(そのクラスから生成されたインスタンスではないことに注意!) return result if result_is_scene? # 選択した結果がシーンかどうかは、result_is_scene?メソッドで確認できる text "#{result}を選びましたね" pause clear end def final @img.hide end end # MainSceneより移動してきたシーン class SubScene include Story::Scene include Yuki def init wc = Sprite.new({:file=>'img/wait_cursor.png',:type=>:ac}) wc.oh = wc.w wa = SpriteAnimation.new({:sprite=>wc, :wait=>0.1}) sc = Sprite.new({:file=>'img/cursor.png',:type=>:ac}) sc.oh = sc.w sa = SpriteAnimation.new({:sprite=>sc, :wait=>0.1}) @box = TextBox.new({:size=>Size.new(20,5), :wc => wa, :sc => sa}) @box.bottom @box.center init_yuki(@box) @img = Sprite.new({:file=>"scene2.png", :type=>:ac}) @img.center @img.top end def setup @img.show end def plot text "無事、別のシーンに飛べました" cr pause end def final @img.hide end end s = Storys.new s.run(MainScene) # シーン指定はクラスを直接指定