playMaker

Author Topic: Best practice cutting phone controls in two areas  (Read 362 times)

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 55
    • View Profile
Best practice cutting phone controls in two areas
« on: April 16, 2017, 10:12:31 PM »
I want to run a project in landscape mode where the left and right side phone are separately controlled with no visible controls on the screen.  So if you press on left side its left button if you swipe on left side its a swipe on left side of the phone if you press down any were on the right side it is a right button press what's best practice for this in play maker? Picture is an example.


escpodgames

  • Hero Member
  • *****
  • Posts: 669
    • View Profile
    • Assets
Re: Best practice cutting phone controls in two areas
« Reply #1 on: April 16, 2017, 11:24:05 PM »
What you can do is use the touch info action to get the normalized touch position in X and then check if it is above or below 0.5. You can also check how long the touch took and set it as a tap if it was short, a press if it was longer than say 0.5 seconds (use store delta time). You can also use the delta position and check if the touch position has moved a set distance within a set time to check if it is a swipe and what direction it is in.

Hope that helps
« Last Edit: April 16, 2017, 11:39:00 PM by escpodgames »

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 55
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #2 on: April 17, 2017, 10:02:50 AM »
I get the concept you're saying it would be great to see simple state machine for left that detects swipe up and button push for example if you happen to have the time.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #3 on: April 17, 2017, 11:02:53 PM »
Hi,

 I would actually try the UI way with two invisible buttons each taking one half of the screen, and the buttons would then be able to react to touches and drags ( for swiping)

 Have you tried this way?

 Bye,

 Jean

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 55
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #4 on: April 18, 2017, 10:19:06 PM »
Jean could you go a little more in-depth with this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #5 on: April 18, 2017, 11:14:58 PM »
Hi,

 basically, you create a UI canvas specifically for your controls, all elements will be invisible but will react to touch events.

-- make one button that fill the left half of the screen, and another that fill the right half of the screen. RectTransform allows you to create buttons that will automatically adjust layout to fit any screen sizes

-- now, you simply use the UI Proxies to catch UI events like click, drags etc etc.

-- You do know about the Unity UI proxy on the Ecosystem right?

 Bye,

 Jean

Captaincrud

  • Junior Playmaker
  • **
  • Posts: 55
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #6 on: April 19, 2017, 12:34:16 PM »
yeah just didn't know it sees drag events

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12098
  • Official Playmaker Support
    • View Profile
Re: Best practice cutting phone controls in two areas
« Reply #7 on: April 19, 2017, 11:04:07 PM »
Hi,

 yep, drag event are supported too, check out the drag sample on the Ecosystem for a regular application, but you are perfectly ok to use drag and not drag anything at all and just watch for a possible swipe or something.

Bye,

 Jean