Build OrbitRun with Smart Shape | Part 3: World changes and replay
Logo

Give your players somewhere to go. The purple hills will turn green, then red as the run continues. At 90 seconds, show their distance and a replay button. Save their best score so there’s something to beat next time.

Continue from Part 2, or open OrbitRun-09-countdown.tap from the checkpoint pack. Keep working in Skimmer's behavior editor.

The rebuilt game changing from Luna to Aurora during a live run

In the diagrams, REUSE means use the behavior you already added. For a reminder of the gestures, see connecting behaviors in Part 1. You can tap an image to open it at full size.

10. Travel through three worlds

The run starts in Luna Shores, changes to Aurora Reach after 30 seconds, and changes to Ember Drift after 60 seconds. The hills keep their physics and shape while their artwork changes.

Build Aurora's transition

Use Set Graphic with the generated terrain’s object ID. The Smart Shape Object reference explains its artwork roles.

Change the top graphic first. If it succeeds, change the fill and update the label.

Animated connection guide: Aurora: change and check

  1. Reuse Generate.
  2. Add Timer named Aurora Timer. Connect a free bottom white circle on Generate to Aurora Timer.
  3. Add Set Graphic named Aurora Top. Connect a free bottom white circle on Aurora Timer to Aurora Top.
  4. Add If named Aurora Top Valid. Connect a free bottom white circle on Aurora Top to Aurora Top Valid.
  5. Add Set Graphic named Aurora Fill. Connect Aurora Top Valid’s bottom (true) circle to Aurora Fill.
  6. Add If named Aurora Fill Valid. Connect a free bottom white circle on Aurora Fill to Aurora Fill Valid.
  7. Add Change Label named Aurora Announce. Connect Aurora Fill Valid’s bottom (true) circle to Aurora Announce.

Use these settings:

  • Aurora Timer: 30 seconds; Repeat Forever Off; Repeat Count 1; Start Immediately Off.
  • Aurora Top: target Generate’s terrainObjectID output; graphic aurora-top; Smart Shape slot Top.
  • Aurora Top Valid: Aurora Top’s smartShapeError output Equals an empty text value. Leave the second value blank, without quote marks.
  • Aurora Fill: target Generate’s terrainObjectID output; graphic aurora-fill; Smart Shape slot Middle.
  • Aurora Fill Valid: Aurora Fill’s smartShapeError output Equals empty text.
  • Aurora Announce: target Stage; text 02 / AURORA REACH.

Use the generated terrain ID

Select the receiving behavior, drag the source output into Object A, choose terrainObjectID, and check the resulting reference

After you drop it, Object A contains Generate · terrainObjectID. Repeat for Aurora Fill, Ember Top and Ember Fill.

Check the graphic change result

Select the receiving behavior, drag the source output into First value (A), choose smartShapeError, and check the resulting reference

After you drop it, First value (A) contains Aurora Top · smartShapeError. Set Equals; leave the second text value empty.

Watch the graphic-selection step. Tap New graphic, open Graphics, and choose aurora-top. Its thumbnail should appear in the properties panel. Keep the Smart Shape slot set to Top / Road / Perimeter; choose Middle when configuring Aurora Fill.

Selecting the Aurora top graphic in the actual asset picker

Aurora Top targets Generate’s terrainObjectID, uses aurora-top, and updates the top slot

Make Ember's transition

Build the Ember behaviors beside Aurora, using the names in the guide below.

Change the timer to 60 seconds, the graphics to ember-top and ember-fill, and the final label to 03 / EMBER DRIFT. Keep both object inputs connected to Generate’s terrainObjectID output. Check that each If reads the output of its own Ember graphic change; the Ember checks must not read the Aurora behaviors.

The Ember connection follows the same order, with its own results to check.

Animated connection guide: Ember: use its own checks

  1. Reuse Generate.
  2. Add Timer named Ember Timer. Connect a free bottom white circle on Generate to Ember Timer.
  3. Add Set Graphic named Ember Top. Connect a free bottom white circle on Ember Timer to Ember Top.
  4. Add If named Ember Top Valid. Connect a free bottom white circle on Ember Top to Ember Top Valid.
  5. Add Set Graphic named Ember Fill. Connect Ember Top Valid’s bottom (true) circle to Ember Fill.
  6. Add If named Ember Fill Valid. Connect a free bottom white circle on Ember Fill to Ember Fill Valid.
  7. Add Change Label named Ember Announce. Connect Ember Fill Valid’s bottom (true) circle to Ember Announce.

Launch and watch the first minute. At roughly 60 seconds remaining, the course becomes green and Stage says AURORA REACH. At roughly 30 seconds remaining, it becomes warm red and says EMBER DRIFT. The ship should continue moving through both changes.

Aurora Reach during a fresh run of the tutorial project

You’ve changed the whole course because terrainObjectID identifies the complete Smart Shape. Its existing sections get the new graphic, and new sections use it too. To change each new section separately in another project, use New Section and sectionObjectID.

Keep both success checks. They let the Stage label change only after the top and middle graphics have changed.

11. Finish the run and offer another flight

Enter the finished state

Use the three build guides below. Run Limit is a 90-second timer: Repeat Forever Off, Repeat Count 1, Start Immediately Off. Finished sets Skimmer’s runState to finished.

Configure its children as follows:

  • Stop Flight (Set Behavior State): Disable Flight Tick
  • Stop Hud (Set Behavior State): Disable Hud Tick
  • Stop Clock (Set Behavior State): Disable Seconds Tick
  • Freeze (Set Velocity): Skimmer; X 0, Y 0; Maintain X Off, Maintain Y Off
  • Zero Gravity (Set Gravity): Skimmer; Object; X 0, Y 0
  • Show Results (Set Visibility): Show Results Card, Results Title, Results Score, Results Tip, Replay, Replay Label
  • Hide Cue (Set Visibility): Hide Cue, Clock, Flow Label
  • Result Score (Change Label): Target Results Score; text from Distance Text’s Combined Text output

Each action branches directly from Finished, as the diagrams show.

At 90 seconds, set the finished state and stop the update timers.

Animated connection guide: Finish: stop all three timers

  1. Reuse Generate.
  2. Add Timer named Run Limit. Connect a free bottom white circle on Generate to Run Limit.
  3. Add Set Attribute named Finished. Connect a free bottom white circle on Run Limit to Finished.
  4. Add Set Behavior State named Stop Flight. Connect a free bottom white circle on Finished to Stop Flight.
  5. Add Set Behavior State named Stop Hud. Connect a free bottom white circle on Finished to Stop Hud.
  6. Add Set Behavior State named Stop Clock. Connect a free bottom white circle on Finished to Stop Clock.

Now stop the ship’s motion. Zero velocity and zero gravity need separate connections.

Animated connection guide: Finish: stop the ship

  1. Reuse Finished.
  2. Add Set Velocity named Freeze. Connect a free bottom white circle on Finished to Freeze.
  3. Add Set Gravity named Zero Gravity. Connect a free bottom white circle on Finished to Zero Gravity.

Use more connections from Finished to show the result.

Animated connection guide: Finish: reveal the result

  1. Reuse Finished.
  2. Add Set Visibility named Show Results. Connect a free bottom white circle on Finished to Show Results.
  3. Add Set Visibility named Hide Cue. Connect a free bottom white circle on Finished to Hide Cue.
  4. Add Change Label named Result Score. Connect a free bottom white circle on Finished to Result Score.

Connect replay

Properties: Replay Touch targets Replay, Touch Anywhere Off, Absorbs Touch On. Replay State reads Skimmer’s runState. Replay Check compares that Attribute Value to finished. Restart uses Restart Scene with Refresh On.

Check for the finished state before restarting the scene.

Animated connection guide: Replay only after finishing

  1. Add Started Touching named Replay Touch.
  2. Add Get Attribute named Replay State. Connect a free bottom white circle on Replay Touch to Replay State.
  3. Add If named Replay Check. Connect a free bottom white circle on Replay State to Replay Check.
  4. Add Restart Scene named Restart. Connect Replay Check’s bottom (true) circle to Restart.

Let a full run end. The ship should stop, the results should show the last displayed distance, and touching the play area should not resume diving. Tap FLY AGAIN: the title screen returns, the clock resets, and the next launch generates a new course.

Results after a complete run of the rebuilt project

Set runState to finished before stopping the ship so the touch checks stop accepting input. Disable the flight timer too, or its next update could move the ship again. Both Maintain switches in Freeze must be off to stop a fall as well as forward movement.

12. Remember the personal best

Your best score should still be there after a replay. Store it in a save file under a key you can read when the scene opens.

Load the previous record

See Load from File and Save to File for keys, defaults, and saved values.

  • Load Best (Load from Save File): at the top level, unconnected to Generate. Use key orbit-best-distance-v1 and default value 0.
  • Best Text (Combine Text): A = PERSONAL BEST, B = Load Best’s Loaded Value output, Space On.
  • Best Label (Change Label): target Menu Best; Text = Best Text’s Combined Text output.

Load Best uses the orbit-best-distance-v1 key and a default value of 0

Load the saved distance when the scene opens, then show it on the title screen.

Animated connection guide: Load the personal best

  1. Add Load from Save File named Load Best.
  2. Add Combine Text named Best Text. Connect a free bottom white circle on Load Best to Best Text.
  3. Add Change Label named Best Label. Connect a free bottom white circle on Best Text to Best Label.

Save only a better run

Save settings: Check Record compares Distance Round’s result Greater Than Load Best’s Loaded Value. Save Best uses Set Key, Dynamic key orbit-best-distance-v1, and Distance Round’s result. Record Label targets Results Title with NEW PERSONAL BEST.

At the end of a run, save the score only if it beats the loaded record.

Animated connection guide: Save only a better distance

  1. Reuse Finished.
  2. Add If named Check Record. Connect a free bottom white circle on Finished to Check Record.
  3. Add Modify Save File named Save Best. Connect Check Record’s bottom (true) circle to Save Best.
  4. Add Change Label named Record Label. Connect Check Record’s bottom (true) circle to Record Label.

Finish a run. If the distance beats the loaded best, the results title should change. Replay and check that Menu Best shows the saved number. A shorter run should leave the existing best unchanged. If you have already played another OrbitRun project using these same save keys, a previous score may already exist.

The title screen after replay, with the loaded personal best and music preference

Compare the number from Distance Round before adding the m label. The saved value stays useful for calculations that way. When you adapt this for another game, give its save keys a unique prefix so it keeps its own scores and preferences.

Add your own challenge

Try a two-minute version. Change both Remaining's starting value and Run Limit to 120, and change Clock's initial text to 120 s. Then decide when its world transitions should occur. Updating only the label would leave the real run limit at 90 seconds.

Continue to Part 4: Sound and finishing touches, or compare your project with checkpoint 12-personal-best.