One Object Type, Multiple Different Events

0 favourites
  • 6 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • 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

  • An easy way is to just use a private variable on those numbers designating the row.

  • 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?

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

    Brett

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

    <img src="https://www.dropbox.com/s/hjitf08re77tzek/forumhelp.png" border="0" />

    Brett

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)