ℹ️ For Yop2D Next, the new 2D + 3D version of Yop2D (coming soon). Button and node names are those of Yop2D Next.
🔍 How do I…? All short recipes, with a search
The most common questions about variables (score, lives, money…), texts and saves. The names in bold are the ones you see on the screen.
👉 A word you don't understand? See Yop2D words. To start: Create and use a variable.
How do I stop a variable from going past a limit?
- Node Keep a variable between two values (category Variables & Inventory): choose the Variable, then the Minimum and the Maximum. Example: life stays between 0 and 100.
- It works at the moment it runs: connect it right after each Add to Variable that changes this variable.
- For a counter that goes back to 0 (a padlock digit), Add to Variable also has the setting Back to 0 after.
How do I pick a random number?
- Node Random number: it puts a random number in the chosen Variable. The setting Between (min, max) contains
random(1, 6)(a dice): change the two numbers, for examplerandom(1, 100). The first and the last number can both come out. - In any formula:
=random(1, 6)(for example in Modify Variable, or for a random X position). - Random number is different: it is a green node (category Values (green wires)) that stores nothing. You connect it to another node's setting with the 🔗 button; it picks a new number every time.
How do I make an inventory?
- Create a game variable (GAME VARIABLES → New variable), for example sac, of type Inventory list.
- When the hero touches an object: If object touches Tag → Add to inventory (Object The involved object (the touched object), Variable sac). The object's name goes into the bag, only once.
- To check: If in inventory (outputs True / False). To remove: Remove from inventory.
- To show it: Object → Interface elements → Inventory grid, then Settings and style… → Or the choices of a list variable (inventory), read during the game: choose sac. Each slot shows the project image that has the object's name, otherwise its name.
👉 These nodes read the name of the chosen object: it must still be in the scene. After picking it up, hide it (Visibility: no) instead of destroying it. A full example: A key that opens a door.
How do I combine two objects (stick + cloth = torch)?
- Node Combine two objects: Object A, Object B and Result object name (for example torche). A and B disappear; a copy of the torch appears where A was.
- The result object must exist in the scene, otherwise nothing changes: place a torch and untick Visible in the game in the Inspector. The copy itself is visible.
- For two objects in the bag: two Remove from inventory (stick, cloth), then Add to inventory with the hidden torch.
How do I make the game react when a variable changes?
- Event When Variable Changes: choose the variable. It starts at every change, wherever it comes from. Example: when vie changes → Modify Text
=vie, then check if life is at 0. - It does not start when the game begins, only when the value changes.
- It works with the GAME VARIABLES, not with an object's variables.
How do I make a shop (buy with coins)?
- A game variable pieces (Whole number) and a Buy button (Object → Interactive → Button with text).
- On Object Click (the button) → If a variable…: pieces, is at least, Value 10 (the price).
- Output True → Add to Variable: pieces, -10 → Add to inventory (the sword, hidden in the scene) → Modify Text
=pieces. - Output False → Small message at the bottom of the screen to say there are not enough coins.
👉 Lots of items? Put the prices in a table: see Make a list of products.
How do I use a data table in a formula?
- Write
=tableau("Monstres", "Orc", "Vie"): the table name, then the row, then the column, in quotes. Capital letters and accents don't matter; if the cell does not exist, the result is 0. - It works in every setting that accepts a formula (Modify Variable, Modify Text, Condition…). The row can come from a variable, without quotes:
=tableau("Monstres", ligne_tableau, "Vie"). - To give all the columns to an object at once: Give a row's values (table). How-to: Make a list of products.
How do I write the dialogues of my game?
- Object → Tools → Texts and dialogues, then Open.
- New sentence, then give it a Sentence name (for the nodes): intro.bonjour puts the sentence in the group intro.
- Write the sentence in each language (button Languages to choose which ones are shown). Preview in the game shows the dialogue box.
- In the Blueprint: Show dialogue writes the sentence in a text object; in Say a line, tap Take from the game texts.
👉 See also Write a text in several languages and Make a character talk.
How do I ask the player for their name?
- The easiest way: node Ask the player for a text (name…) (Variable prenom, of type Text). A window with the keyboard opens; the next nodes start when the player taps OK.
- In Say a line, write
{prenom}in the sentence to show the name. In a text: Modify Text=prenom. - Or a field in your scene: Object → Interface elements → Text field. In Settings and style…, choose the Variable that receives the text, then use the event When the player has finished writing.
How do I change the font of a text?
- Tap the text, then in the Inspector the line Font: choose a font from the library (each name is written in its own font). Normal font brings back the starting one.
- For a button or an interface element: Settings and style… → Font.
- Your own font (.ttf or .otf): FILES part of the left panel → Import (everything). It then shows up in the list of fonts.
- During the game: node Change the text font.
How do I make a nice title?
- Object → Texts → Styled title. In the Inspector, line Style: choose a ready-made style (with its font) or Create a new style….
- The small pencil next to it (Edit this style…) sets the outline, shadow, neon, relief, gradient, curve…
- All the styles of the project: Object → Tools → Title styles.
How do I show a small message at the bottom of the screen?
- Node Small message at the bottom of the screen: write the Message. It stays about 2 seconds, then fades away by itself.
- Start with = for a calculation:
="Score " + score. - For a message that waits for the player to tap OK: Show an alert window. For a text that stays: a text object and Modify Text.
How do I make a text that writes itself letter by letter?
- Node Say a line: the sentence is written letter by letter in a dialogue box. Tapping the screen while it writes shows the whole sentence; tapping again goes on.
- The speed of the letters is set in Object → Tools → Dialogue style.
- Show dialogue and Modify Text show the whole text at once. See Make a character talk.
How do I make a high score (record)?
- Two game variables: score and record (Whole number, 0 at the start).
- On Start → Load variables from a file: Save name record, Variables record.
- At the end of the game → If a variable…: score, is greater than, Value
=record. - Output True → Modify Variable: record, Value
=score→ Save variables to a file: Save name record, Variables record. - To show it: Modify Text
=record.
👉 Don't forget the = in
=score: without it, the variable gets the word "score". More details: Keep the score after closing the game.How do I erase the save (New game)?
- New game button → Delete a save: write the same Save name as in Save variables to a file (* erases all the saves of the game, the high score too).
- The file is erased, but the variables keep their value during the current game: reset them with Modify Variable (score to 0, lives to 3…).
- Continue button: On Start → If a save exists → output False → Visibility: no (the button stays hidden while there is nothing to continue).
- "Save the state" or "to a file"? See What is the difference between…?.
👉 Can't find your question? Look at Where is…? and My game doesn't work.