This commit is contained in:
natural-law 2011-07-08 14:32:09 +08:00
parent db6a5fce23
commit 134a3a0fcf
6 changed files with 35 additions and 24 deletions

View File

@ -37,7 +37,7 @@ namespace cocos2d{
- CCLabelAtlas "characters" have a fixed height and width
- CCLabelAtlas "characters" can be anything you want since they are taken from an image file
A more flexible class is CCBitmapFontAtlas. It supports variable width characters and it also has a nice editor.
A more flexible class is CCLabelBMFont. It supports variable width characters and it also has a nice editor.
*/
class CC_DLL CCLabelAtlas : public CCAtlasNode, public CCLabelProtocol
{

View File

@ -22,6 +22,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Use any of these editors to generate BMFonts:
http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
#ifndef __CCBITMAP_FONT_ATLAS_H__
#define __CCBITMAP_FONT_ATLAS_H__
@ -127,10 +134,11 @@ namespace cocos2d{
CCLabelBMFont has the flexibility of CCLabel, the speed of CCLabelAtlas and all the features of CCSprite.
If in doubt, use CCLabelBMFont instead of CCLabelAtlas / CCLabel.
Supported editors:
- http://www.n4te.com/hiero/hiero.jnlp
- http://slick.cokeandcode.com/demos/hiero.jnlp
- http://www.angelcode.com/products/bmfont/
Supported editors:
http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
@since v0.8
*/

View File

@ -33,7 +33,7 @@ namespace cocos2d{
*
* All features from CCTextureNode are valid in CCLabelTTF
*
* CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCBitmapFontAtlas instead.
* CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCLabelBMFont instead.
*/
class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol
{

View File

@ -22,6 +22,13 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Use any of these editors to generate BMFonts:
http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
****************************************************************************/
#include "CCLabelBMFont.h"
@ -206,7 +213,7 @@ namespace cocos2d{
int index = line.find('=')+1;
int index2 = line.find(' ', index);
std::string value = line.substr(index, index2-index);
CCAssert(atoi(value.c_str()) == 0, "BitmapFontAtlas file could not be found");
CCAssert(atoi(value.c_str()) == 0, "LabelBMFont file could not be found");
// file
index = line.find('"')+1;
index2 = line.find('"', index);
@ -366,13 +373,13 @@ namespace cocos2d{
//CCLabelBMFont
//
//BitmapFontAtlas - Purge Cache
//LabelBMFont - Purge Cache
void CCLabelBMFont::purgeCachedData()
{
FNTConfigRemoveCache();
}
//BitmapFontAtlas - Creation & Init
//LabelBMFont - Creation & Init
CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile)
{
CCLabelBMFont *pRet = new CCLabelBMFont();
@ -396,7 +403,7 @@ namespace cocos2d{
CC_SAFE_RELEASE(m_pConfiguration);// allow re-init
m_pConfiguration = FNTConfigLoadFile(fntFile);
m_pConfiguration->retain();
CCAssert( m_pConfiguration, "Error creating config for BitmapFontAtlas");
CCAssert( m_pConfiguration, "Error creating config for LabelBMFont");
if (CCSpriteBatchNode::initWithFile(m_pConfiguration->m_sAtlasName.c_str(), strlen(theString)))
{
@ -416,7 +423,7 @@ namespace cocos2d{
CC_SAFE_RELEASE(m_pConfiguration);
}
// BitmapFontAtlas - Atlas generation
// LabelBMFont - Atlas generation
int CCLabelBMFont::kerningAmountForFirst(unsigned short first, unsigned short second)
{
int ret = 0;
@ -466,7 +473,7 @@ namespace cocos2d{
for(int i=0; i<len; i++)
{
unsigned short c = m_sString[i];
CCAssert( c < kCCBMFontMaxChars, "BitmapFontAtlas: character outside bounds");
CCAssert( c < kCCBMFontMaxChars, "LabelBMFont: character outside bounds");
if (c == '\n')
{
@ -535,7 +542,7 @@ namespace cocos2d{
this->setContentSizeInPixels(tmpSize);
}
//BitmapFontAtlas - CCLabelProtocol protocol
//LabelBMFont - CCLabelProtocol protocol
void CCLabelBMFont::setString(const char *newString)
{
m_sString.clear();
@ -565,7 +572,7 @@ namespace cocos2d{
setString(label);
}
//BitmapFontAtlas - CCRGBAProtocol protocol
//LabelBMFont - CCRGBAProtocol protocol
void CCLabelBMFont::setColor(ccColor3B var)
{
m_tColor = var;
@ -633,7 +640,7 @@ namespace cocos2d{
return m_bIsOpacityModifyRGB;
}
// BitmapFontAtlas - AnchorPoint
// LabelBMFont - AnchorPoint
void CCLabelBMFont::setAnchorPoint(CCPoint point)
{
if( ! CCPoint::CCPointEqualToPoint(point, m_tAnchorPoint) )
@ -643,7 +650,7 @@ namespace cocos2d{
}
}
//BitmapFontAtlas - Debug draw
//LabelBMFont - Debug draw
#if CC_LABELBMFONT_DEBUG_DRAW
void CCLabelBMFont::draw()
{

View File

@ -223,7 +223,7 @@ namespace cocos2d{
//Menu - Alignment
void CCMenu::alignItemsVertically()
{
return this->alignItemsVerticallyWithPadding(kDefaultPadding);
this->alignItemsVerticallyWithPadding(kDefaultPadding);
}
void CCMenu::alignItemsVerticallyWithPadding(float padding)
@ -260,7 +260,7 @@ namespace cocos2d{
void CCMenu::alignItemsHorizontally(void)
{
return this->alignItemsHorizontallyWithPadding(kDefaultPadding);
this->alignItemsHorizontallyWithPadding(kDefaultPadding);
}
void CCMenu::alignItemsHorizontallyWithPadding(float padding)

View File

@ -40,13 +40,9 @@ namespace cocos2d{
static std::string _fontName = "Marker Felt";
static bool _fontNameRelease = false;
enum {
kCurrentItem = 0xc0c05001,
};
const uint32_t kCurrentItem = 0xc0c05001;
const uint32_t kZoomActionTag = 0xc0c05002;
enum {
kZoomActionTag = 0xc0c05002,
};
//
// CCMenuItem
//