playMaker

Author Topic: iOS touch control set-up  (Read 4672 times)

iloveaphextwin

  • Playmaker Newbie
  • *
  • Posts: 8
iOS touch control set-up
« on: May 01, 2013, 05:24:55 AM »
Hi there,

I am trying to set up touch controls in Playmaker. I have a nearly perfect set-up that is basically the same as the one in the iOS fundamentals tutorial.

However I think in order to move on I need to split my FSMs up into detect touch and implement touch.

I am not sure the best way to do this. I have a master touch tree at the moment that attempts to detect one touch or two touches. It then I hope will send events to a one touch FSM and a two touch FSM. These may then even send events on to move, stationary FSMs.

I'm not sure if that's the best way, seems like a lot of FSMs. If someone could give me a very basic tree diagram of how you would set this up I'd really appreciate it. I know in the iOS tutorial he mentions that you would probably want to split up your touch detects and events, that is basically what I need to know how to do.

Thanks

Will

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: iOS touch control set-up
« Reply #1 on: May 02, 2013, 03:01:31 PM »
Hi,

 this is a recurrent problem because you need to implement a latency, there is no way to implement a one or two touch system without having the event sent if there is only one touch AFTER the second touch time out...

having said that, you only need two fsm to implement this check and dispatch your ONE TOUCH or TWO TOUCH event

one way would be to do this:

watch for touch events, and maintain a counter ( increment on each touch), and when you receive a touch, you measure the time elapsed vs the number of touch, it's it's above 1 and less than a threshold, fire the TWO TOUCH, else when the timer ends fire the ONE TOUCH event.

you can do it with one fsm as well, but it's a little more complex :) or better said, it's a lot easier it you use this custom action:

http://hutonggames.com/playmakerforum/index.php?topic=1249.msg5245#msg5245

where you simply send a delayed event, that will not fire if the state exit, so you can have a timer AND a touch watcher in one fsm.

the other way is to use input.touches, I have ported it with custom action, getting this kind of information is a breeze and actually built in and you benefit from a full features library of touch events.

https://hutonggames.fogbugz.com/default.asp?W961

bye,

 Jean

iloveaphextwin

  • Playmaker Newbie
  • *
  • Posts: 8
Re: iOS touch control set-up
« Reply #2 on: May 03, 2013, 04:09:19 AM »
Hi there,

What was confusing me is that I have an FSM that just constantly detects one or two touches. I have a get touch count on all three states. If it is 1 it goes to one touch, 0 goes to 0 touch etc. These one and two touch states would then send a global event to another FSM a separate one and two touch FSM. This seems to work but it's getting massively confusing.

I also have big problem as my FSM seems to constantly switch between stationary and moving. I'm not sure if this is just the remote. I think what I really need is a slight delay before stationary is set.

I actually bought input.touches but haven't been able to use the custom actions with it. I basically get no information back in the inspector. I have enabled the parts I want in the script control.

I'm going to have to re-read your post above and see if I can move further.

Thanks for your help