Container and button problem?

For questions about using Classic.

Post » Mon Sep 15, 2008 7:01 pm

Hi, I'm having a problem whenever anything destroyed in the container the rest of sprites in the container are destroyed. Also I'm wondering if there's any other way I could make my player see, since the way I'm doing it now destroys everything in the group. Right now I can't even test my game.

About the button problem I have this system if you click the sprite it changes a private variable the problem is there is no way to click it again and do somthing else?
Download Link
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Mon Sep 15, 2008 7:14 pm

This is by design. See Containers.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Sep 15, 2008 7:16 pm

So is there any other way I could make my enemy detect if the player is near it?
Edit:
Why would someone want all the sprites in the container destroyed if one is destroyed?
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Mon Sep 15, 2008 8:57 pm

Also I'm having a problem with making a button, I have this system if you click the sprite it changes a private variable the problem is there is no way to click it again and do somthing else?
Download Link
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Mon Sep 15, 2008 11:19 pm

[quote="Casho":13txofkh]So is there any other way I could make my enemy detect if the player is near it?
Edit:
Why would someone want all the sprites in the container destroyed if one is destroyed?[/quote:13txofkh]

Containers, in essence, are used for making one whole object out of several pieces. It's for ease of use when making compound objects. Rays, bullets, and other temporary things that a sprite creates should not be a part of the container.

If your sprite is spawning sight detectors, they're going to be destroyed. If the detectors are in the same container as your sprite, your sprite will be destroyed also. So the best thing to do would be to not put your sight detectors in the container.

If you're having trouble linking a sight detector with it's originating sprite, then put some kind of identifying number into a private variable when the detector is created so that you can keep track of it.

I don't know about your button though, for some reason your cap won't run for me.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Sep 16, 2008 6:44 am

That seems a bit tedious plus I don't think my way is the best. Would their be a more optimized way to do it?
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Tue Sep 16, 2008 6:53 am

How is that tedious? Dude, it would take like a handful of events to track your detectors that way.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Sep 16, 2008 2:39 pm

I really don't like using detectors, *ahem*.
If you want to pick objects that are under a certain distance from something:
pick OBJECT1 by comparison: Distance(.x,.y,OBJECT2.x,OBJECT2.y) < Z
should work.

If you want line of sight, there is a line of sight behaviour which is pretty much self explanatory.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Tue Sep 16, 2008 3:03 pm

[quote="deadeye":1r0wch04]How is that tedious? Dude, it would take like a handful of events to track your detectors that way.[/quote:1r0wch04]

I must of been thinking of a different way of doing it, So how would I do that then?
B
4
S
2
G
4
Posts: 164
Reputation: 2,178

Post » Tue Sep 16, 2008 9:58 pm

[quote="Casho":14eamw9g][quote="deadeye":14eamw9g]How is that tedious? Dude, it would take like a handful of events to track your detectors that way.[/quote:14eamw9g]

I must of been thinking of a different way of doing it, So how would I do that then?[/quote:14eamw9g]

[code:14eamw9g]
+For each object enemy.sprite
-Create a detector
-Set the detector's "origEnemy" value to enemy.sprite uid
[/code:14eamw9g]

Then when you do your collision event with the detector:

[code:14eamw9g]
+Detector is overlapping player
-Set global value "playerSighted" to detector value "origEnemy"
-destroy detector

+For each object enemy.sprite
+UID equals global value "playerSighted"
-activate your attack routine
[/code:14eamw9g]

That's just one way of doing it that I can think of off the top of my head, and it's probably not even the best way.

Also, as faggatron said there is a line of sight object you could use, and you wouldn't even need detectors at all.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests