如何添加CCSprite在UIView [英] How to add CCSprite over UIView

查看:145
本文介绍了如何添加CCSprite在UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的cocos2d应用程序,我有一个 UIView 我显示在我的屏幕上添加一个子视图到 [[CCDirector sharedDirector] openGLView] ,但我想知道是否有一些在这个视图上显示 CCSprite ,因为我必须做很多的交互和动画与那些CCObjects 。

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...

推荐答案

当然你不能在UIView上添加CCSprite。 CCSprite来自Cocos2d库类,UIView是UIKit类。如果你想在游戏视图中添加UIView,那么你需要访问rootviewcontroller视图,它是UIWindow的根。这样的东西,

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];

始终记住Cocos2d库控件是GLView的一部分。

Always keep remember Cocos2d library control are part of GLView.

这篇关于如何添加CCSprite在UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆