我目前需要在 cocos2d 中不使用 UIKit 的滚动视图来创建自定义滚动视图。我认为最好的方法是创建一个单独的层,然后将我所有的精灵添加到该层。但我不确定如何接收所有精灵的触摸事件。有没有最好的方法来做到这一点?谢谢!
3 回答
你见过CCScrollLayer吗?它可能不适合您,但也许您可以复制它的接触方式。
- https://github.com/cocos2d/cocos2d-iphone-extensions/tree/develop/Extensions/CCScrollLayer
- http://www.cocos2d-iphone.org/forum/topic/17118
这里还有一个,不确定是分叉还是独立的:
但我在这些方面都没有取得太大的成功。弹跳和体验的其他部分永远不会感觉正确,所以我回到使用 UIScrollView 来处理触摸。
我一直面临同样的问题,我在这里找到了 SWScrollView:
https://github.com/saim80/Cocos2D-Extensions
比 CCScrollView 更能满足我的需求。它的作用更像 UIScrollView,因为 CCScrollView 更适合我所看到的分页。
有一个很好的框架叫做 CMMSimpleFramework。
http://www.cocos2d-iphone.org/forum/topic/39018
http://www.cocos2d-iphone.org/forum/topic/60354
有一些示例视频,回购链接在这些页面上。
One of the classes is a scrolling layer that might do what you need. To get the sample project to run, I had to comment out some game center authentication handler code that has changed, but after I did that the demo worked fine.