the menus and buttons on the SwallowLayer can not touch.


#1

engine version: JSB, 3.0alpha1 ,XCODE,模拟器环境
issue: 还是说中文吧… 我的问题是在JSB版本中,如果我要做一个模态类型的层,那我会在当前层注册 cc.registerTargetedDelegate(-2, true, this);,然后在onTouchBegan里returne true。 如果层与层之间的模态,这个毫无问题。但是一旦我在最上层的层上加上了ccmenu,那问题就出来了。
1.如果我Swallow最上层的touch,那ccmenu不会响应事件,就算我把它的priority设置最高也是一样。
2.如果我不Swallow最上层的touch,Swallow下层的touch,ccmenu依然不会响应事件。
3.如果我上下层都不Swallow它们touch,那menu的确响应了,但模态就没有意义了。
4.我不Swallow上层 touch,但下层Swallow了,并且在上层设置了点击区域。表面上是OK了,但其实它是会穿透上下层的。如果有ccmenu是恰好是同一位置,那我觉的这个依然是个问题。。

我总结下我的问题:当前层只要Swallow touch事件,在该层上的ccmenu和button就都不会响应,把他们的priority设置最高也是一样的。

我尝试了很多办法,比如再增加层,或者设置热区,问题依然存在。我不知道是我的方法错了还是原来理解的就不对,望大神指点。。谢谢:(


#2

Hi, @jo_2011

Since Cocos2d-x 3.0, we have refactored the event dispatching system. cc.registerTargetedDelegate and all layer’s event functions have been deprecated. So you should migrate your implementation with the new event dispatching system.

If you want to upgrade your usb project with the newest Cocos2d engine, you should download Cocos2d-JS which include Cocos2d-x 3.0 rc0 and Cocos2d-html5 3.0 alpha: Download link

In the download package, you can find the test cases shared by html5 and jsb. The test case jsb project can be found in the folder build, and you will find tests which shows you how to use the new event system at Event Manager Test. And the sub test PauseResumeTargetTest shows exactly what you want to do.

Tell us if the new event system solve your problem.
Oh, note that the Cocos2d-JS 3.0 API have been refactored to improve javascript development experience, for more details please refer to this topic, and the upgrade guide is here: http://www.cocos2d-x.org/docs/manual/framework/html5/release-notes/v3.0a/upgrade-guide/zh


#3

OK. I’ll try …


#4

我怀疑,为何别人的产品还能上线?!?!
2.2.3 jsb xcode还是有问题。


#5

同问!!!
我几乎试过所有的版本,问题多多,项目一直搁着,无法上线
jsb感觉是沼泽地的鲜花
以后项目开发选型很重要,不然就死悄悄了


#6

We recommend Cocos2d-JS 3.0 to do JSB project.
For now we didn’t have extra time and man to fix 2.x JSB problems. We have been focus on fix all these issues for Cocos2d-JS 3.0
With all new features in Cocos2d-x 3.0, fixed API incompatible issues between html5 and JSB, adopted JS style API in html5 engine, hope you can enjoy much more JSB in Cocos2d-JS !