Input

Reply
Accepted Solution

Capturing a "flick gesture"

Well i'm new to using a touch-screen, it's actually quite exciting programming for one :Smile:, and i'd really like to in-coroprate  quite a few touch screen controls into my game. 
However i'm not 100% sure on what the best method would be specifically for what i'd like to capture which is a "flick" gesture, in both the horizontal & vertcial planes. So i'm just wondering what the best method would be to capturing this type of gesture.

Any help is greatly appreciated. 

Please use plain text.

Level 3

Level 3
liquidwater91
Posts: 119
Registered: ‎20-04-2012
Message 2 of 10 (670 Views)

Re: Capturing a "flick gesture"

hello, i recently cam across a class called "GestureDetector" in HighLevel.UI, i'm just beginning to check it out, so sorry i can't give u any more info.
Please use plain text.

Re: Capturing a "flick gesture"

Thanks for that! I haven't actually even looked at the High Level Stuff just yet :smileytongue:.
However i did actually write my own little one, which works perfectly fine, but it's great to know that Gesture Detection is available.
Please use plain text.

Re: Capturing a "flick gesture"

Yes, for others not aware, in terms of Touch base inputs you can detect (i've also included the classes):
- Simple touches / tap gesture (one finger, multiple fingers) : Touch / TapGestureDetector
- Flick Gestures (flick vertically, flick horizontally, velocity, position etc.) : FlickGestureDetector
- Double tap detectors : DoubleTapGestureDetector
- Drag gestures : DragGestureDetector
- Long press gestures : LongPressGestureDetector
- Pinch detector : PinchGestureDetector

There is a basic sample for simple touch detection in the samples, located at:
C:\Users\Public\Documents\Pss\sample\Input\TouchSample

If you would like further clarification on the above and how to implement them, please do not hesitate to ask us.

Thanks,
James
PlayStation®Mobile Dev Team
Please use plain text.

Level 3

Level 3
Spykam25
Posts: 156
Registered: ‎24-02-2012
Message 5 of 10 (509 Views)

Re: Capturing a "flick gesture"

How do I use a GestureDetector?

Please use plain text.

Re: Capturing a "flick gesture"

Heres a quick example of creating a flick gesture on an ImageBox (UI Toolkit). Listening for other gestures can be done in the similar way.

 

FlickGestureDetector flick_gd = new FlickGestureDetector();
flick_gd.Direction = FlickDirection.Horizontal;
flick_gd.FlickDetected += delegate(object sender, FlickEventArgs e) {
	Console.WriteLine("Flick detected!");
};

ImageBox imagebox = new ImageBox();
// configure imagebox
imagebox.AddGestureDetector(flick_gd);

 

PlayStation®Mobile Dev Team
Please use plain text.

Re: Capturing a "flick gesture"

Hi James,

 

DoubleTapGestureDetector doesn't appear to work.

 

In the simulator it sorta kinda registers a double tap event, on the actual Vita, it doesn't work at all.

Please use plain text.

Re: Capturing a "flick gesture"

For the record, the end events dont fire on the pinchgesterdetector either.

Please use plain text.

Re: Capturing a "flick gesture"

Thanks for reporting it. We've been able to replicate the DoubleTapGestureDetector problem on the PS Vita, and we'll investigate this problem.

 

The end events on the PinchGestureDetector look to be functioning as normal. Do you have a specific example where they do not fire?

 

Regards,

James

PlayStation®Mobile Dev Team
Please use plain text.

Re: Capturing a "flick gesture"

I haven't actually got my Vita in front of me to test with, but I believe the following code should demonstrate the result:

 

using System;
using System.Collections.Generic;

using Sce.Pss.Core;
using Sce.Pss.Core.Environment;
using Sce.Pss.Core.Graphics;
using Sce.Pss.Core.Input;
using Sce.Pss.HighLevel.UI;

namespace PinchExample
{
	public class AppMain
	{
		private static GraphicsContext _graphics;
		private static ImageBox _imageBox;
		private static PinchGestureDetector _pinchGestureDetector;
		
		public static void Main(string[] args)
			{
			_graphics = new GraphicsContext();
			
			UISystem.Initialize(_graphics);
			
			Sce.Pss.HighLevel.UI.Panel dialog = new Panel();
			dialog.Width = _graphics.GetViewport().Width;
			dialog.Height = _graphics.GetViewport().Height;
			
			_imageBox = new Sce.Pss.HighLevel.UI.ImageBox();
			_imageBox.Image = new ImageAsset("/Application/image.png");
			_imageBox.PivotType = PivotType.MiddleCenter;
			_imageBox.Width = _imageBox.Image.Width;
			_imageBox.Height = _imageBox.Image.Height;
			_imageBox.SetPosition(dialog.Width/2,
			                     dialog.Height/2);
			
			
			_pinchGestureDetector = new PinchGestureDetector();
			
			
			_pinchGestureDetector.PinchDetected += delegate(object sender, PinchEventArgs e) {
				// I work fine
			};
			_pinchGestureDetector.PinchEndDetected += delegate(object sender, PinchEventArgs e) {
				// I dont
				MessageDialog.CreateAndShow(MessageDialogStyle.Ok,"Wont be fired soon",
				                            "Can you hear me now?");
			};
			
			_imageBox.AddGestureDetector(_pinchGestureDetector);
			
			dialog.AddChildLast(_imageBox);
		
			Sce.Pss.HighLevel.UI.Scene scene = new Sce.Pss.HighLevel.UI.Scene();
			scene.RootWidget.AddChildLast(dialog);
			
			UISystem.SetScene(scene,new SlideTransition(2000.0f,FourWayDirection.Left,MoveTarget.NextScene,SlideTransitionInterpolator.Linear));
			
			while(42!=43)
			{
				_graphics.SetClearColor(255,255,255,0);
				_graphics.Clear();
				UISystem.Update(Touch.GetData(0));
				UISystem.Render();
				_graphics.SwapBuffers();
			}
		}
	}
}

 

The PinchEndDetected event will never be fired.

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News