If layout exists

  • Hi, Again

    Thanks for the help, but the problem is that all my levels are done in a different events, cause every level have different variables like, health, time limit is different every level. Tried to do it this way like you have shown me, but cant do it, i guess it is because the different events, if you have any suggestions, please tell if not i guess i`ll have to think hard :).

    Thanks

  • You can have the variables that are different attached to an object (like the player). Just click on the object, go to properties, and click "Add/Edit Instance Variables". Then if there isn't anything else different, delete all of the event sheets but one (except for the menu events) and make sure all of the levels point to the same event sheet.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the help, but i find some other solution, i took 10 different sprites, one for every level, then add few events like

    system.every tick - set opacity to 40 for all level boxes in the menu.

    Then i added few events on every level.

    When level 1 is finished - add 1 to "unlock level2" (global variable)

    Again in the menu events i added,

    If Unlock level2 = 1 - then set level 2 opacity opacity to 100% and       

    On levelbox2 clicked, and -

    levelbox2 opacity is 100% - system go to level 2

    and so on for every level.

    Thanks for the help again

  • That would work, but it won't save the player's progress. So if the player closed the game and reopened it, he would be back at level 1.

    Also, it is not a good idea to have multiple copies of the same event sheet. Even if some of the variables have different values.

    • What if you wanted to change how the game works? You'd have to change the same little thing for all of the levels.
    • It increases the file size more than nessesary. In a case where you have a lot of events for each level, the player will become impatient when your game takes forever to load and go find a different game to play.
    • If you wanted to add a few levels, you'd have to duplicate one of the event sheets and change it accordingly.

    It is better not to repeat the same instructions over and over, but instead to say it once and put variable where it's different.

    Instead, you should do something like this:

    Make one sprite object, name it levelbox. Right-click on it, choose add/edit instance variables, click the green plus sign, name the variable level and give it a type of text, click ok, and close the add/edit instance variables window. Hold ctrl and move the levelbox. This copies it. Do this until you have enough for each level. Edit each one to have the name of one of the levels (layouts) in the level instance variable (you can find it in the properties). If you don't want to type the name out each time, you can copy something like "Level " to the clipboard and paste that into the textbox then type the number. Example: Click levelbox, click the box next to "Instance Variables, level", press Ctrl+V, type "1", click the next levelbox, click the box next to "Instance Variables, level", press Ctrl+V, type "2", etc.

    -- Menu Events --

    system.every tick -> set opacity to 40 for all level boxes in the menu.

    Declare Local Variable unlock_level = 1

    System - For Each levelbox

    If unlock_level = 1 -> then set levelbox opacity to 100%

    (Event with no conditions) -> System > set variable unlock_level to WebStore.getLocalKey(levelbox.level)

    On levelbox clicked, and -

    levelbox opacity is 100% -> system go to levelbox.level

    -- Game Events --

    When a level is finished -> WebStorage > Set Local Key > LayoutName to 1.

  • Well my game is already finished and i need to change everything to make it like you said, everything in one game event sheet, but definitely i will use you advice in some future projects.

    BTW i placed save and load option scirra.com/forum/webstorage save-game_topic46118_post288827.html in the game for saving levels.

    Only thing left to do is high score, you can check this if you can help somehow.

    scirra.com/forum/highscores-timelimit_topic51230.html

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)