How do I change default variables on sprites?

0 favourites
  • 6 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • When you create a sprite, you can set instance variables to that sprite. However, once you make a copy of it (not clone it), if you change the variables of THAT copy, and then create the sprite via code, it has all of the variables of the first ever created sprite.

    Is there a way to determine which sprite is the "first created" so if I need variables to be a certain way upon creation, I can change them?

    The reason for my asking is that I've created a button sprite and do an "on created" > if Button Boolean = True, create Text overlay for button. However, if I create the button and set the boolean to false in the same event, it somehow grabs the on created segment of the code before it can be disabled.

  • My English is very bad, I do not know if I understand your problem well, but if you create the same object several times, you will share the value of the variables.

    If you clone the object, that problem should disappear.

  • Taximan - correct, but I wish to use the same sprite to save on memory and make my code more simple to use.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just bumping this - does anyone know if I could at least change the initial value of the Boolean?

  • On your original question, maybe you can use the index ID (IID) to compare sprites to find the newer. A lower IID is older.

    And then, try stepping through your code while changing instance variables.

  • nacra - Good idea! Total pain, and unfortunately I have to still keep that button there, but other than that, it seemed to have fix it. Thanks!

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