
【ティラノスクリプト】クリア後のタイトル画面を変更する方法

ティラノスクリプトでクリア後にタイトル画面を変更する方法について解説します。
タイトル画面の背景画像を変更する
タイトル画面にボタンを追加する
上記の動作を実装します。
【title.ks】
[cm]
@clearstack
[if exp="sf.clear == undefined"]
[bg storage ="title.jpg" time=100]
[elsif exp="sf.clear == true"]
[bg storage="clear.png" time="100"]
[endif]
@wait time = 200
*start
[button x=135 y=230 graphic="title/button_start.png" enterimg="title/button_start2.png" target="gamestart" keyfocus="1"]
[button x=135 y=320 graphic="title/button_load.png" enterimg="title/button_load2.png" role="load" keyfocus="2"]
[button x=135 y=410 graphic="title/button_cg.png" enterimg="title/button_cg2.png" storage="cg.ks" keyfocus="3" cond="sf.clear == true"]
[button x=135 y=500 graphic="title/button_replay.png" enterimg="title/button_replay2.png" storage="replay.ks" keyfocus="4" cond="sf.clear == true"]
[button x=135 y=590 graphic="title/button_config.png" enterimg="title/button_config2.png" role="sleepgame" storage="config.ks" keyfocus="5"]
[s]
*gamestart
;一番最初のシナリオファイルへジャンプする
@jump storage="scene1.ks"
①背景の変更
[if exp="sf.clear == undefined"]
[bg storage ="title.jpg" time=100]
[elsif exp="sf.clear == true"]
[bg storage="clear.png" time="100"]
[endif]
sf.clear == undefined → 通常時の画像(title.jpg)
sf.clear == true → クリア後の画像(clear.png)
今回は上記の様に、背景画像を変更しています。
②ボタンの追加
[button x=135 y=410 graphic="title/button_cg.png" enterimg="title/button_cg2.png" storage="cg.ks" keyfocus="3" cond="sf.clear == true"]
[button x=135 y=500 graphic="title/button_replay.png" enterimg="title/button_replay2.png" storage="replay.ks" keyfocus="4" cond="sf.clear == true"]
cond="sf.clear == true"
上記の様に、condパラメータでsf.clearがtrueの場合のみ実行されるようにします。
【scene1.ks】
;ティラノスクリプトサンプルゲーム
*start
[cm ]
[clearfix]
[start_keyconfig]
[bg storage="room.jpg" time="100"]
;メニューボタンの表示
@showmenubutton
;メッセージウィンドウの設定
[position layer="message0" left=160 top=500 width=1000 height=200 page=fore visible=true]
;文字が表示される領域を調整
[position layer=message0 page=fore margint="45" marginl="50" marginr="70" marginb="60"]
;メッセージウィンドウの表示
@layopt layer=message0 visible=true
;キャラクターの名前が表示される文字領域
[ptext name="chara_name_area" layer="message0" color="white" size=28 bold=true x=180 y=510]
;上記で定義した領域がキャラクターの名前表示であることを宣言(これがないと#の部分でエラーになります)
[chara_config ptext="chara_name_area"]
#
scene1です[p]
[iscript]
sf.clear = true;
[endscript]
クリアしました[l][r]
タイトル画面に戻ります[p]
[layopt layer="message0" visible="false"]
[hidemenubutton]
[jump storage="title.ks"]
[iscript]
sf.clear = true;
[endscript]
クリアしたタイミングで、sf.clearにtrueを代入します。
これで、クリア後にタイトル画面を変更する手順は完了です。
以上で解説を終わります。おつかれさまでした。