Family picking. One works and one doesn't?

Get help using Construct 2

Post » Thu Oct 02, 2014 9:56 pm

I have a confusion. I'll explain (see image below).

allsprites.spritegroup is a variable for the allsprites family and each one is set specifically (for example, I have "Scenery" sprites, "Death" sprites, "Platform" sprites, etc..)

allsprites.keynum is a variable for the same family, also set specifically (so I can have Scenery 1, Scenery 2, Death 1, Death 2, etc..)

LastSprite and LastChosen are variables that update when you push a hotkey or roll the mouse wheel.

My confusion is that, the set cursor action you see here works perfectly. If I push the scenery hotkey, I get scenery if I push the number, it changes accordingly and so on for all the others.

But if take out the cursor change and try to create the appropriate sprite (the disabled action), it just chooses any sprite at random, completely ignoring my variables. (yes, I know I need to destroy the previous one for it to update properly like the cursor, this is not the issue, though. It's simply ignoring my variables or my picking or both.)

What's the difference?
You do not have the required permissions to view the files attached to this post.
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Oct 02, 2014 10:16 pm

There is no way to pick which sprite gets created when Create is called on a Family. This has been discussed many times. You have to create each appropriate sprite.
ImageImageImage
B
71
S
21
G
231
Posts: 3,694
Reputation: 129,364

Post » Thu Oct 02, 2014 10:18 pm

Just seems strange that it can pick the right one for the cursor..
All I want to know is "What's the difference?"
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Oct 02, 2014 10:27 pm

Set Cursor is aware of picked objects, object creation is not. If Construct made assumptions about what kind of object you want to create from a family, it could lead to confusion, thus it simply creates a random object. Honestly, I feel it would make more sense if you couldn't create an instance of a family object.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,116

Post » Thu Oct 02, 2014 10:32 pm

linkman2004 wrote:Set Cursor is aware of picked objects, object creation is not. If Construct made assumptions about what kind of object you want to create from a family, it could lead to confusion, thus it simply creates a random object.


I see. Thank you for the explanation!

linkman2004 wrote: Honestly, I feel it would make more sense if you couldn't create an instance of a family object.


In that case, I'd have to agree with you.
B
86
S
43
G
71
Posts: 601
Reputation: 43,619


Return to How do I....?

Who is online

Users browsing this forum: Matei511 and 61 guests