How do I Save the position of a new Object

Get help using Construct 2

Post » Wed Dec 30, 2015 7:42 pm

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.

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

Thanks guys
B
9
S
3
Posts: 45
Reputation: 805

Post » Wed Dec 30, 2015 8:33 pm

Local storage would be what persists through sessions, so you have to use that.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Wed Dec 30, 2015 9:24 pm

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
B
9
S
3
Posts: 45
Reputation: 805

Post » Wed Dec 30, 2015 9:52 pm

Arrays can store more than one element and can be stored in local storage.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Wed Dec 30, 2015 11:21 pm

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.
B
9
S
3
Posts: 45
Reputation: 805

Post » Fri Jan 01, 2016 12:50 pm

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
B
9
S
3
Posts: 45
Reputation: 805

Post » Fri Jan 01, 2016 1:31 pm

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.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Fri Jan 01, 2016 3:39 pm

Asmodean wrote: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.
B
9
S
3
Posts: 45
Reputation: 805

Post » Fri Jan 01, 2016 4:00 pm

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.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 59 guests