Containers and Spawning

For questions about using Classic.

Post » Sat Dec 19, 2009 8:31 pm

I have a "Ship" sprite object and an "Exhaust" particles object. I created three instances of the Exhaust sprite by CTRL+dragging. I then added all three exhaust instances to the Ship sprite container. However, the sprites are not behaving as I expect in two ways:

1) When I click on the Ship sprite, only the first Exhaust object is highlighted with the green box. Is this a bug?

2) The documentation ([url:kv3dhdqd]http://sourceforge.net/apps/mediawiki/construct/index.php?title=Containers[/url:kv3dhdqd]) says that all objects in a container are spawned when the primary object is. However, when I run in debug mode, no exhaust objects are spawned when I spawn a ship.

Thoughts?
B
2
G
3
Posts: 20
Reputation: 890

Post » Sat Dec 19, 2009 9:04 pm

Posting a .Cap always helps people to see what is going on. and Im not sure how the edit time handles containers, but i dont think it makes the for you. your better off having them created at runtime anyways.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Sat Dec 19, 2009 9:13 pm

[quote="MikeWyatt":1cp3tsn2]and an "Exhaust" particles object.[/quote:1cp3tsn2]
[quote:1cp3tsn2]of the Exhaust sprite [/quote:1cp3tsn2]
Is Exhaust a sprite or a particles object?

Anyhoo, when you select an object, the other objects in the same container get selected in yellow. When you create one, the others get created too, but you need to set their positions. Maybe they were created off-screen?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sat Dec 19, 2009 10:17 pm

[quote="Aeal5566":14y21j9z]
Posting a .Cap always helps people to see what is going on.
[/quote:14y21j9z]

Here it is: [url:14y21j9z]http://sites.google.com/a/mike-wyatt.com/mike-wyatt-s-blog/spacebattle.cap?attredirects=0[/url:14y21j9z]

The "Ship" sprite object is called "Frigate" in the cap, and "Exhaust" is actually "FrigateExhaust".

[quote="Aeal5566":14y21j9z]
Im not sure how the edit time handles containers, but i dont think it makes the for you. your better off having them created at runtime anyways.
[/quote:14y21j9z]

I really hope I can get it working. I want to let the player choose different ships when the game starts, but not duplicate all the events for each ship type. Each ship could have different child objects, so I'd need to write custom event code that spawns them if the container won't take care of that for me.

[quote="Madster":14y21j9z]
Is Exhaust a sprite or a particles object?
[/quote:14y21j9z]

Oops, sorry, that was a typo. The Exhaust object is a "Particles" object.

[quote="Madster":14y21j9z]
Anyhoo, when you select an object, the other objects in the same container get selected in yellow. When you create one, the others get created too, but you need to set their positions. Maybe they were created off-screen?[/quote:14y21j9z]

When running in debug mode, no additional exhaust objects are created at all.

Here's what the sprite/container looks like in the editor:



I've noticed that when adding exhaust objects to the ship container that I'm always selecting the same object from the list. I'd need a way to associate a specific instance, which I don't think I'm doing.
B
2
G
3
Posts: 20
Reputation: 890

Post » Sun Dec 20, 2009 2:02 am

[quote="MikeWyatt":hm2e3g9n]Here it is: [url:hm2e3g9n]http://sites.google.com/a/mike-wyatt.com/mike-wyatt-s-blog/spacebattle.cap[/url:hm2e3g9n][/quote:hm2e3g9n]


Hey MikeWyatt, my name isn't Mike Wyatt, it makes it kind of hard for me to log into Mike Wyatt's blog at MikeWyattDotCom as Mike Wyatt.





You might want to sort out your hosting :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 20, 2009 3:19 am

Doh! That's what I get for trying something new. I'll fix it when I get home.
B
2
G
3
Posts: 20
Reputation: 890

Post » Sun Dec 20, 2009 4:20 am

The link should work now.
B
2
G
3
Posts: 20
Reputation: 890

Post » Sun Dec 20, 2009 6:31 am

Ah, I can see your screenshot now as well. I know what the trouble is.

When something is contained with something else, you can only contain one instance of each object. Think "Ice cream and Cake," not "Ice cream and Cake and Cake and Cake." There's just too much cake.

You have one ship, and three exhausts. You can only contain one of those exhausts. Each of the other two exhaust objects want to belong in a different container with their own respective ships.

Since you want to attach three of the same object to your ship, you should use the Pairer object:

http://dl.dropbox.com/u/529356/awesomespaceship.cap

That should do the trick.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Wed Dec 23, 2009 1:01 am

Your example is exactly what I want. The ObjectPairer makes more sense now. Thanks!
B
2
G
3
Posts: 20
Reputation: 890

Post » Wed Dec 23, 2009 3:26 am

hey! I wanted to know how to use the Object Pairer too, thanks :D


now some thread keywords: Object Pairer example examples file pairing container
:)
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests