21

When I use the

self.isTouchEnabled = YES

in Cocos2d v2.0 for the layer could be touched,the Xcode give me a tip:

setIsTouchEnabled: is deprecated

Now, I just want to know alternative method for isTouchEnabled.

James Webster
  • 31,873
  • 11
  • 70
  • 114
Vienta
  • 213
  • 3
  • 6

2 Answers2

41

Here is new code:

    self.touchEnabled = YES; //In Cocos2d 2.0

    self.userInteractionEnabled = YES; //In Cocos2d 3.0

Just wondering why genius people(Cocos2d team) doing this kind of silly change!

But this one is the right call to setup touch in Cocos2d 2.x and above !!!

Kerem Baydoğan
  • 10,475
  • 1
  • 43
  • 50
Guru
  • 21,652
  • 10
  • 63
  • 102
  • 3
    this is one of the reasons I am migrating all my projects from Cocos2D to SpriteKit. Every new version of Cocos2D is a nightmare of problems. – Duck Oct 13 '13 at 19:37
  • 1
    The idea behind this change is to make the naming consistent with UIKit. I believe this is a good idea in the long run even though it requires some migration from 2.x to 3.x. – Ben-G Mar 30 '14 at 17:34
7

It seems the setIsTouchEnabled is located in "CCDeprecated.h" now.

The following method is in the current "CCLayer.h":

[self setTouchEnabled:YES]
the Tin Man
  • 158,662
  • 42
  • 215
  • 303