Select the closest instance

For questions about using Classic.

Post » Mon Aug 22, 2011 1:02 am

Hi!

I searched a lot for that one... honnest!

What's the principle for the selection of instances using events? I want to create a generic enemy spawner that I can copy paste infinitly, but the enemy will only spawn on the first instance ever created... it's also the only instance considered for proximity triggering.
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Aug 22, 2011 6:43 am

[quote]What's the principle for the selection of instances using events?[/quote]

Go to the wiki to understand how picking instances works: http://sourceforge.net/apps/mediawiki/construct/index.php?title=Conditions

B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Wed Aug 24, 2011 12:29 am

hmm yeah I did, thanks for the tip by the way, but I still don't get it perfectly.

As I understand, if you don't specify any condition other condition than say "every tick", it should pick all instances? Only one seems to be considered in my case...

But if say I modify the private variable from a newly created instance it will still change it for every existing instances?

How can I say pick the closest instance?

Infinite thanks.
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Wed Aug 24, 2011 12:48 am

[QUOTE=Gropwel] hmm yeah I did, thanks for the tip by the way, but I still don't get it perfectly.

As I understand, if you don't specify any condition other condition than say "every tick", it should pick all instances? Only one seems to be considered in my case...

But if say I modify the private variable from a newly created instance it will still change it for every existing instances?

How can I say pick the closest instance?

Infinite thanks.[/QUOTE]
All those questions are answered in the wiki, are you sure you read it?

Most of the time, when nothing is specified all instances are picked. For example:

+Always
-> mySprite: Set X to .X + 1

is essentially the same as

+For each mySprite
-> mySprite: Set X to .X + 1

If you experience something else, then there are other conditions, that make only the first instance getting picked.

If you create an instance it is automatically picked for that event. So, if you change the pv, you only change it on the instance.

You pick the closest instance by using the appropriate object's condition.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Aug 24, 2011 3:13 am

Yes read it and I appreciate the help, my brain just works differently. In all sincerity I will never ask for help unless I spent several hours reading and trying to figure it out.


[QUOTE=tulamide]
You pick the closest instance by using the appropriate object's condition.
[/QUOTE]

Well that seems to be just what I'm looking for, what would be the appropriate object's condition?
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Wed Aug 24, 2011 5:20 am

If you look at your object's conditions you will find a "Pick closest" where you specify the X and Y reference coordinates. Quite obvious if you know the basics of construct.
Scirra Employee
B
129
S
45
G
15
Posts: 705
Reputation: 15,413

Post » Wed Aug 24, 2011 12:54 pm

ahhh... well that was quite obviously simpler than I thought. I was at a stage where I was comparing hypotenuses. Well, you know, sometime you need a little help.

Thanks a bunch!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests