mirror of https://github.com/axmolengine/axmol.git
Merge branch 'natural-law-upto-0.99.5' into upto-0.99.5
This commit is contained in:
commit
07b774bc6f
|
@ -50,7 +50,7 @@ bool HelloWorld::init()
|
|||
|
||||
// add a label shows "Hello World"
|
||||
// create and initialize a label
|
||||
CCLabel* pLabel = CCLabel::labelWithString("HelloWorld", "Thonburi", 34);
|
||||
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("HelloWorld", "Thonburi", 34);
|
||||
|
||||
// ask director the window size
|
||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
|
|
@ -33,8 +33,8 @@ cocoa/NSZone.cpp \
|
|||
cocos2d.cpp \
|
||||
effects/CCGrabber.cpp \
|
||||
effects/CCGrid.cpp \
|
||||
label_nodes/CCBitmapFontAtlas.cpp \
|
||||
label_nodes/CCLabel.cpp \
|
||||
label_nodes/CCLabelBMFont.cpp \
|
||||
label_nodes/CCLabelTTF.cpp \
|
||||
label_nodes/CCLabelAtlas.cpp \
|
||||
layers_scenes_transitions_nodes/CCLayer.cpp \
|
||||
layers_scenes_transitions_nodes/CCPageTurnTransition.cpp \
|
||||
|
|
|
@ -38,9 +38,9 @@ THE SOFTWARE.
|
|||
#include "NSAutoreleasePool.h"
|
||||
#include "platform/platform.h"
|
||||
#include "CCXApplication.h"
|
||||
#include "CCBitmapFontAtlas.h"
|
||||
#include "CCLabelBMFont.h"
|
||||
#include "CCActionManager.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCConfiguration.h"
|
||||
#include "CCKeypadDispatcher.h"
|
||||
|
||||
|
@ -189,7 +189,7 @@ void CCDirector::setGLDefaultValues(void)
|
|||
#if CC_DIRECTOR_FAST_FPS
|
||||
if (! m_pFPSLabel)
|
||||
{
|
||||
m_pFPSLabel = CCLabel::labelWithString("00.0", "XXX", 24);
|
||||
m_pFPSLabel = CCLabelTTF::labelWithString("00.0", "XXX", 24);
|
||||
m_pFPSLabel->retain();
|
||||
}
|
||||
#endif
|
||||
|
@ -415,7 +415,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection)
|
|||
|
||||
void CCDirector::purgeCachedData(void)
|
||||
{
|
||||
CCBitmapFontAtlas::purgeCachedData();
|
||||
CCLabelBMFont::purgeCachedData();
|
||||
// removed in 0.99.4 release
|
||||
/*CCSpriteFrameCache::purgeSharedSpriteFrameCache();*/
|
||||
CCTextureCache::purgeSharedTextureCache();
|
||||
|
@ -658,7 +658,7 @@ void CCDirector::end(void)
|
|||
#endif
|
||||
|
||||
// purge bitmap cache
|
||||
CCBitmapFontAtlas::purgeCachedData();
|
||||
CCLabelBMFont::purgeCachedData();
|
||||
|
||||
// purge all managers
|
||||
CCSpriteFrameCache::purgeSharedSpriteFrameCache();
|
||||
|
|
|
@ -956,11 +956,7 @@ namespace cocos2d
|
|||
void CCSplitRows::startWithTarget(CCNode *pTarget)
|
||||
{
|
||||
CCTiledGrid3DAction::startWithTarget(pTarget);
|
||||
|
||||
/**
|
||||
@todo upto-0.99.5 Use CCDirector::sharedDirector()->getWinSizeInPixels()
|
||||
*/
|
||||
m_winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels();
|
||||
}
|
||||
|
||||
void CCSplitRows::update(cocos2d::ccTime time)
|
||||
|
@ -1037,11 +1033,7 @@ namespace cocos2d
|
|||
void CCSplitCols::startWithTarget(CCNode *pTarget)
|
||||
{
|
||||
CCTiledGrid3DAction::startWithTarget(pTarget);
|
||||
|
||||
/**
|
||||
@todo upto-0.99.5 Use CCDirector::sharedDirector()->getWinSizeInPixels()
|
||||
*/
|
||||
m_winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels();
|
||||
}
|
||||
|
||||
void CCSplitCols::update(cocos2d::ccTime time)
|
||||
|
|
|
@ -169,7 +169,7 @@ typedef enum {
|
|||
CCDeviceOrientationLandscapeRight = kCCDeviceOrientationLandscapeRight,
|
||||
} ccDeviceOrientation;
|
||||
|
||||
class CCLabel;
|
||||
class CCLabelTTF;
|
||||
class CCScene;
|
||||
class cocos2d::CCXEGLView;
|
||||
|
||||
|
@ -459,7 +459,7 @@ protected:
|
|||
ccTime m_fFrameRate;
|
||||
ccTime m_fExpectedFrameRate;
|
||||
#if CC_DIRECTOR_FAST_FPS
|
||||
CCLabel *m_pFPSLabel;
|
||||
CCLabelTTF *m_pFPSLabel;
|
||||
#endif
|
||||
|
||||
/* is the running scene paused */
|
||||
|
|
|
@ -48,7 +48,13 @@ namespace cocos2d{
|
|||
m_sString.clear();
|
||||
}
|
||||
/** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||
static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
|
||||
|
||||
/** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element in points and the starting char of the atlas.
|
||||
@deprecated Will be removed in 1.0.1. Use "labelWithString:" instead
|
||||
*/
|
||||
static CCLabelAtlas * labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
|
||||
/** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||
bool initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
|
||||
|
|
|
@ -29,9 +29,10 @@ namespace cocos2d{
|
|||
struct _KerningHashElement;
|
||||
|
||||
/**
|
||||
bitmap font definition
|
||||
@struct ccBMFontDef
|
||||
BMFont definition
|
||||
*/
|
||||
typedef struct _bitmapFontDef {
|
||||
typedef struct _BMFontDef {
|
||||
//! ID of the character
|
||||
unsigned int charID;
|
||||
//! origin and size of the font
|
||||
|
@ -42,13 +43,13 @@ namespace cocos2d{
|
|||
int yOffset;
|
||||
//! The amount to move the current position after drawing the character (in pixels)
|
||||
int xAdvance;
|
||||
} ccBitmapFontDef;
|
||||
} ccBMFontDef;
|
||||
|
||||
/**
|
||||
bitmap font padding
|
||||
/** @struct ccBMFontPadding
|
||||
BMFont padding
|
||||
@since v0.8.2
|
||||
*/
|
||||
typedef struct _bitmapFontPadding {
|
||||
typedef struct _BMFontPadding {
|
||||
/// padding left
|
||||
int left;
|
||||
/// padding top
|
||||
|
@ -57,43 +58,43 @@ namespace cocos2d{
|
|||
int right;
|
||||
/// padding bottom
|
||||
int bottom;
|
||||
} ccBitmapFontPadding;
|
||||
} ccBMFontPadding;
|
||||
|
||||
enum {
|
||||
// how many characters are supported
|
||||
kCCBitmapFontAtlasMaxChars = 2048, //256,
|
||||
kCCBMFontMaxChars = 2048, //256,
|
||||
};
|
||||
|
||||
/** @brief CCBitmapFontConfiguration has parsed configuration of the the .fnt file
|
||||
/** @brief CCBMFontConfiguration has parsed configuration of the the .fnt file
|
||||
@since v0.8
|
||||
*/
|
||||
class CCX_DLL CCBitmapFontConfiguration : public NSObject
|
||||
class CCX_DLL CCBMFontConfiguration : public NSObject
|
||||
{
|
||||
// XXX: Creating a public interface so that the bitmapFontArray[] is accesible
|
||||
public://@public
|
||||
//! The characters building up the font
|
||||
ccBitmapFontDef m_pBitmapFontArray[kCCBitmapFontAtlasMaxChars];
|
||||
ccBMFontDef m_pBitmapFontArray[kCCBMFontMaxChars];
|
||||
//! FNTConfig: Common Height
|
||||
unsigned int m_uCommonHeight;
|
||||
//! Padding
|
||||
ccBitmapFontPadding m_tPadding;
|
||||
ccBMFontPadding m_tPadding;
|
||||
//! atlas name
|
||||
std::string m_sAtlasName;
|
||||
//! values for kerning
|
||||
struct _KerningHashElement *m_pKerningDictionary;
|
||||
public:
|
||||
CCBitmapFontConfiguration()
|
||||
CCBMFontConfiguration()
|
||||
:m_pKerningDictionary(NULL)
|
||||
{}
|
||||
virtual ~CCBitmapFontConfiguration();
|
||||
virtual ~CCBMFontConfiguration();
|
||||
char * description();
|
||||
/** allocates a CCBitmapFontConfiguration with a FNT file */
|
||||
static CCBitmapFontConfiguration * configurationWithFNTFile(const char *FNTfile);
|
||||
/** allocates a CCBMFontConfiguration with a FNT file */
|
||||
static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile);
|
||||
/** initializes a BitmapFontConfiguration with a FNT file */
|
||||
bool initWithFNTfile(const char *FNTfile);
|
||||
private:
|
||||
void parseConfigFile(const char *controlFile);
|
||||
void parseCharacterDefinition(std::string line, ccBitmapFontDef *characterDefinition);
|
||||
void parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition);
|
||||
void parseInfoArguments(std::string line);
|
||||
void parseCommonArguments(std::string line);
|
||||
void parseImageFileName(std::string line, const char *fntFile);
|
||||
|
@ -102,7 +103,7 @@ namespace cocos2d{
|
|||
void purgeKerningDictionary();
|
||||
};
|
||||
|
||||
/** @brief CCBitmapFontAtlas is a subclass of CCSpriteSheet.
|
||||
/** @brief CCLabelBMFont is a subclass of CCSpriteSheet.
|
||||
|
||||
Features:
|
||||
- Treats each character like a CCSprite. This means that each individual character can be:
|
||||
|
@ -119,9 +120,9 @@ namespace cocos2d{
|
|||
- All inner characters are using an anchorPoint of (0.5f, 0.5f) and it is not recommend to change it
|
||||
because it might affect the rendering
|
||||
|
||||
CCBitmapFontAtlas implements the protocol CCLabelProtocol, like CCLabel and CCLabelAtlas.
|
||||
CCBitmapFontAtlas has the flexibility of CCLabel, the speed of CCLabelAtlas and all the features of CCSprite.
|
||||
If in doubt, use CCBitmapFontAtlas instead of CCLabelAtlas / CCLabel.
|
||||
CCLabelBMFont implements the protocol CCLabelProtocol, like CCLabel and CCLabelAtlas.
|
||||
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
|
||||
|
@ -131,7 +132,7 @@ namespace cocos2d{
|
|||
@since v0.8
|
||||
*/
|
||||
|
||||
class CCX_DLL CCBitmapFontAtlas : public CCSpriteSheet, public CCLabelProtocol, public CCRGBAProtocol
|
||||
class CCX_DLL CCLabelBMFont : public CCSpriteSheet, public CCLabelProtocol, public CCRGBAProtocol
|
||||
{
|
||||
/** conforms to CCRGBAProtocol protocol */
|
||||
CCX_PROPERTY(GLubyte, m_cOpacity, Opacity)
|
||||
|
@ -142,25 +143,33 @@ namespace cocos2d{
|
|||
protected:
|
||||
// string to render
|
||||
std::string m_sString;
|
||||
CCBitmapFontConfiguration *m_pConfiguration;
|
||||
CCBMFontConfiguration *m_pConfiguration;
|
||||
public:
|
||||
CCBitmapFontAtlas()
|
||||
CCLabelBMFont()
|
||||
:m_pConfiguration(NULL)
|
||||
{}
|
||||
virtual ~CCBitmapFontAtlas();
|
||||
virtual ~CCLabelBMFont();
|
||||
/** Purges the cached data.
|
||||
Removes from memory the cached configurations and the atlas name dictionary.
|
||||
@since v0.99.3
|
||||
*/
|
||||
static void purgeCachedData();
|
||||
/** creates a bitmap font altas with an initial string and the FNT file */
|
||||
static CCBitmapFontAtlas * bitmapFontAtlasWithString(const char *str, const char *fntFile);
|
||||
static CCLabelBMFont * labelWithString(const char *str, const char *fntFile);
|
||||
|
||||
/** creates a BMFont label with an initial string and the FNT file
|
||||
@deprecated Will be removed in 1.0.1. Use "labelWithString" instead.
|
||||
@since v0.99.5
|
||||
*/
|
||||
static CCLabelBMFont * bitmapFontAtlasWithString(const char *str, const char *fntFile);
|
||||
|
||||
/** init a bitmap font altas with an initial string and the FNT file */
|
||||
bool initWithString(const char *str, const char *fntFile);
|
||||
/** updates the font chars based on the string to render */
|
||||
void createFontChars();
|
||||
// super method
|
||||
virtual void setString(const char *label);
|
||||
virtual void setCString(const char *label);
|
||||
virtual void setAnchorPoint(CGPoint var);
|
||||
virtual CCRGBAProtocol* convertToRGBAProtocol() { return (CCRGBAProtocol*)this; }
|
||||
virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; }
|
||||
|
@ -175,11 +184,18 @@ namespace cocos2d{
|
|||
|
||||
/** Free function that parses a FNT file a place it on the cache
|
||||
*/
|
||||
CCBitmapFontConfiguration * FNTConfigLoadFile( const char *file );
|
||||
CCBMFontConfiguration * FNTConfigLoadFile( const char *file );
|
||||
/** Purges the FNT config cache
|
||||
*/
|
||||
void FNTConfigRemoveCache( void );
|
||||
|
||||
/** CCBitmapFontAtlas
|
||||
@deprecated Use CCLabelBMFont instead. Will be removed 1.0.1
|
||||
*/
|
||||
class CCBitmapFontAtlas : public CCLabelBMFont
|
||||
{
|
||||
};
|
||||
|
||||
}// namespace cocos2d
|
||||
|
||||
#endif //__CCBITMAP_FONT_ATLAS_H__
|
|
@ -28,31 +28,31 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocos2d{
|
||||
|
||||
/** @brief CCLabel is a subclass of CCTextureNode that knows how to render text labels
|
||||
/** @brief CCLabelTTF is a subclass of CCTextureNode that knows how to render text labels
|
||||
*
|
||||
* All features from CCTextureNode are valid in CCLabel
|
||||
* All features from CCTextureNode are valid in CCLabelTTF
|
||||
*
|
||||
* CCLabel objects are slow. Consider using CCLabelAtlas or CCBitmapFontAtlas instead.
|
||||
* CCLabelTTF objects are slow. Consider using CCLabelAtlas or CCBitmapFontAtlas instead.
|
||||
*/
|
||||
class CCX_DLL CCLabel : public CCSprite, public CCLabelProtocol
|
||||
class CCX_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol
|
||||
{
|
||||
public:
|
||||
CCLabel()
|
||||
CCLabelTTF()
|
||||
:m_sFontName("")
|
||||
{}
|
||||
virtual ~CCLabel(){ m_sFontName.clear(); }
|
||||
virtual ~CCLabelTTF(){ m_sFontName.clear(); }
|
||||
char * description();
|
||||
/** creates a CCLabel from a fontname, alignment, dimension and font size */
|
||||
static CCLabel * labelWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
/** creates a CCLabel from a fontname and font size */
|
||||
static CCLabel * labelWithString(const char *label, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabel with a font name, alignment, dimension and font size */
|
||||
/** creates a CCLabelTTF from a fontname, alignment, dimension and font size */
|
||||
static CCLabelTTF * labelWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
/** creates a CCLabelTTF from a fontname and font size */
|
||||
static CCLabelTTF * labelWithString(const char *label, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabelTTF with a font name, alignment, dimension and font size */
|
||||
bool initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize);
|
||||
/** initializes the CCLabel with a font name and font size */
|
||||
/** initializes the CCLabelTTF with a font name and font size */
|
||||
bool initWithString(const char *label, const char *fontName, float fontSize);
|
||||
|
||||
/** changes the string to render
|
||||
* @warning Changing the string is as expensive as creating a new CCLabel. To obtain better performance use CCLabelAtlas
|
||||
* @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas
|
||||
*/
|
||||
virtual void setString(const char *label);
|
||||
|
|
@ -31,7 +31,7 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocos2d{
|
||||
|
||||
class CCLabel;
|
||||
class CCLabelTTF;
|
||||
class CCLabelAtlas;
|
||||
class CCSprite;
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace cocos2d{
|
|||
Supported nodes:
|
||||
- CCBitmapFontAtlas
|
||||
- CCLabelAtlas
|
||||
- CCLabel
|
||||
- CCLabelTTF
|
||||
*/
|
||||
class CCX_DLL CCMenuItemLabel : public CCMenuItem, public CCRGBAProtocol
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ THE SOFTWARE.
|
|||
#include "CCActionInstant.h"
|
||||
#include "CCActionInterval.h"
|
||||
#include "CCActionEase.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCLabelTTF.h"
|
||||
#include "CCLayer.h"
|
||||
#include "CCMenu.h"
|
||||
#include "CCMenuItem.h"
|
||||
|
@ -62,7 +62,7 @@ THE SOFTWARE.
|
|||
#include "CCActionTiledGrid.h"
|
||||
#include "CCActionGrid3D.h"
|
||||
#include "CCActionGrid.h"
|
||||
#include "CCBitmapFontAtlas.h"
|
||||
#include "CCLabelBMFont.h"
|
||||
#include "CCParallaxNode.h"
|
||||
#include "CCTileMapAtlas.h"
|
||||
#include "CCTMXTiledMap.h"
|
||||
|
|
|
@ -29,7 +29,7 @@ THE SOFTWARE.
|
|||
namespace cocos2d{
|
||||
|
||||
//CCLabelAtlas - Creation & Init
|
||||
CCLabelAtlas * CCLabelAtlas::labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
CCLabelAtlas *pRet = new CCLabelAtlas();
|
||||
if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap))
|
||||
|
@ -40,6 +40,12 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCLabelAtlas * CCLabelAtlas::labelAtlasWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
return labelWithString(label, charMapFile, itemWidth, itemHeight, startCharMap);
|
||||
}
|
||||
|
||||
bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
assert(label != NULL);
|
||||
|
@ -61,19 +67,36 @@ namespace cocos2d{
|
|||
|
||||
const char *s = m_sString.c_str();
|
||||
|
||||
CCTexture2D *texture = m_pTextureAtlas->getTexture();
|
||||
float textureWide = (float) texture->getPixelsWide();
|
||||
float textureHigh = (float) texture->getPixelsHigh();
|
||||
|
||||
for( int i=0; i<n; i++) {
|
||||
unsigned char a = s[i] - m_cMapStartChar;
|
||||
float row = (a % m_nItemsPerRow) * m_fTexStepX;
|
||||
float col = (a / m_nItemsPerRow) * m_fTexStepY;
|
||||
float row = (float) (a % m_nItemsPerRow);
|
||||
float col = (float) (a / m_nItemsPerRow);
|
||||
|
||||
quad.tl.texCoords.u = row;
|
||||
quad.tl.texCoords.v = col;
|
||||
quad.tr.texCoords.u = row + m_fTexStepX;
|
||||
quad.tr.texCoords.v = col;
|
||||
quad.bl.texCoords.u = row;
|
||||
quad.bl.texCoords.v = col + m_fTexStepY;
|
||||
quad.br.texCoords.u = row + m_fTexStepX;
|
||||
quad.br.texCoords.v = col + m_fTexStepY;
|
||||
#if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
// Issue #938. Don't use texStepX & texStepY
|
||||
float left = (2 * row * m_nItemWidth + 1) / (2 * textureWide);
|
||||
float right = left + (m_nItemWidth * 2 - 2) / (2 * textureWide);
|
||||
float top = (2 * col * m_nItemHeight + 1) / (2 * textureHigh);
|
||||
float bottom = top + (m_nItemHeight * 2 - 2) / (2 * textureHigh);
|
||||
#else
|
||||
float left = row * m_nItemWidth / textureWide;
|
||||
float right = left + m_nItemWidth / textureWide;
|
||||
float top = col * m_nItemHeight / textureHigh;
|
||||
float bottom = top + m_nItemHeight / textureHigh;
|
||||
#endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
|
||||
|
||||
quad.tl.texCoords.u = left;
|
||||
quad.tl.texCoords.v = top;
|
||||
quad.tr.texCoords.u = right;
|
||||
quad.tr.texCoords.v = top;
|
||||
quad.bl.texCoords.u = left;
|
||||
quad.bl.texCoords.v = bottom;
|
||||
quad.br.texCoords.u = right;
|
||||
quad.br.texCoords.v = bottom;
|
||||
|
||||
quad.bl.vertices.x = (float) (i * m_nItemWidth);
|
||||
quad.bl.vertices.y = 0;
|
||||
|
@ -106,7 +129,7 @@ namespace cocos2d{
|
|||
CGSize s;
|
||||
s.width = (float)(m_sString.length() * m_nItemWidth);
|
||||
s.height = (float)(m_nItemHeight);
|
||||
this->setContentSize(s);
|
||||
this->setContentSizeInPixels(s);
|
||||
}
|
||||
|
||||
//CCLabelAtlas - draw
|
||||
|
@ -121,9 +144,9 @@ namespace cocos2d{
|
|||
|
||||
glColor4ub( m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity);
|
||||
|
||||
bool newBlend = false;
|
||||
if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST ) {
|
||||
newBlend = true;
|
||||
bool newBlend = (m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST);
|
||||
if(newBlend)
|
||||
{
|
||||
glBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ 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.
|
||||
****************************************************************************/
|
||||
#include "CCBitmapFontAtlas.h"
|
||||
#include "CCLabelBMFont.h"
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "NSMutableDictionary.h"
|
||||
|
@ -40,20 +40,20 @@ namespace cocos2d{
|
|||
//
|
||||
//FNTConfig Cache - free functions
|
||||
//
|
||||
NSMutableDictionary<std::string, CCBitmapFontConfiguration*> *configurations = NULL;
|
||||
CCBitmapFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
||||
NSMutableDictionary<std::string, CCBMFontConfiguration*> *configurations = NULL;
|
||||
CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile)
|
||||
{
|
||||
CCBitmapFontConfiguration *pRet = NULL;
|
||||
CCBMFontConfiguration *pRet = NULL;
|
||||
|
||||
if( configurations == NULL )
|
||||
{
|
||||
configurations = new NSMutableDictionary<std::string, CCBitmapFontConfiguration*>();
|
||||
configurations = new NSMutableDictionary<std::string, CCBMFontConfiguration*>();
|
||||
}
|
||||
std::string key(fntFile);
|
||||
pRet = configurations->objectForKey(key);
|
||||
if( pRet == NULL )
|
||||
{
|
||||
pRet = CCBitmapFontConfiguration::configurationWithFNTFile(fntFile);
|
||||
pRet = CCBMFontConfiguration::configurationWithFNTFile(fntFile);
|
||||
configurations->setObject(pRet, key);
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,9 @@ namespace cocos2d{
|
|||
//BitmapFontConfiguration
|
||||
//
|
||||
|
||||
CCBitmapFontConfiguration * CCBitmapFontConfiguration::configurationWithFNTFile(const char *FNTfile)
|
||||
CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const char *FNTfile)
|
||||
{
|
||||
CCBitmapFontConfiguration * pRet = new CCBitmapFontConfiguration();
|
||||
CCBMFontConfiguration * pRet = new CCBMFontConfiguration();
|
||||
if (pRet->initWithFNTfile(FNTfile))
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
@ -93,26 +93,26 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
bool CCBitmapFontConfiguration::initWithFNTfile(const char *FNTfile)
|
||||
bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile)
|
||||
{
|
||||
assert(FNTfile != NULL && strlen(FNTfile)!=0);
|
||||
m_pKerningDictionary = NULL;
|
||||
this->parseConfigFile(FNTfile);
|
||||
return true;
|
||||
}
|
||||
CCBitmapFontConfiguration::~CCBitmapFontConfiguration()
|
||||
CCBMFontConfiguration::~CCBMFontConfiguration()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing CCBitmapFontConfiguration" );
|
||||
CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration" );
|
||||
this->purgeKerningDictionary();
|
||||
m_sAtlasName.clear();
|
||||
}
|
||||
char * CCBitmapFontConfiguration::description(void)
|
||||
char * CCBMFontConfiguration::description(void)
|
||||
{
|
||||
char *ret = new char[100];
|
||||
sprintf(ret, "<CCBitmapFontConfiguration | Kernings:%d | Image = %s>", HASH_COUNT(m_pKerningDictionary), m_sAtlasName.c_str());
|
||||
sprintf(ret, "<CCBMFontConfiguration | Kernings:%d | Image = %s>", HASH_COUNT(m_pKerningDictionary), m_sAtlasName.c_str());
|
||||
return ret;
|
||||
}
|
||||
void CCBitmapFontConfiguration::purgeKerningDictionary()
|
||||
void CCBMFontConfiguration::purgeKerningDictionary()
|
||||
{
|
||||
tKerningHashElement *current;
|
||||
while(m_pKerningDictionary)
|
||||
|
@ -122,7 +122,7 @@ namespace cocos2d{
|
|||
free(current);
|
||||
}
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseConfigFile(const char *controlFile)
|
||||
void CCBMFontConfiguration::parseConfigFile(const char *controlFile)
|
||||
{
|
||||
std::string fullpath = CCFileUtils::fullPathFromRelativePath(controlFile);
|
||||
|
||||
|
@ -130,7 +130,7 @@ namespace cocos2d{
|
|||
unsigned long nBufSize = 0;
|
||||
char* pBuffer = (char*) data.getFileData(fullpath.c_str(), "r", &nBufSize);
|
||||
|
||||
NSAssert(pBuffer, "CCBitmapFontConfiguration::parseConfigFile | Open file error.");
|
||||
NSAssert(pBuffer, "CCBMFontConfiguration::parseConfigFile | Open file error.");
|
||||
|
||||
if (!pBuffer)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ namespace cocos2d{
|
|||
else if(line.substr(0,strlen("char")) == "char")
|
||||
{
|
||||
// Parse the current line and create a new CharDef
|
||||
ccBitmapFontDef characterDefinition;
|
||||
ccBMFontDef characterDefinition;
|
||||
this->parseCharacterDefinition(line, &characterDefinition);
|
||||
|
||||
// Add the CharDef returned to the charArray
|
||||
|
@ -208,7 +208,7 @@ namespace cocos2d{
|
|||
}
|
||||
}
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseImageFileName(std::string line, const char *fntFile)
|
||||
void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fntFile)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -227,7 +227,7 @@ namespace cocos2d{
|
|||
|
||||
m_sAtlasName = CCFileUtils::fullPathFromRelativeFile(value.c_str(), fntFile);
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseInfoArguments(std::string line)
|
||||
void CCBMFontConfiguration::parseInfoArguments(std::string line)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// possible lines to parse:
|
||||
|
@ -242,7 +242,7 @@ namespace cocos2d{
|
|||
sscanf(value.c_str(), "padding=%d,%d,%d,%d", &m_tPadding.top, &m_tPadding.right, &m_tPadding.bottom, &m_tPadding.left);
|
||||
CCLOG("cocos2d: padding: %d,%d,%d,%d", m_tPadding.left, m_tPadding.top, m_tPadding.right, m_tPadding.bottom);
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseCommonArguments(std::string line)
|
||||
void CCBMFontConfiguration::parseCommonArguments(std::string line)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -258,12 +258,12 @@ namespace cocos2d{
|
|||
index = line.find("scaleW=") + strlen("scaleW=");
|
||||
index2 = line.find(' ', index);
|
||||
value = line.substr(index, index2-index);
|
||||
NSAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCBitmapFontAtlas: page can't be larger than supported");
|
||||
NSAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
|
||||
// scaleH. sanity check
|
||||
index = line.find("scaleH=") + strlen("scaleH=");
|
||||
index2 = line.find(' ', index);
|
||||
value = line.substr(index, index2-index);
|
||||
NSAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCBitmapFontAtlas: page can't be larger than supported");
|
||||
NSAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported");
|
||||
// pages. sanity check
|
||||
index = line.find("pages=") + strlen("pages=");
|
||||
index2 = line.find(' ', index);
|
||||
|
@ -272,7 +272,7 @@ namespace cocos2d{
|
|||
|
||||
// packed (ignore) What does this mean ??
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseCharacterDefinition(std::string line, ccBitmapFontDef *characterDefinition)
|
||||
void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -284,7 +284,7 @@ namespace cocos2d{
|
|||
int index2 = line.find(' ', index);
|
||||
std::string value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "id=%u", &characterDefinition->charID);
|
||||
NSAssert(characterDefinition->charID < kCCBitmapFontAtlasMaxChars, "BitmpaFontAtlas: CharID bigger than supported");
|
||||
NSAssert(characterDefinition->charID < kCCBMFontMaxChars, "BitmpaFontAtlas: CharID bigger than supported");
|
||||
// Character x
|
||||
index = line.find("x=");
|
||||
index2 = line.find(' ', index);
|
||||
|
@ -321,7 +321,7 @@ namespace cocos2d{
|
|||
value = line.substr(index, index2-index);
|
||||
sscanf(value.c_str(), "xadvance=%d", &characterDefinition->xAdvance);
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseKerningCapacity(std::string line)
|
||||
void CCBMFontConfiguration::parseKerningCapacity(std::string line)
|
||||
{
|
||||
// When using uthash there is not need to parse the capacity.
|
||||
|
||||
|
@ -342,7 +342,7 @@ namespace cocos2d{
|
|||
// if( capacity != -1 )
|
||||
// kerningDictionary = ccHashSetNew(capacity, targetSetEql);
|
||||
}
|
||||
void CCBitmapFontConfiguration::parseKerningEntry(std::string line)
|
||||
void CCBMFontConfiguration::parseKerningEntry(std::string line)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// line to parse:
|
||||
|
@ -376,19 +376,19 @@ namespace cocos2d{
|
|||
HASH_ADD_INT(m_pKerningDictionary,key, element);
|
||||
}
|
||||
//
|
||||
//CCBitmapFontAtlas
|
||||
//CCLabelBMFont
|
||||
//
|
||||
|
||||
//BitmapFontAtlas - Purge Cache
|
||||
void CCBitmapFontAtlas::purgeCachedData()
|
||||
void CCLabelBMFont::purgeCachedData()
|
||||
{
|
||||
FNTConfigRemoveCache();
|
||||
}
|
||||
|
||||
//BitmapFontAtlas - Creation & Init
|
||||
CCBitmapFontAtlas *CCBitmapFontAtlas::bitmapFontAtlasWithString(const char *str, const char *fntFile)
|
||||
CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile)
|
||||
{
|
||||
CCBitmapFontAtlas *pRet = new CCBitmapFontAtlas();
|
||||
CCLabelBMFont *pRet = new CCLabelBMFont();
|
||||
if(pRet && pRet->initWithString(str, fntFile))
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
@ -397,7 +397,13 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
bool CCBitmapFontAtlas::initWithString(const char *theString, const char *fntFile)
|
||||
|
||||
CCLabelBMFont * CCLabelBMFont::bitmapFontAtlasWithString(const char *str, const char *fntFile)
|
||||
{
|
||||
return labelWithString(str, fntFile);
|
||||
}
|
||||
|
||||
bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile)
|
||||
{
|
||||
assert(theString != NULL);
|
||||
CCX_SAFE_RELEASE(m_pConfiguration);// allow re-init
|
||||
|
@ -417,14 +423,14 @@ namespace cocos2d{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
CCBitmapFontAtlas::~CCBitmapFontAtlas()
|
||||
CCLabelBMFont::~CCLabelBMFont()
|
||||
{
|
||||
m_sString.clear();
|
||||
m_pConfiguration->release();
|
||||
}
|
||||
|
||||
// BitmapFontAtlas - Atlas generation
|
||||
int CCBitmapFontAtlas::kerningAmountForFirst(unsigned short first, unsigned short second)
|
||||
int CCLabelBMFont::kerningAmountForFirst(unsigned short first, unsigned short second)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int key = (first<<16) | (second & 0xffff);
|
||||
|
@ -437,22 +443,54 @@ namespace cocos2d{
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
void CCBitmapFontAtlas::createFontChars()
|
||||
void CCLabelBMFont::createFontChars()
|
||||
{
|
||||
int nextFontPositionX = 0;
|
||||
int nextFontPositionY = 0;
|
||||
INT16 prev = -1;
|
||||
int kerningAmount = 0;
|
||||
|
||||
CGSize tmpSize = CGSizeZero;
|
||||
|
||||
int longestLine = 0;
|
||||
int totalHeight = 0;
|
||||
|
||||
int quantityOfLines = 1;
|
||||
|
||||
UINT32 len = m_sString.length();
|
||||
|
||||
if (0 == len)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (UINT32 i = 0; i < len - 1; ++i)
|
||||
{
|
||||
INT16 c = m_sString[i];
|
||||
if (c == '\n')
|
||||
{
|
||||
quantityOfLines++;
|
||||
}
|
||||
}
|
||||
|
||||
totalHeight = m_pConfiguration->m_uCommonHeight * quantityOfLines;
|
||||
nextFontPositionY = m_pConfiguration->m_uCommonHeight * (quantityOfLines - 1);
|
||||
|
||||
for(UINT32 i=0; i<len; i++)
|
||||
{
|
||||
INT16 c = m_sString[i];
|
||||
NSAssert( c < kCCBitmapFontAtlasMaxChars, "BitmapFontAtlas: character outside bounds");
|
||||
NSAssert( c < kCCBMFontMaxChars, "BitmapFontAtlas: character outside bounds");
|
||||
|
||||
if (c == '\n')
|
||||
{
|
||||
nextFontPositionX = 0;
|
||||
nextFontPositionY -= m_pConfiguration->m_uCommonHeight;
|
||||
continue;
|
||||
}
|
||||
|
||||
kerningAmount = this->kerningAmountForFirst(prev, c);
|
||||
|
||||
ccBitmapFontDef fontDef = m_pConfiguration->m_pBitmapFontArray[c];
|
||||
ccBMFontDef fontDef = m_pConfiguration->m_pBitmapFontArray[c];
|
||||
|
||||
CGRect rect = fontDef.rect;
|
||||
|
||||
|
@ -469,26 +507,23 @@ namespace cocos2d{
|
|||
else
|
||||
{
|
||||
// reusing fonts
|
||||
fontChar->setTextureRect(rect);
|
||||
fontChar->setTextureRectInPixels(rect, NO, rect.size);
|
||||
|
||||
// restore to default in case they were modified
|
||||
fontChar->setIsVisible(true);
|
||||
fontChar->setOpacity(255);
|
||||
}
|
||||
|
||||
fontChar->setPosition( ccp( nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width / 2.0f ,
|
||||
(m_pConfiguration->m_uCommonHeight - fontDef.yOffset) - rect.size.height/2.0f ) );
|
||||
float yOffset = (float) (m_pConfiguration->m_uCommonHeight - fontDef.yOffset);
|
||||
fontChar->setPositionInPixels( ccp( nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width / 2.0f + kerningAmount,
|
||||
(float) nextFontPositionY + yOffset - rect.size.height/2.0f ) );
|
||||
|
||||
// NSLog(@"position.y: %f", fontChar.position.y);
|
||||
|
||||
// update kerning
|
||||
fontChar->setPosition( ccpAdd( fontChar->getPosition(), ccp((float)kerningAmount,0)) );
|
||||
nextFontPositionX += m_pConfiguration->m_pBitmapFontArray[c].xAdvance + kerningAmount;
|
||||
prev = c;
|
||||
|
||||
tmpSize.width += m_pConfiguration->m_pBitmapFontArray[c].xAdvance + kerningAmount;
|
||||
tmpSize.height = (float)(m_pConfiguration->m_uCommonHeight);
|
||||
|
||||
// Apply label properties
|
||||
fontChar->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB);
|
||||
// Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on
|
||||
|
@ -500,12 +535,21 @@ namespace cocos2d{
|
|||
{
|
||||
fontChar->setOpacity(m_cOpacity);
|
||||
}
|
||||
|
||||
if (longestLine < nextFontPositionX)
|
||||
{
|
||||
longestLine = nextFontPositionX;
|
||||
}
|
||||
}
|
||||
this->setContentSize(tmpSize);
|
||||
|
||||
tmpSize.width = (float) longestLine;
|
||||
tmpSize.height = (float) totalHeight;
|
||||
|
||||
this->setContentSizeInPixels(tmpSize);
|
||||
}
|
||||
|
||||
//BitmapFontAtlas - CCLabelProtocol protocol
|
||||
void CCBitmapFontAtlas::setString(const char *newString)
|
||||
void CCLabelBMFont::setString(const char *newString)
|
||||
{
|
||||
m_sString.clear();
|
||||
m_sString = newString;
|
||||
|
@ -521,8 +565,13 @@ namespace cocos2d{
|
|||
this->createFontChars();
|
||||
}
|
||||
|
||||
void CCLabelBMFont::setCString(const char *label)
|
||||
{
|
||||
setString(label);
|
||||
}
|
||||
|
||||
//BitmapFontAtlas - CCRGBAProtocol protocol
|
||||
void CCBitmapFontAtlas::setColor(ccColor3B var)
|
||||
void CCLabelBMFont::setColor(ccColor3B var)
|
||||
{
|
||||
m_tColor = var;
|
||||
if (m_pChildren && m_pChildren->count() != 0)
|
||||
|
@ -534,11 +583,11 @@ namespace cocos2d{
|
|||
}
|
||||
}
|
||||
}
|
||||
ccColor3B CCBitmapFontAtlas::getColor()
|
||||
ccColor3B CCLabelBMFont::getColor()
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
void CCBitmapFontAtlas::setOpacity(GLubyte var)
|
||||
void CCLabelBMFont::setOpacity(GLubyte var)
|
||||
{
|
||||
m_cOpacity = var;
|
||||
|
||||
|
@ -555,11 +604,11 @@ namespace cocos2d{
|
|||
}
|
||||
}
|
||||
}
|
||||
GLubyte CCBitmapFontAtlas::getOpacity()
|
||||
GLubyte CCLabelBMFont::getOpacity()
|
||||
{
|
||||
return m_cOpacity;
|
||||
}
|
||||
void CCBitmapFontAtlas::setIsOpacityModifyRGB(bool var)
|
||||
void CCLabelBMFont::setIsOpacityModifyRGB(bool var)
|
||||
{
|
||||
m_bIsOpacityModifyRGB = var;
|
||||
if (m_pChildren && m_pChildren->count() != 0)
|
||||
|
@ -575,13 +624,13 @@ namespace cocos2d{
|
|||
}
|
||||
}
|
||||
}
|
||||
bool CCBitmapFontAtlas::getIsOpacityModifyRGB()
|
||||
bool CCLabelBMFont::getIsOpacityModifyRGB()
|
||||
{
|
||||
return m_bIsOpacityModifyRGB;
|
||||
}
|
||||
|
||||
// BitmapFontAtlas - AnchorPoint
|
||||
void CCBitmapFontAtlas::setAnchorPoint(CGPoint point)
|
||||
void CCLabelBMFont::setAnchorPoint(CGPoint point)
|
||||
{
|
||||
if( ! CGPoint::CGPointEqualToPoint(point, m_tAnchorPoint) )
|
||||
{
|
||||
|
@ -592,7 +641,7 @@ namespace cocos2d{
|
|||
|
||||
//BitmapFontAtlas - Debug draw
|
||||
#if CC_BITMAPFONTATLAS_DEBUG_DRAW
|
||||
void CCBitmapFontAtlas::draw()
|
||||
void CCLabelBMFont::draw()
|
||||
{
|
||||
CCSpriteSheet::draw();
|
||||
CGSize s = this->getContentSize();
|
|
@ -21,15 +21,15 @@ 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.
|
||||
****************************************************************************/
|
||||
#include "CCLabel.h"
|
||||
#include "CCLabelTTF.h"
|
||||
|
||||
namespace cocos2d{
|
||||
//
|
||||
//CCLabel
|
||||
//CCLabelTTF
|
||||
//
|
||||
CCLabel * CCLabel::labelWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
CCLabelTTF * CCLabelTTF::labelWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
{
|
||||
CCLabel *pRet = new CCLabel();
|
||||
CCLabelTTF *pRet = new CCLabelTTF();
|
||||
if(pRet && pRet->initWithString(label, dimensions, alignment, fontName, fontSize))
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
@ -38,9 +38,9 @@ namespace cocos2d{
|
|||
CCX_SAFE_DELETE(pRet)
|
||||
return NULL;
|
||||
}
|
||||
CCLabel * CCLabel::labelWithString(const char *label, const char *fontName, float fontSize)
|
||||
CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const char *fontName, float fontSize)
|
||||
{
|
||||
CCLabel *pRet = new CCLabel();
|
||||
CCLabelTTF *pRet = new CCLabelTTF();
|
||||
if(pRet && pRet->initWithString(label, fontName, fontSize))
|
||||
{
|
||||
pRet->autorelease();
|
||||
|
@ -50,34 +50,34 @@ namespace cocos2d{
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bool CCLabel::initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
bool CCLabelTTF::initWithString(const char *label, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
|
||||
{
|
||||
assert(label != NULL);
|
||||
if (CCSprite::init())
|
||||
{
|
||||
m_tDimensions = dimensions;
|
||||
m_tDimensions = CGSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
|
||||
m_eAlignment = alignment;
|
||||
m_sFontName = fontName;
|
||||
m_fFontSize = fontSize;
|
||||
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
|
||||
this->setString(label);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool CCLabel::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
|
||||
{
|
||||
assert(label != NULL);
|
||||
if (CCSprite::init())
|
||||
{
|
||||
m_tDimensions = CGSizeZero;
|
||||
m_sFontName = fontName;
|
||||
m_fFontSize = fontSize;
|
||||
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
|
||||
this->setString(label);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void CCLabel::setString(const char *label)
|
||||
void CCLabelTTF::setString(const char *label)
|
||||
{
|
||||
if (strlen(label)==0)
|
||||
{
|
||||
|
@ -98,14 +98,15 @@ namespace cocos2d{
|
|||
this->setTexture(texture);
|
||||
texture->release();
|
||||
|
||||
CGSize size = m_pobTexture->getContentSize();
|
||||
this->setTextureRect(CGRectMake(0, 0, size.width, size.height));
|
||||
CGRect rect = CGRectZero;
|
||||
rect.size = m_pobTexture->getContentSize();
|
||||
this->setTextureRect(rect);
|
||||
}
|
||||
|
||||
char * CCLabel::description()
|
||||
char * CCLabelTTF::description()
|
||||
{
|
||||
char *ret = new char[100] ;
|
||||
sprintf(ret, "<CCLabel | FontName = %s, FontSize = %.1f>", m_sFontName.c_str(), m_fFontSize);
|
||||
sprintf(ret, "<CCLabelTTF | FontName = %s, FontSize = %.1f>", m_sFontName.c_str(), m_fFontSize);
|
||||
return ret;
|
||||
}
|
||||
}// namespace cocos2d
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
#include "CCActionInterval.h"
|
||||
#include "CCSprite.h"
|
||||
#include "CCLabelAtlas.h"
|
||||
#include "CCLabel.h"
|
||||
#include "CCLabelTTF.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -284,7 +284,7 @@ namespace cocos2d{
|
|||
bool CCMenuItemFont::initFromString(const char *value, SelectorProtocol* target, SEL_MenuHandler selector)
|
||||
{
|
||||
NSAssert( value != NULL && strlen(value) != 0, "Value lenght must be greater than 0");
|
||||
CCLabel *label = CCLabel::labelWithString(value, _fontName.c_str(), (float)_fontSize);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString(value, _fontName.c_str(), (float)_fontSize);
|
||||
if (CCMenuItemLabel::initWithLabel(label, target, selector))
|
||||
{
|
||||
// do something ?
|
||||
|
|
|
@ -312,10 +312,6 @@
|
|||
RelativePath="..\include\CCAtlasNode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCBitmapFontAtlas.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCCamera.h"
|
||||
>
|
||||
|
@ -341,11 +337,15 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabel.h"
|
||||
RelativePath="..\include\CCLabelAtlas.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabelAtlas.h"
|
||||
RelativePath="..\include\CCLabelBMFont.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabelTTF.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -576,18 +576,18 @@
|
|||
<Filter
|
||||
Name="label_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCBitmapFontAtlas.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabel.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelAtlas.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelBMFont.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelTTF.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="layers_scenes_transition_nodes"
|
||||
|
|
|
@ -342,10 +342,6 @@
|
|||
RelativePath="..\include\CCAtlasNode.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCBitmapFontAtlas.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCCamera.h"
|
||||
>
|
||||
|
@ -371,11 +367,15 @@
|
|||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabel.h"
|
||||
RelativePath="..\include\CCLabelAtlas.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabelAtlas.h"
|
||||
RelativePath="..\include\CCLabelBMFont.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\include\CCLabelTTF.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
|
@ -618,18 +618,18 @@
|
|||
<Filter
|
||||
Name="label_nodes"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCBitmapFontAtlas.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabel.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelAtlas.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelBMFont.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\label_nodes\CCLabelTTF.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="layers_scenes_transitions_nodes"
|
||||
|
|
|
@ -50,7 +50,7 @@ bool HelloWorld::init()
|
|||
|
||||
// add a label shows "Hello World"
|
||||
// create and initialize a label
|
||||
CCLabel* pLabel = CCLabel::labelWithString("HelloWorld", "Thonburi", 64);
|
||||
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("HelloWorld", "Thonburi", 64);
|
||||
|
||||
// ask director the window size
|
||||
CGSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
|
|
|
@ -36,7 +36,7 @@ void AccelerometerTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void ActionManagerTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
|
@ -216,7 +216,7 @@ void PauseTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* l = CCLabel::labelWithString("After 5 seconds grossini should move", "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString("After 5 seconds grossini should move", "Thonburi", 16);
|
||||
addChild(l);
|
||||
l->setPosition( CGPointMake(s.width/2, 245) );
|
||||
|
||||
|
@ -258,7 +258,7 @@ void RemoveTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* l = CCLabel::labelWithString("Should not crash", "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString("Should not crash", "Thonburi", 16);
|
||||
addChild(l);
|
||||
l->setPosition( CGPointMake(s.width/2, 245) );
|
||||
|
||||
|
@ -301,7 +301,7 @@ void ResumeTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* l = CCLabel::labelWithString("Grossini only rotate/scale in 3 seconds", "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString("Grossini only rotate/scale in 3 seconds", "Thonburi", 16);
|
||||
addChild(l);
|
||||
l->setPosition( CGPointMake(s.width/2, 245));
|
||||
|
||||
|
|
|
@ -152,14 +152,14 @@ void ActionsDemo::onEnter()
|
|||
// add title and subtitle
|
||||
std::string str = title();
|
||||
const char * pTitle = str.c_str();
|
||||
CCLabel* label = CCLabel::labelWithString(pTitle, "Arial", 18);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(pTitle, "Arial", 18);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height - 30) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 22);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 22);
|
||||
addChild(l, 1);
|
||||
l->setPosition( CGPointMake(s.width/2, s.height - 60) );
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ void ActionSequence2::onEnter()
|
|||
void ActionSequence2::callback1()
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 1 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 1 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*1,s.height/2));
|
||||
|
||||
addChild(label);
|
||||
|
@ -614,7 +614,7 @@ void ActionSequence2::callback1()
|
|||
void ActionSequence2::callback2(CCNode* sender)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 2 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 2 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*2,s.height/2));
|
||||
|
||||
addChild(label);
|
||||
|
@ -623,7 +623,7 @@ void ActionSequence2::callback2(CCNode* sender)
|
|||
void ActionSequence2::callback3(CCNode* sender, void* data)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 3 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 3 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*3,s.height/2));
|
||||
|
||||
addChild(label);
|
||||
|
@ -671,7 +671,7 @@ void ActionCallFunc::onEnter()
|
|||
void ActionCallFunc::callback1()
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 1 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 1 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*1,s.height/2));
|
||||
|
||||
addChild(label);
|
||||
|
@ -680,7 +680,7 @@ void ActionCallFunc::callback1()
|
|||
void ActionCallFunc::callback2(CCNode* pSender)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 2 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 2 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*2,s.height/2));
|
||||
|
||||
addChild(label);
|
||||
|
@ -689,7 +689,7 @@ void ActionCallFunc::callback2(CCNode* pSender)
|
|||
void ActionCallFunc::callback3(CCNode* pTarget, void* data)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel *label = CCLabel::labelWithString("callback 3 called", "Marker Felt", 16);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("callback 3 called", "Marker Felt", 16);
|
||||
label->setPosition(CGPointMake( s.width/4*3,s.height/2));
|
||||
addChild(label);
|
||||
}
|
||||
|
|
|
@ -113,14 +113,14 @@ void AtlasDemo::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ Atlas3::Atlas3()
|
|||
CCColorLayer* col = CCColorLayer::layerWithColor( ccc4(128,128,128,255) );
|
||||
addChild(col, -10);
|
||||
|
||||
CCBitmapFontAtlas* label1 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
CCLabelBMFont* label1 = CCLabelBMFont::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
|
||||
// testing anchors
|
||||
label1->setAnchorPoint( ccp(0,0) );
|
||||
|
@ -367,14 +367,14 @@ Atlas3::Atlas3()
|
|||
// color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
|
||||
// If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
|
||||
// Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
|
||||
CCBitmapFontAtlas *label2 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
CCLabelBMFont *label2 = CCLabelBMFont::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
// testing anchors
|
||||
label2->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
label2->setColor( ccRED );
|
||||
addChild(label2, 0, kTagBitmapAtlas2);
|
||||
label2->runAction( (CCAction*)(repeat->copy()->autorelease()) );
|
||||
|
||||
CCBitmapFontAtlas* label3 = CCBitmapFontAtlas::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
CCLabelBMFont* label3 = CCLabelBMFont::bitmapFontAtlasWithString("Test", "fonts/bitmapFontTest2.fnt");
|
||||
// testing anchors
|
||||
label3->setAnchorPoint( ccp(1,1) );
|
||||
addChild(label3, 0, kTagBitmapAtlas3);
|
||||
|
@ -396,20 +396,20 @@ void Atlas3::step(ccTime dt)
|
|||
sprintf(string, "%2.2f Test j", m_time);
|
||||
//string.format("%2.2f Test j", m_time);
|
||||
|
||||
CCBitmapFontAtlas *label1 = (CCBitmapFontAtlas*) getChildByTag(kTagBitmapAtlas1);
|
||||
CCLabelBMFont *label1 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas1);
|
||||
label1->setString(string);
|
||||
|
||||
CCBitmapFontAtlas *label2 = (CCBitmapFontAtlas*) getChildByTag(kTagBitmapAtlas2);
|
||||
CCLabelBMFont *label2 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas2);
|
||||
label2->setString(string);
|
||||
|
||||
CCBitmapFontAtlas *label3 = (CCBitmapFontAtlas*) getChildByTag(kTagBitmapAtlas3);
|
||||
CCLabelBMFont *label3 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas3);
|
||||
label3->setString(string);
|
||||
|
||||
}
|
||||
|
||||
std::string Atlas3::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string Atlas3::subtitle()
|
||||
|
@ -427,7 +427,7 @@ Atlas4::Atlas4()
|
|||
m_time = 0;
|
||||
|
||||
// Upper Label
|
||||
CCBitmapFontAtlas *label = CCBitmapFontAtlas::bitmapFontAtlasWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
|
||||
CCLabelBMFont *label = CCLabelBMFont::bitmapFontAtlasWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
|
||||
addChild(label);
|
||||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
@ -464,7 +464,7 @@ Atlas4::Atlas4()
|
|||
|
||||
|
||||
// Bottom Label
|
||||
CCBitmapFontAtlas *label2 = CCBitmapFontAtlas::bitmapFontAtlasWithString("00.0", "fonts/bitmapFontTest.fnt");
|
||||
CCLabelBMFont *label2 = CCLabelBMFont::bitmapFontAtlasWithString("00.0", "fonts/bitmapFontTest.fnt");
|
||||
addChild(label2, 0, kTagBitmapAtlas2);
|
||||
label2->setPosition( ccp(s.width/2.0f, 80) );
|
||||
|
||||
|
@ -489,13 +489,13 @@ void Atlas4::step(ccTime dt)
|
|||
// std::string string;
|
||||
// string.format("%04.1f", m_time);
|
||||
|
||||
CCBitmapFontAtlas* label1 = (CCBitmapFontAtlas*) getChildByTag(kTagBitmapAtlas2);
|
||||
CCLabelBMFont* label1 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas2);
|
||||
label1->setString(string);
|
||||
}
|
||||
|
||||
std::string Atlas4::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string Atlas4::subtitle()
|
||||
|
@ -511,7 +511,7 @@ std::string Atlas4::subtitle()
|
|||
|
||||
Atlas5::Atlas5()
|
||||
{
|
||||
CCBitmapFontAtlas *label = CCBitmapFontAtlas::bitmapFontAtlasWithString("abcdefg", "fonts/bitmapFontTest4.fnt");
|
||||
CCLabelBMFont *label = CCLabelBMFont::bitmapFontAtlasWithString("abcdefg", "fonts/bitmapFontTest4.fnt");
|
||||
addChild(label);
|
||||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
@ -522,7 +522,7 @@ Atlas5::Atlas5()
|
|||
|
||||
std::string Atlas5::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string Atlas5::subtitle()
|
||||
|
@ -539,18 +539,18 @@ Atlas6::Atlas6()
|
|||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCBitmapFontAtlas* label = NULL;
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
|
||||
CCLabelBMFont* label = NULL;
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, s.height/2+50) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) ) ;
|
||||
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("fafefifofu", "fonts/bitmapFontTest5.fnt");
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("fafefifofu", "fonts/bitmapFontTest5.fnt");
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, s.height/2) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("aeiou", "fonts/bitmapFontTest5.fnt");
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("aeiou", "fonts/bitmapFontTest5.fnt");
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, s.height/2-50) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
|
@ -558,7 +558,7 @@ Atlas6::Atlas6()
|
|||
|
||||
std::string Atlas6::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string Atlas6::subtitle()
|
||||
|
@ -583,20 +583,20 @@ AtlasBitmapColor::AtlasBitmapColor()
|
|||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCBitmapFontAtlas* label = NULL;
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("Blue", "fonts/bitmapFontTest5.fnt");
|
||||
CCLabelBMFont* label = NULL;
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("Blue", "fonts/bitmapFontTest5.fnt");
|
||||
label->setColor( ccBLUE );
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, s.height/4) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("Red", "fonts/bitmapFontTest5.fnt");
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("Red", "fonts/bitmapFontTest5.fnt");
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, 2*s.height/4) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
label->setColor( ccRED );
|
||||
|
||||
label = CCBitmapFontAtlas::bitmapFontAtlasWithString("G", "fonts/bitmapFontTest5.fnt");
|
||||
label = CCLabelBMFont::bitmapFontAtlasWithString("G", "fonts/bitmapFontTest5.fnt");
|
||||
addChild(label);
|
||||
label->setPosition( ccp(s.width/2, 3*s.height/4) );
|
||||
label->setAnchorPoint( ccp(0.5f, 0.5f) );
|
||||
|
@ -606,7 +606,7 @@ AtlasBitmapColor::AtlasBitmapColor()
|
|||
|
||||
std::string AtlasBitmapColor::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string AtlasBitmapColor::subtitle()
|
||||
|
@ -627,7 +627,7 @@ AtlasFastBitmap::AtlasFastBitmap()
|
|||
{
|
||||
char str[6] = {0};
|
||||
sprintf(str, "-%d-", i);
|
||||
CCBitmapFontAtlas* label = CCBitmapFontAtlas::bitmapFontAtlasWithString(str, "fonts/bitmapFontTest.fnt");
|
||||
CCLabelBMFont* label = CCLabelBMFont::bitmapFontAtlasWithString(str, "fonts/bitmapFontTest.fnt");
|
||||
addChild(label);
|
||||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
@ -640,12 +640,12 @@ AtlasFastBitmap::AtlasFastBitmap()
|
|||
|
||||
std::string AtlasFastBitmap::title()
|
||||
{
|
||||
return "CCBitmapFontAtlas";
|
||||
return "CCLabelBMFont";
|
||||
}
|
||||
|
||||
std::string AtlasFastBitmap::subtitle()
|
||||
{
|
||||
return "Creating several CCBitmapFontAtlas with the same .fnt file should be fast";
|
||||
return "Creating several CCLabelBMFont with the same .fnt file should be fast";
|
||||
}
|
||||
|
||||
void AtlasTestScene::runThisTest()
|
||||
|
|
|
@ -78,7 +78,7 @@ Box2DTestLayer::Box2DTestLayer()
|
|||
|
||||
addNewSpriteWithCoords( CGPointMake(screenSize.width/2, screenSize.height/2) );
|
||||
|
||||
CCLabel *label = CCLabel::labelWithString("Tap screen", "Marker Felt", 32);
|
||||
CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32);
|
||||
addChild(label, 0);
|
||||
label->setColor( ccc3(0,0,255) );
|
||||
label->setPosition( CGPointMake( screenSize.width/2, screenSize.height-50) );
|
||||
|
|
|
@ -58,7 +58,7 @@ bool MenuLayer::initWithEntryID(int entryId)
|
|||
view->setAnchorPoint( ccp(0,0) );
|
||||
view->setPosition( ccp(s.width/2, s.height/3) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(view->title().c_str(), "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(view->title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -426,7 +426,7 @@ void ChipmunkTestLayer::init()
|
|||
|
||||
runDemo(demos[firstDemoIndex]);
|
||||
|
||||
label = CCLabel::labelWithString(demos[firstDemoIndex]->name, "Arial", 32);
|
||||
label = CCLabelTTF::labelWithString(demos[firstDemoIndex]->name, "Arial", 32);
|
||||
label->setPosition( ccp(0, -300) );
|
||||
label->setColor(ccBLACK);
|
||||
addChild(label);
|
||||
|
|
|
@ -63,7 +63,7 @@ class ChipmunkTestLayer : public CCLayer
|
|||
protected:
|
||||
std::string m_strTitle;
|
||||
int demoIndex;
|
||||
CCLabel *label;
|
||||
CCLabelTTF *label;
|
||||
|
||||
public:
|
||||
void init();
|
||||
|
|
|
@ -97,14 +97,14 @@ void TestCocosNodeDemo::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( CGPointMake(s.width/2, s.height-80) );
|
||||
}
|
||||
|
|
|
@ -653,7 +653,7 @@ void EaseSpriteDemo::onEnter()
|
|||
m_kathia->setPosition( CGPointMake(60, 150) );
|
||||
m_tamara->setPosition( CGPointMake(60, 250) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ void EffectAdvanceTextLayer::onEnter(void)
|
|||
CCActionInterval* sc2_back = sc2->reverse();
|
||||
tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Marker Felt", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28);
|
||||
|
||||
label->setPosition( ccp(x/2,y-80) );
|
||||
addChild(label);
|
||||
|
@ -328,7 +328,7 @@ void EffectAdvanceTextLayer::onEnter(void)
|
|||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 101);
|
||||
l->setPosition( ccp(size.width/2, size.height-80) );
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ TextLayer::TextLayer(void)
|
|||
CCActionInterval* sc2_back = sc2->reverse();
|
||||
tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL))) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
|
||||
|
||||
label->setPosition( CGPointMake(x/2,y-80) );
|
||||
addChild(label);
|
||||
|
|
|
@ -24,11 +24,11 @@ IntervalLayer::IntervalLayer()
|
|||
this->addChild(sun);
|
||||
|
||||
// timers
|
||||
m_label0 = CCBitmapFontAtlas::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label1 = CCBitmapFontAtlas::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label2 = CCBitmapFontAtlas::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label3 = CCBitmapFontAtlas::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label4 = CCBitmapFontAtlas::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label0 = CCLabelBMFont::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label1 = CCLabelBMFont::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label2 = CCLabelBMFont::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label3 = CCLabelBMFont::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
m_label4 = CCLabelBMFont::bitmapFontAtlasWithString("0", "fonts/bitmapFontTest4.fnt");
|
||||
|
||||
scheduleUpdate();
|
||||
schedule(schedule_selector(IntervalLayer::step1));
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
class IntervalLayer : public CCLayer
|
||||
{
|
||||
protected:
|
||||
CCBitmapFontAtlas* m_label0;
|
||||
CCBitmapFontAtlas* m_label1;
|
||||
CCBitmapFontAtlas* m_label2;
|
||||
CCBitmapFontAtlas* m_label3;
|
||||
CCBitmapFontAtlas* m_label4;
|
||||
CCLabelBMFont* m_label0;
|
||||
CCLabelBMFont* m_label1;
|
||||
CCLabelBMFont* m_label2;
|
||||
CCLabelBMFont* m_label3;
|
||||
CCLabelBMFont* m_label4;
|
||||
|
||||
ccTime m_time0, m_time1, m_time2, m_time3, m_time4;
|
||||
|
||||
|
|
|
@ -4,18 +4,18 @@ KeypadTest::KeypadTest()
|
|||
: m_bShow(true)
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel* label = CCLabel::labelWithString("Keypad Test", "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("Keypad Test", "Arial", 28);
|
||||
addChild(label, 0);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
CCLabel* subtitle = CCLabel::labelWithString("only goes well in cocos2d-uphone now!", "Arial", 18);
|
||||
CCLabelTTF* subtitle = CCLabelTTF::labelWithString("only goes well in cocos2d-uphone now!", "Arial", 18);
|
||||
addChild(subtitle, 0);
|
||||
subtitle->setPosition( ccp(s.width/2, s.height-100) );
|
||||
|
||||
setIsKeypadEnabled(true);
|
||||
|
||||
// create a label to display the tip string
|
||||
m_pLabel = CCLabel::labelWithString("Key Back Clicked!", "Arial", 22);
|
||||
m_pLabel = CCLabelTTF::labelWithString("Key Back Clicked!", "Arial", 22);
|
||||
m_pLabel->setPosition(ccp(s.width / 2, s.height / 2));
|
||||
addChild(m_pLabel, 0);
|
||||
m_pLabel->setIsVisible(false);
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
virtual void keyBackClicked();
|
||||
|
||||
private:
|
||||
CCLabel* m_pLabel;
|
||||
CCLabelTTF* m_pLabel;
|
||||
bool m_bShow;
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void LayerTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ MenuLayer1::MenuLayer1()
|
|||
CCMenuItem *item4 = CCMenuItemFont::itemFromString("I toggle enable items", this, menu_selector(MenuLayer1::menuCallbackEnable) );
|
||||
|
||||
// Label Item (BitmapFontAtlas)
|
||||
CCBitmapFontAtlas* label = CCBitmapFontAtlas::bitmapFontAtlasWithString("configuration", "fonts/bitmapFontTest3.fnt");
|
||||
CCLabelBMFont* label = CCLabelBMFont::bitmapFontAtlasWithString("configuration", "fonts/bitmapFontTest3.fnt");
|
||||
CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer1::menuCallbackConfig));
|
||||
|
||||
// Testing issue #500
|
||||
|
@ -257,7 +257,7 @@ MenuLayer3::MenuLayer3()
|
|||
CCMenuItemFont::setFontName("Marker Felt");
|
||||
CCMenuItemFont::setFontSize(28);
|
||||
|
||||
CCBitmapFontAtlas* label = CCBitmapFontAtlas::bitmapFontAtlasWithString("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
|
||||
CCLabelBMFont* label = CCLabelBMFont::bitmapFontAtlasWithString("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
|
||||
CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer3::menuCallback2) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::itemFromString("--- Go Back ---", this, menu_selector(MenuLayer3::menuCallback) );
|
||||
|
||||
|
@ -387,7 +387,7 @@ MenuLayer4::MenuLayer4()
|
|||
CCMenuItemFont::setFontName( "Marker Felt" );
|
||||
CCMenuItemFont::setFontSize( 34 );
|
||||
|
||||
CCBitmapFontAtlas *label = CCBitmapFontAtlas::bitmapFontAtlasWithString( "go back", "fonts/bitmapFontTest3.fnt" );
|
||||
CCLabelBMFont *label = CCLabelBMFont::bitmapFontAtlasWithString( "go back", "fonts/bitmapFontTest3.fnt" );
|
||||
CCMenuItemLabel* back = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer4::backCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::menuWithItems(
|
||||
|
|
|
@ -164,7 +164,7 @@ void MotionStreakTest::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ void ParallaxDemo::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ParticleTest.h"
|
||||
// #include "CCActionInterval.h"
|
||||
// #include "CCMenu.h"
|
||||
// #include "CCLabel.h"
|
||||
// #include "CCLabelTTF.h"
|
||||
// #include "CCLabelAtlas.h"
|
||||
// #include "touch_dispatcher/CCTouchDispatcher.h"
|
||||
#include "../testResource.h"
|
||||
|
@ -1049,11 +1049,11 @@ ParticleDemo::ParticleDemo(void)
|
|||
setIsTouchEnabled( true );
|
||||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
|
||||
addChild(label, 100, 1000);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
CCLabel *tapScreen = CCLabel::labelWithString("(Tap the Screen)", "Arial", 20);
|
||||
CCLabelTTF *tapScreen = CCLabelTTF::labelWithString("(Tap the Screen)", "Arial", 20);
|
||||
tapScreen->setPosition( CGPointMake(s.width/2, s.height-80) );
|
||||
addChild(tapScreen, 100);
|
||||
|
||||
|
@ -1105,7 +1105,7 @@ void ParticleDemo::onEnter(void)
|
|||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCLabel* pLabel = (CCLabel*)(this->getChildByTag(1000));
|
||||
CCLabelTTF* pLabel = (CCLabelTTF*)(this->getChildByTag(1000));
|
||||
pLabel->setString(title().c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -86,14 +86,14 @@ void SpriteDemo::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 18);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 18);
|
||||
addChild(label, 1);
|
||||
label->setPosition( CGPointMake(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 22);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 22);
|
||||
addChild(l, 1);
|
||||
l->setPosition( CGPointMake(s.width/2, s.height-80) );
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
RenderTextureTest::RenderTextureTest()
|
||||
{
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
CCLabel* label = CCLabel::labelWithString("Render Texture Test", "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("Render Texture Test", "Arial", 28);
|
||||
addChild(label, 0);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ void TestLayer::onEnter()
|
|||
//NSArray *array = [UIFont familyNames];
|
||||
//for( NSString *s in array )
|
||||
// NSLog( s );
|
||||
CCLabel* label = CCLabel::labelWithString("cocos2d", "Tahoma", 64);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("cocos2d", "Tahoma", 64);
|
||||
|
||||
label->setPosition( CGPointMake(x/2,y/2) );
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ void SceneTestLayer2::onReplaceSceneTran(NSObject* pSender)
|
|||
SceneTestLayer3::SceneTestLayer3()
|
||||
{
|
||||
setIsTouchEnabled( true );
|
||||
CCLabel* label = CCLabel::labelWithString("Touch to popScene", "Marker Felt", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("Touch to popScene", "Marker Felt", 28);
|
||||
addChild(label);
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
label->setPosition( CGPointMake(s.width/2, s.height/2) );
|
||||
|
|
|
@ -72,14 +72,14 @@ void SchedulerTestLayer::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 32);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||
addChild(label);
|
||||
label->setPosition(ccp(s.width/2, s.height-50));
|
||||
|
||||
std::string subTitle = subtitle();
|
||||
if(! subTitle.empty())
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(subTitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition(ccp(s.width/2, s.height-80));
|
||||
}
|
||||
|
|
|
@ -140,14 +140,14 @@ void SpriteTestDemo::onEnter()
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString(title().c_str(), "Arial", 28);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
}
|
||||
|
|
|
@ -1189,7 +1189,7 @@ TileDemo::TileDemo(void)
|
|||
|
||||
CGSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
m_label = CCLabel::labelWithString("", "Arial", 28);
|
||||
m_label = CCLabelTTF::labelWithString("", "Arial", 28);
|
||||
addChild(m_label, 1);
|
||||
m_label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
m_label->retain();
|
||||
|
@ -1197,7 +1197,7 @@ TileDemo::TileDemo(void)
|
|||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabel* l = CCLabel::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
class TileDemo : public CCLayer
|
||||
{
|
||||
protected:
|
||||
CCLabel* m_label;
|
||||
CCLabel* m_subtitle;
|
||||
CCLabelTTF* m_label;
|
||||
CCLabelTTF* m_subtitle;
|
||||
|
||||
public:
|
||||
TileDemo(void);
|
||||
|
|
|
@ -253,12 +253,12 @@ TestLayer1::TestLayer1(void)
|
|||
bg1->setPosition( CGPointMake(size.width/2, size.height/2) );
|
||||
addChild(bg1, -1);
|
||||
|
||||
CCLabel* title = CCLabel::labelWithString( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
||||
CCLabelTTF* title = CCLabelTTF::labelWithString( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
||||
addChild(title);
|
||||
title->setColor( ccc3(255,32,32) );
|
||||
title->setPosition( CGPointMake(x/2, y-100) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString("SCENE 1", "Marker Felt", 38);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("SCENE 1", "Marker Felt", 38);
|
||||
label->setColor( ccc3(16,16,255));
|
||||
label->setPosition( CGPointMake(x/2,y/2));
|
||||
addChild( label);
|
||||
|
@ -358,12 +358,12 @@ TestLayer2::TestLayer2()
|
|||
bg1->setPosition( CGPointMake(size.width/2, size.height/2) );
|
||||
addChild(bg1, -1);
|
||||
|
||||
CCLabel* title = CCLabel::labelWithString((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
||||
CCLabelTTF* title = CCLabelTTF::labelWithString((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 );
|
||||
addChild(title);
|
||||
title->setColor( ccc3(255,32,32) );
|
||||
title->setPosition( CGPointMake(x/2, y-100) );
|
||||
|
||||
CCLabel* label = CCLabel::labelWithString("SCENE 2", "Marker Felt", 38);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("SCENE 2", "Marker Felt", 38);
|
||||
label->setColor( ccc3(16,16,255));
|
||||
label->setPosition( CGPointMake(x/2,y/2));
|
||||
addChild( label);
|
||||
|
|
|
@ -98,7 +98,7 @@ TestController::TestController()
|
|||
// add menu items for tests
|
||||
for (int i = 0; i < ITEM_EVERYPAGE; ++i)
|
||||
{
|
||||
CCLabel* label = CCLabel::labelWithString("For Test", "Arial", 24);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("For Test", "Arial", 24);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestController::menuCallback));
|
||||
pMenu->addChild(pMenuItem, i + 2);
|
||||
pMenuItem->setPosition( CGPointMake( s.width / 2, (s.height - (i + 1) * LINE_SPACE) ));
|
||||
|
@ -116,12 +116,12 @@ TestController::TestController()
|
|||
updateItemsText();
|
||||
|
||||
// add menu item to change the page-number
|
||||
CCLabel* pPreLabel = CCLabel::labelWithString("PrePage", "Arial", 22);
|
||||
CCLabelTTF* pPreLabel = CCLabelTTF::labelWithString("PrePage", "Arial", 22);
|
||||
CCMenuItemLabel* pPreItem = CCMenuItemLabel::itemWithLabel(pPreLabel, this, menu_selector(TestController::prePageCallback));
|
||||
pMenu->addChild(pPreItem, ITEM_EVERYPAGE + 2);
|
||||
pPreItem->setPosition(CGPointMake(s.width - 150, 20));
|
||||
|
||||
CCLabel* pNextLabel = CCLabel::labelWithString("NextPage", "Arial", 22);
|
||||
CCLabelTTF* pNextLabel = CCLabelTTF::labelWithString("NextPage", "Arial", 22);
|
||||
CCMenuItemLabel* pNextItem = CCMenuItemLabel::itemWithLabel(pNextLabel, this, menu_selector(TestController::nextPageCallback));
|
||||
pMenu->addChild(pNextItem, ITEM_EVERYPAGE + 3);
|
||||
pNextItem->setPosition(CGPointMake(s.width - 50, 20));
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
BackToMainMenuLayer::BackToMainMenuLayer()
|
||||
{
|
||||
//add the menu item for back to main menu
|
||||
CCLabel* label = CCLabel::labelWithString("MainMenu", "Arial", 20);
|
||||
CCLabelTTF* label = CCLabelTTF::labelWithString("MainMenu", "Arial", 20);
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(BackToMainMenuLayer::MainMenuCallback));
|
||||
|
||||
CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL);
|
||||
|
|
Loading…
Reference in New Issue