playMaker

Author Topic: 2D Puzzle and NGUI drag  (Read 1625 times)

ramiro

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
2D Puzzle and NGUI drag
« on: December 22, 2013, 09:00:24 PM »
Hi all,

I am learning so hang in there with me  :) I am learning by creating a 2D puzzle game. Fairly straight forward stuff, touch the piece you want to move and drag it to the proper position on the puzzle. Here is what I need help with.

I have setup the GUI using NGUI. I can build the puzzle, drag the pieces with no problems. What I need to figure out is the best way to get the current finger position and then compare whether it is within a reasonable distance from where it should land and then animate it into that position, otherwise have it go back to where the user grabbed it from.

The big gotcha right now is that I am using NGUI to transfer the pieces from a scroll list and re-parenting them to the main playing board. So I would need to make sure those pieces also get re-parented back to the scroll view when the user is not close enough to where the piece should be.

I hope this makes some sort for sense.Thanks for the help in advance.

Ramiro

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • View Profile
    • @stefstivala
Re: 2D Puzzle and NGUI drag
« Reply #1 on: December 24, 2013, 12:02:34 AM »
your setup sounds a little complicated to jump into but i did something similar via a simple tag check system based on colliders. store the location on touch before drag, on mouse off object  init collider & compare tag of colliders, if match is kept - drag was successful, if not return to location.

ramiro

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: 2D Puzzle and NGUI drag
« Reply #2 on: December 28, 2013, 09:37:05 AM »
Thanks MUX, I'll give a go to a similar setup. I have been struggling for the past few days with very lack luster results... aaaarrrrgggg!!! Any FSM samples you have and are willing to sahre, I'll be happy to take a look at  :)

Thanks again!