Hello Guest

Author Topic: Hover button Candy Crush style  (Read 4004 times)

McTomas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Hover button Candy Crush style
« on: May 26, 2014, 12:34:45 pm »
Hi,

In my current project I got the task to create hover state button like candy crush buttons where:
- user press down the button -> moves out the button (and the button goes up) -> moves back in to the button (button goes down) -> user releases the button (button is activated)
You can check this movement here -> https://www.youtube.com/watch?v=f-YXqNoC54g Because it’s a video about a buggy function the reaction is the the contrary as intended but you can get a clue of what is the objective.

Well I try to do this with tk2dUIHoveItem or hover states, but I had no success because hover states only works with the mouse and my game is for the mobile devices.
To solve this I added this lines of code in line 308 of tk2dUIItem.cs on the function public void CurrentOverUIItem(tk2dUIItem overUIItem)
Code: [Select]
else if(!isPressed)
{
Press(overUIItem.Touch);
if (parentUIItem != null)
{
parentUIItem.CurrentOverUIItem(overUIItem);
}
}

I would kindly ask if this effect could be added to 2D toolkit (if a flag like the hover is) so we could have cool effect like candy crush does. If not on every update I’ll add that code :)

Cheers

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Hover button Candy Crush style
« Reply #1 on: May 26, 2014, 03:05:17 pm »
I wouldn't do it this way. If you want to do it properly, the best place to do it is in tk2dUIManager.CheckInputs / CheckMultiTouchInputs. You can modify global behaviour that way without hacking it into each control type. It probably shouldn't be the similar to the hover behaviour.

McTomas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Hover button Candy Crush style
« Reply #2 on: May 26, 2014, 04:19:52 pm »
Yeah I tried to do it on the UIManager, but with no success. I use on all my UI Items the tk2dUIItem so it works perfectly in my game.