Hello Guest

Author Topic: [Newbie]Button event, please help.  (Read 5417 times)

longbottomup

  • Newbie
  • *
  • Posts: 13
    • View Profile
[Newbie]Button event, please help.
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #1 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.

longbottomup

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #2 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:



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:


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.
« Last Edit: August 04, 2014, 03:16:06 am by longbottomup »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #3 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/

longbottomup

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #4 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?
« Last Edit: August 04, 2014, 03:32:39 pm by longbottomup »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #5 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

longbottomup

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: [Newbie]Button event, please help.
« Reply #6 on: August 05, 2014, 03:04:14 am »
Thank you very much.