← BACK

Logic-Only scenes are reusable “backstage control scenes” that define advanced logic in your project.

These scenes do not appear on the screen and contain no assets or interactive elements. Instead, they include actions and events that are all executed as soon as the specified conditions are met.

Logic-Only scenes are computational in nature and exist for only a fraction of a second. You can think of these scenes, especially when you use them in a series, as the “brain” or “CPU” of your project.

Setting a scene as Logic-Only is easy, all you need to do is to select the Logic Only checkbox in the scene’s Properties. It is defining the logic itself, however, that requires time and effort when working with Logic-Only scenes.

The sections below outline the best practices and benefits of using Logic-Only and provide two use cases with step-by-step exercises.

What Exactly Does the Logic Only Checkbox Do?

With each scene transition within a project, all layers in the preceding scene get hidden. In certain scenarios with advanced transition logic, this may cause flickering on the screen. For example, if you show text with a counter value in a scene, recalculate the value in the following scene, and then return to the previous scene to update the counter value, there may be a momentary flicker on the screen when the text layer is made visible again.  

If you select the Logic Only checkbox in the Properties of a scene where calculations are performed, there will be no flickering. Selecting this checkbox ensures smooth, seamless transitions between the scenes separated by a Logic-Only scene or series, without a glitch on the screen. This is especially important for projects with persistent buttons or game settings images.

Selecting the Logic Only checkbox also prevents you from inadvertently adding any assets or elements to Logic-Only scenes as they won’t appear on the screen. Similarly, if you set any regular scene as Logic-Only, any existing assets or layers will be removed from it.

As your expertise with Studio and understanding of its capabilities grow, in some projects, you may consider creating scenes with the Logic-Only-like functionality without selecting the Logic Only checkbox. This is not, however, a recommended practice.

Benefits

Adding Logic-Only scenes to your project has multiple benefits as these scenes let you do the following:

  • Create more true-to-app user experience with variable outcomes.
  • Avoid crowding and overcomplicating regular scenes with numerous actions that are not visible on the canvas.
  • Designate scenes solely to control logic in your project and reuse them as needed.

For example, you can use Logic-Only scenes to set counters, check their values, and then transition to different scenes based on the counter value or display a specific image out of multiple choices. You can also use Update Text actions, for example, to have the counter values displayed in the subsequent scenes. For details, on available counter actions, see Counters.

Logic-Only Series

The most effective way of using Logic-Only scenes is creating a series of them to calculate and produce dynamic results and display them in other scenes.

Oftentimes, when represented visually, the logic implemented by a series of Logic-Only scenes looks like a hierarchical web with the following distinct components:

  • A parent Logic-Only scene at the top.
    It often acts as a randomizer for the Logic-Only child scenes below, either with equal or different probability values.
  • A regular (non-Logic-Only) scene at the bottom.
    It displays the results of the calculations and other actions performed in the Logic-Only scenes above it.
  • Multiple child Logic-Only scenes in between.
    Depending on your design, they may cascade down from the parent scene, loop infinitely back and forth to the parent until a condition is met, or even have child logic-only scenes of their own.

Here’s a cascading series of Logic-Only scenes that lets you display randomized results, for example, based on conditional logic with counter values. You would need to use only one counter to accomplish this. See Use Case 1 below.

Below is an example of a Logic-Only series with randomly looping sequences that keep track of incrementally increased counter values until a set maximum is reached and the results are displayed on the screen for the user. This series would require several counters, with one main counter essentially driving the entire logic in this series. See Use Case 2 below.

Best Practices

Creating Logic-Only scenes to account for numerous variations of possible outcome can be a tedious, repetitive process, which often requires having most regular scenes and elements already in place. To facilitate the process and avoid confusion, follow the guidelines below.

  • Create a storyboard or at least a quick diagram to figure out the overall flow in your project. See an example in What about Alternative Paths.
  • Before you add Logic-Only scenes, add and set up your regular scenes that you expect to appear in the project as described in Working with Scenes.
  • Define all your counters upfront, for example, in the first scene after the splash screen. See also Counters.
  • Always add new Logic-Only scenes rather than changing the properties of an existing regular scene.
  • If you select the Logic Only checkbox in the Properties of a scene that has any media assets or visible layers added to it, they will be removed from the scene. You will not be able to undo this by clearing the checkbox.
  • To expedite the process of creating a series of Logic-Only scenes with the same logic but different values, build one child scene, then duplicate it as many times as necessary for your design and update the scene names, counter values, and transitions.
  • To ensure an immediate transition from a Logic-Only scene without any glitch on the screen, always clear both the After Video and By Counter events in its Transition menu.
Use Case 1—Random Outcome Display

This use case implements the logic illustrated in the first of the two diagrams in Logic-Only Series above.

Suppose you have several monsters (or any other items) in your project and you want to randomize the appearance of each monster in the final output.

To accomplish this, you would use a series of Logic-Only scenes with one counter, several Show Element actions, and transitions with counter conditionals. 

Below is a high-level description of the overall process of implementing this scenario, assuming that the Display Monster scene is already added with the appropriate images for the randomized display.

Tip: If you would like to build and test a mini-project for this use case from scratch without any assets, skip to the Use Case 1—Follow-Along Exercise below.

  1. Select a scene at the beginning of the project, for example, the splash screen, and under Events & Actions, add a Set Counter action to create a counter for keeping track of monster IDs. Leave its value at 0. If needed, for detailed instructions, see Create a Counter and Set Its Value.
  2. Add a scene for setting a monster ID and select the Logic Only checkbox in its properties.
    This is the first child Logic-Only scene. 
  3. Under Events & Actions, add the following to the new scene:
    1. A Set Counter action for the counter you created in step 1 and set its Value to 1.
    2. A transition to the Display Monster scene with the default probability. If needed, for detailed instructions, see Add Transitions.
  4. Go to Scenes and duplicate the above scene as many times as many monsters (or other objects) you have for display. Update the scene names.
  5. For each new scene, under Events & Actions, in the Set Counter action block, update the counter Value with the respective ID number.
  6. Add a new scene that will serve as the randomizer and select the Logic Only checkbox in its properties.
    This is the parent Logic-Only scene.
  7. Under Events & Actions, add several randomized transitions with equal Probability, one for each child Logic-Only scene. If needed, for details, see Randomized Transitions.
  8. In the Display Monster scene, under Events & Actions, add several Show Element actions, one for each monster to be displayed.
  9. In each Show Element action block:
    1. Click the Conditional icon , then under Counter Conditionals in the action menu, click the Add icon .
    2. Select the counter you created in step 1, keep the default Counter Equal conditional, and enter the respective monster ID as the counter Value.  
      For example, to display Monster 2, enter 2 as the counter value.  Each Show Element action block should have a different counter value for the same counter.
  10. (Optional) Click Path View to check the transitions you have defined.
    For example, see the last set of steps in the Use Case1—Follow-Along Exercise below.
Use Case 1—Follow-Along Exercise

This exercise walks you through specific steps of a Use Case 1 example and illustrates the first of the two diagrams in Logic-Only Series above.

In this example, the user can randomly display 5 different “monsters.” No assets are required. You will use containers for images. Just open Studio and follow along!

Step 1. Set up the Display Monster Scene

  1. Create a new project and in the Scenes panel, rename the first scene to Intro.
  2. Add a scene named Display Monster.
  3. From the Elements panel, drag 5 Container Elements to the canvas of the new scene.
  4. Select a container and in the Properties panel, name it Monster 1 and fill it with color.
  5. Repeat the above step for the remaining four containers, naming them Monster 4 through Monster 5 respectively and filling them with different colors.
  6. In the Layers panel, set all five layers as invisible .
  7. Resize and position the bounding boxes on the canvas as you wish, for example, as shown below.

Step 2. Create a Counter and Add Child Logic-Only Scenes

  1. Select the Intro scene and under Events & Actions, add a Set Counter action to create a counter named  monster_id, leaving its value at 0.
    If needed, for detailed instructions, see Create a Counter and Set Its Value.

  2. Go to Scenes, add a scene named Monster ID Set 1  and select the Logic Only checkbox in its properties.
  3. Under Events & Actions, add a Set Counter action for the monster_id counter and set its Value to 1.
  4. Add a transition to the Display Monster scene with the default probability.

    This is the first child Logic-Only scene.
  5. Go to Scenes, click the Duplicate icon next to the Monster ID Set 1 scene 4 times.
  6. Select a duplicate scene and update its name to Monster ID Set 2.
  7. Under Events & Actions, in the Set Counter action block, update the counter value to the respective monster ID.
  8. Repeat steps 6 and 7 for the remaining three monsters with the respective IDs 3-5 in the scene names and counter values.

Step 3. Define the Parent Logic-Only Scene

  1. Go to Scenes, add a scene named Monster Randomizer and select the Logic Only checkbox in its properties.
  2. Under Events & Actions, add a transition to the Monster ID Set 1 scene, with the 20% Probability. If needed, for details, see Randomized Transitions.
  3. Repeat the above step to add four more transitions to the respective Monster ID Set (2-5) scenes.

Step 4. Define the Display Monster Scene

  1. Select the Monster Display scene.
  2. Under Events & Actions, add a Show Element action and in the displayed action menu, select the Monster 1 element in the Name drop-down list.
  3. In the Show Element action block, click the Conditional icon , then under Counter Conditionals in the action menu, click the Add icon .
  4. Select the monster_id counter, keep the default Counter Equal selection, and enter 1 as the counter value. 
  5. Repeat steps 2-5 for the remaining four monsters, selecting the respective monster element names and entering respective ID numbers as counter values.
    For example, enter 2 as the counter value for Monster 2 element and so on.

Step 5. Finalize and Preview the Project

  1. Select the Intro scene and under Events & Actions, add a transition to the Monster Randomizer scene.
  2. Select the Display Monster scene and from the Elements panel, drag a Replay Button element to the canvas.
     

    Note: Adding the Replay button is optional, but it will enhance the experience by letting you replay it as many times as you need.

  3. Resize it to cover most of the screen and under Properties, select the Intro scene as the Go to Scene. If needed, see Add Buttons.
  4. Save the project.
  5. (Optional) Click Path View to check the transitions you have defined.
    In Path View, the transitions for this use case should appear similar to the ones shown below.
    Note that transitions from Logic-Only scenes (as well as regular scenes with no video assets like Intro) are labeled Every Time and with probability percentages in randomized transitions.
  6. Open the AppOnboard Studio app.
  7. In Studio, on the header bar, click Preview and scan the code with the app to preview your project. If needed, see Preview with Studio App for details.
    Your final final project should randomly display a colored block each time you tap the screen, for example, as shown below.
Use Case 2—How to Keep and Display Count

This use case implements the logic illustrated in the second of the two diagrams in Logic-Only Series above.

Suppose your project includes a segment where the user can mine several different resources, and you want to accomplish the following:

  • Randomize the resources received and reduce the likelihood of mining certain rarer resources.
  • Keep count of the amount of each resource received.
  • Display the final count on the screen.
  • Limit the total number of resources received to avoid infinite mining.

For example, the user can randomly mine 7 different resources. As soon as the total resource number limit of 5 is reached, the final resource amount is displayed on the screen with an icon for each resource and a text are for each resource counter value, as shown below.

This scenario requires a counter for tracking the amount of each resource received, for example, 7 counters in the example above. To enforce the limit of 5 resources, you will also need a separate counter for tracking the number of loop iterations between the parent and child Logic-Only scenes. You will also use this counter in conditional statements to drive the transition logic in this scenario. 

Below is a high-level description of the overall process of implementing this scenario, assuming that the Display Final Count scene similar to the one shown above is already added with the appropriate Text areas for displaying counter values.

Tip: If you would like to build and test a mini-project for this use case from scratch without any assets, skip to the Follow-Along Exercise below.

  1. Select a scene earlier in the project, for example, the splash screen, and under Events & Actions, create all your counters, leaving all counter values at 0. If needed, for detailed instructions, see Create a Counter and Set Its Value.
    • One counter for keeping count of the resources already mined.
    • Several resource amount counters, one for each resource the user can mine. 
      For example as shown below.

  2. Go to Scenes and add two new scenes, a Resource Randomizer scene (parent Logic-Only scene) and a Resource 1 scene (first child Logic-Only scene). Select the Logic Only checkbox in their properties.
  3. Select the Resource 1 scene and under Events & Actions and add a transition to the Resource Randomizer scene and the following two actions:
    1. An Add Value to Counter action for resource counter 1, with any appropriate value for the increased resource amount. Increase the Max range as appropriate.
    2. An Update Text with Counter action for the Text Area associated with the resource and add the counter name enclosed in curly braces, for example, as shown below. If needed, see Text Action Menus.
  4. Go to Scenes, duplicate the Resource 1 scene with its actions and transition that you have just defined for each resource in your project and update the scene names accordingly.
  5. Under Events & Actions, update the counters and text areas in the counter and text actions for each resource. Leave the transition as is.
    For example, this is what you would do for Resource 2:

  6. Select the Resource Randomizer scene and under Events & Actions add an Add Value to Counter action for the loop iteration counter and do the following:
    1. Set its Value set to 1.
      This value will be incremented each time the user mines a resource, ensuring that they don’t exceed the total number of resources allowed to be mined.
    2. Set the Max value to the maximum number of resources you want to let the user mine.
    3. To ensure that the count is incremented after all other operations are performed, select the On Exit event in the action block.
  7. Add several randomized transitions, one to each Resource scene, with different Probability for each transition. If needed, see Randomized Transitions.
  8. For each transition, click the Conditional icon , then under Counter Conditionals in the transition menu, click the Add icon . Select the loop iteration counter and create a statement with the Counter Less Than conditional and the maximum number of resources you allow to mine as its Value
  9. Add a transition to the Display Final Count scene with the default 100% Probability and a counter conditional statement with the Counter Equal conditional and the maximum number of resources you allow to mine as its Value
    For example:

  10. (Optional) Click Path View to check the transitions you have defined.
    For example, see the last set of steps in the Follow-Along Exercise below.

Tip: You could also add Show Element actions in the Display Final Count scene to display the resource images and their count sequentially, using the At Time event for each action. You may also want to reset your counters

Use Case 2—Follow-Along Exercise

This exercise walks you through specific steps of a Use Case 2 example and illustrates the second of the two diagrams in Logic-Only Series above.

In this example, the user can mine 3 different resources, with the total number of resources received limited to 10. No assets are required. You will use containers for image icons. Just open Studio and follow along!

Step 1. Set up Display Final Count Scene

  1. Create a new project and in the Scenes panel, rename the first scene to Intro.
  2. Add a scene named Display Final Count
  3. From the Elements panel, drag a Container Element to the canvas of the new scene. Name the container Resource 1 and fill it with yellow color.
  4. Drag a Text Area element and name it Text 1. Leave the default text or type “text area.”
    The actual text doesn’t matter as it will be eventually updated with the counter value.
  5. Resize and position the container and text area, for example, to mimic the layout below:
  6. Copy and paste the container and text area on the canvas and drag them underneath the first group.
  7. Select the container, rename it to Resource 2 and fill it with a different color.
  8. Select the text area, rename it to Text 2.
  9. Repeat steps 6-9 for Resource 3.
    Your final layout should look similar to the one shown below.

Step 2. Create Counters, Parent and Child Logic-Only Scenes 

  1. Select the Intro scene and under Events & Actions, using the Set Counter action, create 4 counters, leaving their values at 0. If needed, for detailed instructions, see Create a Counter and Set Its Value.
    1. A counter for keeping count of the mined resources resource_tracker
    2. Three resource counters: resource_1 , resource_2, and  resource_3.
  2. Go to Scenes, add a new scene Resource Randomizer, and select the Logic Only checkbox in its properties.
    This is the parent Logic-Only scene.
  3. Add a new scene Resource 1,  select the Logic Only checkbox in its properties.
    This is the first child Logic-Only scene.

Step 3. Define and Duplicate Child Logic-Only Scenes

  1. Select the Resource 1 scene.
  2. Go to Events & Actions and add an Add Value to Counter action for the resource amount counter with the following values in the action menu:
  3. Add an Update Text with Counter action with the following values in the action menu. 

    If needed, see Text Action Menus to understand what to provide in the Text field.
  4. Go to Scenes, click the Duplicate icon next to the Resource 1 scene twice.
  5. Update the names of the new scenes to Resource 2 and Resource 3.
  6. Select the Resource 2 scene.
  7. Under Events & Actions update the Add Value to Counter action block as shown below:
  8. Click the Update Text with Counter action block and in the displayed action menu (shown in step 3 above), select Text 2 area and change the counter name in the curly braces to  counter_2.
  9. Select the Resource 3 scene and repeat steps 7 and 8, using the same value of 10 or any other amount you prefer for the resource_3 counter.

Step 4. Define the Parent Logic-Only Scene

  1. Select the Resource Randomizer scene and under Events & Actions, add an Add Value to Counter action.
  2. In the displayed action menu, set the default Max value to 10 and enter 1 as the counter Value.
    The counter value will be automatically incremented by 1 each time the user mines a resource.
  3. Close the action menu and in the Add Value to Counter action block, click On Exit.
    This will ensure that the counter value is incremented after all other calculations are done.

  4. Add a transition to the Resource 1 scene with 20% probability (enter .02 for Probability). If needed, see Randomized Transitions.
  5. In the transition block, click the Conditional icon , then under Counter Conditionals in the transition menu, click the Add icon , and select the following values:
  6. Repeat steps 4 and 5 to add randomized transitions to the Resource 2 and Resource 3 scenes, using different Probability, for example, 40% and 30%.
  7. Repeat steps 4 and 5 to add a transition to the Display Final Count scene but with the default 100% Probability and the following counter conditional values:

Step 5. Finalize and Preview the Project

  1. Select the Intro scene and under Events & Actions add a transition to the Resource Randomizer scene.
  2. Select the Display Final Count scene and from the Elements panel, drag a Replay Button element to the canvas.
     

    Note: Adding the Replay button is optional, but it will enhance the experience by letting you replay it as many times as you need.

  3. Resize and place the button as desired, for example, in the bottom-right corner.
  4. In the Properties panel, fill the button with any color and select the Intro scene as the Go to Scene. If needed, see Add Buttons.
  5. Save the project.
  6. (Optional) Click Path View to check the transitions you have defined.
    In Path View, the transitions for this use case should appear similar to the ones shown below.
    Note that transitions from Logic-Only scenes (as well as regular scenes with no video assets like Intro) are labeled Every Time or with the counter conditional name.
  7. Open the AppOnboard Studio app.
  8. In Studio, on the header bar, click Preview and scan the code with the app to preview your project.
    If needed, see Preview with Studio App for details.
    Your final count display should look similar to the one shown below. Just tap the Replay button to see the randomization effect of the resources received.
Updated June 05, 2019