Object parenting quiz (.cap included)

For questions about using Classic.

Post » Thu Aug 02, 2012 2:40 pm

Hello esteemed possessors of teh knowledge,

I've been trying for months to demystify the notion of object parenting in classic, I've tried containers, object pairer, families and FOR loops with just no success at all.

I've made a .cap quickly illustrating all those failed attempts and I thought maybe one of you guys could shed a light once and for all on this simple but complexe issue.

Object parenting test

Basically I want to spawn mobs with their own collision, visual, trigger box, etc... but this would be useful for any game objects!

Sincerely, thank you so much!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Thu Aug 02, 2012 8:04 pm

Put the sprite12 events as a subevent of a "for each sprite12" then the arrows will act independent of each other. Or did you want it to do something else?
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Thu Aug 02, 2012 8:26 pm

oh niiice now I got independant look at, thanks!
but the spawning of object groups belonging to the "enemy" family still doesn't work properly. Each spawners seem to spawn at random one of the two objects the family includes, or neither. changes every time I restart the build.

what would be the correct way to spawn many groups of objects and affect these groups individually in that same independant way?

just that missing part and I can place my enemies in the levels. :D
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Sun Aug 05, 2012 8:56 pm

sorry, don't mean to spam but this is still giving me a lot of troubles, can't find my way around it...

Posting new cap with the details mentionned above;

http://dl.dropbox.com/u/38319441/TestGrouping2.cap
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Aug 06, 2012 12:37 am

Instead of spawning "enemy" just spawn the objects you want at those spots.
* Add another private variable to spw2 and call it "toSpawn" then change it to the name of the object you want to spawn.
* Edit the spawn action and right click "object" and select "use expression".
* Then input Spw2.Value('toSpawn')
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Mon Aug 06, 2012 1:40 pm

that's a neat trick!
I'm still searching how to express a group of objects into a string... I tried many ways, (sprite1, sprite2) {sprite1; sprite2}

But, correct me if I'm wrong, this would not "parent" the objects to one group. Like for instance, if my character steps into one enemy line of sight, all enemies would activate at once, and not just the one that saw my character.

infinite thanks!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Mon Aug 06, 2012 5:38 pm

There is no grouping done here. Right now you're just spawning different objects on one object type. You could pair the spawned object with the spawner by storing the UID of one in a private variable of the other.
http://dl.dropbox.com/u/5426011/examples13/Gropwel.cap

Give me a more complete description of what you want to do and I can give you a more specific answer.
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Tue Aug 07, 2012 9:16 pm

Hmm I can't seem to be able to open your .cap with r1.2? Strange... there's a more up to date version available?

Well it's all about parenting, to put it simply I'm looking for the method to make "game objects" in construct.

Components, modules, ingredients, groups, classes... names vary between editors I worked with but in all cases the basic principle is having various objects parented to one entity, which is the entity I refer to when scripting, in order not to have to manage every single object individually.

That's why I used the "Enemy" family, which looked to me like the closest thing to a class in construct.

So not only do the enemy spawns with its visual, FX, collision box, triggers, etc, but when one enemy is activated, the game is able to identify which game object/group/module is alerted and activate only the right one, not all existing enemies in the world.

Right now I found a way is to check if the trigger box is simultaneously overlapping the main character, and the enemy to which it belongs to. But this looks like a hack and there must be a better, more bug-proof way to do it.

Well I hope that's clearer! :) Thanks a lot for all your help R0J0!
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Post » Tue Aug 07, 2012 10:55 pm

Here is the newer version of CC:
http://www.scirra.com/forum/construct-classic-r2-released_topic48884.html

Families are used so you don't have to repeat events for each object that does the same thing. Containers sound closer to what you want, they make a set of object types get picked together. The only drawback of containers is they don't work with families, and only one instance of each object type can be in a container. The object pairer could work for some cases but I recommend looking a examples to see how it works. The final way is to use UIDs of other objects stored in private variables like the example in my previous post.

For further info:
Containers:
http://sourceforge.net/apps/mediawiki/construct/index.php?title=Containers

Object pairer:
http://sourceforge.net/apps/mediawiki/construct/index.php?title=Pairer_Object
example:
http://69.24.73.172/scirra/forum/viewtopic.php?f=8&t=2669
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Thu Aug 09, 2012 4:03 am

oh damn there was actually a newer version of construct! sorry about that, I shouldn't stick to the update button. It's always a little stressing to overwrite your game engine ain't it? But the release looks solid.

wow I'll be having dreams about containers and objects pairer. So in the end all the functions of a "game object" module is actually handled by all these different little modules.
Ok, I should be able to find a way to make it work, you brought a lot of fresh ideas, thank you so much for your generosity.
B
4
S
2
G
2
Posts: 108
Reputation: 1,366

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests