2D Toolkit Forum

2D Toolkit => Support => Topic started by: longbottomup on August 03, 2014, 02:08:53 pm

Title: [Newbie]Button event, please help.
Post by: longbottomup on August 03, 2014, 02:08:53 pm
Sorry, i'm a newbie, i don't know how to handle button event. Now, i want to run a Car on keep buttonDown and stop on realease that button(buttonUp). I search on google but have no guild, just Pressbutton. Please tell me.
Title: Re: [Newbie]Button event, please help.
Post by: unikronsoftware on August 03, 2014, 05:57:26 pm
Create a function in your code to run your car or whatever. Drag that gameobject into the target slot of the button, then pick the function name in On Click event handler. That button will now trigger your function.
Title: Re: [Newbie]Button event, please help.
Post by: longbottomup on August 04, 2014, 03:13:08 am
Hi admin,
I have read too many topic of you, and i can see you're thoughtful, i like you. The 2Dtoolkit so great, it help everybody saving time, i'm a one of them. Thank you very much.
I'm use GUI before use 2Dtoolkit, now i'm your package, hope you help me at the begin. Now, thank you your answer, but i know it. Here my question:

(http://www.igreklik.com/slike/images/98861726859539311574.png)

Button Down Spirte: gasd
Button Up Spirte: no use
Button Press Spirte:: no use
Target Object: my car, the Big Foot
Message Name: phanh - the function to run the car

I have read the sources code and found this:
(http://www.igreklik.com/slike/images/08000993479817188419.png)

Yeah, i think it work here. I have few a question:
1/ I want to send message(the run car function) when keep touch Down button and send message(stop the car function) when release it(Up button) or wherever i want, where the code put? Please answer me with image or sample code.
2/ I have read the topic: Button Sounds Manager of you, but i don't undersand. Finally, i turn on/off sounds of all button by: add audio source for the button one by one, and mute it. Ex: if i have 20 button, i will add 20 times Audio source. STUPID, but i have no ideal. Can you tell me the best Sound Button Manager.

Thank you so much.
Title: Re: [Newbie]Button event, please help.
Post by: unikronsoftware on August 04, 2014, 11:47:35 am
You're using the old tk2d button stuff which isn't supported any more - I recommend using the tk2dUI stuff. Check out the samples in TK2dUI_demo folder to get a feel for that. There is a tutorial on getting started here, http://2dtoolkit.com/docs/latest/
Title: Re: [Newbie]Button event, please help.
Post by: longbottomup on August 04, 2014, 03:28:31 pm
Oh, thank you, i got it. But i can't see where put the sprite for up&down button?
Title: Re: [Newbie]Button event, please help.
Post by: unikronsoftware on August 04, 2014, 04:08:56 pm
On the actual sprites. the object has children containing sprites. Everything is set up in the hierarchy
Title: Re: [Newbie]Button event, please help.
Post by: longbottomup on August 05, 2014, 03:04:14 am
Thank you very much.