Game Development Reference
In-Depth Information
Tip The background image of a UIView will always be scaled and stretched
to fit the UIView 's frame. This will often blur or otherwise distort the texture.
To avoid that, you should design background images of UIView s to the exact
dimensions of the UIView . Alternatively, design the texture for the largest pos-
sible size of the UIView so that even if it's scaled, it's scaled down and doesn't
lose as much image quality compared to upscaling the texture.
Adding Views Behind the cocos2d View
What if you want to add a UIView behind the cocos2d view? For example, to play a
video in the background? You need to change a few things to allow UIKit views in the
background. You'll find these code changes in the CocosWithCocoa02 project.
Moving the UITextFields to the Background
Adding the UITextField views to the app's window is straightforward. For this ex-
ample, you get to skip over the UITextField initialization code in the ad-
dSomeTextFields method because it doesn't change. The only change is in adding
the UITextField views as subviews of the cocos2d view's superview, which hap-
pens to be the app's UIWindow object:
-(void) addSomeTextFields
{
// get the cocos2d view (it's the CCGLView class which inherits from UIView)
UIView* glView = [CCDirector sharedDirector].view;
// The window is the superview of the cocos2d view
UIView* window = glView.superview;
// UITextField initialization code omitted
...
// add the text fields to the window
[window addSubview:textField];
Search Nedrilad ::




Custom Search