Git Product home page Git Product logo

cocos2dx-gesture-recognizers's Introduction

Cocos2d-x Gesture Recognizers

This project is an extension of Cocos2d-x that provide touch Gesture Recognizers.

The classes recognize the following gestures :octocat:

  • Swipe (one finger, 4 directions)
  • Long press (one or multiple fingers)
  • Pinch with rotation (two fingers)
  • Pan (one or multiple fingers)
  • Tap (one or multiple taps with one or multiple fingers)

My work was inspired by Apple documentation about the Gesture Recognizers:

Apple Gesture Recognizers for iOS

The code was tested on

  • Android 5.1.1 physical device
  • iOS 10.1 physical devices (iPhone and iPad)

Latest version tested with: Cocos2d-x 3.13 ๐Ÿ‘

Here Gestures in action on YouTube

How to build the sample project

iOS

  • Create a new cocos2d-x project:
	cocos new -l cpp TEST
  • Copy the cocos2d folder from TEST to the repository root folder
  • Open the Xcode project inside the proj.ios_mac folder
  • Build

Android

  • Create a new cocos2d-x project:
	cocos new -l cpp TEST
  • Copy the cocos2d folder from TEST to the repository root folder
  • With terminal go inside the repository root folder
  • Run:
	cocos run -s . -p android --android-studio

How to integrate gestures code inside your (or new) project

The repository contains two folders inside Classes folder:

  • Gestures
  • Test

The actual gesture recognition require only the Gestures folder. The Test folder contains various example scenes. To try the code you can do the following steps:

iOS

  • Create a new cocos2d-x project:
	cocos new -l cpp <project name>
  • Delete Classes e Resources folders from the sample project and add those of this repository
  • Update your Xcode project with Classes and Resources folders
  • Enable multi touch in file ios/AppController.mm. The line you must modify should look like this:
	[eaglView setMultipleTouchEnabled:YES]

For further informations see how to enable multi-touch here

Android

  • Create a new cocos2d-x project:
	cocos new -l cpp <project name>
  • Delete Classes and Resources folders from the sample project and add those of this repository
  • Add the source file of this repo in proj.andorid/jni/Android.mk

Contact [email protected]

License MIT

cocos2dx-gesture-recognizers's People

Contributors

alfogrillo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.