现在的位置: 首页 > 综合 > 正文

cocos2d-x中的多点触摸的问题

2014年06月11日 ⁄ 综合 ⁄ 共 533字 ⁄ 字号 评论关闭

在cocos2d-x中,对于触摸事件有两种模式:

大家都知道,第一种为

CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, 0);//添加触摸委托,

也是cclayer默认的模式,可用于多点触摸;

第二种为

CCDirector::sharedDirector()->getTouchDispatcher()->addTargetDelegate(this, 0);//添加触摸委托,

它将会把多点拆为单点进行传递

现在要说的是第一种,要实现多点触摸,

首先得设置几个关键的地方

1。setTouchEnabled(true);  //允许触摸

2。CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this, 0);//添加触摸委托,

3。也是比较隐蔽的,

在默认的ios目录下的AppController.mm文件里,

设置 [__glView setMultipleTouchEnabled:YES];   //设置多点触摸关键部位;

如果不设置此处,程序将依然知响应单点触摸。

现在就可以显示多点触摸了。

抱歉!评论已关闭.