|
cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
|
00001 /* 00002 * cocos2d for iPhone: http://www.cocos2d-iphone.org 00003 * 00004 * Copyright (c) 2008-2010 Ricardo Quesada 00005 * Copyright (c) 2011 Zynga Inc. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a copy 00008 * of this software and associated documentation files (the "Software"), to deal 00009 * in the Software without restriction, including without limitation the rights 00010 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00011 * copies of the Software, and to permit persons to whom the Software is 00012 * furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included in 00015 * all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00018 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00020 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00021 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00022 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00023 * THE SOFTWARE. 00024 * 00025 * Portions of this code are based and inspired on: 00026 * http://www.71squared.co.uk/2009/04/iphone-game-programming-tutorial-4-bitmap-font-class 00027 * by Michael Daley 00028 * 00029 * Use any of these editors to generate BMFonts: 00030 * http://glyphdesigner.71squared.com/ (Commercial, Mac OS X) 00031 * http://www.n4te.com/hiero/hiero.jnlp (Free, Java) 00032 * http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java) 00033 * http://www.angelcode.com/products/bmfont/ (Free, Windows only) 00034 */ 00035 00036 #import "CCSpriteBatchNode.h" 00037 #import "Support/uthash.h" 00038 00039 struct _KerningHashElement; 00040 00044 typedef struct _BMFontDef { 00046 unsigned int charID; 00048 CGRect rect; 00050 int xOffset; 00052 int yOffset; 00054 int xAdvance; 00055 } ccBMFontDef; 00056 00061 typedef struct _BMFontPadding { 00063 int left; 00065 int top; 00067 int right; 00069 int bottom; 00070 } ccBMFontPadding; 00071 00072 enum { 00073 // how many characters are supported 00074 kCCBMFontMaxChars = 2048, //256, 00075 }; 00076 00080 @interface CCBMFontConfiguration : NSObject 00081 { 00082 // XXX: Creating a public interface so that the bitmapFontArray[] is accesible 00083 @public 00084 // The characters building up the font 00085 ccBMFontDef BMFontArray_[kCCBMFontMaxChars]; 00086 00087 // FNTConfig: Common Height 00088 NSUInteger commonHeight_; 00089 00090 // Padding 00091 ccBMFontPadding padding_; 00092 00093 // atlas name 00094 NSString *atlasName_; 00095 00096 // values for kerning 00097 struct _KerningHashElement *kerningDictionary_; 00098 } 00099 00101 +(id) configurationWithFNTFile:(NSString*)FNTfile; 00103 -(id) initWithFNTfile:(NSString*)FNTfile; 00104 @end 00105 00106 00136 @interface CCLabelBMFont : CCSpriteBatchNode <CCLabelProtocol, CCRGBAProtocol> 00137 { 00138 // string to render 00139 NSString *string_; 00140 00141 CCBMFontConfiguration *configuration_; 00142 00143 // texture RGBA 00144 GLubyte opacity_; 00145 ccColor3B color_; 00146 BOOL opacityModifyRGB_; 00147 } 00148 00153 +(void) purgeCachedData; 00154 00156 @property (nonatomic,readwrite) GLubyte opacity; 00158 @property (nonatomic,readwrite) ccColor3B color; 00159 00160 00162 +(id) labelWithString:(NSString*)string fntFile:(NSString*)fntFile; 00163 00167 +(id) bitmapFontAtlasWithString:(NSString*)string fntFile:(NSString*)fntFile DEPRECATED_ATTRIBUTE; 00168 00170 -(id) initWithString:(NSString*)string fntFile:(NSString*)fntFile; 00171 00173 -(void) createFontChars; 00174 @end 00175 00178 CCBMFontConfiguration * FNTConfigLoadFile( NSString *file ); 00181 void FNTConfigRemoveCache( void ); 00182 00183 00184 00188 DEPRECATED_ATTRIBUTE @interface CCBitmapFontAtlas : CCLabelBMFont 00189 @end 00190