mirror of https://github.com/axmolengine/axmol.git
fixed #1686:finish updating
This commit is contained in:
parent
0070371045
commit
63e4091bfa
|
@ -789,15 +789,11 @@ void CCDirector::getFPSImageData(unsigned char** datapointer, unsigned int* leng
|
|||
|
||||
void CCDirector::createStatsLabel()
|
||||
{
|
||||
CCTexture2D *texture;
|
||||
CCTextureCache *textureCache = CCTextureCache::sharedTextureCache();
|
||||
|
||||
if( m_pFPSLabel && m_pSPFLabel )
|
||||
{
|
||||
CC_SAFE_RELEASE_NULL(m_pFPSLabel);
|
||||
CC_SAFE_RELEASE_NULL(m_pSPFLabel);
|
||||
CC_SAFE_RELEASE_NULL(m_pDrawsLabel);
|
||||
textureCache->removeTextureForKey("cc_fps_images");
|
||||
CCFileUtils::sharedFileUtils()->purgeCachedEntries();
|
||||
}
|
||||
|
||||
|
@ -811,11 +807,11 @@ void CCDirector::createStatsLabel()
|
|||
fontSize = (int)(m_obWinSizeInPoints.width / 320.0f * 24);
|
||||
}
|
||||
|
||||
m_pFPSLabel = CCLabelAtlas::create("00.0", texture, 12, 32, '.');
|
||||
m_pFPSLabel = CCLabelTTF::create("00.0", "Arial", fontSize);
|
||||
m_pFPSLabel->retain();
|
||||
m_pSPFLabel = CCLabelAtlas::create("0.000", texture, 12, 32, '.');
|
||||
m_pSPFLabel = CCLabelTTF::create("0.000", "Arial", fontSize);
|
||||
m_pSPFLabel->retain();
|
||||
m_pDrawsLabel = CCLabelAtlas::create("000", texture, 12, 32, '.');
|
||||
m_pDrawsLabel = CCLabelTTF::create("000", "Arial", fontSize);
|
||||
m_pDrawsLabel->retain();
|
||||
|
||||
CCSize contentSize = m_pDrawsLabel->getContentSize();
|
||||
|
|
|
@ -357,9 +357,9 @@ protected:
|
|||
float m_fAccumDt;
|
||||
float m_fFrameRate;
|
||||
|
||||
CCLabelAtlas *m_pFPSLabel;
|
||||
CCLabelAtlas *m_pSPFLabel;
|
||||
CCLabelAtlas *m_pDrawsLabel;
|
||||
CCLabelTTF *m_pFPSLabel;
|
||||
CCLabelTTF *m_pSPFLabel;
|
||||
CCLabelTTF *m_pDrawsLabel;
|
||||
|
||||
/** Whether or not the Director is paused */
|
||||
bool m_bPaused;
|
||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCAtlasNode.h"
|
||||
#include "textures/CCTextureAtlas.h"
|
||||
#include "textures/CCTextureCache.h"
|
||||
#include "CCDirector.h"
|
||||
#include "shaders/CCGLProgram.h"
|
||||
#include "shaders/CCShaderCache.h"
|
||||
|
@ -136,7 +137,7 @@ void CCAtlasNode::draw(void)
|
|||
|
||||
ccGLBlendFunc( m_tBlendFunc.src, m_tBlendFunc.dst );
|
||||
|
||||
GLfloat colors[4] = {m_tColor.r / 255.0f, m_tColor.g / 255.0f, m_tColor.b / 255.0f, m_cOpacity / 255.0f};
|
||||
GLfloat colors[4] = {_displayedColor.r / 255.0f, _displayedColor.g / 255.0f, _displayedColor.b / 255.0f, _displayedOpacity / 255.0f};
|
||||
getShaderProgram()->setUniformLocationWith4fv(m_nUniformColor, colors, 1);
|
||||
|
||||
m_pTextureAtlas->drawNumberOfQuads(m_uQuadsToDraw, 0);
|
||||
|
@ -144,7 +145,7 @@ void CCAtlasNode::draw(void)
|
|||
|
||||
// CCAtlasNode - RGBA protocol
|
||||
|
||||
const ccColor3B& CCAtlasNode:: getColor()
|
||||
const ccColor3B& CCAtlasNode::getColor()
|
||||
{
|
||||
if(m_bIsOpacityModifyRGB)
|
||||
{
|
||||
|
@ -160,9 +161,9 @@ void CCAtlasNode::setColor(const ccColor3B& color3)
|
|||
|
||||
if( m_bIsOpacityModifyRGB )
|
||||
{
|
||||
tmp.r = tmp.r * m_displayedOpacity/255;
|
||||
tmp.g = tmp.g * m_displayedOpacity/255;
|
||||
tmp.b = tmp.b * m_displayedOpacity/255;
|
||||
tmp.r = tmp.r * _displayedOpacity/255;
|
||||
tmp.g = tmp.g * _displayedOpacity/255;
|
||||
tmp.b = tmp.b * _displayedOpacity/255;
|
||||
}
|
||||
CCNodeRGBA::setColor(tmp);
|
||||
}
|
||||
|
|
|
@ -68,8 +68,6 @@ protected:
|
|||
|
||||
// protocol variables
|
||||
bool m_bIsOpacityModifyRGB;
|
||||
bool isOpacityModifyRGB();
|
||||
void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
|
||||
CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc);
|
||||
|
||||
|
@ -106,6 +104,12 @@ public:
|
|||
/** sets a new texture. it will be retained*/
|
||||
virtual void setTexture(CCTexture2D *texture);
|
||||
|
||||
virtual bool isOpacityModifyRGB();
|
||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||
virtual const ccColor3B& getColor(void);
|
||||
virtual void setColor(const ccColor3B& color);
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
|
||||
private :
|
||||
void calculateMaxItems();
|
||||
void updateBlendFunc();
|
||||
|
|
|
@ -1267,8 +1267,8 @@ void CCNode::updateTransform()
|
|||
|
||||
// CCNodeRGBA
|
||||
CCNodeRGBA::CCNodeRGBA()
|
||||
: _displayedOpacity (0)
|
||||
, _realOpacity(0)
|
||||
: _displayedOpacity (255)
|
||||
, _realOpacity(255)
|
||||
, _displayedColor(ccc3(0,0,0))
|
||||
, _realColor(ccc3(0,0,0))
|
||||
, _cascadeColorEnabled(false)
|
||||
|
@ -1366,7 +1366,7 @@ void CCNodeRGBA::setColor(const ccColor3B& color)
|
|||
parentColor = parent->getDisplayedColor();
|
||||
}
|
||||
|
||||
CCRGBAProtocol::updateDisplayedColor(parentColor);
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
#include "CCLabelAtlas.h"
|
||||
#include "textures/CCTextureAtlas.h"
|
||||
#include "textures/CCTextureCache.h"
|
||||
#include "support/CCPointExtension.h"
|
||||
#include "draw_nodes/CCDrawingPrimitives.h"
|
||||
#include "ccConfig.h"
|
||||
|
@ -165,7 +166,7 @@ void CCLabelAtlas::updateAtlasValues()
|
|||
quad.tr.vertices.y = (float)(m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
ccColor4B c = { m_tDisplayedColor.r, m_tDisplayedColor.g, m_tDisplayedColor.b, m_cDisplayedOpacity };
|
||||
ccColor4B c = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
|
||||
quad.tl.colors = c;
|
||||
quad.tr.colors = c;
|
||||
quad.bl.colors = c;
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
virtual void updateAtlasValues();
|
||||
virtual void setString(const char *label);
|
||||
virtual const char* getString(void);
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
virtual void draw();
|
||||
#endif
|
||||
|
|
|
@ -489,6 +489,16 @@ void CCLayer::ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent)
|
|||
}
|
||||
|
||||
// LayerRGBA
|
||||
CCLayerRGBA::CCLayerRGBA()
|
||||
: _displayedOpacity(255)
|
||||
, _realOpacity (255)
|
||||
, _displayedColor(ccWHITE)
|
||||
, _realColor(ccWHITE)
|
||||
, _cascadeColorEnabled(false)
|
||||
, _cascadeOpacityEnabled(false)
|
||||
{}
|
||||
|
||||
CCLayerRGBA::~CCLayerRGBA() {}
|
||||
|
||||
bool CCLayerRGBA::init()
|
||||
{
|
||||
|
@ -530,7 +540,7 @@ void CCLayerRGBA::setOpacity(GLubyte opacity)
|
|||
{
|
||||
parentOpacity = parent->getDisplayedOpacity();
|
||||
}
|
||||
CCRGBAProtocol::updateDisplayedOpacity(parentOpacity);
|
||||
updateDisplayedOpacity(parentOpacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -557,7 +567,7 @@ void CCLayerRGBA::setColor(const ccColor3B& color)
|
|||
parentColor = parent->getDisplayedColor();
|
||||
}
|
||||
|
||||
CCRGBAProtocol::updateDisplayedColor(parentColor);
|
||||
updateDisplayedColor(parentColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,6 +609,26 @@ void CCLayerRGBA::updateDisplayedColor(const ccColor3B& parentColor)
|
|||
}
|
||||
}
|
||||
|
||||
bool CCLayerRGBA::isCascadeOpacityEnabled()
|
||||
{
|
||||
return _cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
void CCLayerRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||
{
|
||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||
}
|
||||
|
||||
bool CCLayerRGBA::isCascadeColorEnabled()
|
||||
{
|
||||
return _cascadeColorEnabled;
|
||||
}
|
||||
|
||||
void CCLayerRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
|
||||
{
|
||||
_cascadeColorEnabled = cascadeColorEnabled;
|
||||
}
|
||||
|
||||
/// CCLayerColor
|
||||
|
||||
CCLayerColor::CCLayerColor()
|
||||
|
|
|
@ -56,7 +56,7 @@ bool CCParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles
|
|||
return false;
|
||||
}
|
||||
|
||||
setupIndices();
|
||||
initIndices();
|
||||
#if CC_TEXTURE_ATLAS_USE_VAO
|
||||
setupVBOandVAO();
|
||||
#else
|
||||
|
|
|
@ -56,7 +56,6 @@ bool CCTileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int
|
|||
|
||||
if( CCAtlasNode::initWithTileFile(tile, tileWidth, tileHeight, m_nItemsToRender) )
|
||||
{
|
||||
m_tColor = ccWHITE;
|
||||
m_pPosToAtlasIndex = new CCDictionary();
|
||||
this->updateAtlasValues();
|
||||
this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_uItemWidth),
|
||||
|
@ -221,7 +220,7 @@ void CCTileMapAtlas::updateAtlasValueAt(const CCPoint& pos, const ccColor3B& val
|
|||
quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight);
|
||||
quad.tr.vertices.z = 0.0f;
|
||||
|
||||
ccColor4B color = { m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity };
|
||||
ccColor4B color = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
|
||||
quad.tr.colors = color;
|
||||
quad.tl.colors = color;
|
||||
quad.br.colors = color;
|
||||
|
|
|
@ -36,9 +36,7 @@
|
|||
NS_CC_EXT_BEGIN
|
||||
|
||||
CCControl::CCControl()
|
||||
: m_cOpacity(0)
|
||||
, m_tColor(ccBLACK)
|
||||
, m_bIsOpacityModifyRGB(false)
|
||||
: m_bIsOpacityModifyRGB(false)
|
||||
, m_nDefaultTouchPriority(0)
|
||||
, m_eState(CCControlStateNormal)
|
||||
, m_hasVisibleParents(false)
|
||||
|
@ -224,50 +222,6 @@ void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_CCCo
|
|||
|
||||
|
||||
//CRGBA protocol
|
||||
void CCControl::setColor(const ccColor3B& color)
|
||||
{
|
||||
m_tColor=color;
|
||||
CCObject* child;
|
||||
CCArray* children=getChildren();
|
||||
CCARRAY_FOREACH(children, child)
|
||||
{
|
||||
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
if (pNode)
|
||||
{
|
||||
pNode->setColor(m_tColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ccColor3B& CCControl::getColor(void)
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
|
||||
|
||||
void CCControl::setOpacity(GLubyte opacity)
|
||||
{
|
||||
m_cOpacity = opacity;
|
||||
|
||||
CCObject* child;
|
||||
CCArray* children=getChildren();
|
||||
CCARRAY_FOREACH(children, child)
|
||||
{
|
||||
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
if (pNode)
|
||||
{
|
||||
pNode->setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GLubyte CCControl::getOpacity()
|
||||
{
|
||||
return m_cOpacity;
|
||||
}
|
||||
|
||||
|
||||
void CCControl::setOpacityModifyRGB(bool bOpacityModifyRGB)
|
||||
{
|
||||
m_bIsOpacityModifyRGB=bOpacityModifyRGB;
|
||||
|
|
|
@ -85,15 +85,11 @@ typedef unsigned int CCControlState;
|
|||
*
|
||||
* To use the CCControl you have to subclass it.
|
||||
*/
|
||||
class CCControl : public CCLayer, public CCRGBAProtocol
|
||||
class CCControl : public CCLayerRGBA
|
||||
{
|
||||
|
||||
//CCRGBAProtocol
|
||||
CC_PROPERTY(GLubyte, m_cOpacity, Opacity);
|
||||
CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color);
|
||||
bool m_bIsOpacityModifyRGB;
|
||||
bool isOpacityModifyRGB();
|
||||
void setOpacityModifyRGB(bool bOpacityModifyRGB);
|
||||
|
||||
/** Changes the priority of the button. The lower the number, the higher the priority. */
|
||||
CC_SYNTHESIZE(int, m_nDefaultTouchPriority, DefaultTouchPriority);
|
||||
|
@ -120,6 +116,9 @@ public:
|
|||
*/
|
||||
virtual void needsLayout();
|
||||
|
||||
virtual bool isOpacityModifyRGB();
|
||||
virtual void setOpacityModifyRGB(bool bOpacityModifyRGB);
|
||||
|
||||
protected:
|
||||
bool m_bEnabled;
|
||||
bool m_bSelected;
|
||||
|
|
|
@ -689,18 +689,20 @@ void CCControlButton::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
|
|||
|
||||
void CCControlButton::setOpacity(GLubyte opacity)
|
||||
{
|
||||
m_cOpacity = opacity;
|
||||
|
||||
CCObject* child;
|
||||
CCArray* children=getChildren();
|
||||
CCARRAY_FOREACH(children, child)
|
||||
{
|
||||
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
if (pNode)
|
||||
{
|
||||
pNode->setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
// XXX fixed me if not correct
|
||||
CCControl::setOpacity(opacity);
|
||||
// m_cOpacity = opacity;
|
||||
//
|
||||
// CCObject* child;
|
||||
// CCArray* children=getChildren();
|
||||
// CCARRAY_FOREACH(children, child)
|
||||
// {
|
||||
// CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
// if (pNode)
|
||||
// {
|
||||
// pNode->setOpacity(opacity);
|
||||
// }
|
||||
// }
|
||||
CCDictElement * item = NULL;
|
||||
CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item)
|
||||
{
|
||||
|
@ -711,7 +713,7 @@ void CCControlButton::setOpacity(GLubyte opacity)
|
|||
|
||||
GLubyte CCControlButton::getOpacity()
|
||||
{
|
||||
return m_cOpacity;
|
||||
return _realOpacity;
|
||||
}
|
||||
|
||||
void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
|
||||
|
|
|
@ -134,7 +134,8 @@ CCControlColourPicker* CCControlColourPicker::create()
|
|||
|
||||
void CCControlColourPicker::setColor(const ccColor3B& color)
|
||||
{
|
||||
m_tColor = color;
|
||||
// XXX fixed me if not correct
|
||||
CCControl::setColor(color);
|
||||
|
||||
RGBA rgba;
|
||||
rgba.r = color.r / 255.0f;
|
||||
|
@ -181,7 +182,8 @@ void CCControlColourPicker::hueSliderValueChanged(CCObject * sender, CCControlEv
|
|||
|
||||
// Update the value
|
||||
RGBA rgb = CCControlUtils::RGBfromHSV(m_hsv);
|
||||
m_tColor= ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f));
|
||||
// XXX fixed me if not correct
|
||||
CCControl::setColor(ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||
|
||||
// Send CCControl callback
|
||||
sendActionsForControlEvents(CCControlEventValueChanged);
|
||||
|
@ -196,7 +198,8 @@ void CCControlColourPicker::colourSliderValueChanged(CCObject * sender, CCContro
|
|||
|
||||
// Update the value
|
||||
RGBA rgb = CCControlUtils::RGBfromHSV(m_hsv);
|
||||
m_tColor=ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f));
|
||||
// XXX fixed me if not correct
|
||||
CCControl::setColor(ccc3((GLubyte)(rgb.r * 255.0f), (GLubyte)(rgb.g * 255.0f), (GLubyte)(rgb.b * 255.0f)));
|
||||
|
||||
// Send CCControl callback
|
||||
sendActionsForControlEvents(CCControlEventValueChanged);
|
||||
|
|
|
@ -47,7 +47,6 @@ CCScale9Sprite::CCScale9Sprite()
|
|||
, m_insetTop(0)
|
||||
, m_insetRight(0)
|
||||
, m_insetBottom(0)
|
||||
, m_cOpacity(0)
|
||||
, m_bSpritesGenerated(false)
|
||||
, m_bSpriteFrameRotated(false)
|
||||
, m_positionsAreDirty(false)
|
||||
|
@ -110,8 +109,8 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect
|
|||
|
||||
bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets)
|
||||
{
|
||||
GLubyte opacity = m_cOpacity;
|
||||
ccColor3B color = m_tColor;
|
||||
GLubyte opacity = getOpacity();
|
||||
ccColor3B color = getColor();
|
||||
|
||||
// Release old sprites
|
||||
this->removeAllChildrenWithCleanup(true);
|
||||
|
@ -636,56 +635,10 @@ CCScale9Sprite* CCScale9Sprite::create()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//LabelBMFont - CCRGBAProtocol protocol
|
||||
void CCScale9Sprite::setColor(const ccColor3B& color3)
|
||||
{
|
||||
m_tColor = color3;
|
||||
if (scale9Image->getChildren() && scale9Image->getChildren()->count() != 0)
|
||||
{
|
||||
CCObject* child;
|
||||
CCARRAY_FOREACH(scale9Image->getChildren(), child)
|
||||
{
|
||||
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
if (pNode)
|
||||
{
|
||||
pNode->setColor(m_tColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ccColor3B& CCScale9Sprite::getColor(void)
|
||||
{
|
||||
return m_tColor;
|
||||
}
|
||||
|
||||
void CCScale9Sprite::setOpacity(GLubyte var)
|
||||
{
|
||||
m_cOpacity = var;
|
||||
|
||||
if (scale9Image->getChildren() && scale9Image->getChildren()->count() != 0)
|
||||
{
|
||||
CCObject* child;
|
||||
CCARRAY_FOREACH(scale9Image->getChildren(), child)
|
||||
{
|
||||
CCRGBAProtocol* pNode = dynamic_cast<CCRGBAProtocol*>(child);
|
||||
if (pNode)
|
||||
{
|
||||
pNode->setOpacity(m_cOpacity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** sets the opacity.
|
||||
@warning If the the texture has premultiplied alpha then, the R, G and B channels will be modifed.
|
||||
Values goes from 0 to 255, where 255 means fully opaque.
|
||||
*/
|
||||
GLubyte CCScale9Sprite::getOpacity()
|
||||
{
|
||||
return m_cOpacity;
|
||||
}
|
||||
|
||||
void CCScale9Sprite::setPreferredSize(CCSize preferedSize)
|
||||
{
|
||||
|
|
|
@ -40,7 +40,7 @@ NS_CC_EXT_BEGIN
|
|||
* @{
|
||||
*/
|
||||
|
||||
class CCScale9Sprite : public CCNode, public CCRGBAProtocol
|
||||
class CCScale9Sprite : public CCNodeRGBA
|
||||
{
|
||||
public:
|
||||
CCScale9Sprite();
|
||||
|
@ -68,11 +68,6 @@ public:
|
|||
/** Sets the bottom side inset */
|
||||
CC_PROPERTY(float, m_insetBottom, InsetBottom);
|
||||
|
||||
/** Opacity: conforms to CCRGBAProtocol protocol */
|
||||
CC_PROPERTY(GLubyte, m_cOpacity, Opacity)
|
||||
/** Color: conforms to CCRGBAProtocol protocol */
|
||||
CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color)
|
||||
|
||||
protected:
|
||||
bool m_bSpritesGenerated;
|
||||
CCRect m_spriteRect;
|
||||
|
|
Loading…
Reference in New Issue