0

The Cocos2D version is 2.1.

I add a Cocos2D animation to my UIView while searching. After finish searching, I remove the director's view from my UIView:

- (void)didFinishSearchAnimation
{
    CCDirectorIOS *director = self.director;
    [director.view removeFromSuperview];
    self.director = nil;
    _isSearching = NO;    
}

The Cocos2D view did be removed from superview.

But when next time I press the search button and try to show the Cocos2D animation on my UIView, the CCGLView become purple, and the console shows OpenGL error 0x0502 in -[CCSprite draw] 530.

I don't know what happened and how to fix it.


By the way, how to change the background of scene/view of the CCDirectorIOS to transparent for showing the UIView behind them?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Xaree Lee
  • 3,188
  • 3
  • 34
  • 55
  • Cocos2d uses lots of singletons, so just removing the view probably doesn't suffice. You may need to call stopAnimation/startAnimation on the director. If you want to re-use cocos2d throughout your app I suggest to keep it "alive" by simply hiding its view and calling start/stopAnimation as appropriate. – CodeSmile Mar 14 '14 at 08:55
  • Thanks, but the problem still remains. When I leaved the view by the pop view controller and re-enter the view again, and after I did move the director's view to the new UIView, this issue still happened. – Xaree Lee Mar 14 '14 at 09:48

0 Answers0