Game Programming‎ > ‎

FlappyBirds_Stacks_Palettes

2. Adding Substacks and Palettes

Instead of cluttering the main screen with controls, you can create a new substack/card with all the settings.

You can read more about this here: Modeless stacks and palettes


      1. Click on "File", then "Create a substack for flappyBird"

                                  


      2. Name it e.g. "Prefs", add to it - sliders, labels and a button to close it

                                             




      3. Add scripts to the buttons:

A. On the Gravity slider, put the script:

on scrollbarDrag x 
   global gravity
   put x into gravity   
end scrollbarDrag

B. On the Speed slider, put the script:

on scrollbarDrag x 
   global colSpeed
   put x into colSpeed   
end scrollbarDrag 

C. On the Close button, put the script:

on mouseUp
   go to stack "FlappyBird"
   close stack "Prefs"
end mouseUp

      4. On the Stack "Flappy Bird", add a button "Settings"

                       


                 put the following code on the button

on mouseUp
   modal stack "Prefs"
end mouseUp

        Now when you press it, a small palette will pop up to change any settings

                       

Instead of "modal" you can put "modeless", "palette" or "modal"


The different types of stacks that you can create are:

Modal - for blocking other actions
modal dialog box is a window/stack that blocks all other actions as long as the stack is displayed. An example is "Ask" and "Answer" dialog boxes. You can not do anything else as long as it is open.
modal stack "Pop-up" 
or
go stack "Pop-up" as modal
Modeless - for utilities and settings
modeless dialog box is a window/stack that cannot be modified except for fields. It is used for find/replace and preferences. They can stay up while you play the game. 
modeless stack "Find/Replace" 
or
go stack "Find/Replace" as modeless 
Palettes - for Tools
A palette always floats above all other window. They are most often used on cards that need to stay available like tools and they do not block other actions. In LiveCode, the Tools palette and the Property Inspector are palette style windows
palette stack "My Tools" 
or
go stack "My Tools" as palette
Customizing them. You can change what controls are shown by setting the decorations:
set the decorations of stack "myStack" to ...
    "close" -- show only the close gadget
        "close,minimize" -- show the close and minimize gadgets
        to empty -- completely hide the titlebar
        to "default" -- reset the titlebar to the standard look for the window mode
Comments