This project is read-only.

Can't read gesture because CCInputState.Instance

Topics: Controllers and Device Hardware
Jun 21, 2014 at 9:38 AM
I had made game with MonoGame and like its way to read gesture on mobile device using TouchPanel, Which I found doesn't work in Cocos2D-XNA. So I look up in the source code.
In Class Application, Method Update, it shows two ways to handle input State
            if (UseInputStateManagement)
                   //Use CCInputState to manage
                   //Process touch with events
and it does process gesture by Method ProcessGestures().
But it cannot read any gesture because the static method of CCInputState.Instance
public static readonly CCInputState Instance = new CCInputState();

        private CCInputState()
            TouchPanel.EnabledGestures = GestureType.None;
Whether we use CCInputState or not, it will be instantiated and disable gestures.
I'm not sure it is a bug or not.
Jun 22, 2014 at 6:34 AM
You can enable gesture handling via CCApplication. There is a property to set that determines the types of gestures that are desired. You would enable these gestures in the constructor of your app delegate class, which is a specializer of CCApplication.
Jun 22, 2014 at 6:45 AM
I don't think it is necessary to disable the gestures in the CCinput ctor any longer. That must have been from when we did not support gesture reads in CCInputState.
Jun 23, 2014 at 11:04 AM
Edited Jun 23, 2014 at 11:04 AM
sorry for my poor english, you may not get my point.

I enable all gestures in the constructor of AppDelegate which extends from CCApplication, but
this.OnGesture += AppDelegate_OnGesture;
still can't be activated by any gesture. Because CCInputState will be instantiated after AppDelegate not matter whether we use CCInputState or not.
Jun 30, 2014 at 4:32 PM
In the source tree, this has been removed:
    private CCInputState()
        TouchPanel.EnabledGestures = GestureType.None;
The CCInputState static constructor will no longer disable gestures.