mardoch's Recent Forum Activity

  • Oops, sorry for the garbled code.

    Here is a clean version:

    + RestoreA: On clicked
    ----+ MyArray: For each XY element
    --------+ MyArray: Value at (MyArray.CurX, MyArray.CurY) = "TypeA"
    ---------> System: Create object MyArray.At(MyArray.CurX,1) on layer 0 at (0, 0), create hierarchy: False, template: ""
    
    --------+ System: Pick last created SpriteFam
    ---------> SpriteFam: Set from JSON string MyArray.CurValue
    

    I tried already using "For Each X" but i doesn't display anything at all.

    Why can't I use "XY" by the way? My variable is stocked on the second Y line, does it make sense to make it check there?

    Now I'm a bit lost…

  • So I add another data, an instance for each objects like TypeA, TypeB and TypeC.

    Everything is well saved in my array and all the new variables are saved on the new Y row. -> MyArray: Set value at (0, 2) to SpriteFam.Type

    My purpose now is to reload the objects by variable and I tried this:

    + RestoreA: On clicked ----+ MyArray: For each XY element --------+ MyArray: Value at (MyArray.CurX, MyArray.CurY) = "TypeA" ---------> System: Create object MyArray.At(MyArray.CurX,1) on layer 0 at (0, 0), create hierarchy: False, template: "" --------+ System: Pick last created SpriteFam ---------> SpriteFam: Set from JSON string MyArray.CurValue

    It almost worked. I have indeed the good objects with the correct variable but once again it change my object's positions and there is even one not positioned at all:

    Where is my mistake?

  • Alright, it works!!

    Thanks dop2000, I can finally move to my next issue!

    I suppose that if I want to save another data, for exemple an instance of the object, I need to do it in another Y row? (I still don't get when the Z in array is used)

  • Ok so i I get it right, beside of load state from JSON, I also need to save the object name and then use the create by name action (like "-> System: Create object "SpriteFam" on layer 0 at (0, 0), create hierarchy: False, template: """) ?

    I really am a rookie with the array so how can I add the sprite's name on it after -> MyArray: Insert SpriteFam.AsJSON at index 0 on X axis ?

  • Hello everyone,

    I read a very efficient way to save each object's proprieties in with AsJSON on this topic:

    construct.net/en/forum/construct-3/how-do-i-8/save-sprite-properties-json-166321

    But why doesn't it works with families? I tried to reproduce the same code but on family's objects and even if it keep all informations (positions, angle, size, etc…), it display randomly every objects from the family.

    Here is the code I use
    And here is the messy result I get

    Is there a way to fix this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Same for me. I just started to understand how arrays are actually working and I really need to get the logic about it.

    But I did get an important information: all objects has a AsJson expression.

    That's mean that everything about a sprite (size, position, actual frame, etc…) can be saves and load quite easely. Even variable I guess.

    It you create an event to save everything in your array like:

    + System: For each Sprite -> Array: Insert Sprite.AsJSON at index 0 on X axis

    Then if you want to call it back:

    + Array: For each X element -> System: Create object Sprite on layer 0 at (0, 0), create hierarchy: False, template: "" -> Sprite: Set from JSON string Array.CurValue

    Seems it works pretty well but I encountered a major problem: This is not working with families. It can't recognize sprites with their name and it mix everything when you call it back.

    And that's a big problem because I don't want to put this for every single sprite in my game (yep, I'm lazy XD).

    For now I have no solution.

    But even if I need to figure it out, I need to assign a new variable for each room that every single sprite in it can refer to.

    And I may have the solution for this with the mini map I'have created here:

    https://www.dropbox.com/s/yemjzks3vwv11xf/LevelGeneratorTest.c3p?dl=0

    For now it's not that bad even if I didn't really figure how to detect the entrances of the rooms already created, but I'm going on.

  • Ok I think I get it (a bit). I thought I could save every new room created in a JSON without using arrays. In the end there will be a lot of informations and variable for each, it could not be the easiest way to manage it.

    I also started to make a mini map. The interesting thing is that I can also probably save variables on it like "how many entrance there are in a room", etc… So when the player come back in it, the mini map could maybe ask the JSON all the stocked variables to "rebuild" the room?

  • Did you consider asking a studio to do this job? My team often ask to this studio to port our games and they do a pretty good job.

    Maybe you can ask them how much it could cost? Sometimes it’s more efficient and you save a lot of time…

  • Hi everyone,

    I am currently testing a level design where several rooms are generated randomly. Each time the player changes room, a new one is loaded and the player finds himself at the entry point of this one (a bit like Cult of the Lamb).

    For the part of loading the presets rooms I was inspired by dop2000's demo (congratulations to him, it's really well done, you can find some of his demos here).

    My player can therefore move from one room to another but however, I have not found a way to save the rooms he has already gone through.

    For example, if I want the player to go back, it will randomly load a new room and not the room he has already visited.

    I think there is surely something to do by saving the data in an array or a json file for example but I don't see how it could be done.

    Besides, it could also have a mini-map which is built simultaneously according to the progress of the player.

    If anyone here has a method or a solution, I'm all ears!

    You can already test my progress on this file, the purpose will be quite different but it is a basis for understanding how it works.

  • Hello, so for everyone who is looking for a solution about this, you can check this file.

    Hope it will help a bit!

  • Ok I think I start to understand a bit more how I can manage this. Seems my main error was the use of the family instead of a single sprite (containers don't work with Family anyway).

    I will continue my research about this and I will share the final result here for the others guys like me in search of a solution.

    Thanks a lot for your help!

  • Hi! Thanks a lot GeoffB, I can see now that it was close with my previous version.

    So, I tried to change my version [here] but I still have some questions with it. How am I supposed to link my sprite to my 3d shape's face as it seems in the end that it take it randomly? I mean, specify the UID in the instance is working fine but in the end I cannot choose which one of my sprite displayed on the scene will be choose by the 3d shape. There is something I definitely don't get because if I add new 3d shape and sprite in on your sample it works fine but not with my mine… How is it possible? (and why don't you use containers as it was suggested by Ashley on the other topic?)

mardoch's avatar

mardoch

Member since 21 Nov, 2013

None one is following mardoch yet!

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies