playMaker

Author Topic: Drag Down Plunger UI + ngui  (Read 3702 times)

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Drag Down Plunger UI + ngui
« on: June 08, 2012, 09:17:35 PM »
hey there, first post!
i've been using playmaker for a last few months , but today i hit a brickwall in my gamedev and could use some help & tips. the game im building is based on tabletop physics similar to a pinball machine & is targeting touch devices. currently having trouble building the shooting game marble ui that works similar to this graphic
.

I already have the object split into game object ui png layers via NGUI and have put my fsm on the drag button graphic. i have added some fsm's that have detected touch & and that touch drag is started. so how to approach the follow things?

  • touch drag in one axis
  • limit max drag amount to fit slot
  • pitch sound effect according to tension
  • spring back into place after release
  • calculate drag display power in percentage

it might be useful to add that im using NGUI & the WIP script from Alex Chouls http://hutonggames.com/playmakerforum/index.php?topic=1356.15 , with that script attached to drag object and successfully receiving touches, but not sure if i should just send the start touch event to get FSM started then handle all other activity from within playmaker

hope someone can help, thanks in advance.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drag Down Plunger UI + ngui
« Reply #1 on: June 09, 2012, 02:00:12 AM »
Hi,

to touch drag on one axis: simply take in account the vertical axis and that's all, as you are processing touch position only get the y component and you are done

To limit max drag,  if the vertical position if below a certain value, do not process the movement, but still watch for the the touch and as soon as it's above the value again, move again.

to pitch and calculate percent would be using the same base. You need to know the start and end valus on screen. and to compute the percent ( ranging from 0 to 100)  you would do the following:
total travel = max - min
current travel = touch position - min
percent = current travel *100 / total travel

once you have the percent you adjust the pitch using that percent value. note that you will have to choose a range for your pitch min and max and apply the drag percent to that range and set the pitch with that result.


Hope it all make sense :) You'll be fine, because you have already cut down the problem in digestable chunck. so really take them step one at a time. and don't hesitate to ask for more if you get stuck.


 bye,

 Jean

MUX

  • Playmaker Newbie
  • *
  • Posts: 43
    • @stefstivala
Re: Drag Down Plunger UI + ngui
« Reply #2 on: June 09, 2012, 02:20:18 AM »
thanks jean. read so many of your posts, you seem to help this forum alot. 
i'll take your advice and see how i go.
that's a helpful start in the right direction. i've got a deep knowledge already of how this works from my flash background, just trying to make playmaker & ngui do it.  ;)  i'll be a back if stuck