Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into cocos-console-test

This commit is contained in:
shujunqiao 2014-03-28 17:50:29 +08:00
commit 9ffb26fdc9
22 changed files with 184 additions and 87 deletions

View File

@ -1 +1 @@
a3a8c79daf8c98f2aea9b8ed339e11ff81a0f1ce
2edbaaa897088877d60090c2c8fc6725e699e4ee

View File

@ -676,9 +676,9 @@ CC_DEPRECATED_ATTRIBUTE typedef GridBase CCGridBase;
CC_DEPRECATED_ATTRIBUTE typedef Grid3D CCGrid3D;
CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3D CCTiledGrid3D;
CC_DEPRECATED_ATTRIBUTE typedef Sprite CCSprite;
CC_DEPRECATED_ATTRIBUTE typedef LabelTTF CCLabelTTF;
#define CCLabelTTF LabelTTF
CC_DEPRECATED_ATTRIBUTE typedef SpriteBatchNode CCSpriteBatchNode;
CC_DEPRECATED_ATTRIBUTE typedef LabelBMFont CCLabelBMFont;
#define CCLabelBMFont LabelBMFont
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer;
//CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate;
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayerRGBA;

View File

@ -59,91 +59,91 @@ FontAtlas * FontAtlasCache::getFontAtlasTTF(const TTFConfig & config)
fontSize = Label::DistanceFieldFontSize / contentScaleFactor;
}
std::string atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField);
auto atlasName = generateFontName(config.fontFilePath, fontSize, GlyphCollection::DYNAMIC, useDistanceField);
atlasName.append("_outline_");
std::stringstream ss;
ss << config.outlineSize;
atlasName.append(ss.str());
FontAtlas *tempAtlas = _atlasMap[atlasName];
auto it = _atlasMap.find(atlasName);
if ( !tempAtlas )
if ( it == _atlasMap.end() )
{
FontFreeType *font = FontFreeType::create(config.fontFilePath, fontSize * contentScaleFactor, config.glyphs,
auto font = FontFreeType::create(config.fontFilePath, fontSize * contentScaleFactor, config.glyphs,
config.customGlyphs,useDistanceField,config.outlineSize * contentScaleFactor);
if (font)
{
tempAtlas = font->createFontAtlas();
auto tempAtlas = font->createFontAtlas();
if (tempAtlas)
{
_atlasMap[atlasName] = tempAtlas;
}
else
{
return nullptr;
return _atlasMap[atlasName];
}
}
}
else
{
tempAtlas->retain();
_atlasMap[atlasName]->retain();
return _atlasMap[atlasName];
}
return tempAtlas;
return nullptr;
}
FontAtlas * FontAtlasCache::getFontAtlasFNT(const std::string& fontFileName, const Point& imageOffset /* = Point::ZERO */)
{
std::string atlasName = generateFontName(fontFileName, 0, GlyphCollection::CUSTOM,false);
FontAtlas *tempAtlas = _atlasMap[atlasName];
if ( !tempAtlas )
auto it = _atlasMap.find(atlasName);
if ( it == _atlasMap.end() )
{
Font *font = FontFNT::create(fontFileName,imageOffset);
auto font = FontFNT::create(fontFileName,imageOffset);
if(font)
{
tempAtlas = font->createFontAtlas();
auto tempAtlas = font->createFontAtlas();
if (tempAtlas)
{
_atlasMap[atlasName] = tempAtlas;
}
else
{
return nullptr;
return _atlasMap[atlasName];
}
}
}
else
{
tempAtlas->retain();
_atlasMap[atlasName]->retain();
return _atlasMap[atlasName];
}
return tempAtlas;
return nullptr;
}
FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& plistFile)
{
std::string atlasName = generateFontName(plistFile, 0, GlyphCollection::CUSTOM,false);
FontAtlas *tempAtlas = _atlasMap[atlasName];
auto it = _atlasMap.find(atlasName);
if ( !tempAtlas )
if ( it == _atlasMap.end() )
{
Font *font = FontCharMap::create(plistFile);
auto font = FontCharMap::create(plistFile);
if(font)
{
tempAtlas = font->createFontAtlas();
auto tempAtlas = font->createFontAtlas();
if (tempAtlas)
{
_atlasMap[atlasName] = tempAtlas;
}
else
{
return nullptr;
return _atlasMap[atlasName];
}
}
}
else
{
tempAtlas->retain();
_atlasMap[atlasName]->retain();
return _atlasMap[atlasName];
}
return tempAtlas;
return nullptr;
}
FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap)
@ -151,57 +151,57 @@ FontAtlas * FontAtlasCache::getFontAtlasCharMap(Texture2D* texture, int itemWidt
char tmp[30];
sprintf(tmp,"name:%u_%d_%d_%d",texture->getName(),itemWidth,itemHeight,startCharMap);
std::string atlasName = generateFontName(tmp, 0, GlyphCollection::CUSTOM,false);
FontAtlas *tempAtlas = _atlasMap[atlasName];
if ( !tempAtlas )
auto it = _atlasMap.find(atlasName);
if ( it == _atlasMap.end() )
{
Font *font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap);
auto font = FontCharMap::create(texture,itemWidth,itemHeight,startCharMap);
if(font)
{
tempAtlas = font->createFontAtlas();
auto tempAtlas = font->createFontAtlas();
if (tempAtlas)
{
_atlasMap[atlasName] = tempAtlas;
}
else
{
return nullptr;
return _atlasMap[atlasName];
}
}
}
else
{
tempAtlas->retain();
_atlasMap[atlasName]->retain();
return _atlasMap[atlasName];
}
return tempAtlas;
return nullptr;
}
FontAtlas * FontAtlasCache::getFontAtlasCharMap(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
std::string atlasName = generateFontName(charMapFile, 0, GlyphCollection::CUSTOM,false);
FontAtlas *tempAtlas = _atlasMap[atlasName];
if ( !tempAtlas )
auto it = _atlasMap.find(atlasName);
if ( it == _atlasMap.end() )
{
Font *font = FontCharMap::create(charMapFile,itemWidth,itemHeight,startCharMap);
auto font = FontCharMap::create(charMapFile,itemWidth,itemHeight,startCharMap);
if(font)
{
tempAtlas = font->createFontAtlas();
auto tempAtlas = font->createFontAtlas();
if (tempAtlas)
{
_atlasMap[atlasName] = tempAtlas;
}
else
{
return nullptr;
return _atlasMap[atlasName];
}
}
}
else
{
tempAtlas->retain();
_atlasMap[atlasName]->retain();
return _atlasMap[atlasName];
}
return tempAtlas;
return nullptr;
}
std::string FontAtlasCache::generateFontName(const std::string& fontFileName, int size, GlyphCollection theGlyphs, bool useDistanceField)

View File

@ -1361,7 +1361,7 @@ const Size& Label::getContentSize() const
{
const_cast<Label*>(this)->updateContent();
}
return Node::getContentSize();
return _contentSize;
}
Rect Label::getBoundingBox() const

View File

@ -243,7 +243,7 @@ public:
virtual const Size& getContentSize() const override;
virtual Rect getBoundingBox() const;
virtual Rect getBoundingBox() const override;
FontAtlas* getFontAtlas() { return _fontAtlas; }
/** Listen "come to background" message

View File

@ -38,6 +38,13 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
using namespace std;
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
NS_CC_BEGIN
LabelBMFont * LabelBMFont::create()
@ -174,6 +181,27 @@ Node* LabelBMFont::getChildByTag(int tag)
return _label->getLetter(tag);
}
Sprite* LabelBMFont::getLetter(int ID)
{
return _label->getLetter(ID);
}
void LabelBMFont::setColor(const Color3B& color)
{
_label->setColor(color);
}
const Size& LabelBMFont::getContentSize() const
{
const_cast<LabelBMFont*>(this)->setContentSize(_label->getContentSize());
return _contentSize;
}
Rect LabelBMFont::getBoundingBox() const
{
return _label->getBoundingBox();
}
//LabelBMFont - Debug draw
#if CC_LABELBMFONT_DEBUG_DRAW
void LabelBMFont::draw()
@ -188,4 +216,10 @@ void LabelBMFont::draw()
#endif // CC_LABELBMFONT_DEBUG_DRAW
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif
NS_CC_END

View File

@ -68,7 +68,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
@since v0.8
*/
class CC_DLL LabelBMFont : public Node, public LabelProtocol, public BlendProtocol
class CC_DLL CC_DEPRECATED_ATTRIBUTE LabelBMFont : public Node, public LabelProtocol, public BlendProtocol
{
public:
/**
@ -111,10 +111,13 @@ public:
virtual const BlendFunc &getBlendFunc() const override;
virtual Sprite * getLetter(int ID) { return _label->getLetter(ID);}
virtual Sprite * getLetter(int ID);
virtual Node * getChildByTag(int tag) override;
virtual void setColor(const Color3B& color) override { _label->setColor(color);}
virtual void setColor(const Color3B& color) override;
virtual const Size& getContentSize() const override;
virtual Rect getBoundingBox() const override;
virtual std::string getDescription() const override;

View File

@ -29,6 +29,13 @@ THE SOFTWARE.
NS_CC_BEGIN
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
LabelTTF::LabelTTF()
{
_renderLabel = Label::create();
@ -271,4 +278,15 @@ const Size& LabelTTF::getContentSize() const
return _contentSize;
}
Rect LabelTTF::getBoundingBox() const
{
return _renderLabel->getBoundingBox();
}
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif
NS_CC_END

View File

@ -56,7 +56,7 @@ class Label;
* @endcode
*
*/
class CC_DLL LabelTTF : public Node, public LabelProtocol, public BlendProtocol
class CC_DLL CC_DEPRECATED_ATTRIBUTE LabelTTF : public Node, public LabelProtocol, public BlendProtocol
{
public:
/**
@ -143,6 +143,8 @@ public:
virtual void setFlippedX(bool flippedX);
virtual void setFlippedY(bool flippedY);
virtual Rect getBoundingBox() const override;
/**
* @js NA
* @lua NA

View File

@ -154,15 +154,12 @@ Node::~Node()
}
#endif
CC_SAFE_RELEASE_NULL(_actionManager);
CC_SAFE_RELEASE_NULL(_scheduler);
_eventDispatcher->removeEventListenersForTarget(this);
// User object has to be released before others, since userObject may have a weak reference of this node
// It may invoke `node->stopAllAction();` while `_actionManager` is null if the next line is after `CC_SAFE_RELEASE_NULL(_actionManager)`.
CC_SAFE_RELEASE_NULL(_userObject);
// attributes
CC_SAFE_RELEASE_NULL(_shaderProgram);
CC_SAFE_RELEASE_NULL(_userObject);
for (auto& child : _children)
{
@ -177,7 +174,12 @@ Node::~Node()
setPhysicsBody(nullptr);
#endif
CC_SAFE_RELEASE_NULL(_actionManager);
CC_SAFE_RELEASE_NULL(_scheduler);
_eventDispatcher->removeEventListenersForTarget(this);
#if CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS && COCOS2D_DEBUG > 0
_eventDispatcher->debugCheckNodeHasNoEventListenersOnDestruction(this);
#endif

View File

@ -624,6 +624,12 @@ void ParticleSystem::onEnter()
this->scheduleUpdateWithPriority(1);
}
void ParticleSystem::onExit()
{
this->unscheduleUpdate();
Node::onExit();
}
void ParticleSystem::stopSystem()
{
_isActive = false;

View File

@ -191,7 +191,6 @@ public:
//! whether or not the system is full
bool isFull();
virtual void onEnter();
//! should be overridden by subclasses
virtual void updateQuadWithParticle(tParticle* particle, const Point& newPosition);
//! should be overridden by subclasses
@ -355,6 +354,8 @@ public:
inline void setPositionType(PositionType type) { _positionType = type; };
// Overrides
virtual void onEnter() override;
virtual void onExit() override;
virtual void update(float dt) override;
virtual Texture2D* getTexture() const override;
virtual void setTexture(Texture2D *texture) override;

View File

@ -94,11 +94,6 @@
-- @param self
-- @return FontDefinition#FontDefinition ret (return value: cc.FontDefinition)
--------------------------------
-- @function [parent=#Label] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#Label] getFontName
-- @param self
@ -343,6 +338,11 @@
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#Label] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#Label] updateDisplayedColor
-- @param self

View File

@ -89,6 +89,11 @@
-- @param #point_table point
-- @return LabelBMFont#LabelBMFont ret (retunr value: cc.LabelBMFont)
--------------------------------
-- @function [parent=#LabelBMFont] getBoundingBox
-- @param self
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#LabelBMFont] getDescription
-- @param self
@ -105,6 +110,11 @@
-- @param #int int
-- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#LabelBMFont] getContentSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#LabelBMFont] LabelBMFont
-- @param self

View File

@ -163,11 +163,9 @@
-- @return LabelTTF#LabelTTF ret (return value: cc.LabelTTF)
--------------------------------
-- @function [parent=#LabelTTF] visit
-- @function [parent=#LabelTTF] getBoundingBox
-- @param self
-- @param #cc.Renderer renderer
-- @param #kmMat4 kmmat4
-- @param #bool bool
-- @return rect_table#rect_table ret (return value: rect_table)
--------------------------------
-- @function [parent=#LabelTTF] getDescription
@ -179,6 +177,13 @@
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#LabelTTF] visit
-- @param self
-- @param #cc.Renderer renderer
-- @param #kmMat4 kmmat4
-- @param #bool bool
--------------------------------
-- @function [parent=#LabelTTF] LabelTTF
-- @param self

View File

@ -406,9 +406,9 @@
-- @return color4F_table#color4F_table ret (return value: color4F_table)
--------------------------------
-- @function [parent=#ParticleSystem] getEndColor
-- @function [parent=#ParticleSystem] getRotationIsDir
-- @param self
-- @return color4F_table#color4F_table ret (return value: color4F_table)
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#ParticleSystem] setScale
@ -421,9 +421,9 @@
-- @return float#float ret (return value: float)
--------------------------------
-- @function [parent=#ParticleSystem] getRotationIsDir
-- @function [parent=#ParticleSystem] getEndColor
-- @param self
-- @return bool#bool ret (return value: bool)
-- @return color4F_table#color4F_table ret (return value: color4F_table)
--------------------------------
-- @function [parent=#ParticleSystem] getLifeVar

View File

@ -1 +1 @@
506177408f7bc44ccba9d2518adbf47e8994bc83
55307bad4398fdd7bedf9a96f00adb57cbaa7d2e

View File

@ -1561,7 +1561,6 @@ int register_all_cocos2dx(lua_State* tolua_S);
#endif // __cocos2dx_h__

View File

@ -28,7 +28,6 @@
#include "CCControlButton.h"
#include "CCScale9Sprite.h"
#include "CCLabel.h"
#include "CCLabelBMFont.h"
#include "CCAction.h"
#include "CCActionInterval.h"

View File

@ -1495,7 +1495,7 @@ LabelTTFOldNew::LabelTTFOldNew()
auto s = Director::getInstance()->getWinSize();
float delta = s.height/4;
auto label1 = LabelTTF::create("Cocos2d-x Label Test", "arial", 24);
auto label1 = Label::create("Cocos2d-x Label Test", "arial", 24);
addChild(label1, 0, kTagBitmapAtlas1);
label1->setPosition(Point(s.width/2, delta * 2));
label1->setColor(Color3B::RED);
@ -1511,7 +1511,7 @@ void LabelTTFOldNew::onDraw(const kmMat4 &transform, bool transformUpdated)
kmGLPushMatrix();
kmGLLoadMatrix(&transform);
auto label1 = (LabelTTF*)getChildByTag(kTagBitmapAtlas1);
auto label1 = (Label*)getChildByTag(kTagBitmapAtlas1);
auto labelSize = label1->getContentSize();
auto origin = Director::getInstance()->getWinSize();

View File

@ -24,6 +24,15 @@ THE SOFTWARE.
package org.cocos2dx.cpp_tests;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
public class AppActivity extends Cocos2dxActivity {
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// TestCpp should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceView;
}
}

View File

@ -1,6 +1,15 @@
package org.cocos2dx.lua_tests;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
public class AppActivity extends Cocos2dxActivity{
public Cocos2dxGLSurfaceView onCreateView() {
Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
// Tests should create stencil buffer
glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
return glSurfaceView;
}
}