How do I save custom slider settings when switching layout?

0 favourites
  • 7 posts
From the Asset Store
slide the tiles to fill the board.60 awesome levels.
  • I have a custom slider which allows you to change the colour of sprites so that you can customise objects.

    It works well, when i change the colour of a box and go to the next layout, the colour is what i changed it to.

    The issue i have is trying to save the slider settings/values when switching layouts. When i go back to the previous layout to where the sliders are, they revert back to their original position and the boxes on that layout also go back to their original colours. However, if i switch to the other layout again, the boxes colour is what they should be when i changed it.

    So i need to find a way to save the slider settings/values when switching layouts, as everything else seems fine.

    I would appreciate some help on this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The easiest solution would be saving the slider value in a global variable when you exit the layout. On start of the layout, restore slider value and position from that variable.

  • dop2000

    Thanks, I have tried that. I tried replacing the instance variables to global variables and load at the start of layout but still get the same issue.

  • It should work. Are you resetting global variables anywhere in the project?

    Try running your game in debug mode (Ctrl-F4) and see if the variable value is correct when you switching layouts. If nothing helps, please share you code or project file.

  • dop2000

    Unfortunately i forgot to save the project when replacing the instance variable with global, but i can confirm that it still didn't work.

    I've checked with the original project using instance variable and the global variables aren't being reset from what i can see. When checking in debug mode, i can see that the instance variables are being reset when changing layout as the sliders are destroyed, which is why the colour stays as it should as that value is a global variable while the sliders value is an instance variable.

    I suspect its either this or how i've set up the slider X value that is causing the issue. However i'm not sure how to save the slider value.

    I've provided my project file in the first post, heres the link -

  • It's not a great idea to use both Touch and Mouse, especially in the same events. Also, since you have two identical sliders, it's better to use two instances of the same object and containers.

    I don't have the "Adjust HSB" effect you are using, so when I open your project, some events are removed. I decided to made my own example, hope it helps:

    The green rectangle is for easier dragging on touch screen, you can make it invisible of course.

  • dop2000

    Thank you, I've got it working now thanks to your help.

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