How to store color values of multiple instances/copies of an Object using an Array?

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi Guys,

    What I need:

    How to store and save color values of multiple instances/copies of an Object using an Array + how to load the data back into Construct with JSON.

    What I have so far:

    1. I'm having one object that uses a For loop to create multiple instances like in the photo below.

    2. When you click on of the instances it changes color to orange.

    3. When I save the game I want to store all the color values of each instance/copy into an Array.

    4. When I load the game later it remembers which instances/copies has orange color.

    Note: I'm able to save and load variable and text values successfully using an array with Download as JSON data, and loading the data using File Chooser, but when it comes to multiple instances/copies of one object I don't know how to make it work.

    I'm thinking it will work using a For Each command or Repeat, but have no idea how to go about it.

    If anyone could share with me how to do this, I would be very grateful!

    Thanks & Regards,

    Edgar

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the array you can add an instance variable (var1) to the clickables where the value relates to the array row so first one is var=0, second one is 1, third is 2 etc. You then need a second instance variable on the clickable for its colour (var2) like gray/orange or 0/1 which would change when clicked (probably logic you already have in the event sheet as it changes to orange)

    To toggle the colour and update the array you would use - clickable on clicked, set array.at(self.var1) to self.var2. To update the clickables together when you load data into the array you can use - for each clickable set var2 to array.at(self.var1).

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