One Object Type, Multiple Different Events

Get help using Construct 2

Post » Thu Mar 14, 2013 8:57 pm

So I am buildign a child learning game, count the X animal select the number. But what I am lookign to do is to have say four rows of "count the X animal, select the number" so the issue is, I have 9 objects/sprites, 1 for each number png and I want to have four rows all which corrispond to a different animal, see below.

Example:
How many Sheep are there? 1 2 3 4 5 6 7 8 9
How man Cows are there? 1 2 3 4 5 6 7 8 9
How many Ducks are there? 1 2 3 4 5 6 7 8 9

so if I have one object/sprite for Number 1 how can I tell if they child clicked on #1 in row 1 or 2 or 3? Families sound like a possibility, but not sure.

I do have a function where on click of a number params are passed to determine what number what pressed, but cant do that if I dont have multiple objects/sprites. And I know I can just clone 1-9 but I rather not have 28 images when I only need 9.

Help Please!

Brett
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Thu Mar 14, 2013 9:08 pm

An easy way is to just use a private variable on those numbers designating the row.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Mar 14, 2013 9:15 pm

I assume you mean Instance Variables, but they will apply to All of that Type, so all 3 #1 object would have the same value, how would you tell Row 1, #1 from Row 3, #1?
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Fri Mar 15, 2013 1:42 am

Bummer no one has ideas on this, sucks to have to create 4 times the Objects just to enable different events.

Brett
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Fri Mar 15, 2013 2:20 am

Ok so I found a way to do it, might be messy but it works. Not sure why I cant get my images in posts to show, any help on that would be great.

So here is what I did to use a single set of objects but to know where the user clicked.

Place a set of objects, then copy them, not clone. Create a Sprite, fill it with color. Place that over your objects, create one for each set of objects. I named mine Overlay1 (over the first set of objects), Overlay2 (over the second set, but note the objects are the same exact ones just copies of them not clones).

Next in the Events, OnClick of X object, (sub event) OnMouseOver Overlay1, do X. and OnClick of X object, (sub event) OnMouseOver Overlay2, do Y. Works great I am sure its nuts and someone will tell me a better way but for now WOOT!

Please coach me on posting photos I am sure it will help you understand what I did. Thanks



Brettjbmoyer2013-03-15 02:35:05
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Fri Mar 15, 2013 10:49 pm

I am a moron mipey owe you apology. I was confused about how inst vars work until I found an unrelated tut. I thought the value of a var was shared across all of that type but no and that was a stupid assumption they are called inst vars. So after rework, events went from 40 to less the 10. Sorry thank you
B
21
S
7
G
1
Posts: 128
Reputation: 3,076


Return to How do I....?

Who is online

Users browsing this forum: Eisenhans, michaelverdi and 19 guests