Multiple of one object with different events

Get help using Construct 2

Post » Tue Apr 29, 2014 9:13 am

I started adding a shop to my game, and i want to have 4 buy buttons, 4 price tags but i don't wanna add 4 different buttons/price tags for every item in my shop. Is it possible to ctrl, drag a item with other events/sprites?

Sorry for my English.
Image
B
13
S
2
G
1
Posts: 60
Reputation: 1,553

Post » Tue Apr 29, 2014 9:29 am

yeah, just use instance variables and put/modify their values for each instance so each button will do something different from other buttons

or 4 different button objects but all are part of a family and you use family instance variables instead.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Apr 29, 2014 9:29 am

Ninja'd....
Yes, you could use instance variables. Just make one button sprite, and add an instance variable (text) to them. You could call it "whantnot". Then create 4 copies of the same sprite on your layout, change each buttons whatnot property as you deem fit. For example you give two of them health and mana values.. then later in events:

mouse on clicked button
button.whatnot="health"
give health potion
else if
button.whatnot="mana"
give mana potion

Hope this helps.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Tue Apr 29, 2014 9:54 am

@sgn15 , @windwalker thank u guys so much! It's way easier then i thought.
Image
B
13
S
2
G
1
Posts: 60
Reputation: 1,553


Return to How do I....?

Who is online

Users browsing this forum: JackTYGA, Yahoo [Bot] and 21 guests