![見出し画像](https://assets.st-note.com/production/uploads/images/103721064/rectangle_large_type_2_2d2bf1b9f8f386cdbea8f8272066e746.png?width=1200)
【ティラノビルダー】タイトル画面の背景をランダムに表示する方法
![](https://assets.st-note.com/production/uploads/images/103719414/picture_pc_c336a5763db1e5d745ccc0855dea9d17.gif?width=1200)
ティラノビルダーで、タイトル画面の背景をランダムに表示する方法について解説します。
今回は、3つの背景画像からランダムに1つ選び表示させます。
【準備】
![](https://assets.st-note.com/img/1682208292090-bO9tTjlqSz.png?width=1200)
背景を追加します。
①iscriptコンポーネントの配置
![](https://assets.st-note.com/img/1682205619786-bI4eJ3BtTh.png?width=1200)
title_screenにiscriptコンポーネントを配置します。
![](https://assets.st-note.com/img/1682206172507-dDxqKKXJ8y.png?width=1200)
下記のコードを貼り付けます。
f.bg_list = [
"bg1.png",
"bg2.png",
"bg3.png"
];
f.bg_selected = f.bg_list[Math.floor(Math.random() * f.bg_list.length)];
【参考】背景が4つの場合
![](https://assets.st-note.com/img/1682206753253-CEAEC6YYos.png?width=1200)
②ティラノスクリプトコンポーネントの配置
![](https://assets.st-note.com/img/1682206903009-6voDgpKrYs.png?width=1200)
ティラノスクリプトコンポーネントを配置します。
![](https://assets.st-note.com/img/1682207088326-qSoj2o2RcL.png?width=1200)
下記のコードを貼り付けます。
[bg storage="&f.bg_selected" time="1000" method="fadeIn" cross="false"]
【コードの解説】
■ time (背景変更コンポーネントの項目:時間)
時間(ミリ秒)を指定できます。
■ method (背景変更コンポーネントの項目:演出効果)
演出効果を指定できます。
記事の最後に一覧を記載したので、よろしければ、お役立てください。
■ cross (背景変更コンポーネントの項目:元の背景にも効果を入れる)
cross="true"で、元の背景にも効果を入れます。
cross="false"で、元の背景には効果を入れません。
③背景変更コンポーネントの削除
![](https://assets.st-note.com/img/1682207887069-jSpHESWJug.png?width=1200)
背景変更コンポーネントを削除します。
![](https://assets.st-note.com/img/1682207958252-Ukps6PODRP.png?width=1200)
背景変更コンポーネントを削除しました。
これで、タイトル画面の背景をランダムに表示する手順は完了です。
以上で解説を終わります。おつかれさまでした。
【参考】演出効果の一覧
クロスフェード
method="fadeIn"
上からフェードイン
method="fadeInDown"
左からフェードイン
method="fadeInLeft"
右からフェードイン
method="fadeInRight"
下からフェードイン
method="fadeInUp"
左から回転
method="rotateInDownLeft"
右から回転
method="rotateInUpRight"
ズームイン
method="zoomIn"
上からスライド
method="slideInDown"
左からスライド
method="slideInLeft"
右からスライド
method="slideInRight"
下からスライド
method="slideInUp"
バウンド
method="bounceIn"
ローリング
method="rollIn"
バニッシュ
method="vanishIn"
パフ
method="puffIn"
この記事が気に入ったらサポートをしてみませんか?