0 Favourites

How do I Save the position of a new Object

  • Hello all,

    Im working on a calendar like app and i want to save the position of text placed on various points on the calendar. It works ok until the app is forced closed, or the device goes dead or if you refresh the page. The .capx is attached, simply drag any text from the left over to the dates on the right. What i want to happen is as you drag the text over to the right, the position of that newly created text will be saved for when you open the app again.

    Thanks guys

  • Local storage would be what persists through sessions, so you have to use that.

  • Hi Mind,

    I tried using local/web storage but i have no idea how to save coordinates with it. And seeing as an infinite amount of new objects could be created, would a new web/local storage not be needed for each of them.

    Thanks

  • Arrays can store more than one element and can be stored in local storage.

  • Ive looked into using arrays, but couldn't quite wrap my head around it for what im trying to achieve. I was hoping someone could give me a basic template i could build on.

    Thanks again Mind.

  • Could anybody point me to a template/tutorial or start me off in the general direction i need to go in to store the location of newly created objects using arrays or any other means?

    Ty

  • The easiest way to achieve that is with 'save game'.

    You could for example trigger the 'save game' with 'On DragDrop drop'

    TextX|On DragDrop drop -> System| Save game to slot "position"

    and load it in the 'on start of layout' event.

    System| On start of layout -> System |Load game from slot "position"

    The whole thing would be much easier if you use only one text-object and instances of it not so many different text-objects. Now in this example you have to trigger 'save game' with every text-object.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The easiest way to achieve that is with 'save game'.

    You could for example trigger the 'save game' with 'On DragDrop drop'

    TextX|On DragDrop drop -> System| Save game to slot "position"

    and load it in the 'on start of layout' event.

    System| On start of layout -> System |Load game from slot "position"

    The whole thing would be much easier if you use only one text-object and instances of it not so many different text-objects. Now in this example you have to trigger 'save game' with every text-object.

    Thank you VERY much Asmodean

    Simply triggering a "Save" on Drop and refreshing the page saves the position of all the text. Your help is extremely appreciated good man.

  • [quote:21xm5f4h]

    Thank you VERY much

    No Problem, but use 'save game' with care. Use it only with events that trigger (green arrow), otherwise you can get side effects like lags.

    If you have objects that are not to be saved, you can use the 'not save' behavior.

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