- Learn
- Tutorials
- Physics Labs
- Push Lab
- Making What a Card Shows
Making What a Card Shows
Read the story before its card. The story gives you the moment to picture; the card holds the fields to match. Keep this page beside your project while the editor’s names become familiar.
Set Up
Begin with File > New Project… and choose Blank 2D. Give the project a name and a folder, then use Create Project. The Starter Kit goes into this project through File > Install Myth Pack… and Add to This Project.
Game Settings opens from Resources. A heading such as General > World Scale names a tab and its section. Work through the card’s Game Settings from top to bottom. Enter a value in its named field and commit it with Enter.
The Scene row names the room to make. A blank project already has a Scene; rename it to the card’s name through its Resources menu. Open the Scene, drag an Object from Resources onto its canvas, and select that placement. Its position belongs to this copy in the Scene. The Set up card’s X and Y are those placement coordinates. For a row marked hidden, select that Scene placement and turn Visible at Game Start off in its General properties. Leave Active in Play Mode on, so its Logic can reveal it later.
Commands live in Game Settings > Input Manager. Make the named Command with the card’s type and bindings. Global Variables are declared under Project Globals in the Logic editor. Keep a Global’s name distinct from an Object’s own Variable.
Object and Components
The Resources Add menu creates an Object. Name it as its card does and open it. Transform holds its size, presentation and physics settings. Use the Component Toolbox to add each other component named on the card. Select that component under Attached Components to see its fields.
A Sprite supplies a picture. Its Sprite field chooses a resource from the kit. Its own Transform places and sizes that picture inside the Object; the Object’s Bounding Box is a separate size. Collider supplies the shape that meets other bodies. Text / UI displays words or a live text template. In a card’s Text field, replace each [new line] marker with an actual line break. Leave the marker itself out.
A slash on a card follows the editor’s component name. A > within a field leads to a section inside its Properties. Fields left off the card keep their starting values. On and Off mean the corresponding switch positions.
An additional component means another Sprite or Text / UI on the same Object. Add it from the Component Toolbox, select its row in Attached Components, and use that row’s Rename command for the card’s Name. Match the remaining fields on that selected component. The Copper Cart’s load pictures belong to the cart, so they travel with it.
Logic Component and Variables
Use Add to create a Logic Component, then open it in the Logic editor. A card’s Attach to describes what its Object needs. The editor’s Components card lists the component references that Logic uses.
For self.collider, use the Components card’s Add Component, choose Collider, and enter collider in Name. The editor supplies the self. prefix. If that reference already appears through an Action, keep it. This requirement uses the holding Object’s existing Collider; it adds no second physical shape.
For self.sprite, use the same Add Component control, choose Sprite, and enter sprite in Name. This declares a reference to an attached Sprite component. On the Object’s Logic workspace, select the calling attachment and choose its target under Properties > Components > Sprite (Sprite). Pick the attached component named on the card, rather than importing its artwork again.
Declare the card’s Shared Variables and Per Instance Variables in their matching Logic cards. Each card’s add control opens the declaration form. Match the name, type and starting value, plus Kind for Shared Variables. Shared values belong to the Object resource; Per Instance values belong to each running copy.
To give an Object that Logic, open the Object’s Logic workspace and choose the Logic Component for an attachment. Select that attachment to see the Variables it supplies. Their names and types come from the Logic. The Object owns their values.
All Object Variables also appear under Properties > Variables in the Components workspace. Use that view for an existing Object-owned row in a catch-up project. Select the Object itself rather than a Sprite or Collider to show its Variables.
Match the Object card’s Shared Variables here, using each row’s Kind and Value. Attaching the Logic supplies these rows; do not add duplicate Object Variables. The card repeats unchanged rows so you can compare the whole arrangement. A Variable that two attachments need is one Object value, visible from either attachment.
Event and Action
An Event starts a piece of Logic. Use Add Event and choose the Event named on the card. Give it the card’s name and settings. Create runs when an instance is created; Command Pressed responds to its Command. Mouse Press, Mouse Held, Mouse Release, Focus Lost and Touch Cancelled follow their corresponding input moments. The Mouse button field chooses the button.
Variable Changed and Data Table Changed react when their named value changes. Recurring Timer listens for its timer name. Mouse Wheel responds to its Wheel direction. Step runs each game step, and Destroy runs when the instance is removed. A Custom Event listens for the message on its card.
Use Add Action under an Event to choose an Action, then fill its fields from the card. Action Name gives a result a name that later expressions can read. Applies to chooses what receives the Action. Keep the card’s action order: a later Action may need an earlier result.
If, Else and Repeat
An If runs its contents when its condition is true. Else holds the other case. A Repeat runs its contents the number of times its card gives. Right-click the block and use Add Inside with its block name to add its nested Actions. Indented card lines belong inside the block above them.
A For Each Row visits the rows of its chosen Data Table. Its Variable Name names the current row inside its block. An expression such as weight.number reads that row’s number column. The row also has an automatic name: weight.name reads its Entry / Row Name label. You don’t declare that label in the Data Structure. A Declare Variable makes a temporary value at that point in the Actions; later Change Variable Actions can choose its name.
Modes
An Event can have named Modes, different ways for that Event to respond. Add the card’s Modes to that Event, and put each Mode’s Actions inside it. Make an Event and its named Modes before filling any Switch Mode Action that chooses them. You can leave their Actions empty while preparing these targets. Keep its starting Mode and its mode policy as shown. Switch Mode changes the response that later Events use.
A supplied Event-header pack is installed through File > Install Myth Pack… > Add to This Project. Installation creates the named Logic Component in Resources. Open that imported resource instead of creating another Logic Component. It supplies only the stated Events and empty Modes; fill their Actions from the cards. Keep the supplied trigger types.
Function
Use Add to make a Function. Its Parameters are the values its caller supplies. Declare each with its type, then build the Actions beneath it. A Function card’s Return Type describes what comes back. Return gives that result to the calling Action.
For an Object Parameter, match the card’s Compatibility Mode. Structural names that mode; it is not an Object starting value. Under Required Components, use Add Required Component for each listed slot, then match Slot Name and Component Type. These requirements let the Function use the components on the cart it receives.
A Function name can appear where you choose an Action. Choose the named Function and give its arguments as its card shows. These inputs belong to this call, rather than to an Object’s ongoing state.
Data Structure
Create a Data Structure from Add and enter the fields with their types. It describes the shape of one record. A Logic or Data Table can then choose that structure by name. Keep field names exact; expressions read them by those names.
Data Table
Create a Data Table, choose its Data Structure, then enter its rows in their displayed order. Use Add Row, then enter the row’s name in its Entry cell at the left. That editable name field has a label beginning Row Name. In Row 0 / Shared, 0 is the card’s row position; Shared is the name to enter. Each other column belongs to a field in the structure. Empty tables are deliberate: the running workshop fills some of them as you experiment.
Library
A Library card supplies a downloadable JavaScript file. Save that file, create a Library resource through Add, and import its file in the Library editor. The Library editor’s Enabled switch should be on. Match the source name and wiring on the card. Its source is supplied whole; the workshop’s experiment still runs in its native Logic.
Script
Turn on Settings > Advanced Mode for the scripting controls. Use Add to make a Script resource and open it. Its Script Code holds JavaScript source. Copy the supplied source from the Script card into that editor, replacing its starting contents. A download link supplies the same text.
An Execute Script Action chooses that resource by name. A Script resource stays in Resources; attach its calling Logic Component to the Object as the Object card shows.
Changes
A Changes card revises a piece you already made. Keep the unmarked parts, remove the crossed-out lines, and add the marked lines in their shown places. An Object’s additional component has its own name; select that component before changing its fields.
Save the project as you work. Play runs the current Scene; stopping it brings you back to the editor. Each chapter’s Play it! tells you what to watch in that version.
