Save/load state in JSON problem with layers

0 favourites
  • 3 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Description

    This also happens in the free version of C3

    If you save the state of an object that is being used in a layout with several layers, then you change to another layout with the same number and name in the layers and create the same object and restore its status with JSON.

    The layer is not restored, the object is positioned in layer 0, although you saved its state in JSON when the object was in layer 3.

    It only works in the same layout, if you change the layout the error occurs with the layers.

    CAPX

    https://www.dropbox.com/s/ln8f6a2gm17f5jm/bugJSON.capx?dl=0

    GIF in:

    https://imgur.com/a/WaNHupf

    Description CAPX

    A tilemap object saves its status automatically when it is in layout 0.

    After passing to layout 1, this layout has just the same layers as layout 0.

    The tilemap object restores its state with JSON but the layer is not restored correctly.

    The tilemap object is located in a layer that does not correspond to the one it had at the moment of saving its state.

    Steps to reproduce bug

    Simply observe how the object is not placed in its layer correctly when the number 1 layout is executed and it regains its state saved in JSON.

    Everything happens automatically.

    Operating system

    win10 64bits

    C2 version

    259 64

  • This is by design. The runtime saves the layer using a unique ID rather than its name or index, so that if you rename or move the layer, it can still correctly load a savegame or restore the state of a saved instance. The unique ID identifies a specific layer on a specific layout. Therefore if you change layout, that specific layer is not available, so it defaults to layer 0.

    You could work around this by storing its layer index in an instance variable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, I thought that, but it's a bit heavy when you have many different objects, thanks anyway.

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