When restarting the layout, how to destroy a previously obtained object ?????!!!

1 favourites
  • 9 posts
From the Asset Store
112 High-Quality destruction sounds for videogames
  • Hello everybody! First of all, sorry for my English.

    I would like your help for the following situation:

    As an example, you know that in Mario Bros when you get a life and unfortunately an enemy kills you, the game restarts the same stage, but checking that the life (or sprite) has been destroyed so as not to be obtained again (which is logical, otherwiseit would be impossible to lose) ...

    I would like to repeat the same idea in my game ... I have tried it with "families", with "functions" ... etc ... but I still can't find the solution.

    I would really appreciate the help :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i think you need to add this line in your code logic after (restart the layout)

    (RESET GLOBAL VARIABALE) that will reset every variable to default state

  • lahbach uhmm ... yes, I have that code in other sheet. Maybe so that you better understand how I have my code currently I indicate it like this:

    The next part of the code (which is in the character's sheet), validates when the character loses 1 life (works wonderfully), so, at the end of the code and marked with red I highlight the code that allows me to identify when the layout has been restarted ( not started), that is, when the character has lost a life. If you notice, when restarting the layout, the code changes the Global variable "RESTART_LAYOUT" from 0 to 1 ... this makes you understand why the variable "RESTART_LAYOUT" is on the other sheet.-

    At last, but no least, the global variable positioned in the global variable's sheet:

    please, help =) ...thanks!

  • Kikincho i understand now

    you need to use (LOCAL STORAGE) plugin to save any (VARIABLE) value you want, so when you restart the layout you will have no problems

    - Don't use (boolean) use Number

    Check this simple project to understand how to use local storage


  • lahbach Thank you very much for your answer, but I only have one question to the code logic:

    - the game starts and the initial value of the sprite is assumed to be "0", (because there is no "touch" interaction yet) ... so, why the sprite's initial value is "1" before doing "touch"?.

    PS: (my logic with your example would be: "captured" with value "0" means "not yet captured").

    I am right???.

  • 1- for the first question ( i think you just touch the screen by mistake and you didn't notice ) because LOCAL STORAGE PLUGIN save the (Number :1 in CAPTURED ) so every time the layout will restart local storage will change 0 to 1

    i recommend you to learn more about the local storage plugin so you can understand exactly how the plugin work

    2- YES value "0" means "not yet captured"

  • lahbach Thank you!!

  • well ... finally! ... I made it.

    I looked for the option that was easier for me and that was using "ARRAY":

    I created an array of "X" only, ensuring that it could contain only 2 "spaces" (in this case, the only 2 lives that the stage has for the player "). In such a way that I was conditioning each player's move based on whether or not the stage was restarted.

    It worked out wonderfully, since the values of the array are maintained even so when the layout has restarted (unless you tell it otherwise).

    Thanks anyway for the tips!

  • You are welcome my friend

    i'm glade it work for you

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