container - 2nd sprite not automatically created

For questions about using Classic.

Post » Mon Jun 20, 2011 7:38 am

As I understand from the Wiki, If 1 sprite is created, the 2nd sprite will automatically be created too, when the 2 objects are in a container.

This doesn't work in my new test cap, though.
I created sprite1 and sprite2. (red and blue simple square) I placed them so that they overlap eachother.
Clicked on sprite1, add container --> clicked on sprite 2.
Now when I click on sprite 1, sprite 2 gets a yellow outline, suggesting it is in the same container.

But when I create sprite1 every 1000 ms, there is no sprite 2 to be seen in runtime.

(using: C0.99.96)
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Mon Jun 20, 2011 7:56 am

Did you set xy of the 2nd sprite?
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Mon Jun 20, 2011 8:07 am

So that is what I missed.

I added:
always>sprite2 x = sprite1.x, sprite2 y = sprite1.y

And I get the result I wanted and expected, from using containers.
Thanks :)
B
16
S
5
G
7
Posts: 599
Reputation: 5,000

Post » Mon Jun 20, 2011 8:29 am

Speaking of containers i have similar problem, but in my case there are 3 objects in container.
Every one have different sets of behavior (1- physics, 2 rts, 3...) so altogether they make something like "enemy chasing player system" and i havent figure it out how to spawn them via "System -> create object".

Basicaly there's "main sprite" witch always have position set to "sprite detector" (with physix).
"Sprite detector" always follows "sprite follower" (with rts).
"Sprite follower" always moving to player position.

If i spawn "main sprite" usually nothing happening - just sits in his spawn position.
When i spawn "sprite follower" it start chasing player, but no more sprites have been spawned - same with "sprite detector" - just bouncing around if player hit it.

But when i spawn all three of them... well i can't describe that whats happening on the screen :)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Jun 20, 2011 9:41 am

The thing to remember is that if you create one you create all, and all are placed into the selected object list, check the debugger it will show it exists even if you don't see it. Then not all behaviors play well together.
Also not all behaviors work well with Always. Sorry I can't be more specific, but rts and physics are kind of like oil and water.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Mon Jun 20, 2011 9:54 am

Why you use old version of Construct? oO Use new, than you don't got similar problems.
B
2
G
1
Posts: 20
Reputation: 590

Post » Mon Jun 20, 2011 5:58 pm

my container works fine if i manualy copy as many instances as i want - i just copy ie 10 "sprite detctors" to random places on my map, and is all good. It makes me 10 enemies behaving correctly in runtime.
It's only not doing that by "System -> create object" - and debug whows indeed that only one object from container was created :/
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests