Game Development Reference
In-Depth Information
[window addSubview:textFieldSkinned];
}
You can simply access the window because it happens to be the superview of the
cocos2d glView . The superview is the Cocoa term for what you would call the parent
node in the cocos2d node hierarchy. You can then add the text fields to the window in-
stead of the glView .
However, you won't notice a difference if you run the project now. Because you've ad-
ded the text fields after the cocos2d view, they're automatically rendered after the
cocos2d view by default. This is the same behavior as in the cocos2d node hierarchy.
To actually move the text fields to the back, you can either send the sendSub-
viewToBack message to all of them or, more easily, send the bringSub-
viewToFront message to the glView , like so:
// add the text fields to the window
[window addSubview:textField];
[window addSubview:textFieldSkinned];
// send the cocos2d view to the front so it is in front of the other views
[window bringSubviewToFront:glView];
Note that the sendSubviewToBack and bringSubviewToFront messages are
sent to the view that contains the view that should be sent to the back or front. In this
case, that's the window . If you run the project now, you'll see a difference. But you
won't be seeing the text fields anymore. What's the problem now?
Making the cocos2d View Transparent
By default, the cocos2d view is completely opaque. Anything behind the glView will
be obstructed because the cocos2d CCGLView is filled each frame with an opaque
clear color. It also has its opaque property set to YES . You can easily remedy this by
adding the following lines to the addSomeTextFields method:
// make the cocos2d view transparent
glClearColor(0, 0, 0, 0);
glView.opaque = NO;
Search Nedrilad ::




Custom Search