Save object location to array

Get help using Construct 2

Post » Sat Jul 13, 2013 1:56 am

Hi guys,

    Im trying to save a bunch of object locations(x,y) to an array but I cant figure it out. Basically I have it set up to have a slot for every object being saved, and its 2 deep., one for x, one for y. But I cant figure out how to send the x,y coordinates to the array for each object? I figure on using the UID of each object(they are all the same object) to determine the slot. Can I do this?

Thanks
Adam
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Sat Jul 13, 2013 2:49 am

This is one of those 'it depends' questions. Usually you'd use a Dictionary to use an arbitrary key/index. Here's a very quick example:

DictWithRevert_r132.capx
ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sat Jul 13, 2013 3:09 am

I see. Can I use those points to spawn objects? One of the uses Im looking for is setting up spawn points. But I want to be able to physically place them, and move them around. Then have them save location and destroy at start up to reduce the number of objects on screen. Then when the player dies, call on the saved loactions randomly.
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Sat Jul 13, 2013 3:20 am


@mELTINGsKYsTUDIO

Here is one way..

Array
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Sat Jul 13, 2013 3:25 am

[QUOTE=spongehammer]
@mELTINGsKYsTUDIO

Here is one way..

Array[/QUOTE]

Hey man, Thanks. I think I understand how that works. Let me test it out!
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Sat Jul 13, 2013 6:50 am

ImageImageImage
B
71
S
21
G
204
Posts: 3,586
Reputation: 115,576

Post » Sat Jul 13, 2013 10:16 pm

Thanks guys. Now Im just trying to figure out a way to have them not spawn in the middle of the action. Like choose a random spawn point so many pixels away from certain objects. Im trying to use distance, but its not working out so well so far.
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Wed Dec 11, 2013 4:28 am

Any chance Spongehammer or mELTINGsKY has that array capx handy? Im trying to figure out how to generate random points on the layout then store those in an array which I can later loop through to spawn objects at those points / coordinates. I have a feeling the array.capx would have likely saved me a few hours of headaches by showing me the light...

let me know & if so, thank you so much !!
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
26
S
7
G
3
Posts: 377
Reputation: 4,881

Post » Wed Dec 11, 2013 4:29 am

Sounds like you're trying to do the same thing im doing mELTINGsKY -- i have the formula basically worked out i just need to know how to actually get those coordinates into an array to begin with...
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
26
S
7
G
3
Posts: 377
Reputation: 4,881

Post » Wed Dec 11, 2013 8:23 am

@80bit, check out latest tutorial section, there is a ton of tutorials uploaded yesterday on location and storage. Even a cool one which records the movement and allows you to rewind based on previous co-ordinates.

The space game has spawning - have a look at that DUTOIT2013-12-11 08:26:50
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,698

Next

Return to How do I....?

Who is online

Users browsing this forum: CJacobsSA, Magistross, Mato and 7 guests