How to add CCSprite over UIView

旧巷老猫 提交于 2019-12-14 03:52:22

问题


In my cocos2d application, I have a UIView that I am displaying on my screen by adding a subview to [[CCDirector sharedDirector] openGLView], but I am wondering if there is someway to display a CCSprite above this view, since I have to do lots of interactions and animations with those CCObjects.

Please help. Thanks in advance...


回答1:


Of course you can't add CCSprite on UIView. CCSprite is from Cocos2d library class and UIView is UIKit class. If you want add UIView over game view then you need to access rootviewcontroller view which is root of UIWindow. Its something like this,

[appDelegate.yourRootViewController.view addSubview:yourview];

Always keep remember Cocos2d library control are part of GLView.




回答2:


This isn't possible. The cocos2d view is a view and everything it contains can only be "in" this cocos2d view. Any other view is either on top of or behind the cocos2d view. Thus you can't do things like putting a view between two cocos2d nodes.



来源:https://stackoverflow.com/questions/19677986/how-to-add-ccsprite-over-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!