2017-10-10 105 views
0

我試圖用MPMoviePlayerController播放視頻,並希望在cocos2d資產後面顯示它。我能夠播放視頻,但它出現在cocos2d資產之上。 Cocos2D-ObjC版本是3.5.0。如何在CCGLView後面添加UIView(Cocos2d-objc)

這裏是我的代碼片段:

MPMoviePlayerController *moviePlayer = self.moviePlayerController.moviePlayer; 

CCDirectorIOS *director = (CCDirectorIOS*)[CCDirector sharedDirector]; 
CC_VIEW *directorView = [director view]; 
[directorView addSubview:moviePlayer.view]; 
[directorView sendSubviewToBack:[moviePlayer view]]; 
directorView.opaque = NO; 

任何幫助,高度讚賞。

enter image description here

回答

0

只爲信息:有沒有辦法將它添加beetween,因爲cocos2d的視圖控制器(與您的所有圖像)是在directorView加了一層。 所以cocos2d director是一個視圖控制器,繪製成一個視圖,一個CCGLView。您無法將視圖添加到圖層,因爲圖層不是視圖。圖層只是cocos2d使用的對象。

與其他視圖一樣,您可以在cocos2d CCGLView(作爲GLView的父級或更早級別的兄弟)或在cocos2d CCGLView(作爲GLView的子級或更高級別的兄弟)之上添加視圖,但不能在任何位置-之間。因此,您的UIView只能在邏輯上高於或低於所有Cocos2d繪圖。

而對於發回只需使用:

[viewController.view addSubview:moviePlayer.view]; 
[viewController.view sendSubviewToBack:moviePlayer.view];