How to properly use cloned objects?

Get help using Construct 2

Post » Fri May 03, 2013 8:47 am

So when you create objects at runtime you need an example object to exist outside the screen right?
So if you create a new one, and then do something like "every tick, do this" it seems to apply to both objects. If you reference it anywhere outside of the creation event that seems to be what happens.

For a specific example, I would create new particle and set its position to another object in a different condition, and it would set the existing particles and the current particles to the position.

What's a better way to do this?
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Fri May 03, 2013 8:55 am

[QUOTE=Sushin]What's a better way to do this?[/QUOTE]

Most capx's i've seen uploaded as examples delete the original when layout loaded event is triggered. That's what I do as well, and it works reliably for me. If you just add a "<spritename> destroy" action on layout loaded, it will remove any instances of that object currently active.

You can then spawn new ones when needed, and they'll be set up the same way as the one you originally had in your layout.Venivididormi2013-05-03 08:58:44
B
8
S
2
Posts: 63
Reputation: 1,223

Post » Fri May 03, 2013 9:03 am

So what if you have a bunch of enemies that you clone at the same time and they all have particles or something following them?
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Fri May 03, 2013 11:54 pm

Can anyone help? Basically I just want to know how to link objects together that are created on run-time.
B
10
S
3
G
3
Posts: 234
Reputation: 3,467

Post » Sat May 04, 2013 12:08 am

It sounds like Containers maybe able to help.
here is the Containers manual entry
https://www.scirra.com/manual/150/containersonzephyr2013-05-04 00:42:17
B
83
S
12
G
9
Posts: 99
Reputation: 9,478

Post » Sat May 04, 2013 12:32 am

If you want to apply the actions just for an specific clonned object, you can use variables to distinguish them:

https://www.dropbox.com/s/4o5rdigrl39j1jb/clonedobject.capx Ciro2013-05-04 00:33:55
B
11
S
1
G
2
Posts: 24
Reputation: 1,104

Post » Sat May 04, 2013 5:21 am

Thanks. I think I got it though...
I deleted the object everything clones from, and now if I do an every tick update, it magically works for each specific associated object. I love construct...
B
10
S
3
G
3
Posts: 234
Reputation: 3,467


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests