Trouble with Containers

For questions about using Classic.

Post » Thu Jan 15, 2009 8:23 pm

Hi. Can anyone tell me what I'm doing whrong here?

Arrows and Containers

I'm trying to get arrows to point from the player to both of the enemies. I have the enemy and arrow wrapped in a container, so I think that whenever the arrow references the enemy, it should default to the instance of the one that it is grouped with.

Right now I have the arrows centered on the enemies and pointing to the player and everything works fine. However, if I go into the event sheet editor and reverse the targets so that the arrows are centered on the player and point to the enemy, both arrows point to the same enemy.

By the way, I used tips from DeadEye's post about "This Cursed Rock" to initialize the enemies:
This Cursed Rock
So it's possible I made mistakes with that part that are causing my problems.

I appreciate any help!
B
4
G
3
Posts: 21
Reputation: 942

Post » Thu Jan 15, 2009 8:38 pm

I think this is what you want.


The key is the "For Each" condition
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Thu Jan 15, 2009 8:56 pm

Perfect!

Thank you so much. That did the trick.
B
4
G
3
Posts: 21
Reputation: 942

Post » Thu Jan 15, 2009 10:19 pm

I think it's strange that it works without the for each when the arrows are positioned at enemies and pointed to player, but needs for each other way around. Shouldn't it be the same, whatever the actions are? The arrows are pointing to enemies, so shouldn't the action pick THE enemy the arrow is paired with, without need of for each? At least it picks THE enemy when positioning, so why not when pointing?

I think this is a bug.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Thu Jan 15, 2009 11:28 pm

It's not a bug, it's just how Construct works.

When you say "Aim at <something in my container>", it aims at the paired instance from its container.
When you say "Aim at <any old object>", it usually just picks the first.

For Each is the way around it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Jan 15, 2009 11:33 pm

[quote="Ashley":26xwtu56]It's not a bug, it's just how Construct works.

When you say "Aim at <something in my container>", it aims at the paired instance from its container.
When you say "Aim at <any old object>", it usually just picks the first. [/quote:26xwtu56]

I know that, but isn't the enemy something in the arrow's container? According to that logic, it should work both ways around!
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Fri Jan 16, 2009 1:42 am

[quote:3knli77y]When you say "Aim at <any old object>", it usually just picks the first. [/quote:3knli77y]

Ashley are you sure about that? I seem to remember code wise that it usually pairs objects together automatically, so if you have 5 tanks and 5 turrets and use an action 'always - set turrent to tank.x, tank.y' it pairs them up even if they arn't in a container....and when they are in a container the only difference is that any conditions the select/unselect tank will also select/unselect turret....

I'll have a look at this when I get home... at work and cant open cap files :(
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Fri Jan 16, 2009 2:00 am

I modified a test cap from the original, and I think that it shows pretty clearly the odd behavior.

[url:1dyhjux2]http://drasa.nipponfever.net/muu/container_test.cap[/url:1dyhjux2]

I simplified the situation: now there is no spawning, the contained sprites are already there, and it should be clear from the events that the arrow should point to the corresponding sprites, but they doesn't...

WTF. Even having one pair WITHOUT containers trigger this bug, but for each corrects it. Strange.

Also encountered two crashes, which of one I was unable to reproduce, and one happened when cloning a layout, and then copying the all events from layout 1's event sheet editor to layout 2's. I'll post it to the tracker.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Fri Jan 16, 2009 8:34 am

Ah was a bug in the plugin itself.

Basically there was this line:

CRunObject* pTarget = params[0].GetObjectParamFirstInstance(pRuntime);

which should have been this line

CRunObject* pTarget = params[0].GetPairedObjectParam(pRuntime, this);

Having a search through the file I found that ZBehindOf, ZInfrontOf also have the old code and so will have the instance pairing problem. Other than that the pairing system should work.
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sat Jan 17, 2009 11:17 am

yeah i always get those 2 lines mixed up. :shock:
B
37
S
19
G
18
Posts: 613
Reputation: 10,231

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests