Langsung ke konten
Promo terbatasStarter kini US$9 per bulan, sebelumnya US$20.Lihat paket
charmotion

Prompt AI untuk Menambahkan Maskot Splash atau Loading Animasi

Oleh tim Charmotion · Diperbarui · Cara kami menulis panduan

Ilustrasi sampul untuk panduan: Prompt AI untuk Menambahkan Maskot Splash atau Loading Animasi, dengan karakter demo Charmotion

Alat coding AI seperti Cursor, Claude Code, Lovable, Bolt, dan v0 bisa menambahkan maskot splash atau loading animasi jika prompt menyebutkan hal yang biasanya mereka tebak salah: splash OS tetap statis, intro diputar di layar pertama, nama state machine yang tepat, timer 2,6 detik karena file tidak memicu event akhir, satu warna background, dan fallback untuk reduced motion.

Poin penting

  • Tempel blok aturan bersama ke dalam prompt atau aturan proyek Anda agar setiap alat mendapat fakta yang sama.
  • Beri tahu alat bahwa launch screen OS harus tetap statis; jika tidak, alat itu mungkin mencoba menganimasikannya.
  • Sebutkan bahwa file launch tidak memicu event akhir, atau alat akan mengarang callback yang tidak pernah terpanggil.
  • Sebutkan framework, package, dan path file; prompt yang samar menghasilkan kode Lottie untuk file .riv.
  • Tinjau hasilnya dengan checklist singkat: kecocokan warna, timer, timeout pengaman, reduced motion.

Sudah punya karakter atau logo? Lihat contoh di layar aplikasi sungguhan: layar splash, onboarding, loading, dan empty state, dengan animasi yang diputar di masing-masing layar.

Kenapa alat coding AI sering salah membuat splash screen animasi?

Karena jawaban paling umum di data pelatihannya justru jawaban yang salah untuk aplikasi Anda. Minta "splash screen animasi" tanpa detail, dan Anda sering mendapat salah satu dari ini:

  • Upaya memasukkan animasi ke LaunchScreen.storyboard, yang hanya boleh memakai class UIKit standar tanpa koneksi ke kode (Apple).
  • Komponen Lottie yang diarahkan ke file .riv, atau library animasi baru yang tidak Anda minta.
  • Listener untuk event "animasi selesai" yang tidak pernah dipicu file, sehingga aplikasi macet di intro.
  • Kode Rive yang dijalankan di Expo Go, yang tidak bisa memuat native module (Rive).
  • Kilatan putih, karena splash, root view, dan intro memakai warna yang berbeda.
  • Sama sekali tidak ada jalur untuk reduced motion.

Solusinya adalah memberi alat fakta-fakta itu sejak awal. Simpan di instruksi proyek yang permanen agar Anda tidak perlu mengulanginya: Claude Code membaca CLAUDE.md dan bisa membaca AGENTS.md (Claude Code Docs), Cursor membaca aturan proyek di .cursor/rules sebagai file .mdc dan mendukung AGENTS.md (Cursor Docs), dan Lovable punya Knowledge tingkat workspace dan proyek yang selalu ada dalam konteks (Lovable Docs). Untuk Bolt dan v0, tempel aturannya di awal chat.

Aturan apa yang harus ada di setiap prompt splash?

Tempel blok ini sebelum prompt framework mana pun di bawah, lalu ganti nilai di dalam kurung siku. Blok ini mengasumsikan file launch Charmotion (LaunchStateMachine, intro 2,6 detik, tanpa event akhir); jika file Anda berbeda, ubah baris-baris itu.

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.

Kenapa aturan timer penting: state machine Rive hanya memancarkan event yang dibuat oleh pembuatnya. File launch Charmotion diputar sekali, berhenti di pose diam, dan tidak memancarkan apa pun, jadi satu-satunya cara yang benar untuk melanjutkan adalah menunggu sesuai durasinya. Melarang alat mengarang nama event mencegah penyebab macet yang paling umum.

Unduhan Charmotion juga menyertakan kode web, React, dan SwiftUI di samping .riv, jadi Anda bisa melampirkan contoh yang berfungsi ke prompt alih-alih menjelaskannya.

Prompt apa yang menambahkan splash animasi di SwiftUI?

Untuk Cursor atau Claude Code di proyek Xcode:

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.

Versi lengkap yang ditulis manual, termasuk runtime Rive Apple yang baru, ada di splash screen animasi di SwiftUI.

Prompt apa yang menambahkan splash animasi di Expo atau 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.

Latar belakang setiap langkah: splash animasi di Expo dan React Native dan Rive di Expo.

Prompt apa yang menambahkan splash animasi di 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().

Kode yang sama, ditulis lengkap dan dijelaskan: splash screen animasi di Flutter.

Prompt apa yang menambahkan intro animasi di Next.js, Lovable, Bolt, atau v0?

Aplikasi web tidak punya splash OS, jadi padanannya adalah intro di hero atau saat halaman pertama kali tampil. Lovable, Bolt, dan v0 biasanya menghasilkan React, jadi satu prompt cukup untuk semuanya:

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.

Untuk maskot interaktif di web alih-alih video, minta @rive-app/react-webgl2 dengan stateMachine: "CharacterViewModelMachine" dan autoBind: true (Rive). Urutan source dan codec mengikuti pendekatan lintas browser dari Jake Archibald (Jake Archibald); lihat video transparan di website.

Prompt apa yang menambahkan maskot loading, bukan splash?

File karakter yang sama bisa menggerakkan state loading. Prompt ini mengasumsikan struktur file dari aturan di atas (view model Character); ganti nama properti agar sesuai dengan milik Anda:

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".

Selengkapnya tentang timing loader dan aksesibilitas di cara menambahkan animasi loading.

Bagaimana cara memeriksa kode yang ditulis alat AI?

Periksa poin-poin ini sebelum merge:

  1. Splash OS tidak diubah atau tetap statis. Tidak ada kode di launch storyboard, tidak ada drawable animasi di luar drawable-v31 di Android.
  2. Satu warna background untuk splash, root, dan intro, di mode terang dan gelap.
  3. Timer, bukan event karangan, yang mengakhiri intro, plus timeout pengaman.
  4. Splash disembunyikan setelah file dimuat, bukan sebelumnya (tidak ada frame kosong).
  5. Reduced motion melewati intro (periksa dengan pengaturan OS dalam keadaan aktif, memakai prefers-reduced-motion di web) (MDN).
  6. Tidak ada dependensi tak terduga. Hapus library apa pun yang ditambahkan alat atas inisiatifnya sendiri.
  7. Diuji di release build untuk Expo, dan di perangkat asli untuk semua platform.

Pertanyaan yang sering diajukan

Alat coding AI mana yang terbaik untuk menambahkan animasi splash?

Alatnya tidak sepenting prompt-nya. Cursor dan Claude Code bekerja di dalam proyek native atau Expo yang sudah ada; Lovable, Bolt, dan v0 paling kuat untuk aplikasi web React. Semuanya berhasil jika Anda memberikan nama state machine, durasi intro yang tetap, warna background bersama, dan aturan reduced motion.

Kenapa intro splash buatan AI saya tidak pernah selesai?

Biasanya karena kode menunggu event akhir yang tidak dipicu file animasi. LaunchStateMachine Charmotion tidak memancarkan event apa pun saat intro 2,6 detiknya selesai. Ganti listener dengan timer 2.600 ms dan tambahkan timeout pengaman agar aplikasi selalu berlanjut.

Sebaiknya aturan splash ditaruh di CLAUDE.md atau aturan Cursor?

Ya, jika lebih dari satu orang atau sesi akan menyentuh alur launch. Claude Code memuat CLAUDE.md (dan bisa membaca AGENTS.md) di setiap sesi, dan Cursor menerapkan aturan .mdc dari .cursor/rules, sehingga aturan timer, warna, dan reduced motion tetap berlaku di setiap perubahan.

Jawaban cepat dari panduan ini

Sumber

Panduan terkait