Rewind time?

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Actually, I just plugged the code into the game I'm working on and it runs flawlessly. I'm baffled, definitely inspired to learn as much as I can about arrays.

  • R0J0hound Thanks for sharing, could you give some pointers on how to go about multiple instances? I used a family containing multiple objects however I noticed all of the instance JSON records into the same X axis, so i was thinking specifying the ID according to the Y index and then set the JSON into that X axis but with the push method i don't know how to make it work...

    Been up all night trying to wrap my head around it but it either doesn't work or the objects retrieve the wrong data like...man its all over the place Lol.

    Would appreciate any help on how to set & get family instance data from array.

  • Multiple instances should be as simple as giving an array to each instance. With one object type you do that by putting the sprite and the array in a container, then the events would be the same.

    Now, you can't make a family in a container, so we'll have to do it ourselves with events instead.

    Add a family instance variable and call it "uidOfArray" or something. We want to create an array for each family instance and save the array.uid in that variable so we can pick the right one later.

    family: on create 
    -- system: create array at (0,0) 
    -- family: set uidOfArray to array.uid 
     
    keyboard: space is down 
    for each family 
    array: pick by uid family.uidOfArray 
    -- family: load from json family.back 
    -- array: pop back 
     
    [inverted] keyboard: space is down 
    for each family 
    array: pick by uid family.uidOfArray 
    -- array: push back family.asJson
  • Hey R0J0hound, sorry just butting in , it is great to see you are still around. I may have some potential ROJO level questions on the horizon. Hope you are well. Sorry not intending hijacking please carry on....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound It works perfectly! thanks a thousand. Wasn't even aware that Arrays could have multiple instances them self, I really appreciate the help. X-D

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