LoginSignup
6
3

More than 5 years have passed since last update.

Cocos2d-x の GLView を取得して addSubview とか

Posted at

Cocos2d-x の iOS 版で ルートの GLView を取得して iOS ネイティブのビューを貼り付けたりする方法

Director から以下のようにして取得できます:

UIView* rootView = (UIView*)Director::getInstance()->getOpenGLView()->getEAGLView();

これが取れさえすれば、あとは Objective-C のコードで好き勝手できます。たとえば Facebook SDK のログインビューを貼り付けたり。

(Objective-C++ を使うためソースファイルの拡張子を .mm にする必要があります。)

UIView* rootView = (UIView*)Director::getInstance()->getOpenGLView()->getEAGLView();
FBLoginView* loginView = [[FBLoginView alloc] init];
loginView.center = CGPointMake(284, 50);
[rootView addSubview:loginView];

Screen Shot 2014-11-04 at 2.15.49.png

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3