How do I reset an instances variable of a Sprite ?

0 favourites
  • 8 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi!

    Is there an action to restore the default Initial Variables of a Sprite ?

    Like the action "reset global variables", but just for a Sprite 's instance variable.

    Thanks

  • Hi!

    Is there an action to restore the default Initial Variables of a Sprite ?

    Like the action "reset global variables", but just for a Sprite 's instance variable.

    Thanks

    if you remember initial default values you can directly set current value to initial values, otherwise you can do this "indirectly", make a copy of original values of instance variables and when you want to reset them, set current values to original "copy" values

    Example:

    "HP" = 500 (original value) -> "HPcopy" = 500 ( the copy)

    current HP is 700 and you want to reset initial value

    at your condition -> set "HP" to 500 (directly)

    otherwise,

    at your condition -> set "HP" to "HPcopy" (indirectly)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Alex Kidd

    Yes, I remember initial default values, but I have a lot of instances of the same object. So there's a lot of "pick by unique ID" + "set value" to do...

    "Pick all instances" and "reset to default value" would be faster ^^

    So I will do this option : Change the values for each instance...

    Thank you for your answer.

  • Thanks Alex Kidd

    Yes, I remember initial default values, but I have a lot of instances of the same object. So there's a lot of "pick by unique ID" + "set value" to do...

    "Pick all instances" and "reset to default value" would be faster ^^

    So I will do this option : Change the values for each instance...

    Thank you for your answer.

    In that case i think you can use "For Each" action, for change all object instances variable in one time

  • If you destroy the sprite and create it again then it will be created with the default values. That's a way of refreshing it if it's an applicable method to your game.

  • In that case i think you can use "For Each" action, for change all object instances variable in one time

    Thanks NN81. But could that work in my case ? Because every instance have a special variable number.

    Exemple :

    UID 25 = variable 2

    UID 32 = variable 5

    UID 34 = variable 4 etc...

    If you destroy the sprite and create it again then it will be created with the default values. That's a way of refreshing it if it's an applicable method to your game.

    Thanks plinkie. I thought about that, but in my case the instances must stay in the same position (no reset x and y)

    Anyway... Perhaps I may have to find another way to do what I want.

  • > In that case i think you can use "For Each" action, for change all object instances variable in one time

    >

    Thanks NN81. But could that work in my case ? Because every instance have a special variable number.

    Exemple :

    UID 25 = variable 2

    UID 32 = variable 5

    UID 34 = variable 4 etc...

    > If you destroy the sprite and create it again then it will be created with the default values. That's a way of refreshing it if it's an applicable method to your game.

    >

    Thanks plinkie. I thought about that, but in my case the instances must stay in the same position (no reset x and y)

    Anyway... Perhaps I may have to find another way to do what I want.

    you have to make a new instance variable for all instances with default values, then just for each set other variable to copy values, i have just tryed with three instances player box with different initial HP, and work fine.

  • Thanks NN81 !

    It's a good idea. And yes, it work fine

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