How do I families and contaners

Get help using Construct 2

Post » Fri May 15, 2015 3:24 am

Hey. I know a lot of people ask for this. I'm not asking for it to be feature as I know Ash said it would be complex and impact performance. I just want to know what to do.

When I started my project I had one sprite for the player. I added a new sprite to it's container that I use for it's hitbox. When it is created I pined it to the player. and it worked fine. But then I changed the player sprite to a family because I would want to use different sprites for the player at different times, but would not want to copy the code. But now the hitbox object won't pin.

Ideas?

Thanks.
B
14
S
5
Posts: 54
Reputation: 1,059

Post » Fri May 15, 2015 4:42 am

This is strange.
Your having that object in a family doesn't really affect pinning behavior.
If the hitbox code says for example
OnStartOfLayout>HitBox>PinToObject>Sprite
This will keep it pinned to that particular sprite.

Might be best to link your .capx file here.Might be some minor thing you overlooked.

-cheerios
B
18
S
4
Posts: 19
Reputation: 1,851

Post » Fri May 15, 2015 5:44 pm

the player will use the same sprites as NPCs. So I make the NPC family do it's own thing, except for the one that the player will control. one at random will become the player object though variables that state such to the game.

I have one of each on the layout and destroy them at the start, then spawn them in a "repeat nth times" event. then when the hitbox (being in the same container as each sprite) is created I pin it in it's creation event.

Due to my project using plugin's covered under ULAs, I can't share the Capax. But I hope this photo showing the "at start of layout" event will show whats needed.


https://www.dropbox.com/s/zzzefbehffmu8kc/construct.png?dl=0
B
14
S
5
Posts: 54
Reputation: 1,059

Post » Fri May 15, 2015 6:03 pm

why are you setting the attack box to humans.x,humans.y?

As far as I understand the attack box isn't in a container with the family, but with the sprite..
Would setting it's position to sprite.x,sprite.y and pinning it to the sprite work?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 6:09 pm

mmm. that worked. Guess I will just have to know what sprite it's referencing. and use separate events for the pinning. Thanks.
B
14
S
5
Posts: 54
Reputation: 1,059

Post » Fri May 15, 2015 6:17 pm

if it's in a container, it will automatically go to the sprite in the same container, right?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun May 17, 2015 5:22 pm

what happens when you have multiple sprites in the family??and the hitbox is pinned to the family object??
When I tried it just stayed with one sprite.The first on the family list.
B
18
S
4
Posts: 19
Reputation: 1,851

Post » Sun May 17, 2015 5:40 pm

If I understand the question correctly, there are many ways to do that..

For example, something like this should work:
give the hitbox a variable ready (original value 0)

for each family
pick by comparison - hitbox.ready = 0
> hitbox set position to family.x,family.y
> hitbox set value ready = 1
> hitbox pin to family

or if you have to create the hitboxes, you don't even need the variable

for each family
create hitbox at x=family.x y = family.y
-- hitbox pin to family
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun May 17, 2015 5:49 pm

@LittleStain

oh that second one is a good idea. I might try that. thanks!
B
14
S
5
Posts: 54
Reputation: 1,059


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 45 guests