I get a SIGARBT saying “reference count should be greater than 0” when SwipeGesture is being removed.
I haven’t checked the guts of CCSwipeGestureRecognizer, but probably you are trying to remove the children of that layer between ccTouchBegan and ccTouchEnded invocations. I can’t recall the details, but as far as I remember in that case touch delegate is being deleted twice: the first time you delete it by yourself calling removeAllChildren (recall CCSwipeGestureRecognizer is a child of the layer), the second time it is deleted by Cocos2d itself. The solution is to make all removes after ccTouchEnded is called, probably during the next frame.
It seems the current version of CCGestureRecognizer can’t work with gestures attached to not fullscreen nodes, such as random sprites floating somewhere beyond the screen frame. Am I wrong?
Anyway, I’ve added a minor change to fix that (that is convertToNodeSpaceAR):
Is there a way to reference the target node? Something like
>
CCPan* panEvent = (CCPan**)gestureEvent;
CCNode** target = panEvent~~>target;
>
target~~>setPosition(panEvent->location);
Very good question. Unforunately there is no way to do that for now, but you can create a property inside CCPan class and set it’s value the parent node. In the next version I’m gonna include that and other features too. Thanks.
if i copy paste the same snippet into my HelloWorld(Game Layer is my case)’s init() method… CCSwipeGestureRecognizer * swipe = CCSwipeGestureRecognizer::create(); swipe->setTarget(this, callfuncO_selector(GameLayer::didSwipe)); swipe->setDirection(kSwipeGestureRecognizerDirectionRight | kSwipeGestureRecognizerDirectionLeft); swipe->setCancelsTouchesInView(true); this->addChild(swipe);
@
void GameLayer::didSwipe(CCObject * obj)
{
}
@
Given that I only need Swipe Gesture so i added CCGestureRecognizer.h/.cpp AND CCSwipeGestureRecognizer.h/.cpp
I get the following errors while compiling Undefined symbols for architecture i386: "CCGestureRecognizer::setTarget(cocos2d::CCObject*, void (cocos2d::CCObject::*)(cocos2d::CCObject*))", referenced from: GameLayer::init() in GameLayer.o "CCGestureRecognizer::CCGestureRecognizer()", referenced from: CCSwipeGestureRecognizer::create() in GameLayer.o "CCGestureRecognizer::~CCGestureRecognizer()", referenced from: CCSwipeGestureRecognizer::create() in GameLayer.o "vtable for CCSwipeGestureRecognizer", referenced from: CCSwipeGestureRecognizer::create() in GameLayer.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
My HelloWorld(GameLayer) class is inherited from CCLayer
Im working on Cocos2d-x 2.2.0
As I am new in cocos2d-x for android game in window enviroment and i am making a jumping game. I want to jump my player on single tab small jump, on double tap medium jump and triple tap high jump. OR It may be done on Long press duration.
As I divided my touche two parts. Left half for jump and right half for other function. Currently I am only using normal touches event but i want to implement your Extension.
But I am unable to use. I have no Idea How to implement.
Please you can a running example of you extenxion
Hi…sir…
I am trying to integrate your extension into my project.
But I can know how to use it, since I an newbie on cocos2dx.
Can you show some example used your extension?
The targeted method must have 1 parameter of CCObject* type and return void:
void didRecognizeGesture(CCObject * obj);
The received parameter type it’s different in every case. For
example, for the swipe gesture it’s a CCSwipe object, for tap gesture
it’s a CCTap, and so on. So don’t forget to cast correctly before
starting to use it:
CCSwipe * swipe = (CCSwipe*)obj;