本文へスキップ
期間限定Starterは現在$9/月です(通常$20/月)。プランを見る
charmotion

アニメーション付きのスプラッシュやローディング用マスコットを追加するAIプロンプト

Charmotionチーム · 更新日: · ガイドの作成方針

ガイドのカバーイラスト:アニメーション付きスプラッシュやローディングのマスコットを追加するAIプロンプト、Charmotionのデモキャラクター入り

Cursor、Claude Code、Lovable、Bolt、v0などのAIコーディングツールでも、よく推測を誤る点をプロンプトで明示すれば、アニメーション付きのスプラッシュやローディングのマスコットを追加できます。具体的には、OSのスプラッシュは静止画のままにすること、イントロは最初の画面で再生すること、正確なステートマシン名、ファイルが終了イベントを発火しないための2.6秒のタイマー、1つに統一した背景色、動きを減らす設定のときの代替表示です。

要点

  • 共通ルールのブロックをプロンプトかプロジェクトのルールに貼り付ければ、どのツールにも同じ事実が伝わります。
  • OSの起動画面は静止画のままにするよう伝えます。伝えないと、起動画面自体をアニメーションにしようとすることがあります。
  • launchファイルは終了イベントを発火しないと明記します。そうしないと、ツールが決して呼ばれないコールバックを作り出してしまいます。
  • フレームワーク、パッケージ、ファイルパスを指定します。あいまいなプロンプトでは、.rivファイルに対してLottieのコードが生成されます。
  • 結果を短いチェックリストで確認します。色の一致、タイマー、安全用のタイムアウト、動きを減らす設定です。

キャラクターやロゴをすでにお持ちですか?実際のアプリ画面で作例を見る:スプラッシュ、オンボーディング、ローディング、空状態の各画面と、それぞれで再生されるアニメーションを紹介しています。

AIコーディングツールがアニメーション付きスプラッシュ画面を間違えるのはなぜですか?

学習データで最もよく見られる答えが、ご自身のアプリにとっては間違った答えだからです。詳細を伝えずに「アニメーション付きのスプラッシュ画面」を頼むと、次のいずれかがよく返ってきます。

  • LaunchScreen.storyboardにアニメーションを入れようとする。このファイルでは、コード接続のない標準のUIKitクラスしか使えません(Apple)。
  • .rivファイルを指定したLottieコンポーネント、または頼んでいない新しいアニメーションライブラリ。
  • ファイルが決して発火しない「アニメーション終了」イベントのリスナー。そのため、アプリがイントロで止まってしまいます。
  • Expo GoでRiveのコードを実行する。Expo Goではネイティブモジュールを読み込めません(Rive)。
  • スプラッシュ、ルートビュー、イントロの色が異なることによる白いフラッシュ。
  • 動きを減らす設定への対応がまったくない。

解決策は、ツールに事実を最初から伝えることです。毎回繰り返さなくて済むよう、永続的なプロジェクトの指示に書いておきます。Claude CodeはCLAUDE.mdを読み込み、AGENTS.mdも読めます(Claude Code Docs)。Cursorは.cursor/rules内のプロジェクトルールを.mdcファイルとして読み込み、AGENTS.mdにも対応しています(Cursor Docs)。LovableにはワークスペースとプロジェクトのKnowledgeがあり、常にコンテキストに含まれます(Lovable Docs)。Boltとv0では、チャットの冒頭にルールを貼り付けます。

すべてのスプラッシュ用プロンプトに含めるべきルールは?

以下の各フレームワーク用プロンプトの前にこのブロックを貼り付け、角かっこ内の値を置き換えてください。Charmotionのlaunchファイル(LaunchStateMachine、2.6秒のイントロ、終了イベントなし)を前提にしています。ファイルが異なる場合は、該当する行を変更してください。

Rules for the launch animation (follow exactly):
- The OS launch screen stays static. Do not try to animate
  LaunchScreen.storyboard, UILaunchScreen, the Expo splash config
  or flutter_native_splash. The animation plays on the FIRST SCREEN.
- Asset: [assets/launch.riv]. State machine: "LaunchStateMachine".
  It plays a 2.6 s intro once and settles on the resting icon.
- The file fires NO end event. Do not listen for "introDone",
  "onComplete" or any other event. Wait 2.6 s with a timer, then
  continue. Add a 4 s safety timeout in case the file fails to load.
- Background color [#0E1116] must be identical on the native
  splash, the root view and the intro screen (light and dark).
- Show the intro at the same size and center position as the icon
  on the native splash, so there is no visible jump.
- Reduced motion: if the user has it enabled, skip the intro and
  show the still icon [assets/icon_rest.png], then continue.
- Never block the app longer than the intro. Do not add extra delay.
- Do not add Lottie or any other animation library.

タイマーのルールが重要な理由:Riveのステートマシンは、作成者が組み込んだイベントしか発行しません。Charmotionのlaunchファイルは1回だけ再生されて静止ポーズで止まり、何も発行しないため、正しく次へ進む唯一の方法は、その長さだけ待つことです。イベント名をでっち上げないようツールに伝えておけば、最もよくあるフリーズを防げます。

Charmotionのダウンロードには、.rivと一緒にWeb、React、SwiftUIのコードも含まれているため、説明する代わりに動作するサンプルをプロンプトに添付できます。

SwiftUIでアニメーション付きスプラッシュを追加するプロンプトは?

XcodeプロジェクトでCursorやClaude Codeを使う場合:

Add a launch intro to this SwiftUI app.

[paste the rules block]

Details:
- Add the RiveRuntime Swift package (rive-ios) if it is missing.
- Bundle launch.riv in the app target.
- Create LaunchIntroView: full-screen Color("LaunchBackground"),
  centered 160x160 RiveViewModel(fileName: "launch",
  stateMachineName: "LaunchStateMachine").view().
- In the App struct, show LaunchIntroView over ContentView with a
  @State showIntro = true. After 2.6 s (Task.sleep), set it to false
  with a 0.25 s opacity transition.
- Read @Environment(\.accessibilityReduceMotion). If true, do not
  show the intro at all.
- Set UILaunchScreen in Info.plist: UIColorName = LaunchBackground,
  UIImageName = IconRest (same size as the intro's icon).
- Do not modify LaunchScreen.storyboard beyond static views.
Show me the files you changed.

新しいRive Appleランタイムを含む、手書きの完全版はSwiftUIでアニメーション付きスプラッシュ画面を作るにあります。

ExpoやReact Nativeでアニメーション付きスプラッシュを追加するプロンプトは?

Add an animated launch intro to this Expo app (Expo Router).

[paste the rules block]

Details:
- Use expo-splash-screen: call SplashScreen.preventAutoHideAsync()
  in global scope in app/_layout.tsx. Call SplashScreen.hideAsync()
  only after the Rive file has loaded.
- In app.json, set the expo-splash-screen plugin backgroundColor,
  image (assets/icon-rest.png), imageWidth 160 and dark options, and
  the same root "backgroundColor". Install expo-system-ui if needed.
- Use @rive-app/react-native with react-native-nitro-modules, installed
  with npx expo install. This needs a development build, not Expo Go.
- Add "riv" to resolver.assetExts in metro.config.js.
- Create components/LaunchIntro.tsx: useRiveFile(require(...)),
  RiveView with stateMachineName="LaunchStateMachine", autoPlay,
  160x160, centered on the background color. Call onDone after
  2600 ms with setTimeout. Add a 4000 ms safety timeout.
- Check AccessibilityInfo.isReduceMotionEnabled(); if true, hide the
  splash and call onDone immediately.
- Do not use Lottie. Do not listen for any Rive event.

各ステップの背景知識:ExpoとReact Nativeのアニメーション付きスプラッシュとExpoでRiveを使う。

Flutterでアニメーション付きスプラッシュを追加するプロンプトは?

Add an animated launch intro to this Flutter app.

[paste the rules block]

Details:
- Keep flutter_native_splash for the native splash (color [#0E1116],
  image assets/icon_rest.png). It stays static.
- In main(): binding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: binding);
  await RiveNative.init();
- Add the rive package. Create IntroPage (StatefulWidget) as home:
  load File.asset('assets/launch.riv', riveFactory: Factory.rive),
  create RiveWidgetController with
  StateMachineSelector.byName('LaunchStateMachine'), render
  RiveWidget in a 160x160 SizedBox centered on the background color.
- Call FlutterNativeSplash.remove() after the file loads, wait
  2600 ms, then Navigator.pushReplacement to the existing home page.
- If MediaQuery.disableAnimationsOf(context) (or
  platformDispatcher.accessibilityFeatures.disableAnimations) is true,
  show Image.asset('assets/icon_rest.png') and navigate immediately.
- Dispose the controller and the file in dispose().

同じコードを書き出して解説したものはFlutterでアニメーション付きスプラッシュ画面を作るにあります。

Next.js、Lovable、Bolt、v0でアニメーション付きイントロを追加するプロンプトは?

WebアプリにはOSのスプラッシュがないため、それに当たるのはファーストビューや初回描画時のイントロです。Lovable、Bolt、v0は一般にReactを生成するため、1つのプロンプトでまとめて対応できます。

Add an animated logo intro to the hero of this React / Next.js page.

Assets (in /public):
- logo-intro.webm (VP9 with alpha), logo-intro.mov (HEVC with alpha),
  logo-rest.webp (the still final frame, same size).

Rules:
- Render a <video autoplay muted playsinline> with poster="/logo-rest.webp",
  fixed width and height (no layout shift), and two sources in this
  order: logo-intro.mov with type 'video/mp4; codecs="hvc1"', then
  logo-intro.webm with type "video/webm".
- Do not loop. When it ends, keep the last frame (it matches the poster).
- If play() rejects, keep showing the poster.
- With prefers-reduced-motion: reduce, render only the poster image.
- In Next.js, make the component a client component.
- Do not add Lottie, GSAP or any other animation library.

動画ではなくWeb上でインタラクティブなマスコットを使うなら、@rive-app/react-webgl2をstateMachine: "CharacterViewModelMachine"とautoBind: trueで使うよう指定します(Rive)。sourceの順序とコーデックは、Jake Archibaldのクロスブラウザ対応の手法に従っています(Jake Archibald)。Webサイトで背景透過動画を使う方法もご覧ください。

スプラッシュではなくローディングのマスコットを追加するプロンプトは?

同じキャラクターファイルで、ローディングのステートも動かせます。このプロンプトは上のルールのファイル構成(Character view model)を前提にしています。プロパティ名はご自身のファイルに合わせて変更してください。

Show the mascot while [the image generation request] is pending.

- File: [assets/character.riv]. State machine: "CharacterViewModelMachine".
  View model "Character" with a number property "mood". It has
  no triggers.
- Mood values: 0 idle, 1 happy, 4 sad, 5 loading.
- Before the request: set mood = 5. On success: set mood = 1,
  then back to 0 after 1.5 s. On failure: set mood = 4 and show
  the error text.
- Only show the mascot if the request takes longer than 600 ms.
- Keep visible "Loading…" text with role="status" (web) or an
  accessibility label (native). Hide the animation itself from
  screen readers.
- Reduced motion: show the still image and the text, no animation.
- If the file has no "Character" view model, fall back to the
  legacy "CharacterStateMachine" with the same number input "mood".

ローディングのタイミングとアクセシビリティについては、ローディングアニメーションを追加する方法で詳しく解説しています。

AIツールが書いたコードはどう確認すればいいですか?

マージする前に、次の点を確認します。

  1. OSのスプラッシュは手を加えていないか、静止画のまま。起動用のstoryboardにコードはなく、Androidではdrawable-v31以外にアニメーションのdrawableがない。
  2. スプラッシュ、ルート、イントロの背景色が1つに統一されている(ライトモードとダークモードの両方で)。
  3. でっち上げたイベントではなくタイマーでイントロを終了し、安全用のタイムアウトもある。
  4. ファイルの読み込み後にスプラッシュを消している。読み込み前ではない(空のフレームが出ない)。
  5. 動きを減らす設定でイントロをスキップする(OSの設定をオンにして確認し、Webではprefers-reduced-motionを使う)(MDN)。
  6. 予期しない依存関係がない。ツールが勝手に追加したライブラリは削除する。
  7. Expoではリリースビルドでテスト済み、すべてのプラットフォームで実機テスト済み。

よくある質問

スプラッシュアニメーションの追加におすすめのAIコーディングツールは?

ツールよりもプロンプトのほうが重要です。CursorとClaude Codeは既存のネイティブプロジェクトやExpoプロジェクトの中で動作し、Lovable、Bolt、v0はWebのReactアプリに最も強みがあります。ステートマシン名、決まったイントロの長さ、共通の背景色、動きを減らす設定のルールを伝えれば、どれでもうまくいきます。

AIで生成したスプラッシュのイントロがいつまでも終わらないのはなぜですか?

たいていは、アニメーションファイルが発火しない終了イベントをコードが待っているからです。CharmotionのLaunchStateMachineは、2.6秒のイントロが終わってもイベントを発行しません。リスナーを2,600msのタイマーに置き換え、アプリが必ず次へ進むよう安全用のタイムアウトを追加してください。

スプラッシュのルールはCLAUDE.mdやCursorのルールに書くべきですか?

はい。複数の人やセッションが起動フローに手を入れるなら、書いておきましょう。Claude Codeは毎セッションCLAUDE.mdを読み込み(AGENTS.mdも読めます)、Cursorは.cursor/rulesの.mdcルールを適用するため、タイマー、色、動きを減らす設定のルールがどの編集でも守られます。

このガイドのQ&A

出典

関連ガイド