How do I do save and load object positions from an array

Get help using Construct 2

Post » Sat Jul 23, 2016 2:30 am

edit: changed titled as it makes more sense.
I've included an capx example of how far I've got and how on what I'm trying to achieve: https://dl.dropboxusercontent.com/u/121 ... array.capx

Image
Basically the intent is to load instanced sprites into existence and various desired positions. If there is a way to store all this info into a single array then load all the instances via create object that would be excellent. Create Object woodbrick on Layer 2 at (1, 2)(2,4),(3,6).....

Could someone please explain or illustrate, how I create instances of objects at x & y positions, possibly with the extension of angles. With a better method than I'm manually doing here? I plan to have various size shapes, so simply loading them to replace another sprites position (such as in the inventory array example) will unfortunately not do.

Any help would be greatly appreciated.

Edit: If anyone is willing and able to create a Create Object Array Plugin that would be amazing :mrgreen: :mrgreen: :mrgreen: . Basically being able to create an instance at multiple positions.
You could select multiple sprites on the canvas, then save them to an array/group, for:
Example: Create Object woodbrick on Layer 2 at (1, 2)(2,4),(3,6)..... creating an instance at all three or more locations.
Last edited by adcornaglia on Tue Jul 26, 2016 5:03 am, edited 3 times in total.
B
51
S
26
G
8
Posts: 121
Reputation: 8,501

Post » Sat Jul 23, 2016 2:25 pm

Message: Programmer25 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
@adcornaglia

This tutorial might help you: (remove spaces from link)
https://www.scirra.com/ tutorials/ 748/record-and-rewinds-system-similar-to-braid
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Mon Jul 25, 2016 12:29 am

Programmer25 wrote:@adcornaglia

This tutorial might help you: (remove spaces from link)
https://www.scirra.com/ tutorials/ 748/record-and-rewinds-system-similar-to-braid

@Programmer25
Thank you very much for your reply, that is a really interesting system. Though, that isn't exactly what I'm trying to do, or I'm not understanding the parallel.

I've included an capx example of how far I've got and how on what I'm trying to achieve: https://dl.dropboxusercontent.com/u/121 ... array.capx

Basically I want to:
0. Place objects on the layout.
1. Record the positions of instances and objects into an array.
2. Download the array as a XML/JSON file
3. Then load the array of positioned object sets dynamically.

Issues:
○ How do also I add instances of objects into the array?
○ How do I spawn the entities/objects/instances into the desired positions on a layout from the array?
○ Is there an easier way to save a selection of individual objects properties into an array?
Last edited by adcornaglia on Tue Jul 26, 2016 5:04 am, edited 1 time in total.
B
51
S
26
G
8
Posts: 121
Reputation: 8,501

Post » Mon Jul 25, 2016 12:40 pm

@adcornaglia

I started learning Construct 2 about 5 days ago. Im very sorry I dont know how to help you.
@DaniellMesquita Can you have a look? Maybe you know how to solve this problem
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Mon Jul 25, 2016 12:59 pm

Here is a sample capx of prefab. In this capx, it
1. save position of all instances in layout 1 in a JSON string using rex_fncallpkg.
2. goto layout2, create instances by the JSON string saved in step1.

The idea is, transfer function calling of creating an instance into a string, then parse it and run the function calls. Therefore designer can save properties like position, angle, private variables, or properties of other instances in the same container.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Tue Jul 26, 2016 4:56 am

rexrainbow wrote:Here is a sample capx of prefab. In this capx, it
1. save position of all instances in layout 1 in a JSON string using rex_fncallpkg.
2. goto layout2, create instances by the JSON string saved in step1.

The idea is, transfer function calling of creating an instance into a string, then parse it and run the function calls. Therefore designer can save properties like position, angle, private variables, or properties of other instances in the same container.

@rexrainbow
Yes, I have this plugin from you and your many other great plugins.

That said, I would like to learn how to achieve this without a plugin as I have need more practice with arrays and understanding how to do this will better equip me for solving my own problems in the future. I would greatly appreciate it if you would be able to guide me in this way.

Image

I'm still stuck at these issues:
○ How do also I add instances of objects into the array?
○ How do I spawn the entities/objects/instances into the desired positions on a layout from the array?
○ Is there an easier way to save a selection of individual objects properties into an array?
B
51
S
26
G
8
Posts: 121
Reputation: 8,501

Post » Tue Jul 26, 2016 9:40 am

Example capx (2017-05-11).

For "push" to work properly, you need to be sure to set the size (width) of the array to 0 in the first place.
Then Width - 1 corresponds to the maximum X index you can reach in your array.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Tue Jul 26, 2016 8:28 pm

That works! I might try to use this in my project although i dont need it, just for the sake of making it more complex
B
10
S
3
G
1
Posts: 46
Reputation: 1,261

Post » Wed Aug 03, 2016 7:33 am

Kyatric wrote:Example capx.

For "push" to work properly, you need to be sure to set the size (width) of the array to 0 in the first place.
Then Width - 1 corresponds to the maximum X index you can reach in your array.


Thank you, I was certainly not doing it right. I needed a visual example to get how to use the array here. This will help me do my bonus mode and some of the stage effects I need. So, I'll definitely be putting it to good use 🛠
B
51
S
26
G
8
Posts: 121
Reputation: 8,501

Post » Wed May 10, 2017 6:57 pm

@Kyatric

hi man, do you have your Capx yet? link is broken.
B
10
S
3
Posts: 180
Reputation: 1,212

Next

Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, user5487 and 4 guests