Persist Not Persisting Color Value OR Instance Variables

0 favourites
  • 7 posts
From the Asset Store
Color all tiles with the same color in 22 moves or less!
  • I have an object(white circle) being spawned when the user clicks, like a mini-game drawing program. It spawns a new instance of the object every second and the user can select a color which is then put into an instance variable on each circle object. This variable(string) then dictates how C3 re-colors the white circle using rgbEx255.

    PROBLEM: When returning to the layout all of the white circles are colored the same and do not retain the string value that was set upon creation. They all use the Persist behavior and the position and IID remains the same but the variable does not and neither does the color(using color param).

  • Let's see the events

  • There's 18 total colors but I broke it down to just 2 for the screenshot. If I can get the two to work then it should be easier to get them all going. They all use the blobDraw Object

    https://gyazo.com/1c79ae52cc41a6639334a2bafdb1a5a1

    https://gyazo.com/e59eb8014629bbc5a5d5a7a6c271e70e

    They should look like this:

    https://gyazo.com/9b071d548a3f32a0f53d42c79d396cb2

    But after returning to the layout they look like this:

    https://gyazo.com/89c2f2b528740eee64d3481b1b8f23e1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure what's going on there. Check if the variable is correct for the incorrect blobdraw objects, that means it hasn't picked up the setting of the colour. If variables are also wrong, start disabling events to try and determine where the problem is. Seems to me like you don't need the on start of layout set colour events if they are persist objects?

  • Problem is in Debug, on create the blobs are each receiving the proper color instance variable string(e.g. black, red, white, etc)

    Issue is on returning to the layout the string defaults to black, the initial value. I've also tried leaving the string empty in which case the color is unmodified by the Set Color operation. It's like I said, the engine is making an error and Persist is not persisting Instance variables(I am on the latest version of C3)

    https://www.construct.net/en/make-games/manuals/construct-3/behavior-reference/persist

    Ashley

  • The issue is with your on created event, which I assume is true on start of layout, that's why I mentioned to disable events to check where the problem is. On created also targets sprites created on the start of layout, even persist objects are created again, so it's setting everything to black I assume because that event is true when you go in. You could fix this by adding a condition, on blobdraw created and only if the string instance variable is "" then set the color.

  • Sorry for misunderstanding your wording the first time, seems you've nailed the issue on it's head ^.^

    I didn't realize that the objects went through a create event on the return of the layout, really thought I found an engine bug to report!

    Thanks plinkie :)

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