mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3085 from minggo/iss2129-remove_prefix
issue #2129:remove prefix of types in ccTypes.h
This commit is contained in:
commit
cd1801d324
|
@ -1 +1 @@
|
||||||
a99b08b2ffceb676a19dbcca403053c395c80351
|
047da0e8442426e83230e33a5ce40c8d3ae8059e
|
|
@ -11,6 +11,7 @@ CCConfiguration.cpp \
|
||||||
CCScheduler.cpp \
|
CCScheduler.cpp \
|
||||||
CCCamera.cpp \
|
CCCamera.cpp \
|
||||||
ccFPSImages.c \
|
ccFPSImages.c \
|
||||||
|
ccTypes.cpp \
|
||||||
actions/CCAction.cpp \
|
actions/CCAction.cpp \
|
||||||
actions/CCActionCamera.cpp \
|
actions/CCActionCamera.cpp \
|
||||||
actions/CCActionCatmullRom.cpp \
|
actions/CCActionCatmullRom.cpp \
|
||||||
|
|
|
@ -95,19 +95,29 @@ GridBase* Grid3DAction::getGrid(void)
|
||||||
return Grid3D::create(_gridSize);
|
return Grid3D::create(_gridSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccVertex3F Grid3DAction::vertex(const Point& position)
|
Vertex3F Grid3DAction::vertex(const Point& position)
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
return getVertex(position);
|
||||||
return g->vertex(position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ccVertex3F Grid3DAction::originalVertex(const Point& position)
|
Vertex3F Grid3DAction::originalVertex(const Point& position)
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
return getOriginalVertex(position);
|
||||||
return g->originalVertex(position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grid3DAction::setVertex(const Point& position, const ccVertex3F& vertex)
|
Vertex3F Grid3DAction::getVertex(const Point& position)
|
||||||
|
{
|
||||||
|
Grid3D *g = (Grid3D*)_target->getGrid();
|
||||||
|
return g->getVertex(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex3F Grid3DAction::getOriginalVertex(const Point& position)
|
||||||
|
{
|
||||||
|
Grid3D *g = (Grid3D*)_target->getGrid();
|
||||||
|
return g->getOriginalVertex(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex)
|
||||||
{
|
{
|
||||||
Grid3D *g = (Grid3D*)_target->getGrid();
|
Grid3D *g = (Grid3D*)_target->getGrid();
|
||||||
g->setVertex(position, vertex);
|
g->setVertex(position, vertex);
|
||||||
|
@ -120,19 +130,19 @@ GridBase* TiledGrid3DAction::getGrid(void)
|
||||||
return TiledGrid3D::create(_gridSize);
|
return TiledGrid3D::create(_gridSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccQuad3 TiledGrid3DAction::tile(const Point& pos)
|
Quad3 TiledGrid3DAction::tile(const Point& pos)
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
||||||
return g->tile(pos);
|
return g->tile(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccQuad3 TiledGrid3DAction::originalTile(const Point& pos)
|
Quad3 TiledGrid3DAction::originalTile(const Point& pos)
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
||||||
return g->originalTile(pos);
|
return g->originalTile(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TiledGrid3DAction::setTile(const Point& pos, const ccQuad3& coords)
|
void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords)
|
||||||
{
|
{
|
||||||
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
TiledGrid3D *g = (TiledGrid3D*)_target->getGrid();
|
||||||
return g->setTile(pos, coords);
|
return g->setTile(pos, coords);
|
||||||
|
|
|
@ -74,11 +74,17 @@ public:
|
||||||
/** returns the grid */
|
/** returns the grid */
|
||||||
virtual GridBase* getGrid(void);
|
virtual GridBase* getGrid(void);
|
||||||
/** returns the vertex than belongs to certain position in the grid */
|
/** returns the vertex than belongs to certain position in the grid */
|
||||||
ccVertex3F vertex(const Point& position);
|
CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& position);
|
||||||
/** returns the non-transformed vertex than belongs to certain position in the grid */
|
/** returns the non-transformed vertex than belongs to certain position in the grid */
|
||||||
ccVertex3F originalVertex(const Point& position);
|
CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& position);
|
||||||
|
|
||||||
|
/** returns the vertex than belongs to certain position in the grid */
|
||||||
|
Vertex3F getVertex(const Point& position);
|
||||||
|
/** returns the non-transformed vertex than belongs to certain position in the grid */
|
||||||
|
Vertex3F getOriginalVertex(const Point& position);
|
||||||
|
|
||||||
/** sets a new vertex to a certain position of the grid */
|
/** sets a new vertex to a certain position of the grid */
|
||||||
void setVertex(const Point& position, const ccVertex3F& vertex);
|
void setVertex(const Point& position, const Vertex3F& vertex);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Base class for TiledGrid3D actions */
|
/** @brief Base class for TiledGrid3D actions */
|
||||||
|
@ -89,11 +95,17 @@ public:
|
||||||
virtual TiledGrid3DAction * clone() const = 0;
|
virtual TiledGrid3DAction * clone() const = 0;
|
||||||
|
|
||||||
/** returns the tile that belongs to a certain position of the grid */
|
/** returns the tile that belongs to a certain position of the grid */
|
||||||
ccQuad3 tile(const Point& position);
|
CC_DEPRECATED_ATTRIBUTE Quad3 tile(const Point& position);
|
||||||
/** returns the non-transformed tile that belongs to a certain position of the grid */
|
/** returns the non-transformed tile that belongs to a certain position of the grid */
|
||||||
ccQuad3 originalTile(const Point& position);
|
CC_DEPRECATED_ATTRIBUTE Quad3 originalTile(const Point& position);
|
||||||
|
|
||||||
|
/** returns the tile that belongs to a certain position of the grid */
|
||||||
|
Quad3 getTile(const Point& position);
|
||||||
|
/** returns the non-transformed tile that belongs to a certain position of the grid */
|
||||||
|
Quad3 getOriginalTile(const Point& position);
|
||||||
|
|
||||||
/** sets a new tile to a certain position of the grid */
|
/** sets a new tile to a certain position of the grid */
|
||||||
void setTile(const Point& position, const ccQuad3& coords);
|
void setTile(const Point& position, const Quad3& coords);
|
||||||
|
|
||||||
/** returns the grid */
|
/** returns the grid */
|
||||||
virtual GridBase* getGrid(void);
|
virtual GridBase* getGrid(void);
|
||||||
|
|
|
@ -104,7 +104,7 @@ void Waves3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i ,j));
|
Vertex3F v = originalVertex(ccp(i ,j));
|
||||||
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
|
v.z += (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * 0.01f) * _amplitude * _amplitudeRate);
|
||||||
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
|
//CCLOG("v.z offset is %f\n", (sinf((float)M_PI * time * _waves * 2 + (v.y+v.x) * .01f) * _amplitude * _amplitudeRate));
|
||||||
setVertex(ccp(i, j), v);
|
setVertex(ccp(i, j), v);
|
||||||
|
@ -190,7 +190,7 @@ void FlipX3D::update(float time)
|
||||||
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
||||||
float mx = cosf(angle);
|
float mx = cosf(angle);
|
||||||
|
|
||||||
ccVertex3F v0, v1, v, diff;
|
Vertex3F v0, v1, v, diff;
|
||||||
|
|
||||||
v0 = originalVertex(ccp(1, 1));
|
v0 = originalVertex(ccp(1, 1));
|
||||||
v1 = originalVertex(ccp(0, 0));
|
v1 = originalVertex(ccp(0, 0));
|
||||||
|
@ -298,7 +298,7 @@ void FlipY3D::update(float time)
|
||||||
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
angle = angle / 2.0f; // x calculates degrees from 0 to 90
|
||||||
float my = cosf(angle);
|
float my = cosf(angle);
|
||||||
|
|
||||||
ccVertex3F v0, v1, v, diff;
|
Vertex3F v0, v1, v, diff;
|
||||||
|
|
||||||
v0 = originalVertex(ccp(1, 1));
|
v0 = originalVertex(ccp(1, 1));
|
||||||
v1 = originalVertex(ccp(0, 0));
|
v1 = originalVertex(ccp(0, 0));
|
||||||
|
@ -446,7 +446,7 @@ void Lens3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i, j));
|
Vertex3F v = originalVertex(ccp(i, j));
|
||||||
Point vect = ccpSub(_position, ccp(v.x, v.y));
|
Point vect = ccpSub(_position, ccp(v.x, v.y));
|
||||||
float r = ccpLength(vect);
|
float r = ccpLength(vect);
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ void Ripple3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i, j));
|
Vertex3F v = originalVertex(ccp(i, j));
|
||||||
Point vect = ccpSub(_position, ccp(v.x,v.y));
|
Point vect = ccpSub(_position, ccp(v.x,v.y));
|
||||||
float r = ccpLength(vect);
|
float r = ccpLength(vect);
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ void Shaky3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i ,j));
|
Vertex3F v = originalVertex(ccp(i ,j));
|
||||||
v.x += (rand() % (_randrange*2)) - _randrange;
|
v.x += (rand() % (_randrange*2)) - _randrange;
|
||||||
v.y += (rand() % (_randrange*2)) - _randrange;
|
v.y += (rand() % (_randrange*2)) - _randrange;
|
||||||
if (_shakeZ)
|
if (_shakeZ)
|
||||||
|
@ -740,7 +740,7 @@ void Liquid::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 1; j < _gridSize.height; ++j)
|
for (j = 1; j < _gridSize.height; ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i, j));
|
Vertex3F v = originalVertex(ccp(i, j));
|
||||||
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
v.x = (v.x + (sinf(time * (float)M_PI * _waves * 2 + v.x * .01f) * _amplitude * _amplitudeRate));
|
||||||
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
v.y = (v.y + (sinf(time * (float)M_PI * _waves * 2 + v.y * .01f) * _amplitude * _amplitudeRate));
|
||||||
setVertex(ccp(i, j), v);
|
setVertex(ccp(i, j), v);
|
||||||
|
@ -825,7 +825,7 @@ void Waves::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < _gridSize.height + 1; ++j)
|
for (j = 0; j < _gridSize.height + 1; ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i, j));
|
Vertex3F v = originalVertex(ccp(i, j));
|
||||||
|
|
||||||
if (_vertical)
|
if (_vertical)
|
||||||
{
|
{
|
||||||
|
@ -925,7 +925,7 @@ void Twirl::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < (_gridSize.height+1); ++j)
|
for (j = 0; j < (_gridSize.height+1); ++j)
|
||||||
{
|
{
|
||||||
ccVertex3F v = originalVertex(ccp(i ,j));
|
Vertex3F v = originalVertex(ccp(i ,j));
|
||||||
|
|
||||||
Point avg = ccp(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
Point avg = ccp(i-(_gridSize.width/2.0f), j-(_gridSize.height/2.0f));
|
||||||
float r = ccpLength(avg);
|
float r = ccpLength(avg);
|
||||||
|
|
|
@ -2199,7 +2199,7 @@ bool TintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLubyt
|
||||||
{
|
{
|
||||||
if (ActionInterval::initWithDuration(duration))
|
if (ActionInterval::initWithDuration(duration))
|
||||||
{
|
{
|
||||||
_to = ccc3(red, green, blue);
|
_to = Color3B(red, green, blue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2260,7 +2260,7 @@ void TintTo::update(float time)
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||||
if (pRGBAProtocol)
|
if (pRGBAProtocol)
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setColor(ccc3(GLubyte(_from.r + (_to.r - _from.r) * time),
|
pRGBAProtocol->setColor(Color3B(GLubyte(_from.r + (_to.r - _from.r) * time),
|
||||||
(GLbyte)(_from.g + (_to.g - _from.g) * time),
|
(GLbyte)(_from.g + (_to.g - _from.g) * time),
|
||||||
(GLbyte)(_from.b + (_to.b - _from.b) * time)));
|
(GLbyte)(_from.b + (_to.b - _from.b) * time)));
|
||||||
}
|
}
|
||||||
|
@ -2332,7 +2332,7 @@ void TintBy::startWithTarget(Node *pTarget)
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(pTarget);
|
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(pTarget);
|
||||||
if (pRGBAProtocol)
|
if (pRGBAProtocol)
|
||||||
{
|
{
|
||||||
ccColor3B color = pRGBAProtocol->getColor();
|
Color3B color = pRGBAProtocol->getColor();
|
||||||
_fromR = color.r;
|
_fromR = color.r;
|
||||||
_fromG = color.g;
|
_fromG = color.g;
|
||||||
_fromB = color.b;
|
_fromB = color.b;
|
||||||
|
@ -2344,7 +2344,7 @@ void TintBy::update(float time)
|
||||||
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
RGBAProtocol *pRGBAProtocol = dynamic_cast<RGBAProtocol*>(_target);
|
||||||
if (pRGBAProtocol)
|
if (pRGBAProtocol)
|
||||||
{
|
{
|
||||||
pRGBAProtocol->setColor(ccc3((GLubyte)(_fromR + _deltaR * time),
|
pRGBAProtocol->setColor(Color3B((GLubyte)(_fromR + _deltaR * time),
|
||||||
(GLubyte)(_fromG + _deltaG * time),
|
(GLubyte)(_fromG + _deltaG * time),
|
||||||
(GLubyte)(_fromB + _deltaB * time)));
|
(GLubyte)(_fromB + _deltaB * time)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -727,8 +727,8 @@ public:
|
||||||
/** creates an action with duration and color */
|
/** creates an action with duration and color */
|
||||||
static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
|
static TintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue);
|
||||||
protected:
|
protected:
|
||||||
ccColor3B _to;
|
Color3B _to;
|
||||||
ccColor3B _from;
|
Color3B _from;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
|
/** @brief Tints a Node that implements the NodeRGB protocol from current tint to a custom one.
|
||||||
|
|
|
@ -77,7 +77,7 @@ void PageTurn3D::update(float time)
|
||||||
for (int j = 0; j <= _gridSize.height; ++j)
|
for (int j = 0; j <= _gridSize.height; ++j)
|
||||||
{
|
{
|
||||||
// Get original vertex
|
// Get original vertex
|
||||||
ccVertex3F p = originalVertex(ccp(i ,j));
|
Vertex3F p = originalVertex(ccp(i ,j));
|
||||||
|
|
||||||
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
|
float R = sqrtf((p.x * p.x) + ((p.y - ay) * (p.y - ay)));
|
||||||
float r = R * sinTheta;
|
float r = R * sinTheta;
|
||||||
|
|
|
@ -114,7 +114,7 @@ void ShakyTiles3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < _gridSize.height; ++j)
|
for (j = 0; j < _gridSize.height; ++j)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(i, j));
|
Quad3 coords = originalTile(ccp(i, j));
|
||||||
|
|
||||||
// X
|
// X
|
||||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||||
|
@ -219,7 +219,7 @@ void ShatteredTiles3D::update(float time)
|
||||||
{
|
{
|
||||||
for (j = 0; j < _gridSize.height; ++j)
|
for (j = 0; j < _gridSize.height; ++j)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(i ,j));
|
Quad3 coords = originalTile(ccp(i ,j));
|
||||||
|
|
||||||
// X
|
// X
|
||||||
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
|
||||||
|
@ -347,7 +347,7 @@ Size ShuffleTiles::getDelta(const Size& pos) const
|
||||||
|
|
||||||
void ShuffleTiles::placeTile(const Point& pos, Tile *t)
|
void ShuffleTiles::placeTile(const Point& pos, Tile *t)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(pos);
|
Quad3 coords = originalTile(pos);
|
||||||
|
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _target->getGrid()->getStep();
|
||||||
coords.bl.x += (int)(t->position.x * step.x);
|
coords.bl.x += (int)(t->position.x * step.x);
|
||||||
|
@ -470,14 +470,14 @@ void FadeOutTRTiles::turnOnTile(const Point& pos)
|
||||||
|
|
||||||
void FadeOutTRTiles::turnOffTile(const Point& pos)
|
void FadeOutTRTiles::turnOffTile(const Point& pos)
|
||||||
{
|
{
|
||||||
ccQuad3 coords;
|
Quad3 coords;
|
||||||
memset(&coords, 0, sizeof(ccQuad3));
|
memset(&coords, 0, sizeof(Quad3));
|
||||||
setTile(pos, coords);
|
setTile(pos, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FadeOutTRTiles::transformTile(const Point& pos, float distance)
|
void FadeOutTRTiles::transformTile(const Point& pos, float distance)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(pos);
|
Quad3 coords = originalTile(pos);
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _target->getGrid()->getStep();
|
||||||
|
|
||||||
coords.bl.x += (step.x / 2) * (1.0f - distance);
|
coords.bl.x += (step.x / 2) * (1.0f - distance);
|
||||||
|
@ -604,7 +604,7 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time)
|
||||||
|
|
||||||
void FadeOutUpTiles::transformTile(const Point& pos, float distance)
|
void FadeOutUpTiles::transformTile(const Point& pos, float distance)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(pos);
|
Quad3 coords = originalTile(pos);
|
||||||
Point step = _target->getGrid()->getStep();
|
Point step = _target->getGrid()->getStep();
|
||||||
|
|
||||||
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
coords.bl.y += (step.y / 2) * (1.0f - distance);
|
||||||
|
@ -759,9 +759,9 @@ void TurnOffTiles::turnOnTile(const Point& pos)
|
||||||
|
|
||||||
void TurnOffTiles::turnOffTile(const Point& pos)
|
void TurnOffTiles::turnOffTile(const Point& pos)
|
||||||
{
|
{
|
||||||
ccQuad3 coords;
|
Quad3 coords;
|
||||||
|
|
||||||
memset(&coords, 0, sizeof(ccQuad3));
|
memset(&coords, 0, sizeof(Quad3));
|
||||||
setTile(pos, coords);
|
setTile(pos, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -883,7 +883,7 @@ void WavesTiles3D::update(float time)
|
||||||
{
|
{
|
||||||
for( j = 0; j < _gridSize.height; j++ )
|
for( j = 0; j < _gridSize.height; j++ )
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(i, j));
|
Quad3 coords = originalTile(ccp(i, j));
|
||||||
|
|
||||||
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
|
coords.bl.z = (sinf(time * (float)M_PI *_waves * 2 +
|
||||||
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
|
(coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
|
||||||
|
@ -972,7 +972,7 @@ void JumpTiles3D::update(float time)
|
||||||
{
|
{
|
||||||
for( j = 0; j < _gridSize.height; j++ )
|
for( j = 0; j < _gridSize.height; j++ )
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(i, j));
|
Quad3 coords = originalTile(ccp(i, j));
|
||||||
|
|
||||||
if ( ((i+j) % 2) == 0 )
|
if ( ((i+j) % 2) == 0 )
|
||||||
{
|
{
|
||||||
|
@ -1065,7 +1065,7 @@ void SplitRows::update(float time)
|
||||||
|
|
||||||
for (j = 0; j < _gridSize.height; ++j)
|
for (j = 0; j < _gridSize.height; ++j)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(0, j));
|
Quad3 coords = originalTile(ccp(0, j));
|
||||||
float direction = 1;
|
float direction = 1;
|
||||||
|
|
||||||
if ( (j % 2 ) == 0 )
|
if ( (j % 2 ) == 0 )
|
||||||
|
@ -1151,7 +1151,7 @@ void SplitCols::update(float time)
|
||||||
|
|
||||||
for (i = 0; i < _gridSize.width; ++i)
|
for (i = 0; i < _gridSize.width; ++i)
|
||||||
{
|
{
|
||||||
ccQuad3 coords = originalTile(ccp(i, 0));
|
Quad3 coords = originalTile(ccp(i, 0));
|
||||||
float direction = 1;
|
float direction = 1;
|
||||||
|
|
||||||
if ( (i % 2 ) == 0 )
|
if ( (i % 2 ) == 0 )
|
||||||
|
|
|
@ -87,7 +87,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi
|
||||||
_itemWidth = tileWidth;
|
_itemWidth = tileWidth;
|
||||||
_itemHeight = tileHeight;
|
_itemHeight = tileHeight;
|
||||||
|
|
||||||
_colorUnmodified = ccWHITE;
|
_colorUnmodified = Color3B::white;
|
||||||
_isOpacityModifyRGB = true;
|
_isOpacityModifyRGB = true;
|
||||||
|
|
||||||
_blendFunc.src = CC_BLEND_SRC;
|
_blendFunc.src = CC_BLEND_SRC;
|
||||||
|
@ -152,7 +152,7 @@ void AtlasNode::draw(void)
|
||||||
|
|
||||||
// AtlasNode - RGBA protocol
|
// AtlasNode - RGBA protocol
|
||||||
|
|
||||||
const ccColor3B& AtlasNode::getColor() const
|
const Color3B& AtlasNode::getColor() const
|
||||||
{
|
{
|
||||||
if(_isOpacityModifyRGB)
|
if(_isOpacityModifyRGB)
|
||||||
{
|
{
|
||||||
|
@ -161,9 +161,9 @@ const ccColor3B& AtlasNode::getColor() const
|
||||||
return NodeRGBA::getColor();
|
return NodeRGBA::getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasNode::setColor(const ccColor3B& color3)
|
void AtlasNode::setColor(const Color3B& color3)
|
||||||
{
|
{
|
||||||
ccColor3B tmp = color3;
|
Color3B tmp = color3;
|
||||||
_colorUnmodified = color3;
|
_colorUnmodified = color3;
|
||||||
|
|
||||||
if( _isOpacityModifyRGB )
|
if( _isOpacityModifyRGB )
|
||||||
|
@ -186,7 +186,7 @@ void AtlasNode::setOpacity(GLubyte opacity)
|
||||||
|
|
||||||
void AtlasNode::setOpacityModifyRGB(bool bValue)
|
void AtlasNode::setOpacityModifyRGB(bool bValue)
|
||||||
{
|
{
|
||||||
ccColor3B oldColor = this->getColor();
|
Color3B oldColor = this->getColor();
|
||||||
_isOpacityModifyRGB = bValue;
|
_isOpacityModifyRGB = bValue;
|
||||||
this->setColor(oldColor);
|
this->setColor(oldColor);
|
||||||
}
|
}
|
||||||
|
@ -208,12 +208,12 @@ void AtlasNode::setIgnoreContentScaleFactor(bool bIgnoreContentScaleFactor)
|
||||||
|
|
||||||
// AtlasNode - CocosNodeTexture protocol
|
// AtlasNode - CocosNodeTexture protocol
|
||||||
|
|
||||||
const ccBlendFunc& AtlasNode::getBlendFunc() const
|
const BlendFunc& AtlasNode::getBlendFunc() const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtlasNode::setBlendFunc(const ccBlendFunc &blendFunc)
|
void AtlasNode::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,14 +62,14 @@ protected:
|
||||||
//! height of each char
|
//! height of each char
|
||||||
unsigned int _itemHeight;
|
unsigned int _itemHeight;
|
||||||
|
|
||||||
ccColor3B _colorUnmodified;
|
Color3B _colorUnmodified;
|
||||||
|
|
||||||
CC_PROPERTY(TextureAtlas*, _textureAtlas, TextureAtlas);
|
CC_PROPERTY(TextureAtlas*, _textureAtlas, TextureAtlas);
|
||||||
|
|
||||||
// protocol variables
|
// protocol variables
|
||||||
bool _isOpacityModifyRGB;
|
bool _isOpacityModifyRGB;
|
||||||
|
|
||||||
CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc);
|
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc);
|
||||||
|
|
||||||
// quads to draw
|
// quads to draw
|
||||||
CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw);
|
CC_PROPERTY(unsigned int, _quadsToDraw, QuadsToDraw);
|
||||||
|
@ -109,8 +109,8 @@ public:
|
||||||
|
|
||||||
virtual bool isOpacityModifyRGB() const;
|
virtual bool isOpacityModifyRGB() const;
|
||||||
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB);
|
||||||
virtual const ccColor3B& getColor(void) const;
|
virtual const Color3B& getColor(void) const;
|
||||||
virtual void setColor(const ccColor3B& color);
|
virtual void setColor(const Color3B& color);
|
||||||
virtual void setOpacity(GLubyte opacity);
|
virtual void setOpacity(GLubyte opacity);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
|
@ -1349,8 +1349,8 @@ void Node::removeAllComponents()
|
||||||
NodeRGBA::NodeRGBA()
|
NodeRGBA::NodeRGBA()
|
||||||
: _displayedOpacity(255)
|
: _displayedOpacity(255)
|
||||||
, _realOpacity(255)
|
, _realOpacity(255)
|
||||||
, _displayedColor(ccWHITE)
|
, _displayedColor(Color3B::white)
|
||||||
, _realColor(ccWHITE)
|
, _realColor(Color3B::white)
|
||||||
, _cascadeColorEnabled(false)
|
, _cascadeColorEnabled(false)
|
||||||
, _cascadeOpacityEnabled(false)
|
, _cascadeOpacityEnabled(false)
|
||||||
{}
|
{}
|
||||||
|
@ -1362,7 +1362,7 @@ bool NodeRGBA::init()
|
||||||
if (Node::init())
|
if (Node::init())
|
||||||
{
|
{
|
||||||
_displayedOpacity = _realOpacity = 255;
|
_displayedOpacity = _realOpacity = 255;
|
||||||
_displayedColor = _realColor = ccWHITE;
|
_displayedColor = _realColor = Color3B::white;
|
||||||
_cascadeOpacityEnabled = _cascadeColorEnabled = false;
|
_cascadeOpacityEnabled = _cascadeColorEnabled = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1423,23 +1423,23 @@ void NodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
||||||
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& NodeRGBA::getColor(void) const
|
const Color3B& NodeRGBA::getColor(void) const
|
||||||
{
|
{
|
||||||
return _realColor;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& NodeRGBA::getDisplayedColor() const
|
const Color3B& NodeRGBA::getDisplayedColor() const
|
||||||
{
|
{
|
||||||
return _displayedColor;
|
return _displayedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::setColor(const ccColor3B& color)
|
void NodeRGBA::setColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_displayedColor = _realColor = color;
|
_displayedColor = _realColor = color;
|
||||||
|
|
||||||
if (_cascadeColorEnabled)
|
if (_cascadeColorEnabled)
|
||||||
{
|
{
|
||||||
ccColor3B parentColor = ccWHITE;
|
Color3B parentColor = Color3B::white;
|
||||||
RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(_parent);
|
RGBAProtocol *parent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||||
if (parent && parent->isCascadeColorEnabled())
|
if (parent && parent->isCascadeColorEnabled())
|
||||||
{
|
{
|
||||||
|
@ -1450,7 +1450,7 @@ void NodeRGBA::setColor(const ccColor3B& color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeRGBA::updateDisplayedColor(const ccColor3B& parentColor)
|
void NodeRGBA::updateDisplayedColor(const Color3B& parentColor)
|
||||||
{
|
{
|
||||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||||
|
|
|
@ -1435,10 +1435,10 @@ public:
|
||||||
virtual bool isCascadeOpacityEnabled() const;
|
virtual bool isCascadeOpacityEnabled() const;
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||||
|
|
||||||
virtual const ccColor3B& getColor(void) const;
|
virtual const Color3B& getColor(void) const;
|
||||||
virtual const ccColor3B& getDisplayedColor() const;
|
virtual const Color3B& getDisplayedColor() const;
|
||||||
virtual void setColor(const ccColor3B& color);
|
virtual void setColor(const Color3B& color);
|
||||||
virtual void updateDisplayedColor(const ccColor3B& parentColor);
|
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||||
virtual bool isCascadeColorEnabled() const;
|
virtual bool isCascadeColorEnabled() const;
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||||
|
|
||||||
|
@ -1448,8 +1448,8 @@ public:
|
||||||
protected:
|
protected:
|
||||||
GLubyte _displayedOpacity;
|
GLubyte _displayedOpacity;
|
||||||
GLubyte _realOpacity;
|
GLubyte _realOpacity;
|
||||||
ccColor3B _displayedColor;
|
Color3B _displayedColor;
|
||||||
ccColor3B _realColor;
|
Color3B _realColor;
|
||||||
bool _cascadeColorEnabled;
|
bool _cascadeColorEnabled;
|
||||||
bool _cascadeOpacityEnabled;
|
bool _cascadeOpacityEnabled;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2013 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "include/ccTypes.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
const Color3B Color3B::white(255,255,255);
|
||||||
|
const Color3B Color3B::yellow(255,255,0);
|
||||||
|
const Color3B Color3B::green(0,255,0);
|
||||||
|
const Color3B Color3B::blue(0,0,255);
|
||||||
|
const Color3B Color3B::red(255,0,0);
|
||||||
|
const Color3B Color3B::magenta(255,0,255);
|
||||||
|
const Color3B Color3B::black(0,0,0);
|
||||||
|
const Color3B Color3B::orange(255,127,0);
|
||||||
|
const Color3B Color3B::gray(166,166,166);
|
||||||
|
|
||||||
|
Color4B::Color4B(const Color4F &color4F)
|
||||||
|
: r((GLubyte)(color4F.r * 255.0f)),
|
||||||
|
g((GLubyte)(color4F.g * 255.0f)),
|
||||||
|
b((GLubyte)(color4F.b * 255.0f)),
|
||||||
|
a((GLubyte)(color4F.a * 255.0f))
|
||||||
|
{}
|
||||||
|
|
||||||
|
const BlendFunc BlendFunc::blendFuncDisable = {GL_ONE, GL_ZERO};
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -27,69 +27,69 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
// ccVertex2F == CGPoint in 32-bits, but not in 64-bits (OS X)
|
// Vertex2F == CGPoint in 32-bits, but not in 64-bits (OS X)
|
||||||
// that's why the "v2f" functions are needed
|
// that's why the "v2f" functions are needed
|
||||||
static ccVertex2F v2fzero = {0.0f,0.0f};
|
static Vertex2F v2fzero(0.0f,0.0f);
|
||||||
|
|
||||||
static inline ccVertex2F v2f(float x, float y)
|
static inline Vertex2F v2f(float x, float y)
|
||||||
{
|
{
|
||||||
ccVertex2F ret = {x, y};
|
Vertex2F ret(x, y);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fadd(const ccVertex2F &v0, const ccVertex2F &v1)
|
static inline Vertex2F v2fadd(const Vertex2F &v0, const Vertex2F &v1)
|
||||||
{
|
{
|
||||||
return v2f(v0.x+v1.x, v0.y+v1.y);
|
return v2f(v0.x+v1.x, v0.y+v1.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fsub(const ccVertex2F &v0, const ccVertex2F &v1)
|
static inline Vertex2F v2fsub(const Vertex2F &v0, const Vertex2F &v1)
|
||||||
{
|
{
|
||||||
return v2f(v0.x-v1.x, v0.y-v1.y);
|
return v2f(v0.x-v1.x, v0.y-v1.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fmult(const ccVertex2F &v, float s)
|
static inline Vertex2F v2fmult(const Vertex2F &v, float s)
|
||||||
{
|
{
|
||||||
return v2f(v.x * s, v.y * s);
|
return v2f(v.x * s, v.y * s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fperp(const ccVertex2F &p0)
|
static inline Vertex2F v2fperp(const Vertex2F &p0)
|
||||||
{
|
{
|
||||||
return v2f(-p0.y, p0.x);
|
return v2f(-p0.y, p0.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fneg(const ccVertex2F &p0)
|
static inline Vertex2F v2fneg(const Vertex2F &p0)
|
||||||
{
|
{
|
||||||
return v2f(-p0.x, - p0.y);
|
return v2f(-p0.x, - p0.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float v2fdot(const ccVertex2F &p0, const ccVertex2F &p1)
|
static inline float v2fdot(const Vertex2F &p0, const Vertex2F &p1)
|
||||||
{
|
{
|
||||||
return p0.x * p1.x + p0.y * p1.y;
|
return p0.x * p1.x + p0.y * p1.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fforangle(float _a_)
|
static inline Vertex2F v2fforangle(float _a_)
|
||||||
{
|
{
|
||||||
return v2f(cosf(_a_), sinf(_a_));
|
return v2f(cosf(_a_), sinf(_a_));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F v2fnormalize(const ccVertex2F &p)
|
static inline Vertex2F v2fnormalize(const Vertex2F &p)
|
||||||
{
|
{
|
||||||
Point r = ccpNormalize(ccp(p.x, p.y));
|
Point r = ccpNormalize(ccp(p.x, p.y));
|
||||||
return v2f(r.x, r.y);
|
return v2f(r.x, r.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccVertex2F __v2f(const Point &v)
|
static inline Vertex2F __v2f(const Point &v)
|
||||||
{
|
{
|
||||||
//#ifdef __LP64__
|
//#ifdef __LP64__
|
||||||
return v2f(v.x, v.y);
|
return v2f(v.x, v.y);
|
||||||
// #else
|
// #else
|
||||||
// return * ((ccVertex2F*) &v);
|
// return * ((Vertex2F*) &v);
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ccTex2F __t(const ccVertex2F &v)
|
static inline Tex2F __t(const Vertex2F &v)
|
||||||
{
|
{
|
||||||
return *(ccTex2F*)&v;
|
return *(Tex2F*)&v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// implementation of DrawNode
|
// implementation of DrawNode
|
||||||
|
@ -140,7 +140,7 @@ void DrawNode::ensureCapacity(unsigned int count)
|
||||||
if(_bufferCount + count > _bufferCapacity)
|
if(_bufferCount + count > _bufferCapacity)
|
||||||
{
|
{
|
||||||
_bufferCapacity += MAX(_bufferCapacity, count);
|
_bufferCapacity += MAX(_bufferCapacity, count);
|
||||||
_buffer = (ccV2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(ccV2F_C4B_T2F));
|
_buffer = (V2F_C4B_T2F*)realloc(_buffer, _bufferCapacity*sizeof(V2F_C4B_T2F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,16 +160,16 @@ bool DrawNode::init()
|
||||||
|
|
||||||
glGenBuffers(1, &_vbo);
|
glGenBuffers(1, &_vbo);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW);
|
||||||
|
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||||
|
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||||
|
|
||||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ void DrawNode::render()
|
||||||
if (_dirty)
|
if (_dirty)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW);
|
||||||
_dirty = false;
|
_dirty = false;
|
||||||
}
|
}
|
||||||
#if CC_TEXTURE_ATLAS_USE_VAO
|
#if CC_TEXTURE_ATLAS_USE_VAO
|
||||||
|
@ -198,13 +198,13 @@ void DrawNode::render()
|
||||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||||
// vertex
|
// vertex
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||||
|
|
||||||
// color
|
// color
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||||
|
|
||||||
// texcood
|
// texcood
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
|
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
|
||||||
|
@ -224,19 +224,19 @@ void DrawNode::draw()
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNode::drawDot(const Point &pos, float radius, const ccColor4F &color)
|
void DrawNode::drawDot(const Point &pos, float radius, const Color4F &color)
|
||||||
{
|
{
|
||||||
unsigned int vertex_count = 2*3;
|
unsigned int vertex_count = 2*3;
|
||||||
ensureCapacity(vertex_count);
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
ccV2F_C4B_T2F a = {{pos.x - radius, pos.y - radius}, ccc4BFromccc4F(color), {-1.0, -1.0} };
|
V2F_C4B_T2F a = {Vertex2F(pos.x - radius, pos.y - radius), Color4B(color), Tex2F(-1.0, -1.0) };
|
||||||
ccV2F_C4B_T2F b = {{pos.x - radius, pos.y + radius}, ccc4BFromccc4F(color), {-1.0, 1.0} };
|
V2F_C4B_T2F b = {Vertex2F(pos.x - radius, pos.y + radius), Color4B(color), Tex2F(-1.0, 1.0) };
|
||||||
ccV2F_C4B_T2F c = {{pos.x + radius, pos.y + radius}, ccc4BFromccc4F(color), { 1.0, 1.0} };
|
V2F_C4B_T2F c = {Vertex2F(pos.x + radius, pos.y + radius), Color4B(color), Tex2F( 1.0, 1.0) };
|
||||||
ccV2F_C4B_T2F d = {{pos.x + radius, pos.y - radius}, ccc4BFromccc4F(color), { 1.0, -1.0} };
|
V2F_C4B_T2F d = {Vertex2F(pos.x + radius, pos.y - radius), Color4B(color), Tex2F( 1.0, -1.0) };
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||||
ccV2F_C4B_T2F_Triangle triangle0 = {a, b, c};
|
V2F_C4B_T2F_Triangle triangle0 = {a, b, c};
|
||||||
ccV2F_C4B_T2F_Triangle triangle1 = {a, c, d};
|
V2F_C4B_T2F_Triangle triangle1 = {a, c, d};
|
||||||
triangles[0] = triangle0;
|
triangles[0] = triangle0;
|
||||||
triangles[1] = triangle1;
|
triangles[1] = triangle1;
|
||||||
|
|
||||||
|
@ -245,71 +245,71 @@ void DrawNode::drawDot(const Point &pos, float radius, const ccColor4F &color)
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNode::drawSegment(const Point &from, const Point &to, float radius, const ccColor4F &color)
|
void DrawNode::drawSegment(const Point &from, const Point &to, float radius, const Color4F &color)
|
||||||
{
|
{
|
||||||
unsigned int vertex_count = 6*3;
|
unsigned int vertex_count = 6*3;
|
||||||
ensureCapacity(vertex_count);
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
ccVertex2F a = __v2f(from);
|
Vertex2F a = __v2f(from);
|
||||||
ccVertex2F b = __v2f(to);
|
Vertex2F b = __v2f(to);
|
||||||
|
|
||||||
|
|
||||||
ccVertex2F n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
Vertex2F n = v2fnormalize(v2fperp(v2fsub(b, a)));
|
||||||
ccVertex2F t = v2fperp(n);
|
Vertex2F t = v2fperp(n);
|
||||||
|
|
||||||
ccVertex2F nw = v2fmult(n, radius);
|
Vertex2F nw = v2fmult(n, radius);
|
||||||
ccVertex2F tw = v2fmult(t, radius);
|
Vertex2F tw = v2fmult(t, radius);
|
||||||
ccVertex2F v0 = v2fsub(b, v2fadd(nw, tw));
|
Vertex2F v0 = v2fsub(b, v2fadd(nw, tw));
|
||||||
ccVertex2F v1 = v2fadd(b, v2fsub(nw, tw));
|
Vertex2F v1 = v2fadd(b, v2fsub(nw, tw));
|
||||||
ccVertex2F v2 = v2fsub(b, nw);
|
Vertex2F v2 = v2fsub(b, nw);
|
||||||
ccVertex2F v3 = v2fadd(b, nw);
|
Vertex2F v3 = v2fadd(b, nw);
|
||||||
ccVertex2F v4 = v2fsub(a, nw);
|
Vertex2F v4 = v2fsub(a, nw);
|
||||||
ccVertex2F v5 = v2fadd(a, nw);
|
Vertex2F v5 = v2fadd(a, nw);
|
||||||
ccVertex2F v6 = v2fsub(a, v2fsub(nw, tw));
|
Vertex2F v6 = v2fsub(a, v2fsub(nw, tw));
|
||||||
ccVertex2F v7 = v2fadd(a, v2fadd(nw, tw));
|
Vertex2F v7 = v2fadd(a, v2fadd(nw, tw));
|
||||||
|
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles0 = {
|
V2F_C4B_T2F_Triangle triangles0 = {
|
||||||
{v0, ccc4BFromccc4F(color), __t(v2fneg(v2fadd(n, t)))},
|
{v0, Color4B(color), __t(v2fneg(v2fadd(n, t)))},
|
||||||
{v1, ccc4BFromccc4F(color), __t(v2fsub(n, t))},
|
{v1, Color4B(color), __t(v2fsub(n, t))},
|
||||||
{v2, ccc4BFromccc4F(color), __t(v2fneg(n))},
|
{v2, Color4B(color), __t(v2fneg(n))},
|
||||||
};
|
};
|
||||||
triangles[0] = triangles0;
|
triangles[0] = triangles0;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles1 = {
|
V2F_C4B_T2F_Triangle triangles1 = {
|
||||||
{v3, ccc4BFromccc4F(color), __t(n)},
|
{v3, Color4B(color), __t(n)},
|
||||||
{v1, ccc4BFromccc4F(color), __t(v2fsub(n, t))},
|
{v1, Color4B(color), __t(v2fsub(n, t))},
|
||||||
{v2, ccc4BFromccc4F(color), __t(v2fneg(n))},
|
{v2, Color4B(color), __t(v2fneg(n))},
|
||||||
};
|
};
|
||||||
triangles[1] = triangles1;
|
triangles[1] = triangles1;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles2 = {
|
V2F_C4B_T2F_Triangle triangles2 = {
|
||||||
{v3, ccc4BFromccc4F(color), __t(n)},
|
{v3, Color4B(color), __t(n)},
|
||||||
{v4, ccc4BFromccc4F(color), __t(v2fneg(n))},
|
{v4, Color4B(color), __t(v2fneg(n))},
|
||||||
{v2, ccc4BFromccc4F(color), __t(v2fneg(n))},
|
{v2, Color4B(color), __t(v2fneg(n))},
|
||||||
};
|
};
|
||||||
triangles[2] = triangles2;
|
triangles[2] = triangles2;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles3 = {
|
V2F_C4B_T2F_Triangle triangles3 = {
|
||||||
{v3, ccc4BFromccc4F(color), __t(n)},
|
{v3, Color4B(color), __t(n)},
|
||||||
{v4, ccc4BFromccc4F(color), __t(v2fneg(n))},
|
{v4, Color4B(color), __t(v2fneg(n))},
|
||||||
{v5, ccc4BFromccc4F(color), __t(n) },
|
{v5, Color4B(color), __t(n) },
|
||||||
};
|
};
|
||||||
triangles[3] = triangles3;
|
triangles[3] = triangles3;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles4 = {
|
V2F_C4B_T2F_Triangle triangles4 = {
|
||||||
{v6, ccc4BFromccc4F(color), __t(v2fsub(t, n))},
|
{v6, Color4B(color), __t(v2fsub(t, n))},
|
||||||
{v4, ccc4BFromccc4F(color), __t(v2fneg(n)) },
|
{v4, Color4B(color), __t(v2fneg(n)) },
|
||||||
{v5, ccc4BFromccc4F(color), __t(n)},
|
{v5, Color4B(color), __t(n)},
|
||||||
};
|
};
|
||||||
triangles[4] = triangles4;
|
triangles[4] = triangles4;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle triangles5 = {
|
V2F_C4B_T2F_Triangle triangles5 = {
|
||||||
{v6, ccc4BFromccc4F(color), __t(v2fsub(t, n))},
|
{v6, Color4B(color), __t(v2fsub(t, n))},
|
||||||
{v7, ccc4BFromccc4F(color), __t(v2fadd(n, t))},
|
{v7, Color4B(color), __t(v2fadd(n, t))},
|
||||||
{v5, ccc4BFromccc4F(color), __t(n)},
|
{v5, Color4B(color), __t(n)},
|
||||||
};
|
};
|
||||||
triangles[5] = triangles5;
|
triangles[5] = triangles5;
|
||||||
|
|
||||||
|
@ -318,22 +318,22 @@ void DrawNode::drawSegment(const Point &from, const Point &to, float radius, con
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNode::drawPolygon(Point *verts, unsigned int count, const ccColor4F &fillColor, float borderWidth, const ccColor4F &borderColor)
|
void DrawNode::drawPolygon(Point *verts, unsigned int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor)
|
||||||
{
|
{
|
||||||
struct ExtrudeVerts {ccVertex2F offset, n;};
|
struct ExtrudeVerts {Vertex2F offset, n;};
|
||||||
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
|
struct ExtrudeVerts* extrude = (struct ExtrudeVerts*)malloc(sizeof(struct ExtrudeVerts)*count);
|
||||||
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
|
memset(extrude, 0, sizeof(struct ExtrudeVerts)*count);
|
||||||
|
|
||||||
for(unsigned int i = 0; i < count; i++)
|
for(unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
ccVertex2F v0 = __v2f(verts[(i-1+count)%count]);
|
Vertex2F v0 = __v2f(verts[(i-1+count)%count]);
|
||||||
ccVertex2F v1 = __v2f(verts[i]);
|
Vertex2F v1 = __v2f(verts[i]);
|
||||||
ccVertex2F v2 = __v2f(verts[(i+1)%count]);
|
Vertex2F v2 = __v2f(verts[(i+1)%count]);
|
||||||
|
|
||||||
ccVertex2F n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
|
Vertex2F n1 = v2fnormalize(v2fperp(v2fsub(v1, v0)));
|
||||||
ccVertex2F n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
|
Vertex2F n2 = v2fnormalize(v2fperp(v2fsub(v2, v1)));
|
||||||
|
|
||||||
ccVertex2F offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
|
Vertex2F offset = v2fmult(v2fadd(n1, n2), 1.0/(v2fdot(n1, n2) + 1.0));
|
||||||
struct ExtrudeVerts tmp = {offset, n2};
|
struct ExtrudeVerts tmp = {offset, n2};
|
||||||
extrude[i] = tmp;
|
extrude[i] = tmp;
|
||||||
}
|
}
|
||||||
|
@ -344,20 +344,20 @@ void DrawNode::drawPolygon(Point *verts, unsigned int count, const ccColor4F &fi
|
||||||
unsigned int vertex_count = 3*triangle_count;
|
unsigned int vertex_count = 3*triangle_count;
|
||||||
ensureCapacity(vertex_count);
|
ensureCapacity(vertex_count);
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle *triangles = (ccV2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount);
|
||||||
ccV2F_C4B_T2F_Triangle *cursor = triangles;
|
V2F_C4B_T2F_Triangle *cursor = triangles;
|
||||||
|
|
||||||
float inset = (outline == 0.0 ? 0.5 : 0.0);
|
float inset = (outline == 0.0 ? 0.5 : 0.0);
|
||||||
for(unsigned int i = 0; i < count-2; i++)
|
for(unsigned int i = 0; i < count-2; i++)
|
||||||
{
|
{
|
||||||
ccVertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
|
Vertex2F v0 = v2fsub(__v2f(verts[0 ]), v2fmult(extrude[0 ].offset, inset));
|
||||||
ccVertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
|
Vertex2F v1 = v2fsub(__v2f(verts[i+1]), v2fmult(extrude[i+1].offset, inset));
|
||||||
ccVertex2F v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
|
Vertex2F v2 = v2fsub(__v2f(verts[i+2]), v2fmult(extrude[i+2].offset, inset));
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle tmp = {
|
V2F_C4B_T2F_Triangle tmp = {
|
||||||
{v0, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{v0, Color4B(fillColor), __t(v2fzero)},
|
||||||
{v1, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{v1, Color4B(fillColor), __t(v2fzero)},
|
||||||
{v2, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{v2, Color4B(fillColor), __t(v2fzero)},
|
||||||
};
|
};
|
||||||
|
|
||||||
*cursor++ = tmp;
|
*cursor++ = tmp;
|
||||||
|
@ -366,52 +366,52 @@ void DrawNode::drawPolygon(Point *verts, unsigned int count, const ccColor4F &fi
|
||||||
for(unsigned int i = 0; i < count; i++)
|
for(unsigned int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
int j = (i+1)%count;
|
int j = (i+1)%count;
|
||||||
ccVertex2F v0 = __v2f(verts[i]);
|
Vertex2F v0 = __v2f(verts[i]);
|
||||||
ccVertex2F v1 = __v2f(verts[j]);
|
Vertex2F v1 = __v2f(verts[j]);
|
||||||
|
|
||||||
ccVertex2F n0 = extrude[i].n;
|
Vertex2F n0 = extrude[i].n;
|
||||||
|
|
||||||
ccVertex2F offset0 = extrude[i].offset;
|
Vertex2F offset0 = extrude[i].offset;
|
||||||
ccVertex2F offset1 = extrude[j].offset;
|
Vertex2F offset1 = extrude[j].offset;
|
||||||
|
|
||||||
if(outline)
|
if(outline)
|
||||||
{
|
{
|
||||||
ccVertex2F inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
|
Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, borderWidth));
|
||||||
ccVertex2F inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
|
Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, borderWidth));
|
||||||
ccVertex2F outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
|
Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, borderWidth));
|
||||||
ccVertex2F outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
|
Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, borderWidth));
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle tmp1 = {
|
V2F_C4B_T2F_Triangle tmp1 = {
|
||||||
{inner0, ccc4BFromccc4F(borderColor), __t(v2fneg(n0))},
|
{inner0, Color4B(borderColor), __t(v2fneg(n0))},
|
||||||
{inner1, ccc4BFromccc4F(borderColor), __t(v2fneg(n0))},
|
{inner1, Color4B(borderColor), __t(v2fneg(n0))},
|
||||||
{outer1, ccc4BFromccc4F(borderColor), __t(n0)}
|
{outer1, Color4B(borderColor), __t(n0)}
|
||||||
};
|
};
|
||||||
*cursor++ = tmp1;
|
*cursor++ = tmp1;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle tmp2 = {
|
V2F_C4B_T2F_Triangle tmp2 = {
|
||||||
{inner0, ccc4BFromccc4F(borderColor), __t(v2fneg(n0))},
|
{inner0, Color4B(borderColor), __t(v2fneg(n0))},
|
||||||
{outer0, ccc4BFromccc4F(borderColor), __t(n0)},
|
{outer0, Color4B(borderColor), __t(n0)},
|
||||||
{outer1, ccc4BFromccc4F(borderColor), __t(n0)}
|
{outer1, Color4B(borderColor), __t(n0)}
|
||||||
};
|
};
|
||||||
*cursor++ = tmp2;
|
*cursor++ = tmp2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ccVertex2F inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
|
Vertex2F inner0 = v2fsub(v0, v2fmult(offset0, 0.5));
|
||||||
ccVertex2F inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
|
Vertex2F inner1 = v2fsub(v1, v2fmult(offset1, 0.5));
|
||||||
ccVertex2F outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
|
Vertex2F outer0 = v2fadd(v0, v2fmult(offset0, 0.5));
|
||||||
ccVertex2F outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
|
Vertex2F outer1 = v2fadd(v1, v2fmult(offset1, 0.5));
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle tmp1 = {
|
V2F_C4B_T2F_Triangle tmp1 = {
|
||||||
{inner0, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{inner0, Color4B(fillColor), __t(v2fzero)},
|
||||||
{inner1, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{inner1, Color4B(fillColor), __t(v2fzero)},
|
||||||
{outer1, ccc4BFromccc4F(fillColor), __t(n0)}
|
{outer1, Color4B(fillColor), __t(n0)}
|
||||||
};
|
};
|
||||||
*cursor++ = tmp1;
|
*cursor++ = tmp1;
|
||||||
|
|
||||||
ccV2F_C4B_T2F_Triangle tmp2 = {
|
V2F_C4B_T2F_Triangle tmp2 = {
|
||||||
{inner0, ccc4BFromccc4F(fillColor), __t(v2fzero)},
|
{inner0, Color4B(fillColor), __t(v2fzero)},
|
||||||
{outer0, ccc4BFromccc4F(fillColor), __t(n0)},
|
{outer0, Color4B(fillColor), __t(n0)},
|
||||||
{outer1, ccc4BFromccc4F(fillColor), __t(n0)}
|
{outer1, Color4B(fillColor), __t(n0)}
|
||||||
};
|
};
|
||||||
*cursor++ = tmp2;
|
*cursor++ = tmp2;
|
||||||
}
|
}
|
||||||
|
@ -430,12 +430,12 @@ void DrawNode::clear()
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccBlendFunc& DrawNode::getBlendFunc() const
|
const BlendFunc& DrawNode::getBlendFunc() const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawNode::setBlendFunc(const ccBlendFunc &blendFunc)
|
void DrawNode::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ protected:
|
||||||
|
|
||||||
unsigned int _bufferCapacity;
|
unsigned int _bufferCapacity;
|
||||||
GLsizei _bufferCount;
|
GLsizei _bufferCount;
|
||||||
ccV2F_C4B_T2F *_buffer;
|
V2F_C4B_T2F *_buffer;
|
||||||
|
|
||||||
ccBlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
|
|
||||||
bool _dirty;
|
bool _dirty;
|
||||||
|
|
||||||
|
@ -63,19 +63,19 @@ public:
|
||||||
virtual void draw();
|
virtual void draw();
|
||||||
|
|
||||||
/** draw a dot at a position, with a given radius and color */
|
/** draw a dot at a position, with a given radius and color */
|
||||||
void drawDot(const Point &pos, float radius, const ccColor4F &color);
|
void drawDot(const Point &pos, float radius, const Color4F &color);
|
||||||
|
|
||||||
/** draw a segment with a radius and color */
|
/** draw a segment with a radius and color */
|
||||||
void drawSegment(const Point &from, const Point &to, float radius, const ccColor4F &color);
|
void drawSegment(const Point &from, const Point &to, float radius, const Color4F &color);
|
||||||
|
|
||||||
/** draw a polygon with a fill color and line color */
|
/** draw a polygon with a fill color and line color */
|
||||||
void drawPolygon(Point *verts, unsigned int count, const ccColor4F &fillColor, float borderWidth, const ccColor4F &borderColor);
|
void drawPolygon(Point *verts, unsigned int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
|
||||||
|
|
||||||
/** Clear the geometry in the node's buffer. */
|
/** Clear the geometry in the node's buffer. */
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
const ccBlendFunc& getBlendFunc() const;
|
const BlendFunc& getBlendFunc() const;
|
||||||
void setBlendFunc(const ccBlendFunc &blendFunc);
|
void setBlendFunc(const BlendFunc &blendFunc);
|
||||||
|
|
||||||
DrawNode();
|
DrawNode();
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ NS_CC_BEGIN
|
||||||
static bool s_bInitialized = false;
|
static bool s_bInitialized = false;
|
||||||
static GLProgram* s_pShader = NULL;
|
static GLProgram* s_pShader = NULL;
|
||||||
static int s_nColorLocation = -1;
|
static int s_nColorLocation = -1;
|
||||||
static ccColor4F s_tColor = {1.0f,1.0f,1.0f,1.0f};
|
static Color4F s_tColor(1.0f,1.0f,1.0f,1.0f);
|
||||||
static int s_nPointSizeLocation = -1;
|
static int s_nPointSizeLocation = -1;
|
||||||
static GLfloat s_fPointSize = 1.0f;
|
static GLfloat s_fPointSize = 1.0f;
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ void ccDrawPoint( const Point& point )
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
ccVertex2F p;
|
Vertex2F p;
|
||||||
p.x = point.x;
|
p.x = point.x;
|
||||||
p.y = point.y;
|
p.y = point.y;
|
||||||
|
|
||||||
|
@ -156,10 +156,10 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
|
||||||
s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize);
|
s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize);
|
||||||
|
|
||||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||||
ccVertex2F* newPoints = new ccVertex2F[numberOfPoints];
|
Vertex2F* newPoints = new Vertex2F[numberOfPoints];
|
||||||
|
|
||||||
// iPhone and 32-bit machines optimization
|
// iPhone and 32-bit machines optimization
|
||||||
if( sizeof(Point) == sizeof(ccVertex2F) )
|
if( sizeof(Point) == sizeof(Vertex2F) )
|
||||||
{
|
{
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData((void*) points, numberOfPoints * sizeof(Point));
|
setGLBufferData((void*) points, numberOfPoints * sizeof(Point));
|
||||||
|
@ -178,7 +178,7 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
|
// Suspect Emscripten won't be emitting 64-bit code for a while yet,
|
||||||
// but want to make sure this continues to work even if they do.
|
// but want to make sure this continues to work even if they do.
|
||||||
setGLBufferData(newPoints, numberOfPoints * sizeof(ccVertex2F));
|
setGLBufferData(newPoints, numberOfPoints * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints);
|
||||||
|
@ -197,9 +197,9 @@ void ccDrawLine( const Point& origin, const Point& destination )
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
ccVertex2F vertices[2] = {
|
Vertex2F vertices[2] = {
|
||||||
{origin.x, origin.y},
|
Vertex2F(origin.x, origin.y),
|
||||||
{destination.x, destination.y}
|
Vertex2F(destination.x, destination.y)
|
||||||
};
|
};
|
||||||
|
|
||||||
s_pShader->use();
|
s_pShader->use();
|
||||||
|
@ -226,7 +226,7 @@ void ccDrawRect( Point origin, Point destination )
|
||||||
ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y));
|
ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ccDrawSolidRect( Point origin, Point destination, ccColor4F color )
|
void ccDrawSolidRect( Point origin, Point destination, Color4F color )
|
||||||
{
|
{
|
||||||
Point vertices[] = {
|
Point vertices[] = {
|
||||||
origin,
|
origin,
|
||||||
|
@ -249,7 +249,7 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
|
||||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||||
|
|
||||||
// iPhone and 32-bit machines optimization
|
// iPhone and 32-bit machines optimization
|
||||||
if( sizeof(Point) == sizeof(ccVertex2F) )
|
if( sizeof(Point) == sizeof(Vertex2F) )
|
||||||
{
|
{
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
||||||
|
@ -267,13 +267,13 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
|
||||||
{
|
{
|
||||||
// Mac on 64-bit
|
// Mac on 64-bit
|
||||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||||
ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];
|
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
|
||||||
for( unsigned int i=0; i<numberOfPoints;i++) {
|
for( unsigned int i=0; i<numberOfPoints;i++) {
|
||||||
newPoli[i].x = poli[i].x;
|
newPoli[i].x = poli[i].x;
|
||||||
newPoli[i].y = poli[i].y;
|
newPoli[i].y = poli[i].y;
|
||||||
}
|
}
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(newPoli, numberOfPoints * sizeof(ccVertex2F));
|
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||||
|
@ -290,7 +290,7 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg
|
||||||
CC_INCREMENT_GL_DRAWS(1);
|
CC_INCREMENT_GL_DRAWS(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, ccColor4F color )
|
void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color )
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
|
@ -301,10 +301,10 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, ccColor4F
|
||||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||||
|
|
||||||
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
// XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed
|
||||||
ccVertex2F* newPoli = new ccVertex2F[numberOfPoints];
|
Vertex2F* newPoli = new Vertex2F[numberOfPoints];
|
||||||
|
|
||||||
// iPhone and 32-bit machines optimization
|
// iPhone and 32-bit machines optimization
|
||||||
if( sizeof(Point) == sizeof(ccVertex2F) )
|
if( sizeof(Point) == sizeof(Vertex2F) )
|
||||||
{
|
{
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
setGLBufferData((void*) poli, numberOfPoints * sizeof(Point));
|
||||||
|
@ -318,10 +318,10 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, ccColor4F
|
||||||
// Mac on 64-bit
|
// Mac on 64-bit
|
||||||
for( unsigned int i=0; i<numberOfPoints;i++)
|
for( unsigned int i=0; i<numberOfPoints;i++)
|
||||||
{
|
{
|
||||||
newPoli[i] = vertex2( poli[i].x, poli[i].y );
|
newPoli[i] = Vertex2F( poli[i].x, poli[i].y );
|
||||||
}
|
}
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(newPoli, numberOfPoints * sizeof(ccVertex2F));
|
setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli);
|
||||||
|
@ -433,7 +433,7 @@ void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& de
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
ccVertex2F* vertices = new ccVertex2F[segments + 1];
|
Vertex2F* vertices = new Vertex2F[segments + 1];
|
||||||
|
|
||||||
float t = 0.0f;
|
float t = 0.0f;
|
||||||
for(unsigned int i = 0; i < segments; i++)
|
for(unsigned int i = 0; i < segments; i++)
|
||||||
|
@ -452,7 +452,7 @@ void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& de
|
||||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(vertices, (segments + 1) * sizeof(ccVertex2F));
|
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||||
|
@ -472,7 +472,7 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
ccVertex2F* vertices = new ccVertex2F[segments + 1];
|
Vertex2F* vertices = new Vertex2F[segments + 1];
|
||||||
|
|
||||||
unsigned int p;
|
unsigned int p;
|
||||||
float lt;
|
float lt;
|
||||||
|
@ -509,7 +509,7 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm
|
||||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(vertices, (segments + 1) * sizeof(ccVertex2F));
|
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||||
|
@ -524,7 +524,7 @@ void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point&
|
||||||
{
|
{
|
||||||
lazy_init();
|
lazy_init();
|
||||||
|
|
||||||
ccVertex2F* vertices = new ccVertex2F[segments + 1];
|
Vertex2F* vertices = new Vertex2F[segments + 1];
|
||||||
|
|
||||||
float t = 0;
|
float t = 0;
|
||||||
for(unsigned int i = 0; i < segments; i++)
|
for(unsigned int i = 0; i < segments; i++)
|
||||||
|
@ -543,7 +543,7 @@ void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point&
|
||||||
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
ccGLEnableVertexAttribs( kVertexAttribFlag_Position );
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(vertices, (segments + 1) * sizeof(ccVertex2F));
|
setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F));
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||||
|
|
|
@ -98,7 +98,7 @@ void CC_DLL ccDrawRect( Point origin, Point destination );
|
||||||
/** draws a solid rectangle given the origin and destination point measured in points.
|
/** draws a solid rectangle given the origin and destination point measured in points.
|
||||||
@since 1.1
|
@since 1.1
|
||||||
*/
|
*/
|
||||||
void CC_DLL ccDrawSolidRect( Point origin, Point destination, ccColor4F color );
|
void CC_DLL ccDrawSolidRect( Point origin, Point destination, Color4F color );
|
||||||
|
|
||||||
/** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points.
|
/** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points.
|
||||||
The polygon can be closed or open
|
The polygon can be closed or open
|
||||||
|
@ -107,7 +107,7 @@ void CC_DLL ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool
|
||||||
|
|
||||||
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
|
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
|
||||||
*/
|
*/
|
||||||
void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, ccColor4F color );
|
void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color );
|
||||||
|
|
||||||
/** draws a circle given the center, radius and number of segments. */
|
/** draws a circle given the center, radius and number of segments. */
|
||||||
void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
||||||
|
|
|
@ -328,11 +328,11 @@ void Grid3D::blit(void)
|
||||||
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
||||||
|
|
||||||
// position
|
// position
|
||||||
setGLBufferData(_vertices, numOfPoints * sizeof(ccVertex3F), 0);
|
setGLBufferData(_vertices, numOfPoints * sizeof(Vertex3F), 0);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
// texCoords
|
// texCoords
|
||||||
setGLBufferData(_texCoordinates, numOfPoints * sizeof(ccVertex2F), 1);
|
setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
setGLIndexData(_indices, n * 12, 0);
|
setGLIndexData(_indices, n * 12, 0);
|
||||||
|
@ -363,9 +363,9 @@ void Grid3D::calculateVertexPoints(void)
|
||||||
|
|
||||||
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
unsigned int numOfPoints = (_gridSize.width+1) * (_gridSize.height+1);
|
||||||
|
|
||||||
_vertices = malloc(numOfPoints * sizeof(ccVertex3F));
|
_vertices = malloc(numOfPoints * sizeof(Vertex3F));
|
||||||
_originalVertices = malloc(numOfPoints * sizeof(ccVertex3F));
|
_originalVertices = malloc(numOfPoints * sizeof(Vertex3F));
|
||||||
_texCoordinates = malloc(numOfPoints * sizeof(ccVertex2F));
|
_texCoordinates = malloc(numOfPoints * sizeof(Vertex2F));
|
||||||
_indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6);
|
_indices = (GLushort*)malloc(_gridSize.width * _gridSize.height * sizeof(GLushort) * 6);
|
||||||
|
|
||||||
GLfloat *vertArray = (GLfloat*)_vertices;
|
GLfloat *vertArray = (GLfloat*)_vertices;
|
||||||
|
@ -393,15 +393,15 @@ void Grid3D::calculateVertexPoints(void)
|
||||||
memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
|
memcpy(&idxArray[6*idx], tempidx, 6*sizeof(GLushort));
|
||||||
|
|
||||||
int l1[4] = {a*3, b*3, c*3, d*3};
|
int l1[4] = {a*3, b*3, c*3, d*3};
|
||||||
ccVertex3F e = {x1, y1, 0};
|
Vertex3F e(x1, y1, 0);
|
||||||
ccVertex3F f = {x2, y1, 0};
|
Vertex3F f(x2, y1, 0);
|
||||||
ccVertex3F g = {x2, y2, 0};
|
Vertex3F g(x2, y2, 0);
|
||||||
ccVertex3F h = {x1, y2, 0};
|
Vertex3F h(x1, y2, 0);
|
||||||
|
|
||||||
ccVertex3F l2[4] = {e, f, g, h};
|
Vertex3F l2[4] = {e, f, g, h};
|
||||||
|
|
||||||
int tex1[4] = {a*2, b*2, c*2, d*2};
|
int tex1[4] = {a*2, b*2, c*2, d*2};
|
||||||
Point tex2[4] = {ccp(x1, y1), ccp(x2, y1), ccp(x2, y2), ccp(x1, y2)};
|
Point Tex2F[4] = {ccp(x1, y1), ccp(x2, y1), ccp(x2, y2), ccp(x1, y2)};
|
||||||
|
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
|
@ -409,47 +409,57 @@ void Grid3D::calculateVertexPoints(void)
|
||||||
vertArray[l1[i] + 1] = l2[i].y;
|
vertArray[l1[i] + 1] = l2[i].y;
|
||||||
vertArray[l1[i] + 2] = l2[i].z;
|
vertArray[l1[i] + 2] = l2[i].z;
|
||||||
|
|
||||||
texArray[tex1[i]] = tex2[i].x / width;
|
texArray[tex1[i]] = Tex2F[i].x / width;
|
||||||
if (_isTextureFlipped)
|
if (_isTextureFlipped)
|
||||||
{
|
{
|
||||||
texArray[tex1[i] + 1] = (imageH - tex2[i].y) / height;
|
texArray[tex1[i] + 1] = (imageH - Tex2F[i].y) / height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
texArray[tex1[i] + 1] = tex2[i].y / height;
|
texArray[tex1[i] + 1] = Tex2F[i].y / height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(ccVertex3F));
|
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vertex3F));
|
||||||
}
|
}
|
||||||
|
|
||||||
ccVertex3F Grid3D::vertex(const Point& pos)
|
Vertex3F Grid3D::vertex(const Point& pos)
|
||||||
|
{
|
||||||
|
return getVertex(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex3F Grid3D::getVertex(const Point& pos)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
|
|
||||||
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
||||||
float *vertArray = (float*)_vertices;
|
float *vertArray = (float*)_vertices;
|
||||||
|
|
||||||
ccVertex3F vert = {vertArray[index], vertArray[index+1], vertArray[index+2]};
|
Vertex3F vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||||
|
|
||||||
return vert;
|
return vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccVertex3F Grid3D::originalVertex(const Point& pos)
|
Vertex3F Grid3D::originalVertex(const Point& pos)
|
||||||
|
{
|
||||||
|
return getOriginalVertex(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vertex3F Grid3D::getOriginalVertex(const Point& pos)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
|
|
||||||
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
int index = (pos.x * (_gridSize.height+1) + pos.y) * 3;
|
||||||
float *vertArray = (float*)_originalVertices;
|
float *vertArray = (float*)_originalVertices;
|
||||||
|
|
||||||
ccVertex3F vert = {vertArray[index], vertArray[index+1], vertArray[index+2]};
|
Vertex3F vert(vertArray[index], vertArray[index+1], vertArray[index+2]);
|
||||||
|
|
||||||
return vert;
|
return vert;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Grid3D::setVertex(const Point& pos, const ccVertex3F& vertex)
|
void Grid3D::setVertex(const Point& pos, const Vertex3F& vertex)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
|
int index = (pos.x * (_gridSize.height + 1) + pos.y) * 3;
|
||||||
|
@ -463,7 +473,7 @@ void Grid3D::reuse(void)
|
||||||
{
|
{
|
||||||
if (_reuseGrid > 0)
|
if (_reuseGrid > 0)
|
||||||
{
|
{
|
||||||
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(ccVertex3F));
|
memcpy(_originalVertices, _vertices, (_gridSize.width+1) * (_gridSize.height+1) * sizeof(Vertex3F));
|
||||||
--_reuseGrid;
|
--_reuseGrid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,11 +553,11 @@ void TiledGrid3D::blit(void)
|
||||||
int numQuads = _gridSize.width * _gridSize.height;
|
int numQuads = _gridSize.width * _gridSize.height;
|
||||||
|
|
||||||
// position
|
// position
|
||||||
setGLBufferData(_vertices, (numQuads*4*sizeof(ccVertex3F)), 0);
|
setGLBufferData(_vertices, (numQuads*4*sizeof(Vertex3F)), 0);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
// texCoords
|
// texCoords
|
||||||
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(ccVertex2F)), 1);
|
setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
setGLIndexData(_indices, n * 12, 0);
|
setGLIndexData(_indices, n * 12, 0);
|
||||||
|
@ -578,9 +588,9 @@ void TiledGrid3D::calculateVertexPoints(void)
|
||||||
CC_SAFE_FREE(_texCoordinates);
|
CC_SAFE_FREE(_texCoordinates);
|
||||||
CC_SAFE_FREE(_indices);
|
CC_SAFE_FREE(_indices);
|
||||||
|
|
||||||
_vertices = malloc(numQuads*4*sizeof(ccVertex3F));
|
_vertices = malloc(numQuads*4*sizeof(Vertex3F));
|
||||||
_originalVertices = malloc(numQuads*4*sizeof(ccVertex3F));
|
_originalVertices = malloc(numQuads*4*sizeof(Vertex3F));
|
||||||
_texCoordinates = malloc(numQuads*4*sizeof(ccVertex2F));
|
_texCoordinates = malloc(numQuads*4*sizeof(Vertex2F));
|
||||||
_indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort));
|
_indices = (GLushort*)malloc(numQuads*6*sizeof(GLushort));
|
||||||
|
|
||||||
GLfloat *vertArray = (GLfloat*)_vertices;
|
GLfloat *vertArray = (GLfloat*)_vertices;
|
||||||
|
@ -645,34 +655,34 @@ void TiledGrid3D::calculateVertexPoints(void)
|
||||||
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat));
|
memcpy(_originalVertices, _vertices, numQuads * 12 * sizeof(GLfloat));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TiledGrid3D::setTile(const Point& pos, const ccQuad3& coords)
|
void TiledGrid3D::setTile(const Point& pos, const Quad3& coords)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||||
float *vertArray = (float*)_vertices;
|
float *vertArray = (float*)_vertices;
|
||||||
memcpy(&vertArray[idx], &coords, sizeof(ccQuad3));
|
memcpy(&vertArray[idx], &coords, sizeof(Quad3));
|
||||||
}
|
}
|
||||||
|
|
||||||
ccQuad3 TiledGrid3D::originalTile(const Point& pos)
|
Quad3 TiledGrid3D::originalTile(const Point& pos)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||||
float *vertArray = (float*)_originalVertices;
|
float *vertArray = (float*)_originalVertices;
|
||||||
|
|
||||||
ccQuad3 ret;
|
Quad3 ret;
|
||||||
memcpy(&ret, &vertArray[idx], sizeof(ccQuad3));
|
memcpy(&ret, &vertArray[idx], sizeof(Quad3));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccQuad3 TiledGrid3D::tile(const Point& pos)
|
Quad3 TiledGrid3D::tile(const Point& pos)
|
||||||
{
|
{
|
||||||
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
CCAssert( pos.x == (unsigned int)pos.x && pos.y == (unsigned int) pos.y , "Numbers must be integers");
|
||||||
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
int idx = (_gridSize.height * pos.x + pos.y) * 4 * 3;
|
||||||
float *vertArray = (float*)_vertices;
|
float *vertArray = (float*)_vertices;
|
||||||
|
|
||||||
ccQuad3 ret;
|
Quad3 ret;
|
||||||
memcpy(&ret, &vertArray[idx], sizeof(ccQuad3));
|
memcpy(&ret, &vertArray[idx], sizeof(Quad3));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,11 +117,17 @@ public:
|
||||||
~Grid3D(void);
|
~Grid3D(void);
|
||||||
|
|
||||||
/** returns the vertex at a given position */
|
/** returns the vertex at a given position */
|
||||||
ccVertex3F vertex(const Point& pos);
|
CC_DEPRECATED_ATTRIBUTE Vertex3F vertex(const Point& pos);
|
||||||
/** returns the original (non-transformed) vertex at a given position */
|
/** returns the original (non-transformed) vertex at a given position */
|
||||||
ccVertex3F originalVertex(const Point& pos);
|
CC_DEPRECATED_ATTRIBUTE Vertex3F originalVertex(const Point& pos);
|
||||||
|
|
||||||
|
/** returns the vertex at a given position */
|
||||||
|
Vertex3F getVertex(const Point& pos);
|
||||||
|
/** returns the original (non-transformed) vertex at a given position */
|
||||||
|
Vertex3F getOriginalVertex(const Point& pos);
|
||||||
|
|
||||||
/** sets a new vertex at a given position */
|
/** sets a new vertex at a given position */
|
||||||
void setVertex(const Point& pos, const ccVertex3F& vertex);
|
void setVertex(const Point& pos, const Vertex3F& vertex);
|
||||||
|
|
||||||
virtual void blit(void);
|
virtual void blit(void);
|
||||||
virtual void reuse(void);
|
virtual void reuse(void);
|
||||||
|
@ -154,11 +160,11 @@ public:
|
||||||
~TiledGrid3D(void);
|
~TiledGrid3D(void);
|
||||||
|
|
||||||
/** returns the tile at the given position */
|
/** returns the tile at the given position */
|
||||||
ccQuad3 tile(const Point& pos);
|
Quad3 tile(const Point& pos);
|
||||||
/** returns the original tile (untransformed) at the given position */
|
/** returns the original tile (untransformed) at the given position */
|
||||||
ccQuad3 originalTile(const Point& pos);
|
Quad3 originalTile(const Point& pos);
|
||||||
/** sets a new tile */
|
/** sets a new tile */
|
||||||
void setTile(const Point& pos, const ccQuad3& coords);
|
void setTile(const Point& pos, const Quad3& coords);
|
||||||
|
|
||||||
virtual void blit(void);
|
virtual void blit(void);
|
||||||
virtual void reuse(void);
|
virtual void reuse(void);
|
||||||
|
|
|
@ -41,23 +41,23 @@ public:
|
||||||
/**
|
/**
|
||||||
* Changes the color with R,G,B bytes
|
* Changes the color with R,G,B bytes
|
||||||
*
|
*
|
||||||
* @param color Example: ccc3(255,100,0) means R=255, G=100, B=0
|
* @param color Example: Color3B(255,100,0) means R=255, G=100, B=0
|
||||||
*/
|
*/
|
||||||
virtual void setColor(const ccColor3B& color) = 0;
|
virtual void setColor(const Color3B& color) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns color that is currently used.
|
* Returns color that is currently used.
|
||||||
*
|
*
|
||||||
* @return The ccColor3B contains R,G,B bytes.
|
* @return The Color3B contains R,G,B bytes.
|
||||||
*/
|
*/
|
||||||
virtual const ccColor3B& getColor(void) const = 0;
|
virtual const Color3B& getColor(void) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the displayed color.
|
* Returns the displayed color.
|
||||||
*
|
*
|
||||||
* @return The ccColor3B contains R,G,B bytes.
|
* @return The Color3B contains R,G,B bytes.
|
||||||
*/
|
*/
|
||||||
virtual const ccColor3B& getDisplayedColor(void) const = 0;
|
virtual const Color3B& getDisplayedColor(void) const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the displayed opacity.
|
* Returns the displayed opacity.
|
||||||
|
@ -111,7 +111,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* recursive method that updates display color
|
* recursive method that updates display color
|
||||||
*/
|
*/
|
||||||
virtual void updateDisplayedColor(const ccColor3B& color) = 0;
|
virtual void updateDisplayedColor(const Color3B& color) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether or not opacity should be propagated to its children.
|
* whether or not opacity should be propagated to its children.
|
||||||
|
@ -140,14 +140,14 @@ public:
|
||||||
* e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.
|
* e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void setBlendFunc(const ccBlendFunc &blendFunc) = 0;
|
virtual void setBlendFunc(const BlendFunc &blendFunc) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the blending function that is currently being used.
|
* Returns the blending function that is currently being used.
|
||||||
*
|
*
|
||||||
* @return A ccBlendFunc structure with source and destination factor which specified pixel arithmetic.
|
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
|
||||||
*/
|
*/
|
||||||
virtual const ccBlendFunc &getBlendFunc(void) const = 0;
|
virtual const BlendFunc &getBlendFunc(void) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,289 +35,274 @@ THE SOFTWARE.
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
/** RGB color composed of bytes 3 bytes
|
/** RGB color composed of bytes 3 bytes
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccColor3B
|
struct Color3B
|
||||||
{
|
{
|
||||||
|
Color3B(): r(0), g(0), b(0) {}
|
||||||
|
|
||||||
|
Color3B(GLubyte _r, GLubyte _g, GLubyte _b)
|
||||||
|
:r(_r),
|
||||||
|
g(_g),
|
||||||
|
b(_b)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool equals(const Color3B &other)
|
||||||
|
{
|
||||||
|
return (this->r == other.r &&
|
||||||
|
this->g == other.g &&
|
||||||
|
this->b == other.b);
|
||||||
|
}
|
||||||
|
|
||||||
GLubyte r;
|
GLubyte r;
|
||||||
GLubyte g;
|
GLubyte g;
|
||||||
GLubyte b;
|
GLubyte b;
|
||||||
} ccColor3B;
|
|
||||||
|
|
||||||
//! helper macro that creates an ccColor3B type
|
const static Color3B white;
|
||||||
static inline ccColor3B
|
const static Color3B yellow;
|
||||||
ccc3(const GLubyte r, const GLubyte g, const GLubyte b)
|
const static Color3B blue;
|
||||||
{
|
const static Color3B green;
|
||||||
ccColor3B c = {r, g, b};
|
const static Color3B red;
|
||||||
return c;
|
const static Color3B magenta;
|
||||||
}
|
const static Color3B black;
|
||||||
|
const static Color3B orange;
|
||||||
|
const static Color3B gray;
|
||||||
|
};
|
||||||
|
|
||||||
/** returns true if both ccColor3B are equal. Otherwise it returns false.
|
struct Color4F;
|
||||||
*/
|
|
||||||
static inline bool ccc3BEqual(const ccColor3B &col1, const ccColor3B &col2)
|
|
||||||
{
|
|
||||||
return col1.r == col2.r && col1.g == col2.g && col1.b == col2.b;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ccColor3B predefined colors
|
|
||||||
//! White color (255,255,255)
|
|
||||||
static const ccColor3B ccWHITE={255,255,255};
|
|
||||||
//! Yellow color (255,255,0)
|
|
||||||
static const ccColor3B ccYELLOW={255,255,0};
|
|
||||||
//! Blue color (0,0,255)
|
|
||||||
static const ccColor3B ccBLUE={0,0,255};
|
|
||||||
//! Green Color (0,255,0)
|
|
||||||
static const ccColor3B ccGREEN={0,255,0};
|
|
||||||
//! Red Color (255,0,0,)
|
|
||||||
static const ccColor3B ccRED={255,0,0};
|
|
||||||
//! Magenta Color (255,0,255)
|
|
||||||
static const ccColor3B ccMAGENTA={255,0,255};
|
|
||||||
//! Black Color (0,0,0)
|
|
||||||
static const ccColor3B ccBLACK={0,0,0};
|
|
||||||
//! Orange Color (255,127,0)
|
|
||||||
static const ccColor3B ccORANGE={255,127,0};
|
|
||||||
//! Gray Color (166,166,166)
|
|
||||||
static const ccColor3B ccGRAY={166,166,166};
|
|
||||||
|
|
||||||
/** RGBA color composed of 4 bytes
|
/** RGBA color composed of 4 bytes
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccColor4B
|
struct Color4B
|
||||||
{
|
{
|
||||||
|
Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)
|
||||||
|
:r(_r),
|
||||||
|
g(_g),
|
||||||
|
b(_b),
|
||||||
|
a(_a)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Color4B(): r(0.f), g(0.f), b(0.f), a(0.f) {}
|
||||||
|
|
||||||
|
// This function should use Color4F, so implement it in .cpp file.
|
||||||
|
explicit Color4B(const Color4F &color4F);
|
||||||
|
|
||||||
GLubyte r;
|
GLubyte r;
|
||||||
GLubyte g;
|
GLubyte g;
|
||||||
GLubyte b;
|
GLubyte b;
|
||||||
GLubyte a;
|
GLubyte a;
|
||||||
} ccColor4B;
|
};
|
||||||
//! helper macro that creates an ccColor4B type
|
|
||||||
static inline ccColor4B
|
|
||||||
ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)
|
|
||||||
{
|
|
||||||
ccColor4B c = {r, g, b, o};
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** RGBA color composed of 4 floats
|
/** RGBA color composed of 4 floats
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccColor4F {
|
struct Color4F
|
||||||
|
{
|
||||||
|
Color4F(float _r, float _g, float _b, float _a)
|
||||||
|
:r(_r),
|
||||||
|
g(_g),
|
||||||
|
b(_b),
|
||||||
|
a(_a)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit Color4F(const Color3B &color3B)
|
||||||
|
:r(color3B.r)
|
||||||
|
,g(color3B.g)
|
||||||
|
,b(color3B.b)
|
||||||
|
,a(1.f)
|
||||||
|
{}
|
||||||
|
|
||||||
|
explicit Color4F(const Color4B &color4B)
|
||||||
|
:r(color4B.r / 255.0f),
|
||||||
|
g(color4B.g / 255.0f),
|
||||||
|
b(color4B.b / 255.0f),
|
||||||
|
a(color4B.a / 255.0f)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Color4F(): r(0.f), g(0.f), b(0.f), a(0.f) {}
|
||||||
|
|
||||||
|
bool equals(const Color4F &other)
|
||||||
|
{
|
||||||
|
return (this->r == other.r &&
|
||||||
|
this->g == other.g &&
|
||||||
|
this->b == other.b &&
|
||||||
|
this->a == other.a);
|
||||||
|
}
|
||||||
|
|
||||||
GLfloat r;
|
GLfloat r;
|
||||||
GLfloat g;
|
GLfloat g;
|
||||||
GLfloat b;
|
GLfloat b;
|
||||||
GLfloat a;
|
GLfloat a;
|
||||||
} ccColor4F;
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.
|
|
||||||
@since v0.99.1
|
|
||||||
*/
|
|
||||||
static inline ccColor4F ccc4FFromccc3B(ccColor3B c)
|
|
||||||
{
|
|
||||||
ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, 1.f};
|
|
||||||
return c4;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! helper that creates a ccColor4f type
|
|
||||||
static inline ccColor4F
|
|
||||||
ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)
|
|
||||||
{
|
|
||||||
ccColor4F c4 = {r, g, b, a};
|
|
||||||
return c4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns a ccColor4F from a ccColor4B.
|
|
||||||
@since v0.99.1
|
|
||||||
*/
|
|
||||||
static inline ccColor4F ccc4FFromccc4B(ccColor4B c)
|
|
||||||
{
|
|
||||||
ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f};
|
|
||||||
return c4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline ccColor4B ccc4BFromccc4F(ccColor4F c)
|
|
||||||
{
|
|
||||||
ccColor4B ret = {(GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255)};
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** returns YES if both ccColor4F are equal. Otherwise it returns NO.
|
|
||||||
@since v0.99.1
|
|
||||||
*/
|
|
||||||
static inline bool ccc4FEqual(ccColor4F a, ccColor4F b)
|
|
||||||
{
|
|
||||||
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A vertex composed of 2 floats: x, y
|
/** A vertex composed of 2 floats: x, y
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccVertex2F
|
struct Vertex2F
|
||||||
{
|
{
|
||||||
|
Vertex2F(float _x, float _y) :x(_x), y(_y) {}
|
||||||
|
|
||||||
|
Vertex2F(): x(0.f), y(0.f) {}
|
||||||
|
|
||||||
GLfloat x;
|
GLfloat x;
|
||||||
GLfloat y;
|
GLfloat y;
|
||||||
} ccVertex2F;
|
};
|
||||||
|
|
||||||
static inline ccVertex2F vertex2(const float x, const float y)
|
|
||||||
{
|
|
||||||
ccVertex2F c = {x, y};
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** A vertex composed of 2 floats: x, y
|
/** A vertex composed of 2 floats: x, y
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccVertex3F
|
struct Vertex3F
|
||||||
{
|
{
|
||||||
|
Vertex3F(float _x, float _y, float _z)
|
||||||
|
:x(_x),
|
||||||
|
y(_y),
|
||||||
|
z(_z)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Vertex3F(): x(0.f), y(0.f), z(0.f) {}
|
||||||
|
|
||||||
GLfloat x;
|
GLfloat x;
|
||||||
GLfloat y;
|
GLfloat y;
|
||||||
GLfloat z;
|
GLfloat z;
|
||||||
} ccVertex3F;
|
};
|
||||||
|
|
||||||
static inline ccVertex3F vertex3(const float x, const float y, const float z)
|
|
||||||
{
|
|
||||||
ccVertex3F c = {x, y, z};
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A texcoord composed of 2 floats: u, y
|
/** A texcoord composed of 2 floats: u, y
|
||||||
@since v0.8
|
@since v3.0
|
||||||
*/
|
*/
|
||||||
typedef struct _ccTex2F {
|
struct Tex2F {
|
||||||
GLfloat u;
|
Tex2F(float _u, float _v): u(_u), v(_v) {}
|
||||||
GLfloat v;
|
|
||||||
} ccTex2F;
|
|
||||||
|
|
||||||
static inline ccTex2F tex2(const float u, const float v)
|
Tex2F(): u(0.f), v(0.f) {}
|
||||||
{
|
|
||||||
ccTex2F t = {u , v};
|
GLfloat u;
|
||||||
return t;
|
GLfloat v;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
//! Point Sprite component
|
//! Point Sprite component
|
||||||
typedef struct _ccPointSprite
|
struct PointSprite
|
||||||
{
|
{
|
||||||
ccVertex2F pos; // 8 bytes
|
Vertex2F pos; // 8 bytes
|
||||||
ccColor4B color; // 4 bytes
|
Color4B color; // 4 bytes
|
||||||
GLfloat size; // 4 bytes
|
GLfloat size; // 4 bytes
|
||||||
} ccPointSprite;
|
};
|
||||||
|
|
||||||
//! A 2D Quad. 4 * 2 floats
|
//! A 2D Quad. 4 * 2 floats
|
||||||
typedef struct _ccQuad2 {
|
struct Quad2
|
||||||
ccVertex2F tl;
|
{
|
||||||
ccVertex2F tr;
|
Vertex2F tl;
|
||||||
ccVertex2F bl;
|
Vertex2F tr;
|
||||||
ccVertex2F br;
|
Vertex2F bl;
|
||||||
} ccQuad2;
|
Vertex2F br;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//! A 3D Quad. 4 * 3 floats
|
//! A 3D Quad. 4 * 3 floats
|
||||||
typedef struct _ccQuad3 {
|
struct Quad3 {
|
||||||
ccVertex3F bl;
|
Vertex3F bl;
|
||||||
ccVertex3F br;
|
Vertex3F br;
|
||||||
ccVertex3F tl;
|
Vertex3F tl;
|
||||||
ccVertex3F tr;
|
Vertex3F tr;
|
||||||
} ccQuad3;
|
};
|
||||||
|
|
||||||
//! a Point with a vertex point, a tex coord point and a color 4B
|
//! a Point with a vertex point, a tex coord point and a color 4B
|
||||||
typedef struct _ccV2F_C4B_T2F
|
struct V2F_C4B_T2F
|
||||||
{
|
{
|
||||||
//! vertices (2F)
|
//! vertices (2F)
|
||||||
ccVertex2F vertices;
|
Vertex2F vertices;
|
||||||
//! colors (4B)
|
//! colors (4B)
|
||||||
ccColor4B colors;
|
Color4B colors;
|
||||||
//! tex coords (2F)
|
//! tex coords (2F)
|
||||||
ccTex2F texCoords;
|
Tex2F texCoords;
|
||||||
} ccV2F_C4B_T2F;
|
};
|
||||||
|
|
||||||
//! a Point with a vertex point, a tex coord point and a color 4F
|
//! a Point with a vertex point, a tex coord point and a color 4F
|
||||||
typedef struct _ccV2F_C4F_T2F
|
struct V2F_C4F_T2F
|
||||||
{
|
{
|
||||||
//! vertices (2F)
|
//! vertices (2F)
|
||||||
ccVertex2F vertices;
|
Vertex2F vertices;
|
||||||
//! colors (4F)
|
//! colors (4F)
|
||||||
ccColor4F colors;
|
Color4F colors;
|
||||||
//! tex coords (2F)
|
//! tex coords (2F)
|
||||||
ccTex2F texCoords;
|
Tex2F texCoords;
|
||||||
} ccV2F_C4F_T2F;
|
};
|
||||||
|
|
||||||
//! a Point with a vertex point, a tex coord point and a color 4B
|
//! a Point with a vertex point, a tex coord point and a color 4B
|
||||||
typedef struct _ccV3F_C4B_T2F
|
struct V3F_C4B_T2F
|
||||||
{
|
{
|
||||||
//! vertices (3F)
|
//! vertices (3F)
|
||||||
ccVertex3F vertices; // 12 bytes
|
Vertex3F vertices; // 12 bytes
|
||||||
// char __padding__[4];
|
|
||||||
|
|
||||||
//! colors (4B)
|
//! colors (4B)
|
||||||
ccColor4B colors; // 4 bytes
|
Color4B colors; // 4 bytes
|
||||||
// char __padding2__[4];
|
|
||||||
|
|
||||||
// tex coords (2F)
|
// tex coords (2F)
|
||||||
ccTex2F texCoords; // 8 bytes
|
Tex2F texCoords; // 8 bytes
|
||||||
} ccV3F_C4B_T2F;
|
};
|
||||||
|
|
||||||
//! A Triangle of ccV2F_C4B_T2F
|
//! A Triangle of V2F_C4B_T2F
|
||||||
typedef struct _ccV2F_C4B_T2F_Triangle
|
struct V2F_C4B_T2F_Triangle
|
||||||
{
|
{
|
||||||
//! Point A
|
//! Point A
|
||||||
ccV2F_C4B_T2F a;
|
V2F_C4B_T2F a;
|
||||||
//! Point B
|
//! Point B
|
||||||
ccV2F_C4B_T2F b;
|
V2F_C4B_T2F b;
|
||||||
//! Point B
|
//! Point B
|
||||||
ccV2F_C4B_T2F c;
|
V2F_C4B_T2F c;
|
||||||
} ccV2F_C4B_T2F_Triangle;
|
};
|
||||||
|
|
||||||
//! A Quad of ccV2F_C4B_T2F
|
//! A Quad of V2F_C4B_T2F
|
||||||
typedef struct _ccV2F_C4B_T2F_Quad
|
struct V2F_C4B_T2F_Quad
|
||||||
{
|
{
|
||||||
//! bottom left
|
//! bottom left
|
||||||
ccV2F_C4B_T2F bl;
|
V2F_C4B_T2F bl;
|
||||||
//! bottom right
|
//! bottom right
|
||||||
ccV2F_C4B_T2F br;
|
V2F_C4B_T2F br;
|
||||||
//! top left
|
//! top left
|
||||||
ccV2F_C4B_T2F tl;
|
V2F_C4B_T2F tl;
|
||||||
//! top right
|
//! top right
|
||||||
ccV2F_C4B_T2F tr;
|
V2F_C4B_T2F tr;
|
||||||
} ccV2F_C4B_T2F_Quad;
|
};
|
||||||
|
|
||||||
//! 4 ccVertex3FTex2FColor4B
|
//! 4 Vertex3FTex2FColor4B
|
||||||
typedef struct _ccV3F_C4B_T2F_Quad
|
struct V3F_C4B_T2F_Quad
|
||||||
{
|
{
|
||||||
//! top left
|
//! top left
|
||||||
ccV3F_C4B_T2F tl;
|
V3F_C4B_T2F tl;
|
||||||
//! bottom left
|
//! bottom left
|
||||||
ccV3F_C4B_T2F bl;
|
V3F_C4B_T2F bl;
|
||||||
//! top right
|
//! top right
|
||||||
ccV3F_C4B_T2F tr;
|
V3F_C4B_T2F tr;
|
||||||
//! bottom right
|
//! bottom right
|
||||||
ccV3F_C4B_T2F br;
|
V3F_C4B_T2F br;
|
||||||
} ccV3F_C4B_T2F_Quad;
|
};
|
||||||
|
|
||||||
//! 4 ccVertex2FTex2FColor4F Quad
|
//! 4 Vertex2FTex2FColor4F Quad
|
||||||
typedef struct _ccV2F_C4F_T2F_Quad
|
struct V2F_C4F_T2F_Quad
|
||||||
{
|
{
|
||||||
//! bottom left
|
//! bottom left
|
||||||
ccV2F_C4F_T2F bl;
|
V2F_C4F_T2F bl;
|
||||||
//! bottom right
|
//! bottom right
|
||||||
ccV2F_C4F_T2F br;
|
V2F_C4F_T2F br;
|
||||||
//! top left
|
//! top left
|
||||||
ccV2F_C4F_T2F tl;
|
V2F_C4F_T2F tl;
|
||||||
//! top right
|
//! top right
|
||||||
ccV2F_C4F_T2F tr;
|
V2F_C4F_T2F tr;
|
||||||
} ccV2F_C4F_T2F_Quad;
|
};
|
||||||
|
|
||||||
//! Blend Function used for textures
|
//! Blend Function used for textures
|
||||||
typedef struct _ccBlendFunc
|
struct BlendFunc
|
||||||
{
|
{
|
||||||
//! source blend function
|
//! source blend function
|
||||||
GLenum src;
|
GLenum src;
|
||||||
//! destination blend function
|
//! destination blend function
|
||||||
GLenum dst;
|
GLenum dst;
|
||||||
} ccBlendFunc;
|
|
||||||
|
|
||||||
static const ccBlendFunc kBlendFuncDisable = {GL_ONE, GL_ZERO};
|
const static BlendFunc blendFuncDisable;
|
||||||
|
};
|
||||||
|
|
||||||
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
// XXX: If any of these enums are edited and/or reordered, update Texture2D.m
|
||||||
//! Vertical text alignment type
|
//! Vertical text alignment type
|
||||||
|
@ -340,25 +325,25 @@ typedef enum
|
||||||
// types for animation in particle systems
|
// types for animation in particle systems
|
||||||
|
|
||||||
// texture coordinates for a quad
|
// texture coordinates for a quad
|
||||||
typedef struct _ccT2F_Quad
|
struct T2F_Quad
|
||||||
{
|
{
|
||||||
//! bottom left
|
//! bottom left
|
||||||
ccTex2F bl;
|
Tex2F bl;
|
||||||
//! bottom right
|
//! bottom right
|
||||||
ccTex2F br;
|
Tex2F br;
|
||||||
//! top left
|
//! top left
|
||||||
ccTex2F tl;
|
Tex2F tl;
|
||||||
//! top right
|
//! top right
|
||||||
ccTex2F tr;
|
Tex2F tr;
|
||||||
} ccT2F_Quad;
|
};
|
||||||
|
|
||||||
// struct that holds the size in pixels, texture coordinates and delays for animated ParticleSystemQuad
|
// struct that holds the size in pixels, texture coordinates and delays for animated ParticleSystemQuad
|
||||||
typedef struct
|
struct AnimationFrameData
|
||||||
{
|
{
|
||||||
ccT2F_Quad texCoords;
|
T2F_Quad texCoords;
|
||||||
float delay;
|
float delay;
|
||||||
Size size;
|
Size size;
|
||||||
} ccAnimationFrameData;
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,55 +352,54 @@ typedef struct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// shadow attributes
|
// shadow attributes
|
||||||
typedef struct _ccFontShadow
|
struct FontShadow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// shadow is not enabled by default
|
// shadow is not enabled by default
|
||||||
_ccFontShadow(): _shadowEnabled(false) {}
|
FontShadow(): _shadowEnabled(false) {}
|
||||||
|
|
||||||
// true if shadow enabled
|
// true if shadow enabled
|
||||||
bool _shadowEnabled;
|
bool _shadowEnabled;
|
||||||
// shadow x and y offset
|
// shadow x and y offset
|
||||||
Size _shadowOffset;
|
Size _shadowOffset;
|
||||||
// shadow blurrines
|
// shadow blurrines
|
||||||
float _shadowBlur;
|
float _shadowBlur;
|
||||||
// shadow opacity
|
// shadow opacity
|
||||||
float _shadowOpacity;
|
float _shadowOpacity;
|
||||||
|
};
|
||||||
} ccFontShadow;
|
|
||||||
|
|
||||||
// stroke attributes
|
// stroke attributes
|
||||||
typedef struct _ccFontStroke
|
struct FontStroke
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// stroke is disabled by default
|
// stroke is disabled by default
|
||||||
_ccFontStroke(): _strokeEnabled(false) {}
|
FontStroke(): _strokeEnabled(false) {}
|
||||||
|
|
||||||
// true if stroke enabled
|
// true if stroke enabled
|
||||||
bool _strokeEnabled;
|
bool _strokeEnabled;
|
||||||
// stroke color
|
// stroke color
|
||||||
ccColor3B _strokeColor;
|
Color3B _strokeColor;
|
||||||
// stroke size
|
// stroke size
|
||||||
float _strokeSize;
|
float _strokeSize;
|
||||||
|
|
||||||
} ccFontStroke;
|
};
|
||||||
|
|
||||||
// font attributes
|
// font attributes
|
||||||
typedef struct _ccFontDefinition
|
struct FontDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
_ccFontDefinition(): _alignment(kTextAlignmentCenter),
|
FontDefinition(): _alignment(kTextAlignmentCenter),
|
||||||
_vertAlignment(kVerticalTextAlignmentTop),
|
_vertAlignment(kVerticalTextAlignmentTop),
|
||||||
_fontFillColor(ccWHITE)
|
_fontFillColor(Color3B::white)
|
||||||
{ _dimensions = CCSizeMake(0,0); }
|
{ _dimensions = CCSizeMake(0,0); }
|
||||||
|
|
||||||
// font name
|
// font name
|
||||||
std::string _fontName;
|
std::string _fontName;
|
||||||
// font size
|
// font size
|
||||||
int _fontSize;
|
int _fontSize;
|
||||||
// horizontal alignment
|
// horizontal alignment
|
||||||
TextAlignment _alignment;
|
TextAlignment _alignment;
|
||||||
// vertical alignment
|
// vertical alignment
|
||||||
|
@ -423,13 +407,13 @@ public:
|
||||||
// renering box
|
// renering box
|
||||||
Size _dimensions;
|
Size _dimensions;
|
||||||
// font color
|
// font color
|
||||||
ccColor3B _fontFillColor;
|
Color3B _fontFillColor;
|
||||||
// font shadow
|
// font shadow
|
||||||
ccFontShadow _shadow;
|
FontShadow _shadow;
|
||||||
// font stroke
|
// font stroke
|
||||||
ccFontStroke _stroke;
|
FontStroke _stroke;
|
||||||
|
|
||||||
} ccFontDefinition;
|
};
|
||||||
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -130,7 +130,7 @@ void LabelAtlas::updateAtlasValues()
|
||||||
}
|
}
|
||||||
|
|
||||||
CCAssert( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
CCAssert( n <= _textureAtlas->getCapacity(), "updateAtlasValues: Invalid String length");
|
||||||
ccV3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
||||||
for(unsigned int i = 0; i < n; i++) {
|
for(unsigned int i = 0; i < n; i++) {
|
||||||
|
|
||||||
unsigned char a = s[i] - _mapStartChar;
|
unsigned char a = s[i] - _mapStartChar;
|
||||||
|
@ -171,7 +171,7 @@ void LabelAtlas::updateAtlasValues()
|
||||||
quads[i].tr.vertices.x = (float)(i * _itemWidth + _itemWidth);
|
quads[i].tr.vertices.x = (float)(i * _itemWidth + _itemWidth);
|
||||||
quads[i].tr.vertices.y = (float)(_itemHeight);
|
quads[i].tr.vertices.y = (float)(_itemHeight);
|
||||||
quads[i].tr.vertices.z = 0.0f;
|
quads[i].tr.vertices.z = 0.0f;
|
||||||
ccColor4B c = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
|
Color4B c(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity);
|
||||||
quads[i].tl.colors = c;
|
quads[i].tl.colors = c;
|
||||||
quads[i].tr.colors = c;
|
quads[i].tr.colors = c;
|
||||||
quads[i].bl.colors = c;
|
quads[i].bl.colors = c;
|
||||||
|
|
|
@ -507,7 +507,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo
|
||||||
_alignment = alignment;
|
_alignment = alignment;
|
||||||
|
|
||||||
_displayedOpacity = _realOpacity = 255;
|
_displayedOpacity = _realOpacity = 255;
|
||||||
_displayedColor = _realColor = ccWHITE;
|
_displayedColor = _realColor = Color3B::white;
|
||||||
_cascadeOpacityEnabled = true;
|
_cascadeOpacityEnabled = true;
|
||||||
_cascadeColorEnabled = true;
|
_cascadeColorEnabled = true;
|
||||||
|
|
||||||
|
@ -540,8 +540,8 @@ LabelBMFont::LabelBMFont()
|
||||||
, _reusedChar(NULL)
|
, _reusedChar(NULL)
|
||||||
, _displayedOpacity(255)
|
, _displayedOpacity(255)
|
||||||
, _realOpacity(255)
|
, _realOpacity(255)
|
||||||
, _displayedColor(ccWHITE)
|
, _displayedColor(Color3B::white)
|
||||||
, _realColor(ccWHITE)
|
, _realColor(Color3B::white)
|
||||||
, _cascadeColorEnabled(true)
|
, _cascadeColorEnabled(true)
|
||||||
, _cascadeOpacityEnabled(true)
|
, _cascadeOpacityEnabled(true)
|
||||||
, _isOpacityModifyRGB(false)
|
, _isOpacityModifyRGB(false)
|
||||||
|
@ -788,22 +788,22 @@ void LabelBMFont::setCString(const char *label)
|
||||||
}
|
}
|
||||||
|
|
||||||
//LabelBMFont - RGBAProtocol protocol
|
//LabelBMFont - RGBAProtocol protocol
|
||||||
const ccColor3B& LabelBMFont::getColor() const
|
const Color3B& LabelBMFont::getColor() const
|
||||||
{
|
{
|
||||||
return _realColor;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& LabelBMFont::getDisplayedColor() const
|
const Color3B& LabelBMFont::getDisplayedColor() const
|
||||||
{
|
{
|
||||||
return _displayedColor;
|
return _displayedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelBMFont::setColor(const ccColor3B& color)
|
void LabelBMFont::setColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_displayedColor = _realColor = color;
|
_displayedColor = _realColor = color;
|
||||||
|
|
||||||
if( _cascadeColorEnabled ) {
|
if( _cascadeColorEnabled ) {
|
||||||
ccColor3B parentColor = ccWHITE;
|
Color3B parentColor = Color3B::white;
|
||||||
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
RGBAProtocol* pParent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||||
if (pParent && pParent->isCascadeColorEnabled())
|
if (pParent && pParent->isCascadeColorEnabled())
|
||||||
{
|
{
|
||||||
|
@ -876,7 +876,7 @@ void LabelBMFont::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelBMFont::updateDisplayedColor(const ccColor3B& parentColor)
|
void LabelBMFont::updateDisplayedColor(const Color3B& parentColor)
|
||||||
{
|
{
|
||||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||||
|
|
|
@ -234,10 +234,10 @@ public:
|
||||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||||
virtual bool isCascadeOpacityEnabled() const;
|
virtual bool isCascadeOpacityEnabled() const;
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||||
virtual const ccColor3B& getColor(void) const;
|
virtual const Color3B& getColor(void) const;
|
||||||
virtual const ccColor3B& getDisplayedColor() const;
|
virtual const Color3B& getDisplayedColor() const;
|
||||||
virtual void setColor(const ccColor3B& color);
|
virtual void setColor(const Color3B& color);
|
||||||
virtual void updateDisplayedColor(const ccColor3B& parentColor);
|
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||||
virtual bool isCascadeColorEnabled() const;
|
virtual bool isCascadeColorEnabled() const;
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ protected:
|
||||||
// texture RGBA
|
// texture RGBA
|
||||||
GLubyte _displayedOpacity;
|
GLubyte _displayedOpacity;
|
||||||
GLubyte _realOpacity;
|
GLubyte _realOpacity;
|
||||||
ccColor3B _displayedColor;
|
Color3B _displayedColor;
|
||||||
ccColor3B _realColor;
|
Color3B _realColor;
|
||||||
bool _cascadeColorEnabled;
|
bool _cascadeColorEnabled;
|
||||||
bool _cascadeOpacityEnabled;
|
bool _cascadeOpacityEnabled;
|
||||||
/** conforms to RGBAProtocol protocol */
|
/** conforms to RGBAProtocol protocol */
|
||||||
|
|
|
@ -47,7 +47,7 @@ LabelTTF::LabelTTF()
|
||||||
, _string("")
|
, _string("")
|
||||||
, _shadowEnabled(false)
|
, _shadowEnabled(false)
|
||||||
, _strokeEnabled(false)
|
, _strokeEnabled(false)
|
||||||
, _textFillColor(ccWHITE)
|
, _textFillColor(Color3B::white)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontS
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelTTF * LabelTTF::createWithFontDefinition(const char *string, ccFontDefinition &textDefinition)
|
LabelTTF * LabelTTF::createWithFontDefinition(const char *string, FontDefinition &textDefinition)
|
||||||
{
|
{
|
||||||
LabelTTF *pRet = new LabelTTF();
|
LabelTTF *pRet = new LabelTTF();
|
||||||
if(pRet && pRet->initWithStringAndTextDefinition(string, textDefinition))
|
if(pRet && pRet->initWithStringAndTextDefinition(string, textDefinition))
|
||||||
|
@ -148,7 +148,7 @@ bool LabelTTF::initWithString(const char *string, const char *fontName, float fo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LabelTTF::initWithStringAndTextDefinition(const char *string, ccFontDefinition &textDefinition)
|
bool LabelTTF::initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition)
|
||||||
{
|
{
|
||||||
if (Sprite::init())
|
if (Sprite::init())
|
||||||
{
|
{
|
||||||
|
@ -300,8 +300,8 @@ bool LabelTTF::updateTexture()
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
||||||
ccFontDefinition texDef = _prepareTextDefinition(true);
|
FontDefinition texDef = _prepareTextDefinition(true);
|
||||||
tex->initWithString( _string.c_str(), &texDef );
|
tex->initWithString( _string.c_str(), texDef );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ void LabelTTF::disableShadow(bool updateTexture)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTTF::enableStroke(const ccColor3B &strokeColor, float strokeSize, bool updateTexture)
|
void LabelTTF::enableStroke(const Color3B &strokeColor, float strokeSize, bool updateTexture)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ void LabelTTF::disableStroke(bool updateTexture)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTTF::setFontFillColor(const ccColor3B &tintColor, bool updateTexture)
|
void LabelTTF::setFontFillColor(const Color3B &tintColor, bool updateTexture)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
if (_textFillColor.r != tintColor.r || _textFillColor.g != tintColor.g || _textFillColor.b != tintColor.b)
|
if (_textFillColor.r != tintColor.r || _textFillColor.g != tintColor.g || _textFillColor.b != tintColor.b)
|
||||||
|
@ -458,22 +458,17 @@ void LabelTTF::setFontFillColor(const ccColor3B &tintColor, bool updateTexture)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTTF::setTextDefinition(ccFontDefinition *theDefinition)
|
void LabelTTF::setTextDefinition(const FontDefinition& theDefinition)
|
||||||
{
|
{
|
||||||
if (theDefinition)
|
_updateWithTextDefinition(theDefinition, true);
|
||||||
{
|
|
||||||
_updateWithTextDefinition(*theDefinition, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ccFontDefinition *LabelTTF::getTextDefinition()
|
FontDefinition LabelTTF::getTextDefinition()
|
||||||
{
|
{
|
||||||
ccFontDefinition *tempDefinition = new ccFontDefinition;
|
return _prepareTextDefinition(false);
|
||||||
*tempDefinition = _prepareTextDefinition(false);
|
|
||||||
return tempDefinition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTTF::_updateWithTextDefinition(ccFontDefinition & textDefinition, bool mustUpdateTexture)
|
void LabelTTF::_updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture)
|
||||||
{
|
{
|
||||||
_dimensions = CCSizeMake(textDefinition._dimensions.width, textDefinition._dimensions.height);
|
_dimensions = CCSizeMake(textDefinition._dimensions.width, textDefinition._dimensions.height);
|
||||||
_alignment = textDefinition._alignment;
|
_alignment = textDefinition._alignment;
|
||||||
|
@ -502,9 +497,9 @@ void LabelTTF::_updateWithTextDefinition(ccFontDefinition & textDefinition, bool
|
||||||
updateTexture();
|
updateTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
ccFontDefinition LabelTTF::_prepareTextDefinition(bool adjustForResolution)
|
FontDefinition LabelTTF::_prepareTextDefinition(bool adjustForResolution)
|
||||||
{
|
{
|
||||||
ccFontDefinition texDef;
|
FontDefinition texDef;
|
||||||
|
|
||||||
if (adjustForResolution)
|
if (adjustForResolution)
|
||||||
texDef._fontSize = _fontSize * CC_CONTENT_SCALE_FACTOR();
|
texDef._fontSize = _fontSize * CC_CONTENT_SCALE_FACTOR();
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/** Create a lable with string and a font definition*/
|
/** Create a lable with string and a font definition*/
|
||||||
static LabelTTF * createWithFontDefinition(const char *string, ccFontDefinition &textDefinition);
|
static LabelTTF * createWithFontDefinition(const char *string, FontDefinition &textDefinition);
|
||||||
|
|
||||||
/** initializes the LabelTTF with a font name and font size */
|
/** initializes the LabelTTF with a font name and font size */
|
||||||
bool initWithString(const char *string, const char *fontName, float fontSize);
|
bool initWithString(const char *string, const char *fontName, float fontSize);
|
||||||
|
@ -96,13 +96,13 @@ public:
|
||||||
VerticalTextAlignment vAlignment);
|
VerticalTextAlignment vAlignment);
|
||||||
|
|
||||||
/** initializes the LabelTTF with a font name, alignment, dimension and font size */
|
/** initializes the LabelTTF with a font name, alignment, dimension and font size */
|
||||||
bool initWithStringAndTextDefinition(const char *string, ccFontDefinition &textDefinition);
|
bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition);
|
||||||
|
|
||||||
/** set the text definition used by this label */
|
/** set the text definition used by this label */
|
||||||
void setTextDefinition(ccFontDefinition *theDefinition);
|
void setTextDefinition(const FontDefinition& theDefinition);
|
||||||
|
|
||||||
/** get the text definition used by this label */
|
/** get the text definition used by this label */
|
||||||
ccFontDefinition * getTextDefinition();
|
FontDefinition getTextDefinition();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,13 +113,13 @@ public:
|
||||||
void disableShadow(bool mustUpdateTexture = true);
|
void disableShadow(bool mustUpdateTexture = true);
|
||||||
|
|
||||||
/** enable or disable stroke */
|
/** enable or disable stroke */
|
||||||
void enableStroke(const ccColor3B &strokeColor, float strokeSize, bool mustUpdateTexture = true);
|
void enableStroke(const Color3B &strokeColor, float strokeSize, bool mustUpdateTexture = true);
|
||||||
|
|
||||||
/** disable stroke */
|
/** disable stroke */
|
||||||
void disableStroke(bool mustUpdateTexture = true);
|
void disableStroke(bool mustUpdateTexture = true);
|
||||||
|
|
||||||
/** set text tinting */
|
/** set text tinting */
|
||||||
void setFontFillColor(const ccColor3B &tintColor, bool mustUpdateTexture = true);
|
void setFontFillColor(const Color3B &tintColor, bool mustUpdateTexture = true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ private:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** set the text definition for this label */
|
/** set the text definition for this label */
|
||||||
void _updateWithTextDefinition(ccFontDefinition & textDefinition, bool mustUpdateTexture = true);
|
void _updateWithTextDefinition(const FontDefinition& textDefinition, bool mustUpdateTexture = true);
|
||||||
ccFontDefinition _prepareTextDefinition(bool adjustForResolution = false);
|
FontDefinition _prepareTextDefinition(bool adjustForResolution = false);
|
||||||
|
|
||||||
/** Dimensions of the label in Points */
|
/** Dimensions of the label in Points */
|
||||||
Size _dimensions;
|
Size _dimensions;
|
||||||
|
@ -174,18 +174,18 @@ protected:
|
||||||
|
|
||||||
/** font shadow */
|
/** font shadow */
|
||||||
bool _shadowEnabled;
|
bool _shadowEnabled;
|
||||||
Size _shadowOffset;
|
Size _shadowOffset;
|
||||||
float _shadowOpacity;
|
float _shadowOpacity;
|
||||||
float _shadowBlur;
|
float _shadowBlur;
|
||||||
|
|
||||||
|
|
||||||
/** font stroke */
|
/** font stroke */
|
||||||
bool _strokeEnabled;
|
bool _strokeEnabled;
|
||||||
ccColor3B _strokeColor;
|
Color3B _strokeColor;
|
||||||
float _strokeSize;
|
float _strokeSize;
|
||||||
|
|
||||||
/** font tint */
|
/** font tint */
|
||||||
ccColor3B _textFillColor;
|
Color3B _textFillColor;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -557,8 +557,8 @@ void Layer::ccTouchesCancelled(Set *pTouches, Event *pEvent)
|
||||||
LayerRGBA::LayerRGBA()
|
LayerRGBA::LayerRGBA()
|
||||||
: _displayedOpacity(255)
|
: _displayedOpacity(255)
|
||||||
, _realOpacity (255)
|
, _realOpacity (255)
|
||||||
, _displayedColor(ccWHITE)
|
, _displayedColor(Color3B::white)
|
||||||
, _realColor(ccWHITE)
|
, _realColor(Color3B::white)
|
||||||
, _cascadeOpacityEnabled(false)
|
, _cascadeOpacityEnabled(false)
|
||||||
, _cascadeColorEnabled(false)
|
, _cascadeColorEnabled(false)
|
||||||
{}
|
{}
|
||||||
|
@ -570,7 +570,7 @@ bool LayerRGBA::init()
|
||||||
if (Layer::init())
|
if (Layer::init())
|
||||||
{
|
{
|
||||||
_displayedOpacity = _realOpacity = 255;
|
_displayedOpacity = _realOpacity = 255;
|
||||||
_displayedColor = _realColor = ccWHITE;
|
_displayedColor = _realColor = Color3B::white;
|
||||||
setCascadeOpacityEnabled(false);
|
setCascadeOpacityEnabled(false);
|
||||||
setCascadeColorEnabled(false);
|
setCascadeColorEnabled(false);
|
||||||
|
|
||||||
|
@ -609,23 +609,23 @@ void LayerRGBA::setOpacity(GLubyte opacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& LayerRGBA::getColor() const
|
const Color3B& LayerRGBA::getColor() const
|
||||||
{
|
{
|
||||||
return _realColor;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& LayerRGBA::getDisplayedColor() const
|
const Color3B& LayerRGBA::getDisplayedColor() const
|
||||||
{
|
{
|
||||||
return _displayedColor;
|
return _displayedColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerRGBA::setColor(const ccColor3B& color)
|
void LayerRGBA::setColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_displayedColor = _realColor = color;
|
_displayedColor = _realColor = color;
|
||||||
|
|
||||||
if (_cascadeColorEnabled)
|
if (_cascadeColorEnabled)
|
||||||
{
|
{
|
||||||
ccColor3B parentColor = ccWHITE;
|
Color3B parentColor = Color3B::white;
|
||||||
RGBAProtocol* parent = dynamic_cast<RGBAProtocol*>(_parent);
|
RGBAProtocol* parent = dynamic_cast<RGBAProtocol*>(_parent);
|
||||||
if (parent && parent->isCascadeColorEnabled())
|
if (parent && parent->isCascadeColorEnabled())
|
||||||
{
|
{
|
||||||
|
@ -654,7 +654,7 @@ void LayerRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerRGBA::updateDisplayedColor(const ccColor3B& parentColor)
|
void LayerRGBA::updateDisplayedColor(const Color3B& parentColor)
|
||||||
{
|
{
|
||||||
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
||||||
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
||||||
|
@ -708,12 +708,12 @@ LayerColor::~LayerColor()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// blendFunc getter
|
/// blendFunc getter
|
||||||
const ccBlendFunc &LayerColor::getBlendFunc() const
|
const BlendFunc &LayerColor::getBlendFunc() const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
/// blendFunc setter
|
/// blendFunc setter
|
||||||
void LayerColor::setBlendFunc(const ccBlendFunc &var)
|
void LayerColor::setBlendFunc(const BlendFunc &var)
|
||||||
{
|
{
|
||||||
_blendFunc = var;
|
_blendFunc = var;
|
||||||
}
|
}
|
||||||
|
@ -732,7 +732,7 @@ LayerColor* LayerColor::create()
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerColor * LayerColor::create(const ccColor4B& color, GLfloat width, GLfloat height)
|
LayerColor * LayerColor::create(const Color4B& color, GLfloat width, GLfloat height)
|
||||||
{
|
{
|
||||||
LayerColor * pLayer = new LayerColor();
|
LayerColor * pLayer = new LayerColor();
|
||||||
if( pLayer && pLayer->initWithColor(color,width,height))
|
if( pLayer && pLayer->initWithColor(color,width,height))
|
||||||
|
@ -744,7 +744,7 @@ LayerColor * LayerColor::create(const ccColor4B& color, GLfloat width, GLfloat h
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerColor * LayerColor::create(const ccColor4B& color)
|
LayerColor * LayerColor::create(const Color4B& color)
|
||||||
{
|
{
|
||||||
LayerColor * pLayer = new LayerColor();
|
LayerColor * pLayer = new LayerColor();
|
||||||
if(pLayer && pLayer->initWithColor(color))
|
if(pLayer && pLayer->initWithColor(color))
|
||||||
|
@ -759,10 +759,10 @@ LayerColor * LayerColor::create(const ccColor4B& color)
|
||||||
bool LayerColor::init()
|
bool LayerColor::init()
|
||||||
{
|
{
|
||||||
Size s = Director::sharedDirector()->getWinSize();
|
Size s = Director::sharedDirector()->getWinSize();
|
||||||
return initWithColor(ccc4(0,0,0,0), s.width, s.height);
|
return initWithColor(Color4B(0,0,0,0), s.width, s.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerColor::initWithColor(const ccColor4B& color, GLfloat w, GLfloat h)
|
bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h)
|
||||||
{
|
{
|
||||||
if (Layer::init())
|
if (Layer::init())
|
||||||
{
|
{
|
||||||
|
@ -791,7 +791,7 @@ bool LayerColor::initWithColor(const ccColor4B& color, GLfloat w, GLfloat h)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerColor::initWithColor(const ccColor4B& color)
|
bool LayerColor::initWithColor(const Color4B& color)
|
||||||
{
|
{
|
||||||
Size s = Director::sharedDirector()->getWinSize();
|
Size s = Director::sharedDirector()->getWinSize();
|
||||||
this->initWithColor(color, s.width, s.height);
|
this->initWithColor(color, s.width, s.height);
|
||||||
|
@ -845,10 +845,10 @@ void LayerColor::draw()
|
||||||
// Attributes
|
// Attributes
|
||||||
//
|
//
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData(_squareVertices, 4 * sizeof(ccVertex2F), 0);
|
setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
setGLBufferData(_squareColors, 4 * sizeof(ccColor4F), 1);
|
setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices);
|
||||||
|
@ -862,7 +862,7 @@ void LayerColor::draw()
|
||||||
CC_INCREMENT_GL_DRAWS(1);
|
CC_INCREMENT_GL_DRAWS(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerColor::setColor(const ccColor3B &color)
|
void LayerColor::setColor(const Color3B &color)
|
||||||
{
|
{
|
||||||
LayerRGBA::setColor(color);
|
LayerRGBA::setColor(color);
|
||||||
updateColor();
|
updateColor();
|
||||||
|
@ -877,7 +877,7 @@ void LayerColor::setOpacity(GLubyte opacity)
|
||||||
//
|
//
|
||||||
// LayerGradient
|
// LayerGradient
|
||||||
//
|
//
|
||||||
LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& end)
|
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
|
||||||
{
|
{
|
||||||
LayerGradient * pLayer = new LayerGradient();
|
LayerGradient * pLayer = new LayerGradient();
|
||||||
if( pLayer && pLayer->initWithColor(start, end))
|
if( pLayer && pLayer->initWithColor(start, end))
|
||||||
|
@ -889,7 +889,7 @@ LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& en
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& end, const Point& v)
|
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end, const Point& v)
|
||||||
{
|
{
|
||||||
LayerGradient * pLayer = new LayerGradient();
|
LayerGradient * pLayer = new LayerGradient();
|
||||||
if( pLayer && pLayer->initWithColor(start, end, v))
|
if( pLayer && pLayer->initWithColor(start, end, v))
|
||||||
|
@ -917,15 +917,15 @@ LayerGradient* LayerGradient::create()
|
||||||
|
|
||||||
bool LayerGradient::init()
|
bool LayerGradient::init()
|
||||||
{
|
{
|
||||||
return initWithColor(ccc4(0, 0, 0, 255), ccc4(0, 0, 0, 255));
|
return initWithColor(Color4B(0, 0, 0, 255), Color4B(0, 0, 0, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerGradient::initWithColor(const ccColor4B& start, const ccColor4B& end)
|
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end)
|
||||||
{
|
{
|
||||||
return initWithColor(start, end, ccp(0, -1));
|
return initWithColor(start, end, ccp(0, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayerGradient::initWithColor(const ccColor4B& start, const ccColor4B& end, const Point& v)
|
bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, const Point& v)
|
||||||
{
|
{
|
||||||
_endColor.r = end.r;
|
_endColor.r = end.r;
|
||||||
_endColor.g = end.g;
|
_endColor.g = end.g;
|
||||||
|
@ -937,7 +937,7 @@ bool LayerGradient::initWithColor(const ccColor4B& start, const ccColor4B& end,
|
||||||
|
|
||||||
_compressedInterpolation = true;
|
_compressedInterpolation = true;
|
||||||
|
|
||||||
return LayerColor::initWithColor(ccc4(start.r, start.g, start.b, 255));
|
return LayerColor::initWithColor(Color4B(start.r, start.g, start.b, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerGradient::updateColor()
|
void LayerGradient::updateColor()
|
||||||
|
@ -960,19 +960,19 @@ void LayerGradient::updateColor()
|
||||||
|
|
||||||
float opacityf = (float)_displayedOpacity / 255.0f;
|
float opacityf = (float)_displayedOpacity / 255.0f;
|
||||||
|
|
||||||
ccColor4F S = {
|
Color4F S(
|
||||||
_displayedColor.r / 255.0f,
|
_displayedColor.r / 255.0f,
|
||||||
_displayedColor.g / 255.0f,
|
_displayedColor.g / 255.0f,
|
||||||
_displayedColor.b / 255.0f,
|
_displayedColor.b / 255.0f,
|
||||||
_startOpacity * opacityf / 255.0f
|
_startOpacity * opacityf / 255.0f
|
||||||
};
|
);
|
||||||
|
|
||||||
ccColor4F E = {
|
Color4F E(
|
||||||
_endColor.r / 255.0f,
|
_endColor.r / 255.0f,
|
||||||
_endColor.g / 255.0f,
|
_endColor.g / 255.0f,
|
||||||
_endColor.b / 255.0f,
|
_endColor.b / 255.0f,
|
||||||
_endOpacity * opacityf / 255.0f
|
_endOpacity * opacityf / 255.0f
|
||||||
};
|
);
|
||||||
|
|
||||||
// (-1, -1)
|
// (-1, -1)
|
||||||
_squareColors[0].r = E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c));
|
_squareColors[0].r = E.r + (S.r - E.r) * ((c + u.x + u.y) / (2.0f * c));
|
||||||
|
@ -996,23 +996,23 @@ void LayerGradient::updateColor()
|
||||||
_squareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c));
|
_squareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c));
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& LayerGradient::getStartColor() const
|
const Color3B& LayerGradient::getStartColor() const
|
||||||
{
|
{
|
||||||
return _realColor;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerGradient::setStartColor(const ccColor3B& color)
|
void LayerGradient::setStartColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerGradient::setEndColor(const ccColor3B& color)
|
void LayerGradient::setEndColor(const Color3B& color)
|
||||||
{
|
{
|
||||||
_endColor = color;
|
_endColor = color;
|
||||||
updateColor();
|
updateColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& LayerGradient::getEndColor() const
|
const Color3B& LayerGradient::getEndColor() const
|
||||||
{
|
{
|
||||||
return _endColor;
|
return _endColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,10 +202,10 @@ public:
|
||||||
virtual bool isCascadeOpacityEnabled() const;
|
virtual bool isCascadeOpacityEnabled() const;
|
||||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||||
|
|
||||||
virtual const ccColor3B& getColor() const;
|
virtual const Color3B& getColor() const;
|
||||||
virtual const ccColor3B& getDisplayedColor() const;
|
virtual const Color3B& getDisplayedColor() const;
|
||||||
virtual void setColor(const ccColor3B& color);
|
virtual void setColor(const Color3B& color);
|
||||||
virtual void updateDisplayedColor(const ccColor3B& parentColor);
|
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||||
virtual bool isCascadeColorEnabled() const;
|
virtual bool isCascadeColorEnabled() const;
|
||||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ public:
|
||||||
virtual bool isOpacityModifyRGB() const { return false; }
|
virtual bool isOpacityModifyRGB() const { return false; }
|
||||||
protected:
|
protected:
|
||||||
GLubyte _displayedOpacity, _realOpacity;
|
GLubyte _displayedOpacity, _realOpacity;
|
||||||
ccColor3B _displayedColor, _realColor;
|
Color3B _displayedColor, _realColor;
|
||||||
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
bool _cascadeOpacityEnabled, _cascadeColorEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,8 +232,8 @@ class CC_DLL LayerColor : public LayerRGBA, public BlendProtocol
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ccVertex2F _squareVertices[4];
|
Vertex2F _squareVertices[4];
|
||||||
ccColor4F _squareColors[4];
|
Color4F _squareColors[4];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LayerColor();
|
LayerColor();
|
||||||
|
@ -246,15 +246,15 @@ public:
|
||||||
static LayerColor* create();
|
static LayerColor* create();
|
||||||
|
|
||||||
/** creates a Layer with color, width and height in Points */
|
/** creates a Layer with color, width and height in Points */
|
||||||
static LayerColor * create(const ccColor4B& color, GLfloat width, GLfloat height);
|
static LayerColor * create(const Color4B& color, GLfloat width, GLfloat height);
|
||||||
/** creates a Layer with color. Width and height are the window size. */
|
/** creates a Layer with color. Width and height are the window size. */
|
||||||
static LayerColor * create(const ccColor4B& color);
|
static LayerColor * create(const Color4B& color);
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
/** initializes a Layer with color, width and height in Points */
|
/** initializes a Layer with color, width and height in Points */
|
||||||
virtual bool initWithColor(const ccColor4B& color, GLfloat width, GLfloat height);
|
virtual bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
|
||||||
/** initializes a Layer with color. Width and height are the window size. */
|
/** initializes a Layer with color. Width and height are the window size. */
|
||||||
virtual bool initWithColor(const ccColor4B& color);
|
virtual bool initWithColor(const Color4B& color);
|
||||||
|
|
||||||
/** change width in Points*/
|
/** change width in Points*/
|
||||||
void changeWidth(GLfloat w);
|
void changeWidth(GLfloat w);
|
||||||
|
@ -266,11 +266,11 @@ public:
|
||||||
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
void changeWidthAndHeight(GLfloat w ,GLfloat h);
|
||||||
|
|
||||||
/** BlendFunction. Conforms to BlendProtocol protocol */
|
/** BlendFunction. Conforms to BlendProtocol protocol */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc)
|
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
|
||||||
|
|
||||||
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
|
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
|
||||||
virtual bool isOpacityModifyRGB(void) const { return false;}
|
virtual bool isOpacityModifyRGB(void) const { return false;}
|
||||||
virtual void setColor(const ccColor3B &color);
|
virtual void setColor(const Color3B &color);
|
||||||
virtual void setOpacity(GLubyte opacity);
|
virtual void setOpacity(GLubyte opacity);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -307,17 +307,17 @@ public:
|
||||||
static LayerGradient* create();
|
static LayerGradient* create();
|
||||||
|
|
||||||
/** Creates a full-screen Layer with a gradient between start and end. */
|
/** Creates a full-screen Layer with a gradient between start and end. */
|
||||||
static LayerGradient* create(const ccColor4B& start, const ccColor4B& end);
|
static LayerGradient* create(const Color4B& start, const Color4B& end);
|
||||||
|
|
||||||
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
|
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
|
||||||
static LayerGradient* create(const ccColor4B& start, const ccColor4B& end, const Point& v);
|
static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v);
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
/** Initializes the Layer with a gradient between start and end. */
|
/** Initializes the Layer with a gradient between start and end. */
|
||||||
virtual bool initWithColor(const ccColor4B& start, const ccColor4B& end);
|
virtual bool initWithColor(const Color4B& start, const Color4B& end);
|
||||||
|
|
||||||
/** Initializes the Layer with a gradient between start and end in the direction of v. */
|
/** Initializes the Layer with a gradient between start and end in the direction of v. */
|
||||||
virtual bool initWithColor(const ccColor4B& start, const ccColor4B& end, const Point& v);
|
virtual bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
|
||||||
|
|
||||||
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
|
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
|
||||||
Default: YES
|
Default: YES
|
||||||
|
@ -325,8 +325,8 @@ public:
|
||||||
virtual void setCompressedInterpolation(bool bCompressedInterpolation);
|
virtual void setCompressedInterpolation(bool bCompressedInterpolation);
|
||||||
virtual bool isCompressedInterpolation() const;
|
virtual bool isCompressedInterpolation() const;
|
||||||
|
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor3B, _startColor, StartColor)
|
CC_PROPERTY_PASS_BY_REF(Color3B, _startColor, StartColor)
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor3B, _endColor, EndColor)
|
CC_PROPERTY_PASS_BY_REF(Color3B, _endColor, EndColor)
|
||||||
CC_PROPERTY(GLubyte, _startOpacity, StartOpacity)
|
CC_PROPERTY(GLubyte, _startOpacity, StartOpacity)
|
||||||
CC_PROPERTY(GLubyte, _endOpacity, EndOpacity)
|
CC_PROPERTY(GLubyte, _endOpacity, EndOpacity)
|
||||||
CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector)
|
CC_PROPERTY_PASS_BY_REF(Point, _alongVector, Vector)
|
||||||
|
|
|
@ -1179,7 +1179,7 @@ TransitionFade::~TransitionFade()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TransitionFade * TransitionFade::create(float duration, Scene *scene, const ccColor3B& color)
|
TransitionFade * TransitionFade::create(float duration, Scene *scene, const Color3B& color)
|
||||||
{
|
{
|
||||||
TransitionFade * pTransition = new TransitionFade();
|
TransitionFade * pTransition = new TransitionFade();
|
||||||
pTransition->initWithDuration(duration, scene, color);
|
pTransition->initWithDuration(duration, scene, color);
|
||||||
|
@ -1189,10 +1189,10 @@ TransitionFade * TransitionFade::create(float duration, Scene *scene, const ccCo
|
||||||
|
|
||||||
TransitionFade* TransitionFade::create(float duration,Scene* scene)
|
TransitionFade* TransitionFade::create(float duration,Scene* scene)
|
||||||
{
|
{
|
||||||
return TransitionFade::create(duration, scene, ccBLACK);
|
return TransitionFade::create(duration, scene, Color3B::black);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TransitionFade::initWithDuration(float duration, Scene *scene, const ccColor3B& color)
|
bool TransitionFade::initWithDuration(float duration, Scene *scene, const Color3B& color)
|
||||||
{
|
{
|
||||||
if (TransitionScene::initWithDuration(duration, scene))
|
if (TransitionScene::initWithDuration(duration, scene))
|
||||||
{
|
{
|
||||||
|
@ -1206,7 +1206,7 @@ bool TransitionFade::initWithDuration(float duration, Scene *scene, const ccColo
|
||||||
|
|
||||||
bool TransitionFade::initWithDuration(float t, Scene *scene)
|
bool TransitionFade::initWithDuration(float t, Scene *scene)
|
||||||
{
|
{
|
||||||
this->initWithDuration(t, scene, ccBLACK);
|
this->initWithDuration(t, scene, Color3B::black);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1270,7 +1270,7 @@ void TransitionCrossFade::onEnter()
|
||||||
|
|
||||||
// create a transparent color layer
|
// create a transparent color layer
|
||||||
// in which we are going to add our rendertextures
|
// in which we are going to add our rendertextures
|
||||||
ccColor4B color = {0,0,0,0};
|
Color4B color(0,0,0,0);
|
||||||
Size size = Director::sharedDirector()->getWinSize();
|
Size size = Director::sharedDirector()->getWinSize();
|
||||||
LayerColor* layer = LayerColor::create(color);
|
LayerColor* layer = LayerColor::create(color);
|
||||||
|
|
||||||
|
@ -1304,8 +1304,8 @@ void TransitionCrossFade::onEnter()
|
||||||
|
|
||||||
// create blend functions
|
// create blend functions
|
||||||
|
|
||||||
ccBlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha
|
BlendFunc blend1 = {GL_ONE, GL_ONE}; // inScene will lay on background and will not be used with alpha
|
||||||
ccBlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha
|
BlendFunc blend2 = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; // we are going to blend outScene via alpha
|
||||||
|
|
||||||
// set blendfunctions
|
// set blendfunctions
|
||||||
inTexture->getSprite()->setBlendFunc(blend1);
|
inTexture->getSprite()->setBlendFunc(blend1);
|
||||||
|
|
|
@ -416,7 +416,7 @@ Fade out the outgoing scene and then fade in the incoming scene.'''
|
||||||
class CC_DLL TransitionFade : public TransitionScene
|
class CC_DLL TransitionFade : public TransitionScene
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ccColor4B _color;
|
Color4B _color;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -424,13 +424,13 @@ public:
|
||||||
virtual ~TransitionFade();
|
virtual ~TransitionFade();
|
||||||
|
|
||||||
/** creates the transition with a duration and with an RGB color
|
/** creates the transition with a duration and with an RGB color
|
||||||
* Example: FadeTransition::create(2, scene, ccc3(255,0,0); // red color
|
* Example: FadeTransition::create(2, scene, Color3B(255,0,0); // red color
|
||||||
*/
|
*/
|
||||||
static TransitionFade* create(float duration,Scene* scene, const ccColor3B& color);
|
static TransitionFade* create(float duration,Scene* scene, const Color3B& color);
|
||||||
static TransitionFade* create(float duration,Scene* scene);
|
static TransitionFade* create(float duration,Scene* scene);
|
||||||
|
|
||||||
/** initializes the transition with a duration and with an RGB color */
|
/** initializes the transition with a duration and with an RGB color */
|
||||||
virtual bool initWithDuration(float t, Scene*scene ,const ccColor3B& color);
|
virtual bool initWithDuration(float t, Scene*scene ,const Color3B& color);
|
||||||
|
|
||||||
virtual bool initWithDuration(float t,Scene* scene);
|
virtual bool initWithDuration(float t,Scene* scene);
|
||||||
virtual void onEnter();
|
virtual void onEnter();
|
||||||
|
|
|
@ -185,11 +185,11 @@ void MenuItem::setCallback(const ccMenuCallback& callback)
|
||||||
//CCMenuItemLabel
|
//CCMenuItemLabel
|
||||||
//
|
//
|
||||||
|
|
||||||
const ccColor3B& MenuItemLabel::getDisabledColor() const
|
const Color3B& MenuItemLabel::getDisabledColor() const
|
||||||
{
|
{
|
||||||
return _disabledColor;
|
return _disabledColor;
|
||||||
}
|
}
|
||||||
void MenuItemLabel::setDisabledColor(const ccColor3B& var)
|
void MenuItemLabel::setDisabledColor(const Color3B& var)
|
||||||
{
|
{
|
||||||
_disabledColor = var;
|
_disabledColor = var;
|
||||||
}
|
}
|
||||||
|
@ -251,8 +251,8 @@ bool MenuItemLabel::initWithLabel(Node* label, const ccMenuCallback& callback)
|
||||||
{
|
{
|
||||||
MenuItem::initWithCallback(callback);
|
MenuItem::initWithCallback(callback);
|
||||||
_originalScale = 1.0f;
|
_originalScale = 1.0f;
|
||||||
_colorBackup = ccWHITE;
|
_colorBackup = Color3B::white;
|
||||||
setDisabledColor(ccc3(126,126,126));
|
setDisabledColor(Color3B(126,126,126));
|
||||||
this->setLabel(label);
|
this->setLabel(label);
|
||||||
|
|
||||||
setCascadeColorEnabled(true);
|
setCascadeColorEnabled(true);
|
||||||
|
|
|
@ -125,7 +125,7 @@ protected:
|
||||||
class CC_DLL MenuItemLabel : public MenuItem
|
class CC_DLL MenuItemLabel : public MenuItem
|
||||||
{
|
{
|
||||||
/** the color that will be used to disable the item */
|
/** the color that will be used to disable the item */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor3B, _disabledColor, DisabledColor);
|
CC_PROPERTY_PASS_BY_REF(Color3B, _disabledColor, DisabledColor);
|
||||||
/** Label that is rendered. It can be any Node that implements the LabelProtocol */
|
/** Label that is rendered. It can be any Node that implements the LabelProtocol */
|
||||||
CC_PROPERTY(Node*, _label, Label);
|
CC_PROPERTY(Node*, _label, Label);
|
||||||
public:
|
public:
|
||||||
|
@ -162,8 +162,8 @@ public:
|
||||||
virtual void setEnabled(bool enabled);
|
virtual void setEnabled(bool enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ccColor3B _colorBackup;
|
Color3B _colorBackup;
|
||||||
float _originalScale;
|
float _originalScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -255,8 +255,8 @@ void ClippingNode::visit()
|
||||||
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
glStencilOp(!_inverted ? GL_ZERO : GL_REPLACE, GL_KEEP, GL_KEEP);
|
||||||
|
|
||||||
// draw a fullscreen solid rectangle to clear the stencil buffer
|
// draw a fullscreen solid rectangle to clear the stencil buffer
|
||||||
//ccDrawSolidRect(PointZero, ccpFromSize([[Director sharedDirector] winSize]), ccc4f(1, 1, 1, 1));
|
//ccDrawSolidRect(PointZero, ccpFromSize([[Director sharedDirector] winSize]), Color4F(1, 1, 1, 1));
|
||||||
ccDrawSolidRect(PointZero, ccpFromSize(Director::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
|
ccDrawSolidRect(PointZero, ccpFromSize(Director::sharedDirector()->getWinSize()), Color4F(1, 1, 1, 1));
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// DRAW CLIPPING STENCIL
|
// DRAW CLIPPING STENCIL
|
||||||
|
|
|
@ -65,7 +65,7 @@ MotionStreak::~MotionStreak()
|
||||||
CC_SAFE_FREE(_texCoords);
|
CC_SAFE_FREE(_texCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path)
|
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
||||||
{
|
{
|
||||||
MotionStreak *pRet = new MotionStreak();
|
MotionStreak *pRet = new MotionStreak();
|
||||||
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path))
|
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path))
|
||||||
|
@ -78,7 +78,7 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture)
|
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
||||||
{
|
{
|
||||||
MotionStreak *pRet = new MotionStreak();
|
MotionStreak *pRet = new MotionStreak();
|
||||||
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture))
|
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture))
|
||||||
|
@ -91,7 +91,7 @@ MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path)
|
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
||||||
{
|
{
|
||||||
CCAssert(path != NULL, "Invalid filename");
|
CCAssert(path != NULL, "Invalid filename");
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const cc
|
||||||
return initWithFade(fade, minSeg, stroke, color, texture);
|
return initWithFade(fade, minSeg, stroke, color, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture)
|
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
||||||
{
|
{
|
||||||
Node::setPosition(PointZero);
|
Node::setPosition(PointZero);
|
||||||
setAnchorPoint(PointZero);
|
setAnchorPoint(PointZero);
|
||||||
|
@ -119,8 +119,8 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const cc
|
||||||
_pointState = (float *)malloc(sizeof(float) * _maxPoints);
|
_pointState = (float *)malloc(sizeof(float) * _maxPoints);
|
||||||
_pointVertexes = (Point*)malloc(sizeof(Point) * _maxPoints);
|
_pointVertexes = (Point*)malloc(sizeof(Point) * _maxPoints);
|
||||||
|
|
||||||
_vertices = (ccVertex2F*)malloc(sizeof(ccVertex2F) * _maxPoints * 2);
|
_vertices = (Vertex2F*)malloc(sizeof(Vertex2F) * _maxPoints * 2);
|
||||||
_texCoords = (ccTex2F*)malloc(sizeof(ccTex2F) * _maxPoints * 2);
|
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
|
||||||
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
|
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
|
||||||
|
|
||||||
// Set blend mode
|
// Set blend mode
|
||||||
|
@ -143,14 +143,14 @@ void MotionStreak::setPosition(const Point& position)
|
||||||
_positionR = position;
|
_positionR = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionStreak::tintWithColor(const ccColor3B& colors)
|
void MotionStreak::tintWithColor(const Color3B& colors)
|
||||||
{
|
{
|
||||||
setColor(colors);
|
setColor(colors);
|
||||||
|
|
||||||
// Fast assignation
|
// Fast assignation
|
||||||
for(unsigned int i = 0; i<_nuPoints*2; i++)
|
for(unsigned int i = 0; i<_nuPoints*2; i++)
|
||||||
{
|
{
|
||||||
*((ccColor3B*) (_colorPointer+i*4)) = colors;
|
*((Color3B*) (_colorPointer+i*4)) = colors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,12 +169,12 @@ void MotionStreak::setTexture(Texture2D *texture)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MotionStreak::setBlendFunc(const ccBlendFunc &blendFunc)
|
void MotionStreak::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccBlendFunc& MotionStreak::getBlendFunc(void) const
|
const BlendFunc& MotionStreak::getBlendFunc(void) const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
@ -280,8 +280,8 @@ void MotionStreak::update(float delta)
|
||||||
|
|
||||||
// Color assignment
|
// Color assignment
|
||||||
const unsigned int offset = _nuPoints*8;
|
const unsigned int offset = _nuPoints*8;
|
||||||
*((ccColor3B*)(_colorPointer + offset)) = _displayedColor;
|
*((Color3B*)(_colorPointer + offset)) = _displayedColor;
|
||||||
*((ccColor3B*)(_colorPointer + offset+4)) = _displayedColor;
|
*((Color3B*)(_colorPointer + offset+4)) = _displayedColor;
|
||||||
|
|
||||||
// Opacity
|
// Opacity
|
||||||
_colorPointer[offset+3] = 255;
|
_colorPointer[offset+3] = 255;
|
||||||
|
@ -312,8 +312,8 @@ void MotionStreak::update(float delta)
|
||||||
if( _nuPoints && _previousNuPoints != _nuPoints ) {
|
if( _nuPoints && _previousNuPoints != _nuPoints ) {
|
||||||
float texDelta = 1.0f / _nuPoints;
|
float texDelta = 1.0f / _nuPoints;
|
||||||
for( i=0; i < _nuPoints; i++ ) {
|
for( i=0; i < _nuPoints; i++ ) {
|
||||||
_texCoords[i*2] = tex2(0, texDelta*i);
|
_texCoords[i*2] = Tex2F(0, texDelta*i);
|
||||||
_texCoords[i*2+1] = tex2(1, texDelta*i);
|
_texCoords[i*2+1] = Tex2F(1, texDelta*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
_previousNuPoints = _nuPoints;
|
_previousNuPoints = _nuPoints;
|
||||||
|
@ -339,10 +339,10 @@ void MotionStreak::draw()
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
// Size calculations from ::initWithFade
|
// Size calculations from ::initWithFade
|
||||||
setGLBufferData(_vertices, (sizeof(ccVertex2F) * _maxPoints * 2), 0);
|
setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
setGLBufferData(_texCoords, (sizeof(ccTex2F) * _maxPoints * 2), 1);
|
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
||||||
|
|
||||||
setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
|
setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
|
||||||
|
|
|
@ -53,17 +53,17 @@ public:
|
||||||
virtual ~MotionStreak();
|
virtual ~MotionStreak();
|
||||||
|
|
||||||
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
|
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */
|
||||||
static MotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
|
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, const char* path);
|
||||||
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
|
/** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */
|
||||||
static MotionStreak* create(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture);
|
static MotionStreak* create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
||||||
|
|
||||||
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
|
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */
|
||||||
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, const char* path);
|
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path);
|
||||||
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
|
/** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture */
|
||||||
bool initWithFade(float fade, float minSeg, float stroke, const ccColor3B& color, Texture2D* texture);
|
bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
|
||||||
|
|
||||||
/** color used for the tint */
|
/** color used for the tint */
|
||||||
void tintWithColor(const ccColor3B& colors);
|
void tintWithColor(const Color3B& colors);
|
||||||
|
|
||||||
/** Remove all living segments of the ribbon */
|
/** Remove all living segments of the ribbon */
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -76,8 +76,8 @@ public:
|
||||||
/* Implement interfaces */
|
/* Implement interfaces */
|
||||||
virtual Texture2D* getTexture(void);
|
virtual Texture2D* getTexture(void);
|
||||||
virtual void setTexture(Texture2D *texture);
|
virtual void setTexture(Texture2D *texture);
|
||||||
virtual void setBlendFunc(const ccBlendFunc &blendFunc);
|
virtual void setBlendFunc(const BlendFunc &blendFunc);
|
||||||
virtual const ccBlendFunc& getBlendFunc(void) const;
|
virtual const BlendFunc& getBlendFunc(void) const;
|
||||||
virtual GLubyte getOpacity(void) const;
|
virtual GLubyte getOpacity(void) const;
|
||||||
virtual void setOpacity(GLubyte opacity);
|
virtual void setOpacity(GLubyte opacity);
|
||||||
virtual void setOpacityModifyRGB(bool bValue);
|
virtual void setOpacityModifyRGB(bool bValue);
|
||||||
|
@ -98,7 +98,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
/** texture used for the motion streak */
|
/** texture used for the motion streak */
|
||||||
Texture2D* _texture;
|
Texture2D* _texture;
|
||||||
ccBlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
Point _positionR;
|
Point _positionR;
|
||||||
|
|
||||||
float _stroke;
|
float _stroke;
|
||||||
|
@ -114,9 +114,9 @@ private:
|
||||||
float* _pointState;
|
float* _pointState;
|
||||||
|
|
||||||
// Opengl
|
// Opengl
|
||||||
ccVertex2F* _vertices;
|
Vertex2F* _vertices;
|
||||||
GLubyte* _colorPointer;
|
GLubyte* _colorPointer;
|
||||||
ccTex2F* _texCoords;
|
Tex2F* _texCoords;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of misc_nodes group
|
// end of misc_nodes group
|
||||||
|
|
|
@ -164,29 +164,29 @@ bool ProgressTimer::isOpacityModifyRGB(void) const
|
||||||
///
|
///
|
||||||
// @returns the vertex position from the texture coordinate
|
// @returns the vertex position from the texture coordinate
|
||||||
///
|
///
|
||||||
ccTex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha)
|
Tex2F ProgressTimer::textureCoordFromAlphaPoint(Point alpha)
|
||||||
{
|
{
|
||||||
ccTex2F ret = {0.0f, 0.0f};
|
Tex2F ret(0.0f, 0.0f);
|
||||||
if (!_sprite) {
|
if (!_sprite) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ccV3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||||
Point min = ccp(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
Point min = ccp(quad.bl.texCoords.u,quad.bl.texCoords.v);
|
||||||
Point max = ccp(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
Point max = ccp(quad.tr.texCoords.u,quad.tr.texCoords.v);
|
||||||
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
|
// Fix bug #1303 so that progress timer handles sprite frame texture rotation
|
||||||
if (_sprite->isTextureRectRotated()) {
|
if (_sprite->isTextureRectRotated()) {
|
||||||
CC_SWAP(alpha.x, alpha.y, float);
|
CC_SWAP(alpha.x, alpha.y, float);
|
||||||
}
|
}
|
||||||
return tex2(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
|
return Tex2F(min.x * (1.f - alpha.x) + max.x * alpha.x, min.y * (1.f - alpha.y) + max.y * alpha.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
ccVertex2F ProgressTimer::vertexFromAlphaPoint(Point alpha)
|
Vertex2F ProgressTimer::vertexFromAlphaPoint(Point alpha)
|
||||||
{
|
{
|
||||||
ccVertex2F ret = {0.0f, 0.0f};
|
Vertex2F ret(0.0f, 0.0f);
|
||||||
if (!_sprite) {
|
if (!_sprite) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ccV3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
V3F_C4B_T2F_Quad quad = _sprite->getQuad();
|
||||||
Point min = ccp(quad.bl.vertices.x,quad.bl.vertices.y);
|
Point min = ccp(quad.bl.vertices.x,quad.bl.vertices.y);
|
||||||
Point max = ccp(quad.tr.vertices.x,quad.tr.vertices.y);
|
Point max = ccp(quad.tr.vertices.x,quad.tr.vertices.y);
|
||||||
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
|
ret.x = min.x * (1.f - alpha.x) + max.x * alpha.x;
|
||||||
|
@ -202,7 +202,7 @@ void ProgressTimer::updateColor(void)
|
||||||
|
|
||||||
if (_vertexData)
|
if (_vertexData)
|
||||||
{
|
{
|
||||||
ccColor4B sc = _sprite->getQuad().tl.colors;
|
Color4B sc = _sprite->getQuad().tl.colors;
|
||||||
for (int i = 0; i < _vertexDataCount; ++i)
|
for (int i = 0; i < _vertexDataCount; ++i)
|
||||||
{
|
{
|
||||||
_vertexData[i].colors = sc;
|
_vertexData[i].colors = sc;
|
||||||
|
@ -344,7 +344,7 @@ void ProgressTimer::updateRadial(void)
|
||||||
|
|
||||||
if(!_vertexData) {
|
if(!_vertexData) {
|
||||||
_vertexDataCount = index + 3;
|
_vertexDataCount = index + 3;
|
||||||
_vertexData = (ccV2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(ccV2F_C4B_T2F));
|
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||||
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
||||||
}
|
}
|
||||||
updateColor();
|
updateColor();
|
||||||
|
@ -415,7 +415,7 @@ void ProgressTimer::updateBar(void)
|
||||||
if (!_reverseDirection) {
|
if (!_reverseDirection) {
|
||||||
if(!_vertexData) {
|
if(!_vertexData) {
|
||||||
_vertexDataCount = 4;
|
_vertexDataCount = 4;
|
||||||
_vertexData = (ccV2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(ccV2F_C4B_T2F));
|
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||||
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
||||||
}
|
}
|
||||||
// TOPLEFT
|
// TOPLEFT
|
||||||
|
@ -436,7 +436,7 @@ void ProgressTimer::updateBar(void)
|
||||||
} else {
|
} else {
|
||||||
if(!_vertexData) {
|
if(!_vertexData) {
|
||||||
_vertexDataCount = 8;
|
_vertexDataCount = 8;
|
||||||
_vertexData = (ccV2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(ccV2F_C4B_T2F));
|
_vertexData = (V2F_C4B_T2F*)malloc(_vertexDataCount * sizeof(V2F_C4B_T2F));
|
||||||
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
CCAssert( _vertexData, "CCProgressTimer. Not enough memory");
|
||||||
// TOPLEFT 1
|
// TOPLEFT 1
|
||||||
_vertexData[0].texCoords = textureCoordFromAlphaPoint(ccp(0,1));
|
_vertexData[0].texCoords = textureCoordFromAlphaPoint(ccp(0,1));
|
||||||
|
@ -500,16 +500,16 @@ void ProgressTimer::draw(void)
|
||||||
ccGLBindTexture2D( _sprite->getTexture()->getName() );
|
ccGLBindTexture2D( _sprite->getTexture()->getName() );
|
||||||
|
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(ccV2F_C4B_T2F)), 0);
|
setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 0);
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid*)offset);
|
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
|
||||||
|
|
||||||
offset += sizeof(ccVertex2F);
|
offset += sizeof(Vertex2F);
|
||||||
glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ccV2F_C4B_T2F), (GLvoid*)offset);
|
glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
|
||||||
|
|
||||||
offset += sizeof(ccColor4B);
|
offset += sizeof(Color4B);
|
||||||
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid*)offset);
|
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset);
|
||||||
#else
|
#else
|
||||||
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices);
|
glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices);
|
||||||
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords);
|
glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords);
|
||||||
|
|
|
@ -92,8 +92,8 @@ public:
|
||||||
/** Creates a progress timer with the sprite as the shape the timer goes through */
|
/** Creates a progress timer with the sprite as the shape the timer goes through */
|
||||||
static ProgressTimer* create(Sprite* sp);
|
static ProgressTimer* create(Sprite* sp);
|
||||||
protected:
|
protected:
|
||||||
ccTex2F textureCoordFromAlphaPoint(Point alpha);
|
Tex2F textureCoordFromAlphaPoint(Point alpha);
|
||||||
ccVertex2F vertexFromAlphaPoint(Point alpha);
|
Vertex2F vertexFromAlphaPoint(Point alpha);
|
||||||
void updateProgress(void);
|
void updateProgress(void);
|
||||||
void updateBar(void);
|
void updateBar(void);
|
||||||
void updateRadial(void);
|
void updateRadial(void);
|
||||||
|
@ -105,7 +105,7 @@ protected:
|
||||||
float _percentage;
|
float _percentage;
|
||||||
Sprite *_sprite;
|
Sprite *_sprite;
|
||||||
int _vertexDataCount;
|
int _vertexDataCount;
|
||||||
ccV2F_C4B_T2F *_vertexData;
|
V2F_C4B_T2F *_vertexData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Midpoint is used to modify the progress start position.
|
* Midpoint is used to modify the progress start position.
|
||||||
|
|
|
@ -54,7 +54,7 @@ RenderTexture::RenderTexture()
|
||||||
, _UITextureImage(NULL)
|
, _UITextureImage(NULL)
|
||||||
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
|
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
|
||||||
, _clearFlags(0)
|
, _clearFlags(0)
|
||||||
, _clearColor(ccc4f(0,0,0,0))
|
, _clearColor(Color4F(0,0,0,0))
|
||||||
, _clearDepth(0.0f)
|
, _clearDepth(0.0f)
|
||||||
, _clearStencil(0)
|
, _clearStencil(0)
|
||||||
, _autoDraw(false)
|
, _autoDraw(false)
|
||||||
|
@ -163,12 +163,12 @@ void RenderTexture::setClearFlags(unsigned int uClearFlags)
|
||||||
_clearFlags = uClearFlags;
|
_clearFlags = uClearFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor4F& RenderTexture::getClearColor() const
|
const Color4F& RenderTexture::getClearColor() const
|
||||||
{
|
{
|
||||||
return _clearColor;
|
return _clearColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderTexture::setClearColor(const ccColor4F &clearColor)
|
void RenderTexture::setClearColor(const Color4F &clearColor)
|
||||||
{
|
{
|
||||||
_clearColor = clearColor;
|
_clearColor = clearColor;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF
|
||||||
_texture->release();
|
_texture->release();
|
||||||
_sprite->setScaleY(-1);
|
_sprite->setScaleY(-1);
|
||||||
|
|
||||||
ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
BlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA };
|
||||||
_sprite->setBlendFunc(tBlendFunc);
|
_sprite->setBlendFunc(tBlendFunc);
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
|
glBindRenderbuffer(GL_RENDERBUFFER, oldRBO);
|
||||||
|
|
|
@ -56,7 +56,7 @@ class CC_DLL RenderTexture : public Node
|
||||||
/** The Sprite being used.
|
/** The Sprite being used.
|
||||||
The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA.
|
The sprite, by default, will use the following blending function: GL_ONE, GL_ONE_MINUS_SRC_ALPHA.
|
||||||
The blending function can be changed in runtime by calling:
|
The blending function can be changed in runtime by calling:
|
||||||
- [[renderTexture sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
|
- [[renderTexture sprite] setBlendFunc:(BlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
|
||||||
*/
|
*/
|
||||||
CC_PROPERTY(Sprite*, _sprite, Sprite)
|
CC_PROPERTY(Sprite*, _sprite, Sprite)
|
||||||
public:
|
public:
|
||||||
|
@ -140,8 +140,8 @@ public:
|
||||||
void setClearFlags(unsigned int uClearFlags);
|
void setClearFlags(unsigned int uClearFlags);
|
||||||
|
|
||||||
/** Clear color value. Valid only when "autoDraw" is true. */
|
/** Clear color value. Valid only when "autoDraw" is true. */
|
||||||
const ccColor4F& getClearColor() const;
|
const Color4F& getClearColor() const;
|
||||||
void setClearColor(const ccColor4F &clearColor);
|
void setClearColor(const Color4F &clearColor);
|
||||||
|
|
||||||
/** Value for clearDepth. Valid only when autoDraw is true. */
|
/** Value for clearDepth. Valid only when autoDraw is true. */
|
||||||
float getClearDepth() const;
|
float getClearDepth() const;
|
||||||
|
@ -171,7 +171,7 @@ protected:
|
||||||
|
|
||||||
// code for "auto" update
|
// code for "auto" update
|
||||||
GLbitfield _clearFlags;
|
GLbitfield _clearFlags;
|
||||||
ccColor4F _clearColor;
|
Color4F _clearColor;
|
||||||
GLclampf _clearDepth;
|
GLclampf _clearDepth;
|
||||||
GLint _clearStencil;
|
GLint _clearStencil;
|
||||||
bool _autoDraw;
|
bool _autoDraw;
|
||||||
|
|
|
@ -437,7 +437,7 @@ void ParticleBatchNode::increaseAtlasCapacityTo(unsigned int quantity)
|
||||||
//sets a 0'd quad into the quads array
|
//sets a 0'd quad into the quads array
|
||||||
void ParticleBatchNode::disableParticle(unsigned int particleIndex)
|
void ParticleBatchNode::disableParticle(unsigned int particleIndex)
|
||||||
{
|
{
|
||||||
ccV3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]);
|
V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[particleIndex]);
|
||||||
quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f;
|
quad->br.vertices.x = quad->br.vertices.y = quad->tr.vertices.x = quad->tr.vertices.y = quad->tl.vertices.x = quad->tl.vertices.y = quad->bl.vertices.x = quad->bl.vertices.y = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,12 +509,12 @@ Texture2D* ParticleBatchNode::getTexture(void)
|
||||||
return _textureAtlas->getTexture();
|
return _textureAtlas->getTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleBatchNode::setBlendFunc(const ccBlendFunc &blendFunc)
|
void ParticleBatchNode::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
}
|
}
|
||||||
// returns the blending function used for the texture
|
// returns the blending function used for the texture
|
||||||
const ccBlendFunc& ParticleBatchNode::getBlendFunc(void) const
|
const BlendFunc& ParticleBatchNode::getBlendFunc(void) const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,9 @@ public:
|
||||||
virtual Texture2D* getTexture(void);
|
virtual Texture2D* getTexture(void);
|
||||||
// sets a new texture. it will be retained
|
// sets a new texture. it will be retained
|
||||||
virtual void setTexture(Texture2D *texture);
|
virtual void setTexture(Texture2D *texture);
|
||||||
virtual void setBlendFunc(const ccBlendFunc &blendFunc);
|
virtual void setBlendFunc(const BlendFunc &blendFunc);
|
||||||
// returns the blending function used for the texture
|
// returns the blending function used for the texture
|
||||||
virtual const ccBlendFunc& getBlendFunc(void) const;
|
virtual const BlendFunc& getBlendFunc(void) const;
|
||||||
|
|
||||||
void visit();
|
void visit();
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ private:
|
||||||
CC_SYNTHESIZE(TextureAtlas*, _textureAtlas, TextureAtlas);
|
CC_SYNTHESIZE(TextureAtlas*, _textureAtlas, TextureAtlas);
|
||||||
private:
|
private:
|
||||||
/** the blend function used for drawing the quads */
|
/** the blend function used for drawing the quads */
|
||||||
ccBlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
};
|
};
|
||||||
|
|
||||||
// end of particle_nodes group
|
// end of particle_nodes group
|
||||||
|
|
|
@ -479,13 +479,13 @@ void ParticleSystem::initParticle(tParticle* particle)
|
||||||
|
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
ccColor4F start;
|
Color4F start;
|
||||||
start.r = clampf(_startColor.r + _startColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
start.r = clampf(_startColor.r + _startColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
start.g = clampf(_startColor.g + _startColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
start.g = clampf(_startColor.g + _startColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
start.b = clampf(_startColor.b + _startColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
start.b = clampf(_startColor.b + _startColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
start.a = clampf(_startColor.a + _startColorVar.a * CCRANDOM_MINUS1_1(), 0, 1);
|
start.a = clampf(_startColor.a + _startColorVar.a * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
|
|
||||||
ccColor4F end;
|
Color4F end;
|
||||||
end.r = clampf(_endColor.r + _endColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
end.r = clampf(_endColor.r + _endColorVar.r * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
end.g = clampf(_endColor.g + _endColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
end.g = clampf(_endColor.g + _endColorVar.g * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
end.b = clampf(_endColor.b + _endColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
end.b = clampf(_endColor.b + _endColorVar.b * CCRANDOM_MINUS1_1(), 0, 1);
|
||||||
|
@ -1146,42 +1146,42 @@ void ParticleSystem::setEndSizeVar(float var)
|
||||||
_endSizeVar = var;
|
_endSizeVar = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor4F& ParticleSystem::getStartColor() const
|
const Color4F& ParticleSystem::getStartColor() const
|
||||||
{
|
{
|
||||||
return _startColor;
|
return _startColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::setStartColor(const ccColor4F& var)
|
void ParticleSystem::setStartColor(const Color4F& var)
|
||||||
{
|
{
|
||||||
_startColor = var;
|
_startColor = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor4F& ParticleSystem::getStartColorVar() const
|
const Color4F& ParticleSystem::getStartColorVar() const
|
||||||
{
|
{
|
||||||
return _startColorVar;
|
return _startColorVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::setStartColorVar(const ccColor4F& var)
|
void ParticleSystem::setStartColorVar(const Color4F& var)
|
||||||
{
|
{
|
||||||
_startColorVar = var;
|
_startColorVar = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor4F& ParticleSystem::getEndColor() const
|
const Color4F& ParticleSystem::getEndColor() const
|
||||||
{
|
{
|
||||||
return _endColor;
|
return _endColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::setEndColor(const ccColor4F& var)
|
void ParticleSystem::setEndColor(const Color4F& var)
|
||||||
{
|
{
|
||||||
_endColor = var;
|
_endColor = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor4F& ParticleSystem::getEndColorVar() const
|
const Color4F& ParticleSystem::getEndColorVar() const
|
||||||
{
|
{
|
||||||
return _endColorVar;
|
return _endColorVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::setEndColorVar(const ccColor4F& var)
|
void ParticleSystem::setEndColorVar(const Color4F& var)
|
||||||
{
|
{
|
||||||
_endColorVar = var;
|
_endColorVar = var;
|
||||||
}
|
}
|
||||||
|
@ -1246,12 +1246,12 @@ void ParticleSystem::setTotalParticles(unsigned int var)
|
||||||
_totalParticles = var;
|
_totalParticles = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccBlendFunc& ParticleSystem::getBlendFunc() const
|
const BlendFunc& ParticleSystem::getBlendFunc() const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystem::setBlendFunc(const ccBlendFunc &blendFunc)
|
void ParticleSystem::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
if( _blendFunc.src != blendFunc.src || _blendFunc.dst != blendFunc.dst ) {
|
if( _blendFunc.src != blendFunc.src || _blendFunc.dst != blendFunc.dst ) {
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
|
|
|
@ -86,8 +86,8 @@ typedef struct sParticle {
|
||||||
Point pos;
|
Point pos;
|
||||||
Point startPos;
|
Point startPos;
|
||||||
|
|
||||||
ccColor4F color;
|
Color4F color;
|
||||||
ccColor4F deltaColor;
|
Color4F deltaColor;
|
||||||
|
|
||||||
float size;
|
float size;
|
||||||
float deltaSize;
|
float deltaSize;
|
||||||
|
@ -305,13 +305,13 @@ public:
|
||||||
/** end size variance in pixels of each particle */
|
/** end size variance in pixels of each particle */
|
||||||
CC_PROPERTY(float, _endSizeVar, EndSizeVar)
|
CC_PROPERTY(float, _endSizeVar, EndSizeVar)
|
||||||
/** start color of each particle */
|
/** start color of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor4F, _startColor, StartColor)
|
CC_PROPERTY_PASS_BY_REF(Color4F, _startColor, StartColor)
|
||||||
/** start color variance of each particle */
|
/** start color variance of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor4F, _startColorVar, StartColorVar)
|
CC_PROPERTY_PASS_BY_REF(Color4F, _startColorVar, StartColorVar)
|
||||||
/** end color and end color variation of each particle */
|
/** end color and end color variation of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor4F, _endColor, EndColor)
|
CC_PROPERTY_PASS_BY_REF(Color4F, _endColor, EndColor)
|
||||||
/** end color variance of each particle */
|
/** end color variance of each particle */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccColor4F, _endColorVar, EndColorVar)
|
CC_PROPERTY_PASS_BY_REF(Color4F, _endColorVar, EndColorVar)
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
CC_PROPERTY(float, _startSpin, StartSpin)
|
CC_PROPERTY(float, _startSpin, StartSpin)
|
||||||
//* initial angle of each particle
|
//* initial angle of each particle
|
||||||
|
@ -327,7 +327,7 @@ public:
|
||||||
/** conforms to CocosNodeTexture protocol */
|
/** conforms to CocosNodeTexture protocol */
|
||||||
CC_PROPERTY(Texture2D*, _texture, Texture)
|
CC_PROPERTY(Texture2D*, _texture, Texture)
|
||||||
/** conforms to CocosNodeTexture protocol */
|
/** conforms to CocosNodeTexture protocol */
|
||||||
CC_PROPERTY_PASS_BY_REF(ccBlendFunc, _blendFunc, BlendFunc)
|
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
|
||||||
/** does the alpha value modify color */
|
/** does the alpha value modify color */
|
||||||
CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB)
|
CC_PROPERTY(bool, _opacityModifyRGB, OpacityModifyRGB)
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ void ParticleSystemQuad::initTexCoordsWithRect(const Rect& pointRect)
|
||||||
// Important. Texture in cocos2d are inverted, so the Y component should be inverted
|
// Important. Texture in cocos2d are inverted, so the Y component should be inverted
|
||||||
CC_SWAP( top, bottom, float);
|
CC_SWAP( top, bottom, float);
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad *quads = NULL;
|
V3F_C4B_T2F_Quad *quads = NULL;
|
||||||
unsigned int start = 0, end = 0;
|
unsigned int start = 0, end = 0;
|
||||||
if (_batchNode)
|
if (_batchNode)
|
||||||
{
|
{
|
||||||
|
@ -239,20 +239,20 @@ void ParticleSystemQuad::initIndices()
|
||||||
|
|
||||||
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point& newPosition)
|
void ParticleSystemQuad::updateQuadWithParticle(tParticle* particle, const Point& newPosition)
|
||||||
{
|
{
|
||||||
ccV3F_C4B_T2F_Quad *quad;
|
V3F_C4B_T2F_Quad *quad;
|
||||||
|
|
||||||
if (_batchNode)
|
if (_batchNode)
|
||||||
{
|
{
|
||||||
ccV3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
|
V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
|
||||||
quad = &(batchQuads[_atlasIndex+particle->atlasIndex]);
|
quad = &(batchQuads[_atlasIndex+particle->atlasIndex]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
quad = &(_quads[_particleIdx]);
|
quad = &(_quads[_particleIdx]);
|
||||||
}
|
}
|
||||||
ccColor4B color = (_opacityModifyRGB)
|
Color4B color = (_opacityModifyRGB)
|
||||||
? ccc4( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255)
|
? Color4B( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255)
|
||||||
: ccc4( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255);
|
: Color4B( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255);
|
||||||
|
|
||||||
quad->bl.colors = color;
|
quad->bl.colors = color;
|
||||||
quad->br.colors = color;
|
quad->br.colors = color;
|
||||||
|
@ -378,11 +378,11 @@ void ParticleSystemQuad::draw()
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
|
||||||
// vertices
|
// vertices
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||||
// colors
|
// colors
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||||
// tex coords
|
// tex coords
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ void ParticleSystemQuad::setTotalParticles(unsigned int tp)
|
||||||
size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1;
|
size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1;
|
||||||
|
|
||||||
tParticle* particlesNew = (tParticle*)realloc(_particles, particlesSize);
|
tParticle* particlesNew = (tParticle*)realloc(_particles, particlesSize);
|
||||||
ccV3F_C4B_T2F_Quad* quadsNew = (ccV3F_C4B_T2F_Quad*)realloc(_quads, quadsSize);
|
V3F_C4B_T2F_Quad* quadsNew = (V3F_C4B_T2F_Quad*)realloc(_quads, quadsSize);
|
||||||
GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize);
|
GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize);
|
||||||
|
|
||||||
if (particlesNew && quadsNew && indicesNew)
|
if (particlesNew && quadsNew && indicesNew)
|
||||||
|
@ -483,15 +483,15 @@ void ParticleSystemQuad::setupVBOandVAO()
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||||
|
|
||||||
// tex coords
|
// tex coords
|
||||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW);
|
||||||
|
@ -541,7 +541,7 @@ bool ParticleSystemQuad::allocMemory()
|
||||||
CC_SAFE_FREE(_quads);
|
CC_SAFE_FREE(_quads);
|
||||||
CC_SAFE_FREE(_indices);
|
CC_SAFE_FREE(_indices);
|
||||||
|
|
||||||
_quads = (ccV3F_C4B_T2F_Quad*)malloc(_totalParticles * sizeof(ccV3F_C4B_T2F_Quad));
|
_quads = (V3F_C4B_T2F_Quad*)malloc(_totalParticles * sizeof(V3F_C4B_T2F_Quad));
|
||||||
_indices = (GLushort*)malloc(_totalParticles * 6 * sizeof(GLushort));
|
_indices = (GLushort*)malloc(_totalParticles * 6 * sizeof(GLushort));
|
||||||
|
|
||||||
if( !_quads || !_indices)
|
if( !_quads || !_indices)
|
||||||
|
@ -553,7 +553,7 @@ bool ParticleSystemQuad::allocMemory()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(_quads, 0, _totalParticles * sizeof(ccV3F_C4B_T2F_Quad));
|
memset(_quads, 0, _totalParticles * sizeof(V3F_C4B_T2F_Quad));
|
||||||
memset(_indices, 0, _totalParticles * 6 * sizeof(GLushort));
|
memset(_indices, 0, _totalParticles * 6 * sizeof(GLushort));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -583,8 +583,8 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
|
||||||
else if( !oldBatch )
|
else if( !oldBatch )
|
||||||
{
|
{
|
||||||
// copy current state to batch
|
// copy current state to batch
|
||||||
ccV3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
|
V3F_C4B_T2F_Quad *batchQuads = _batchNode->getTextureAtlas()->getQuads();
|
||||||
ccV3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] );
|
V3F_C4B_T2F_Quad *quad = &(batchQuads[_atlasIndex] );
|
||||||
memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) );
|
memcpy( quad, _quads, _totalParticles * sizeof(_quads[0]) );
|
||||||
|
|
||||||
CC_SAFE_FREE(_quads);
|
CC_SAFE_FREE(_quads);
|
||||||
|
|
|
@ -53,7 +53,7 @@ Special features and Limitations:
|
||||||
class CC_DLL ParticleSystemQuad : public ParticleSystem
|
class CC_DLL ParticleSystemQuad : public ParticleSystem
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ccV3F_C4B_T2F_Quad *_quads; // quads to be rendered
|
V3F_C4B_T2F_Quad *_quads; // quads to be rendered
|
||||||
GLushort *_indices; // indices
|
GLushort *_indices; // indices
|
||||||
|
|
||||||
#if CC_TEXTURE_ATLAS_USE_VAO
|
#if CC_TEXTURE_ATLAS_USE_VAO
|
||||||
|
|
|
@ -328,7 +328,7 @@ static bool _isValidFontName(const char *fontName)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::ccColor3B* pStrokeColor)
|
static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo, cocos2d::Color3B* pStrokeColor)
|
||||||
{
|
{
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,7 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../CCDirector.cpp \
|
../CCDirector.cpp \
|
||||||
../CCScheduler.cpp \
|
../CCScheduler.cpp \
|
||||||
../ccFPSImages.c \
|
../ccFPSImages.c \
|
||||||
|
../ccTypes.cpp \
|
||||||
../cocos2d.cpp
|
../cocos2d.cpp
|
||||||
|
|
||||||
COCOS_ROOT = ../..
|
COCOS_ROOT = ../..
|
||||||
|
|
|
@ -132,6 +132,7 @@ SOURCES = ../actions/CCAction.cpp \
|
||||||
../CCDirector.cpp \
|
../CCDirector.cpp \
|
||||||
../CCScheduler.cpp \
|
../CCScheduler.cpp \
|
||||||
../ccFPSImages.c \
|
../ccFPSImages.c \
|
||||||
|
../ccTypes.cpp \
|
||||||
../cocos2d.cpp
|
../cocos2d.cpp
|
||||||
|
|
||||||
include cocos2dx.mk
|
include cocos2dx.mk
|
||||||
|
|
|
@ -143,6 +143,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
||||||
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp" />
|
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp" />
|
||||||
<ClCompile Include="..\base_nodes\CCNode.cpp" />
|
<ClCompile Include="..\base_nodes\CCNode.cpp" />
|
||||||
<ClCompile Include="..\ccFPSImages.c" />
|
<ClCompile Include="..\ccFPSImages.c" />
|
||||||
|
<ClCompile Include="..\ccTypes.cpp" />
|
||||||
<ClCompile Include="..\cocoa\CCAffineTransform.cpp" />
|
<ClCompile Include="..\cocoa\CCAffineTransform.cpp" />
|
||||||
<ClCompile Include="..\cocoa\CCArray.cpp" />
|
<ClCompile Include="..\cocoa\CCArray.cpp" />
|
||||||
<ClCompile Include="..\cocoa\CCAutoreleasePool.cpp" />
|
<ClCompile Include="..\cocoa\CCAutoreleasePool.cpp" />
|
||||||
|
|
|
@ -489,6 +489,7 @@
|
||||||
<ClCompile Include="..\keyboard_dispatcher\CCKeyboardDispatcher.cpp">
|
<ClCompile Include="..\keyboard_dispatcher\CCKeyboardDispatcher.cpp">
|
||||||
<Filter>keyboard_dispatcher</Filter>
|
<Filter>keyboard_dispatcher</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\ccTypes.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
|
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
|
||||||
|
|
|
@ -176,7 +176,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated
|
||||||
memset(&_quad, 0, sizeof(_quad));
|
memset(&_quad, 0, sizeof(_quad));
|
||||||
|
|
||||||
// Atlas: Color
|
// Atlas: Color
|
||||||
ccColor4B tmpColor = { 255, 255, 255, 255 };
|
Color4B tmpColor(255, 255, 255, 255);
|
||||||
_quad.bl.colors = tmpColor;
|
_quad.bl.colors = tmpColor;
|
||||||
_quad.br.colors = tmpColor;
|
_quad.br.colors = tmpColor;
|
||||||
_quad.tl.colors = tmpColor;
|
_quad.tl.colors = tmpColor;
|
||||||
|
@ -351,10 +351,10 @@ void Sprite::setTextureRect(const Rect& rect, bool rotated, const Size& untrimme
|
||||||
float y2 = y1 + _rect.size.height;
|
float y2 = y1 + _rect.size.height;
|
||||||
|
|
||||||
// Don't update Z.
|
// Don't update Z.
|
||||||
_quad.bl.vertices = vertex3(x1, y1, 0);
|
_quad.bl.vertices = Vertex3F(x1, y1, 0);
|
||||||
_quad.br.vertices = vertex3(x2, y1, 0);
|
_quad.br.vertices = Vertex3F(x2, y1, 0);
|
||||||
_quad.tl.vertices = vertex3(x1, y2, 0);
|
_quad.tl.vertices = Vertex3F(x1, y2, 0);
|
||||||
_quad.tr.vertices = vertex3(x2, y2, 0);
|
_quad.tr.vertices = Vertex3F(x2, y2, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ void Sprite::updateTransform(void)
|
||||||
// If it is not visible, or one of its ancestors is not visible, then do nothing:
|
// If it is not visible, or one of its ancestors is not visible, then do nothing:
|
||||||
if( !_visible || ( _parent && _parent != _batchNode && ((Sprite*)_parent)->_shouldBeHidden) )
|
if( !_visible || ( _parent && _parent != _batchNode && ((Sprite*)_parent)->_shouldBeHidden) )
|
||||||
{
|
{
|
||||||
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = vertex3(0,0,0);
|
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0,0,0);
|
||||||
_shouldBeHidden = true;
|
_shouldBeHidden = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -504,10 +504,10 @@ void Sprite::updateTransform(void)
|
||||||
float dx = x1 * cr - y2 * sr2 + x;
|
float dx = x1 * cr - y2 * sr2 + x;
|
||||||
float dy = x1 * sr + y2 * cr2 + y;
|
float dy = x1 * sr + y2 * cr2 + y;
|
||||||
|
|
||||||
_quad.bl.vertices = vertex3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
||||||
_quad.br.vertices = vertex3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
||||||
_quad.tl.vertices = vertex3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
||||||
_quad.tr.vertices = vertex3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
// MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||||
|
@ -579,18 +579,18 @@ void Sprite::draw(void)
|
||||||
#endif // EMSCRIPTEN
|
#endif // EMSCRIPTEN
|
||||||
|
|
||||||
// vertex
|
// vertex
|
||||||
int diff = offsetof( ccV3F_C4B_T2F, vertices);
|
int diff = offsetof( V3F_C4B_T2F, vertices);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
|
||||||
|
|
||||||
if (_texture != NULL)
|
if (_texture != NULL)
|
||||||
{
|
{
|
||||||
// texCoods
|
// texCoods
|
||||||
diff = offsetof( ccV3F_C4B_T2F, texCoords);
|
diff = offsetof( V3F_C4B_T2F, texCoords);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
|
||||||
}
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
diff = offsetof( ccV3F_C4B_T2F, colors);
|
diff = offsetof( V3F_C4B_T2F, colors);
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
||||||
|
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ bool Sprite::isFlipY(void) const
|
||||||
|
|
||||||
void Sprite::updateColor(void)
|
void Sprite::updateColor(void)
|
||||||
{
|
{
|
||||||
ccColor4B color4 = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
|
Color4B color4( _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity );
|
||||||
|
|
||||||
// special opacity for premultiplied textures
|
// special opacity for premultiplied textures
|
||||||
if (_opacityModifyRGB)
|
if (_opacityModifyRGB)
|
||||||
|
@ -943,7 +943,7 @@ void Sprite::setOpacity(GLubyte opacity)
|
||||||
updateColor();
|
updateColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setColor(const ccColor3B& color3)
|
void Sprite::setColor(const Color3B& color3)
|
||||||
{
|
{
|
||||||
NodeRGBA::setColor(color3);
|
NodeRGBA::setColor(color3);
|
||||||
|
|
||||||
|
@ -964,7 +964,7 @@ bool Sprite::isOpacityModifyRGB(void) const
|
||||||
return _opacityModifyRGB;
|
return _opacityModifyRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::updateDisplayedColor(const ccColor3B& parentColor)
|
void Sprite::updateDisplayedColor(const Color3B& parentColor)
|
||||||
{
|
{
|
||||||
NodeRGBA::updateDisplayedColor(parentColor);
|
NodeRGBA::updateDisplayedColor(parentColor);
|
||||||
|
|
||||||
|
@ -1049,10 +1049,10 @@ void Sprite::setBatchNode(SpriteBatchNode *pobSpriteBatchNode)
|
||||||
float y1 = _offsetPosition.y;
|
float y1 = _offsetPosition.y;
|
||||||
float x2 = x1 + _rect.size.width;
|
float x2 = x1 + _rect.size.width;
|
||||||
float y2 = y1 + _rect.size.height;
|
float y2 = y1 + _rect.size.height;
|
||||||
_quad.bl.vertices = vertex3( x1, y1, 0 );
|
_quad.bl.vertices = Vertex3F( x1, y1, 0 );
|
||||||
_quad.br.vertices = vertex3( x2, y1, 0 );
|
_quad.br.vertices = Vertex3F( x2, y1, 0 );
|
||||||
_quad.tl.vertices = vertex3( x1, y2, 0 );
|
_quad.tl.vertices = Vertex3F( x1, y2, 0 );
|
||||||
_quad.tr.vertices = vertex3( x2, y2, 0 );
|
_quad.tr.vertices = Vertex3F( x2, y2, 0 );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -263,8 +263,8 @@ public:
|
||||||
/// @name Functions inherited from TextureProtocol
|
/// @name Functions inherited from TextureProtocol
|
||||||
virtual void setTexture(Texture2D *texture);
|
virtual void setTexture(Texture2D *texture);
|
||||||
virtual Texture2D* getTexture(void);
|
virtual Texture2D* getTexture(void);
|
||||||
virtual void setBlendFunc(const ccBlendFunc &blendFunc) { _blendFunc = blendFunc; }
|
inline void setBlendFunc(const BlendFunc &blendFunc) { _blendFunc = blendFunc; }
|
||||||
virtual const ccBlendFunc& getBlendFunc(void) const { return _blendFunc; }
|
inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; }
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -294,8 +294,8 @@ public:
|
||||||
|
|
||||||
/// @{
|
/// @{
|
||||||
/// @name Functions inherited from NodeRGBA
|
/// @name Functions inherited from NodeRGBA
|
||||||
virtual void setColor(const ccColor3B& color3);
|
virtual void setColor(const Color3B& color3);
|
||||||
virtual void updateDisplayedColor(const ccColor3B& parentColor);
|
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||||
virtual void setOpacity(GLubyte opacity);
|
virtual void setOpacity(GLubyte opacity);
|
||||||
virtual void setOpacityModifyRGB(bool modify);
|
virtual void setOpacityModifyRGB(bool modify);
|
||||||
virtual bool isOpacityModifyRGB(void) const;
|
virtual bool isOpacityModifyRGB(void) const;
|
||||||
|
@ -410,7 +410,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the quad (tex coords, vertex coords and color) information.
|
* Returns the quad (tex coords, vertex coords and color) information.
|
||||||
*/
|
*/
|
||||||
inline ccV3F_C4B_T2F_Quad getQuad(void) const { return _quad; }
|
inline V3F_C4B_T2F_Quad getQuad(void) const { return _quad; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the texture rectangle is rotated.
|
* Returns whether or not the texture rectangle is rotated.
|
||||||
|
@ -510,7 +510,7 @@ protected:
|
||||||
//
|
//
|
||||||
// Data used when the sprite is self-rendered
|
// Data used when the sprite is self-rendered
|
||||||
//
|
//
|
||||||
ccBlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
|
BlendFunc _blendFunc; /// It's required for TextureProtocol inheritance
|
||||||
Texture2D* _texture; /// Texture2D object that is used to render the sprite
|
Texture2D* _texture; /// Texture2D object that is used to render the sprite
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -526,7 +526,7 @@ protected:
|
||||||
Point _unflippedOffsetPositionFromCenter;
|
Point _unflippedOffsetPositionFromCenter;
|
||||||
|
|
||||||
// vertex coords, texture coords and color info
|
// vertex coords, texture coords and color info
|
||||||
ccV3F_C4B_T2F_Quad _quad;
|
V3F_C4B_T2F_Quad _quad;
|
||||||
|
|
||||||
// opacity and RGB protocol
|
// opacity and RGB protocol
|
||||||
bool _opacityModifyRGB;
|
bool _opacityModifyRGB;
|
||||||
|
|
|
@ -365,10 +365,10 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex)
|
||||||
void SpriteBatchNode::swap(int oldIndex, int newIndex)
|
void SpriteBatchNode::swap(int oldIndex, int newIndex)
|
||||||
{
|
{
|
||||||
Object** x = _descendants->data->arr;
|
Object** x = _descendants->data->arr;
|
||||||
ccV3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
V3F_C4B_T2F_Quad* quads = _textureAtlas->getQuads();
|
||||||
|
|
||||||
Object* tempItem = x[oldIndex];
|
Object* tempItem = x[oldIndex];
|
||||||
ccV3F_C4B_T2F_Quad tempItemQuad=quads[oldIndex];
|
V3F_C4B_T2F_Quad tempItemQuad=quads[oldIndex];
|
||||||
|
|
||||||
//update the index of other swapped item
|
//update the index of other swapped item
|
||||||
((Sprite*) x[newIndex])->setAtlasIndex(oldIndex);
|
((Sprite*) x[newIndex])->setAtlasIndex(oldIndex);
|
||||||
|
@ -566,7 +566,7 @@ void SpriteBatchNode::insertChild(Sprite *pSprite, unsigned int uIndex)
|
||||||
increaseAtlasCapacity();
|
increaseAtlasCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad quad = pSprite->getQuad();
|
V3F_C4B_T2F_Quad quad = pSprite->getQuad();
|
||||||
_textureAtlas->insertQuad(&quad, uIndex);
|
_textureAtlas->insertQuad(&quad, uIndex);
|
||||||
|
|
||||||
ccArray *descendantsData = _descendants->data;
|
ccArray *descendantsData = _descendants->data;
|
||||||
|
@ -611,7 +611,7 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
||||||
|
|
||||||
sprite->setAtlasIndex(index);
|
sprite->setAtlasIndex(index);
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad quad = sprite->getQuad();
|
V3F_C4B_T2F_Quad quad = sprite->getQuad();
|
||||||
_textureAtlas->insertQuad(&quad, index);
|
_textureAtlas->insertQuad(&quad, index);
|
||||||
|
|
||||||
// add children recursively
|
// add children recursively
|
||||||
|
@ -673,12 +673,12 @@ void SpriteBatchNode::updateBlendFunc(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CocosNodeTexture protocol
|
// CocosNodeTexture protocol
|
||||||
void SpriteBatchNode::setBlendFunc(const ccBlendFunc &blendFunc)
|
void SpriteBatchNode::setBlendFunc(const BlendFunc &blendFunc)
|
||||||
{
|
{
|
||||||
_blendFunc = blendFunc;
|
_blendFunc = blendFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccBlendFunc& SpriteBatchNode::getBlendFunc(void) const
|
const BlendFunc& SpriteBatchNode::getBlendFunc(void) const
|
||||||
{
|
{
|
||||||
return _blendFunc;
|
return _blendFunc;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +714,7 @@ void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, unsigned int index)
|
||||||
sprite->setBatchNode(this);
|
sprite->setBatchNode(this);
|
||||||
sprite->setAtlasIndex(index);
|
sprite->setAtlasIndex(index);
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad quad = sprite->getQuad();
|
V3F_C4B_T2F_Quad quad = sprite->getQuad();
|
||||||
_textureAtlas->insertQuad(&quad, index);
|
_textureAtlas->insertQuad(&quad, index);
|
||||||
|
|
||||||
// XXX: updateTransform will update the textureAtlas too, using updateQuad.
|
// XXX: updateTransform will update the textureAtlas too, using updateQuad.
|
||||||
|
|
|
@ -131,8 +131,8 @@ public:
|
||||||
// TextureProtocol
|
// TextureProtocol
|
||||||
virtual Texture2D* getTexture(void);
|
virtual Texture2D* getTexture(void);
|
||||||
virtual void setTexture(Texture2D *texture);
|
virtual void setTexture(Texture2D *texture);
|
||||||
virtual void setBlendFunc(const ccBlendFunc &blendFunc);
|
virtual void setBlendFunc(const BlendFunc &blendFunc);
|
||||||
virtual const ccBlendFunc& getBlendFunc(void) const;
|
virtual const BlendFunc& getBlendFunc(void) const;
|
||||||
|
|
||||||
virtual void visit(void);
|
virtual void visit(void);
|
||||||
virtual void addChild(Node * child);
|
virtual void addChild(Node * child);
|
||||||
|
@ -168,7 +168,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextureAtlas *_textureAtlas;
|
TextureAtlas *_textureAtlas;
|
||||||
ccBlendFunc _blendFunc;
|
BlendFunc _blendFunc;
|
||||||
|
|
||||||
// all descendants: children, gran children, etc...
|
// all descendants: children, gran children, etc...
|
||||||
Array* _descendants;
|
Array* _descendants;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
void ccVertexLineToPolygon(Point *points, float stroke, ccVertex2F *vertices, unsigned int offset, unsigned int nuPoints)
|
void ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints)
|
||||||
{
|
{
|
||||||
nuPoints += offset;
|
nuPoints += offset;
|
||||||
if(nuPoints<=1) return;
|
if(nuPoints<=1) return;
|
||||||
|
@ -69,8 +69,8 @@ void ccVertexLineToPolygon(Point *points, float stroke, ccVertex2F *vertices, un
|
||||||
}
|
}
|
||||||
perpVector = ccpMult(perpVector, stroke);
|
perpVector = ccpMult(perpVector, stroke);
|
||||||
|
|
||||||
vertices[idx] = vertex2(p1.x+perpVector.x, p1.y+perpVector.y);
|
vertices[idx] = Vertex2F(p1.x+perpVector.x, p1.y+perpVector.y);
|
||||||
vertices[idx+1] = vertex2(p1.x-perpVector.x, p1.y-perpVector.y);
|
vertices[idx+1] = Vertex2F(p1.x-perpVector.x, p1.y-perpVector.y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +81,10 @@ void ccVertexLineToPolygon(Point *points, float stroke, ccVertex2F *vertices, un
|
||||||
idx = i*2;
|
idx = i*2;
|
||||||
const unsigned int idx1 = idx+2;
|
const unsigned int idx1 = idx+2;
|
||||||
|
|
||||||
ccVertex2F p1 = vertices[idx];
|
Vertex2F p1 = vertices[idx];
|
||||||
ccVertex2F p2 = vertices[idx+1];
|
Vertex2F p2 = vertices[idx+1];
|
||||||
ccVertex2F p3 = vertices[idx1];
|
Vertex2F p3 = vertices[idx1];
|
||||||
ccVertex2F p4 = vertices[idx1+1];
|
Vertex2F p4 = vertices[idx1+1];
|
||||||
|
|
||||||
float s;
|
float s;
|
||||||
//BOOL fixVertex = !ccpLineIntersect(ccp(p1.x, p1.y), ccp(p4.x, p4.y), ccp(p2.x, p2.y), ccp(p3.x, p3.y), &s, &t);
|
//BOOL fixVertex = !ccpLineIntersect(ccp(p1.x, p1.y), ccp(p4.x, p4.y), ccp(p2.x, p2.y), ccp(p3.x, p3.y), &s, &t);
|
||||||
|
|
|
@ -37,7 +37,7 @@ NS_CC_BEGIN
|
||||||
/** @file Vertex.h */
|
/** @file Vertex.h */
|
||||||
|
|
||||||
/** converts a line to a polygon */
|
/** converts a line to a polygon */
|
||||||
void CC_DLL ccVertexLineToPolygon(Point *points, float stroke, ccVertex2F *vertices, unsigned int offset, unsigned int nuPoints);
|
void CC_DLL ccVertexLineToPolygon(Point *points, float stroke, Vertex2F *vertices, unsigned int offset, unsigned int nuPoints);
|
||||||
|
|
||||||
/** returns whether or not the line intersects */
|
/** returns whether or not the line intersects */
|
||||||
bool CC_DLL ccVertexLineIntersect(float Ax, float Ay,
|
bool CC_DLL ccVertexLineIntersect(float Ax, float Ay,
|
||||||
|
|
|
@ -265,18 +265,18 @@ void TextFieldTTF::draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw placeholder
|
// draw placeholder
|
||||||
ccColor3B color = getColor();
|
Color3B color = getColor();
|
||||||
setColor(_colorSpaceHolder);
|
setColor(_colorSpaceHolder);
|
||||||
LabelTTF::draw();
|
LabelTTF::draw();
|
||||||
setColor(color);
|
setColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& TextFieldTTF::getColorSpaceHolder()
|
const Color3B& TextFieldTTF::getColorSpaceHolder()
|
||||||
{
|
{
|
||||||
return _colorSpaceHolder;
|
return _colorSpaceHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextFieldTTF::setColorSpaceHolder(const ccColor3B& color)
|
void TextFieldTTF::setColorSpaceHolder(const Color3B& color)
|
||||||
{
|
{
|
||||||
_colorSpaceHolder = color;
|
_colorSpaceHolder = color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,8 +127,8 @@ public:
|
||||||
|
|
||||||
CC_SYNTHESIZE(TextFieldDelegate *, _delegate, Delegate);
|
CC_SYNTHESIZE(TextFieldDelegate *, _delegate, Delegate);
|
||||||
CC_SYNTHESIZE_READONLY(int, _charCount, CharCount);
|
CC_SYNTHESIZE_READONLY(int, _charCount, CharCount);
|
||||||
virtual const ccColor3B& getColorSpaceHolder();
|
virtual const Color3B& getColorSpaceHolder();
|
||||||
virtual void setColorSpaceHolder(const ccColor3B& color);
|
virtual void setColorSpaceHolder(const Color3B& color);
|
||||||
|
|
||||||
// input text property
|
// input text property
|
||||||
public:
|
public:
|
||||||
|
@ -144,7 +144,7 @@ public:
|
||||||
virtual const char * getPlaceHolder(void);
|
virtual const char * getPlaceHolder(void);
|
||||||
protected:
|
protected:
|
||||||
std::string * _placeHolder;
|
std::string * _placeHolder;
|
||||||
ccColor3B _colorSpaceHolder;
|
Color3B _colorSpaceHolder;
|
||||||
public:
|
public:
|
||||||
virtual void setSecureTextEntry(bool value);
|
virtual void setSecureTextEntry(bool value);
|
||||||
virtual bool isSecureTextEntry();
|
virtual bool isSecureTextEntry();
|
||||||
|
|
|
@ -444,7 +444,7 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
||||||
ccFontDefinition tempDef;
|
FontDefinition tempDef;
|
||||||
|
|
||||||
tempDef._shadow._shadowEnabled = false;
|
tempDef._shadow._shadowEnabled = false;
|
||||||
tempDef._stroke._strokeEnabled = false;
|
tempDef._stroke._strokeEnabled = false;
|
||||||
|
@ -455,9 +455,9 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
|
||||||
tempDef._dimensions = dimensions;
|
tempDef._dimensions = dimensions;
|
||||||
tempDef._alignment = hAlignment;
|
tempDef._alignment = hAlignment;
|
||||||
tempDef._vertAlignment = vAlignment;
|
tempDef._vertAlignment = vAlignment;
|
||||||
tempDef._fontFillColor = ccWHITE;
|
tempDef._fontFillColor = Color3B::white;
|
||||||
|
|
||||||
return initWithString(text, &tempDef);
|
return initWithString(text, tempDef);
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -510,32 +510,32 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinition)
|
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// cache the texture data
|
// cache the texture data
|
||||||
VolatileTexture::addStringTexture(this, text, textDefinition->_dimensions, textDefinition->_alignment, textDefinition->_vertAlignment, textDefinition->_fontName.c_str(), textDefinition->_fontSize);
|
VolatileTexture::addStringTexture(this, text, textDefinition._dimensions, textDefinition._alignment, textDefinition._vertAlignment, textDefinition._fontName.c_str(), textDefinition._fontSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
Image::ETextAlign eAlign;
|
Image::ETextAlign eAlign;
|
||||||
|
|
||||||
if (kVerticalTextAlignmentTop == textDefinition->_vertAlignment)
|
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (kTextAlignmentCenter == textDefinition->_alignment) ? Image::kAlignTop
|
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
|
||||||
: (kTextAlignmentLeft == textDefinition->_alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
|
||||||
}
|
}
|
||||||
else if (kVerticalTextAlignmentCenter == textDefinition->_vertAlignment)
|
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (kTextAlignmentCenter == textDefinition->_alignment) ? Image::kAlignCenter
|
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter
|
||||||
: (kTextAlignmentLeft == textDefinition->_alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
|
||||||
}
|
}
|
||||||
else if (kVerticalTextAlignmentBottom == textDefinition->_vertAlignment)
|
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment)
|
||||||
{
|
{
|
||||||
eAlign = (kTextAlignmentCenter == textDefinition->_alignment) ? Image::kAlignBottom
|
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom
|
||||||
: (kTextAlignmentLeft == textDefinition->_alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -550,13 +550,13 @@ bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinitio
|
||||||
float shadowBlur = 0.0f;
|
float shadowBlur = 0.0f;
|
||||||
float shadowOpacity = 0.0f;
|
float shadowOpacity = 0.0f;
|
||||||
|
|
||||||
if ( textDefinition->_shadow._shadowEnabled )
|
if ( textDefinition._shadow._shadowEnabled )
|
||||||
{
|
{
|
||||||
shadowEnabled = true;
|
shadowEnabled = true;
|
||||||
shadowDX = textDefinition->_shadow._shadowOffset.width;
|
shadowDX = textDefinition._shadow._shadowOffset.width;
|
||||||
shadowDY = textDefinition->_shadow._shadowOffset.height;
|
shadowDY = textDefinition._shadow._shadowOffset.height;
|
||||||
shadowBlur = textDefinition->_shadow._shadowBlur;
|
shadowBlur = textDefinition._shadow._shadowBlur;
|
||||||
shadowOpacity = textDefinition->_shadow._shadowOpacity;
|
shadowOpacity = textDefinition._shadow._shadowOpacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle stroke parameters
|
// handle stroke parameters
|
||||||
|
@ -566,13 +566,13 @@ bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinitio
|
||||||
float strokeColorB = 0.0f;
|
float strokeColorB = 0.0f;
|
||||||
float strokeSize = 0.0f;
|
float strokeSize = 0.0f;
|
||||||
|
|
||||||
if ( textDefinition->_stroke._strokeEnabled )
|
if ( textDefinition._stroke._strokeEnabled )
|
||||||
{
|
{
|
||||||
strokeEnabled = true;
|
strokeEnabled = true;
|
||||||
strokeColorR = textDefinition->_stroke._strokeColor.r / 255.0f;
|
strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
|
||||||
strokeColorG = textDefinition->_stroke._strokeColor.g / 255.0f;
|
strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
|
||||||
strokeColorB = textDefinition->_stroke._strokeColor.b / 255.0f;
|
strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
|
||||||
strokeSize = textDefinition->_stroke._strokeSize;
|
strokeSize = textDefinition._stroke._strokeSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image* pImage = new Image();
|
Image* pImage = new Image();
|
||||||
|
@ -581,14 +581,14 @@ bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinitio
|
||||||
CC_BREAK_IF(NULL == pImage);
|
CC_BREAK_IF(NULL == pImage);
|
||||||
|
|
||||||
bRet = pImage->initWithStringShadowStroke(text,
|
bRet = pImage->initWithStringShadowStroke(text,
|
||||||
(int)textDefinition->_dimensions.width,
|
(int)textDefinition._dimensions.width,
|
||||||
(int)textDefinition->_dimensions.height,
|
(int)textDefinition._dimensions.height,
|
||||||
eAlign,
|
eAlign,
|
||||||
textDefinition->_fontName.c_str(),
|
textDefinition._fontName.c_str(),
|
||||||
textDefinition->_fontSize,
|
textDefinition._fontSize,
|
||||||
textDefinition->_fontFillColor.r / 255.0f,
|
textDefinition._fontFillColor.r / 255.0f,
|
||||||
textDefinition->_fontFillColor.g / 255.0f,
|
textDefinition._fontFillColor.g / 255.0f,
|
||||||
textDefinition->_fontFillColor.b / 255.0f,
|
textDefinition._fontFillColor.b / 255.0f,
|
||||||
shadowEnabled,
|
shadowEnabled,
|
||||||
shadowDX,
|
shadowDX,
|
||||||
shadowDY,
|
shadowDY,
|
||||||
|
|
|
@ -136,7 +136,7 @@ public:
|
||||||
/** Initializes a texture from a string with font name and font size */
|
/** Initializes a texture from a string with font name and font size */
|
||||||
bool initWithString(const char *text, const char *fontName, float fontSize);
|
bool initWithString(const char *text, const char *fontName, float fontSize);
|
||||||
/** Initializes a texture from a string using a text definition*/
|
/** Initializes a texture from a string using a text definition*/
|
||||||
bool initWithString(const char *text, ccFontDefinition *textDefinition);
|
bool initWithString(const char *text, const FontDefinition& textDefinition);
|
||||||
|
|
||||||
/** Initializes a texture from a PVR file */
|
/** Initializes a texture from a PVR file */
|
||||||
bool initWithPVRFile(const char* file);
|
bool initWithPVRFile(const char* file);
|
||||||
|
|
|
@ -90,14 +90,14 @@ void TextureAtlas::setTexture(Texture2D * var)
|
||||||
_texture = var;
|
_texture = var;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad* TextureAtlas::getQuads()
|
V3F_C4B_T2F_Quad* TextureAtlas::getQuads()
|
||||||
{
|
{
|
||||||
//if someone accesses the quads directly, presume that changes will be made
|
//if someone accesses the quads directly, presume that changes will be made
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
return _quads;
|
return _quads;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::setQuads(ccV3F_C4B_T2F_Quad *var)
|
void TextureAtlas::setQuads(V3F_C4B_T2F_Quad *var)
|
||||||
{
|
{
|
||||||
_quads = var;
|
_quads = var;
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
|
||||||
// Re-initialization is not allowed
|
// Re-initialization is not allowed
|
||||||
CCAssert(_quads == NULL && _indices == NULL, "");
|
CCAssert(_quads == NULL && _indices == NULL, "");
|
||||||
|
|
||||||
_quads = (ccV3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(ccV3F_C4B_T2F_Quad) );
|
_quads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(V3F_C4B_T2F_Quad) );
|
||||||
_indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) );
|
_indices = (GLushort *)malloc( _capacity * 6 * sizeof(GLushort) );
|
||||||
|
|
||||||
if( ! ( _quads && _indices) && _capacity > 0)
|
if( ! ( _quads && _indices) && _capacity > 0)
|
||||||
|
@ -172,7 +172,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset( _quads, 0, _capacity * sizeof(ccV3F_C4B_T2F_Quad) );
|
memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) );
|
||||||
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
|
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
|
||||||
|
|
||||||
// listen the event when app go to background
|
// listen the event when app go to background
|
||||||
|
@ -256,15 +256,15 @@ void TextureAtlas::setupVBOandVAO()
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Position);
|
glEnableVertexAttribArray(kVertexAttrib_Position);
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
glEnableVertexAttribArray(kVertexAttrib_Color);
|
glEnableVertexAttribArray(kVertexAttrib_Color);
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
|
||||||
|
|
||||||
// tex coords
|
// tex coords
|
||||||
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
glEnableVertexAttribArray(kVertexAttrib_TexCoords);
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( ccV3F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW);
|
||||||
|
@ -303,7 +303,7 @@ void TextureAtlas::mapBuffers()
|
||||||
|
|
||||||
// TextureAtlas - Update, Insert, Move & Remove
|
// TextureAtlas - Update, Insert, Move & Remove
|
||||||
|
|
||||||
void TextureAtlas::updateQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
|
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
|
||||||
{
|
{
|
||||||
CCAssert( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
CCAssert( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ void TextureAtlas::updateQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
|
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, unsigned int index)
|
||||||
{
|
{
|
||||||
CCAssert( index < _capacity, "insertQuadWithTexture: Invalid index");
|
CCAssert( index < _capacity, "insertQuadWithTexture: Invalid index");
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ void TextureAtlas::insertQuad(ccV3F_C4B_T2F_Quad *quad, unsigned int index)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::insertQuads(ccV3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount)
|
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount)
|
||||||
{
|
{
|
||||||
CCAssert(index + amount <= _capacity, "insertQuadWithTexture: Invalid index + amount");
|
CCAssert(index + amount <= _capacity, "insertQuadWithTexture: Invalid index + amount");
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ void TextureAtlas::insertQuadFromIndex(unsigned int oldIndex, unsigned int newIn
|
||||||
}
|
}
|
||||||
|
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
ccV3F_C4B_T2F_Quad quadsBackup = _quads[oldIndex];
|
V3F_C4B_T2F_Quad quadsBackup = _quads[oldIndex];
|
||||||
memmove( &_quads[dst],&_quads[src], sizeof(_quads[0]) * howMany );
|
memmove( &_quads[dst],&_quads[src], sizeof(_quads[0]) * howMany );
|
||||||
_quads[newIndex] = quadsBackup;
|
_quads[newIndex] = quadsBackup;
|
||||||
|
|
||||||
|
@ -455,14 +455,14 @@ bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
|
||||||
_totalQuads = MIN(_totalQuads, newCapacity);
|
_totalQuads = MIN(_totalQuads, newCapacity);
|
||||||
_capacity = newCapacity;
|
_capacity = newCapacity;
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad* tmpQuads = NULL;
|
V3F_C4B_T2F_Quad* tmpQuads = NULL;
|
||||||
GLushort* tmpIndices = NULL;
|
GLushort* tmpIndices = NULL;
|
||||||
|
|
||||||
// when calling initWithTexture(fileName, 0) on bada device, calloc(0, 1) will fail and return NULL,
|
// when calling initWithTexture(fileName, 0) on bada device, calloc(0, 1) will fail and return NULL,
|
||||||
// so here must judge whether _quads and _indices is NULL.
|
// so here must judge whether _quads and _indices is NULL.
|
||||||
if (_quads == NULL)
|
if (_quads == NULL)
|
||||||
{
|
{
|
||||||
tmpQuads = (ccV3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(_quads[0]) );
|
tmpQuads = (V3F_C4B_T2F_Quad*)malloc( _capacity * sizeof(_quads[0]) );
|
||||||
if (tmpQuads != NULL)
|
if (tmpQuads != NULL)
|
||||||
{
|
{
|
||||||
memset(tmpQuads, 0, _capacity * sizeof(_quads[0]) );
|
memset(tmpQuads, 0, _capacity * sizeof(_quads[0]) );
|
||||||
|
@ -470,7 +470,7 @@ bool TextureAtlas::resizeCapacity(unsigned int newCapacity)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmpQuads = (ccV3F_C4B_T2F_Quad*)realloc( _quads, sizeof(_quads[0]) * _capacity );
|
tmpQuads = (V3F_C4B_T2F_Quad*)realloc( _quads, sizeof(_quads[0]) * _capacity );
|
||||||
if (tmpQuads != NULL && _capacity > uOldCapactiy)
|
if (tmpQuads != NULL && _capacity > uOldCapactiy)
|
||||||
{
|
{
|
||||||
memset(tmpQuads+uOldCapactiy, 0, (_capacity - uOldCapactiy)*sizeof(_quads[0]) );
|
memset(tmpQuads+uOldCapactiy, 0, (_capacity - uOldCapactiy)*sizeof(_quads[0]) );
|
||||||
|
@ -532,8 +532,8 @@ void TextureAtlas::moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//create buffer
|
//create buffer
|
||||||
size_t quadSize = sizeof(ccV3F_C4B_T2F_Quad);
|
size_t quadSize = sizeof(V3F_C4B_T2F_Quad);
|
||||||
ccV3F_C4B_T2F_Quad* tempQuads = (ccV3F_C4B_T2F_Quad*)malloc( quadSize * amount);
|
V3F_C4B_T2F_Quad* tempQuads = (V3F_C4B_T2F_Quad*)malloc( quadSize * amount);
|
||||||
memcpy( tempQuads, &_quads[oldIndex], quadSize * amount );
|
memcpy( tempQuads, &_quads[oldIndex], quadSize * amount );
|
||||||
|
|
||||||
if (newIndex < oldIndex)
|
if (newIndex < oldIndex)
|
||||||
|
@ -562,7 +562,7 @@ void TextureAtlas::moveQuadsFromIndex(unsigned int index, unsigned int newIndex)
|
||||||
|
|
||||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount)
|
void TextureAtlas::fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount)
|
||||||
{
|
{
|
||||||
ccV3F_C4B_T2F_Quad quad;
|
V3F_C4B_T2F_Quad quad;
|
||||||
memset(&quad, 0, sizeof(quad));
|
memset(&quad, 0, sizeof(quad));
|
||||||
|
|
||||||
unsigned int to = index + amount;
|
unsigned int to = index + amount;
|
||||||
|
@ -656,13 +656,13 @@ void TextureAtlas::drawNumberOfQuads(unsigned int n, unsigned int start)
|
||||||
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
|
||||||
|
|
||||||
// vertices
|
// vertices
|
||||||
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(ccV3F_C4B_T2F, vertices));
|
glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(ccV3F_C4B_T2F, colors));
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
|
||||||
|
|
||||||
// tex coords
|
// tex coords
|
||||||
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(ccV3F_C4B_T2F, texCoords));
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
|
||||||
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ protected:
|
||||||
/** Texture of the texture atlas */
|
/** Texture of the texture atlas */
|
||||||
CC_PROPERTY(Texture2D *, _texture, Texture)
|
CC_PROPERTY(Texture2D *, _texture, Texture)
|
||||||
/** Quads that are going to be rendered */
|
/** Quads that are going to be rendered */
|
||||||
CC_PROPERTY(ccV3F_C4B_T2F_Quad *, _quads, Quads)
|
CC_PROPERTY(V3F_C4B_T2F_Quad *, _quads, Quads)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -111,20 +111,20 @@ public:
|
||||||
* index must be between 0 and the atlas capacity - 1
|
* index must be between 0 and the atlas capacity - 1
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
void updateQuad(ccV3F_C4B_T2F_Quad* quad, unsigned int index);
|
void updateQuad(V3F_C4B_T2F_Quad* quad, unsigned int index);
|
||||||
|
|
||||||
/** Inserts a Quad (texture, vertex and color) at a certain index
|
/** Inserts a Quad (texture, vertex and color) at a certain index
|
||||||
index must be between 0 and the atlas capacity - 1
|
index must be between 0 and the atlas capacity - 1
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
void insertQuad(ccV3F_C4B_T2F_Quad* quad, unsigned int index);
|
void insertQuad(V3F_C4B_T2F_Quad* quad, unsigned int index);
|
||||||
|
|
||||||
/** Inserts a c array of quads at a given index
|
/** Inserts a c array of quads at a given index
|
||||||
index must be between 0 and the atlas capacity - 1
|
index must be between 0 and the atlas capacity - 1
|
||||||
this method doesn't enlarge the array when amount + index > totalQuads
|
this method doesn't enlarge the array when amount + index > totalQuads
|
||||||
@since v1.1
|
@since v1.1
|
||||||
*/
|
*/
|
||||||
void insertQuads(ccV3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount);
|
void insertQuads(V3F_C4B_T2F_Quad* quads, unsigned int index, unsigned int amount);
|
||||||
|
|
||||||
/** Removes the quad that is located at a certain index and inserts it at a new index
|
/** Removes the quad that is located at a certain index and inserts it at a new index
|
||||||
This operation is faster than removing and inserting in a quad in 2 different steps
|
This operation is faster than removing and inserting in a quad in 2 different steps
|
||||||
|
|
|
@ -101,8 +101,8 @@ void TileMapAtlas::calculateItemsToRender()
|
||||||
{
|
{
|
||||||
for( int y=0; y < _TGAInfo->height; y++ )
|
for( int y=0; y < _TGAInfo->height; y++ )
|
||||||
{
|
{
|
||||||
ccColor3B *ptr = (ccColor3B*) _TGAInfo->imageData;
|
Color3B *ptr = (Color3B*) _TGAInfo->imageData;
|
||||||
ccColor3B value = ptr[x + y * _TGAInfo->width];
|
Color3B value = ptr[x + y * _TGAInfo->width];
|
||||||
if( value.r )
|
if( value.r )
|
||||||
{
|
{
|
||||||
++_itemsToRender;
|
++_itemsToRender;
|
||||||
|
@ -132,7 +132,7 @@ void TileMapAtlas::loadTGAfile(const char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TileMapAtlas - Atlas generation / updates
|
// TileMapAtlas - Atlas generation / updates
|
||||||
void TileMapAtlas::setTile(const ccColor3B& tile, const Point& position)
|
void TileMapAtlas::setTile(const Color3B& tile, const Point& position)
|
||||||
{
|
{
|
||||||
CCAssert(_TGAInfo != NULL, "tgaInfo must not be nil");
|
CCAssert(_TGAInfo != NULL, "tgaInfo must not be nil");
|
||||||
CCAssert(_posToAtlasIndex != NULL, "posToAtlasIndex must not be nil");
|
CCAssert(_posToAtlasIndex != NULL, "posToAtlasIndex must not be nil");
|
||||||
|
@ -140,8 +140,8 @@ void TileMapAtlas::setTile(const ccColor3B& tile, const Point& position)
|
||||||
CCAssert(position.y < _TGAInfo->height, "Invalid position.x");
|
CCAssert(position.y < _TGAInfo->height, "Invalid position.x");
|
||||||
CCAssert(tile.r != 0, "R component must be non 0");
|
CCAssert(tile.r != 0, "R component must be non 0");
|
||||||
|
|
||||||
ccColor3B *ptr = (ccColor3B*)_TGAInfo->imageData;
|
Color3B *ptr = (Color3B*)_TGAInfo->imageData;
|
||||||
ccColor3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
|
Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
|
||||||
if( value.r == 0 )
|
if( value.r == 0 )
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: Value.r must be non 0.");
|
CCLOG("cocos2d: Value.r must be non 0.");
|
||||||
|
@ -159,23 +159,23 @@ void TileMapAtlas::setTile(const ccColor3B& tile, const Point& position)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ccColor3B TileMapAtlas::tileAt(const Point& position)
|
Color3B TileMapAtlas::tileAt(const Point& position)
|
||||||
{
|
{
|
||||||
CCAssert( _TGAInfo != NULL, "tgaInfo must not be nil");
|
CCAssert( _TGAInfo != NULL, "tgaInfo must not be nil");
|
||||||
CCAssert( position.x < _TGAInfo->width, "Invalid position.x");
|
CCAssert( position.x < _TGAInfo->width, "Invalid position.x");
|
||||||
CCAssert( position.y < _TGAInfo->height, "Invalid position.y");
|
CCAssert( position.y < _TGAInfo->height, "Invalid position.y");
|
||||||
|
|
||||||
ccColor3B *ptr = (ccColor3B*)_TGAInfo->imageData;
|
Color3B *ptr = (Color3B*)_TGAInfo->imageData;
|
||||||
ccColor3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
|
Color3B value = ptr[(unsigned int)(position.x + position.y * _TGAInfo->width)];
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const ccColor3B& value, unsigned int index)
|
void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index)
|
||||||
{
|
{
|
||||||
CCAssert( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
|
CCAssert( index >= 0 && index < _textureAtlas->getCapacity(), "updateAtlasValueAt: Invalid index");
|
||||||
|
|
||||||
ccV3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[index]);
|
V3F_C4B_T2F_Quad* quad = &((_textureAtlas->getQuads())[index]);
|
||||||
|
|
||||||
int x = pos.x;
|
int x = pos.x;
|
||||||
int y = pos.y;
|
int y = pos.y;
|
||||||
|
@ -222,7 +222,7 @@ void TileMapAtlas::updateAtlasValueAt(const Point& pos, const ccColor3B& value,
|
||||||
quad->tr.vertices.y = (float)(y * _itemHeight + _itemHeight);
|
quad->tr.vertices.y = (float)(y * _itemHeight + _itemHeight);
|
||||||
quad->tr.vertices.z = 0.0f;
|
quad->tr.vertices.z = 0.0f;
|
||||||
|
|
||||||
ccColor4B color = { _displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity };
|
Color4B color(_displayedColor.r, _displayedColor.g, _displayedColor.b, _displayedOpacity);
|
||||||
quad->tr.colors = color;
|
quad->tr.colors = color;
|
||||||
quad->tl.colors = color;
|
quad->tl.colors = color;
|
||||||
quad->br.colors = color;
|
quad->br.colors = color;
|
||||||
|
@ -247,8 +247,8 @@ void TileMapAtlas::updateAtlasValues()
|
||||||
{
|
{
|
||||||
if( total < _itemsToRender )
|
if( total < _itemsToRender )
|
||||||
{
|
{
|
||||||
ccColor3B *ptr = (ccColor3B*) _TGAInfo->imageData;
|
Color3B *ptr = (Color3B*) _TGAInfo->imageData;
|
||||||
ccColor3B value = ptr[x + y * _TGAInfo->width];
|
Color3B value = ptr[x + y * _TGAInfo->width];
|
||||||
|
|
||||||
if( value.r != 0 )
|
if( value.r != 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,17 +74,17 @@ public:
|
||||||
/** returns a tile from position x,y.
|
/** returns a tile from position x,y.
|
||||||
For the moment only channel R is used
|
For the moment only channel R is used
|
||||||
*/
|
*/
|
||||||
ccColor3B tileAt(const Point& position);
|
Color3B tileAt(const Point& position);
|
||||||
/** sets a tile at position x,y.
|
/** sets a tile at position x,y.
|
||||||
For the moment only channel R is used
|
For the moment only channel R is used
|
||||||
*/
|
*/
|
||||||
void setTile(const ccColor3B& tile, const Point& position);
|
void setTile(const Color3B& tile, const Point& position);
|
||||||
/** dealloc the map from memory */
|
/** dealloc the map from memory */
|
||||||
void releaseMap();
|
void releaseMap();
|
||||||
private:
|
private:
|
||||||
void loadTGAfile(const char *file);
|
void loadTGAfile(const char *file);
|
||||||
void calculateItemsToRender();
|
void calculateItemsToRender();
|
||||||
void updateAtlasValueAt(const Point& pos, const ccColor3B& value, unsigned int index);
|
void updateAtlasValueAt(const Point& pos, const Color3B& value, unsigned int index);
|
||||||
void updateAtlasValues();
|
void updateAtlasValues();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -120,8 +120,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void updateOffsetPoint();
|
virtual void updateOffsetPoint();
|
||||||
|
|
||||||
virtual void setBlendFunc(const ccBlendFunc& blendFunc) { _blendFunc = blendFunc; }
|
inline void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; }
|
||||||
virtual const ccBlendFunc& getBlendFunc(void) const { return _blendFunc; }
|
inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ protected:
|
||||||
|
|
||||||
static std::map<int, Armature*> _armatureIndexDic; //! Use to save armature zorder info,
|
static std::map<int, Armature*> _armatureIndexDic; //! Use to save armature zorder info,
|
||||||
|
|
||||||
ccBlendFunc _blendFunc; //! It's required for TextureProtocol inheritance
|
BlendFunc _blendFunc; //! It's required for TextureProtocol inheritance
|
||||||
|
|
||||||
Point _offsetPoint;
|
Point _offsetPoint;
|
||||||
};
|
};
|
||||||
|
|
|
@ -196,7 +196,7 @@ void Bone::update(float delta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Bone::updateDisplayedColor(const ccColor3B &parentColor)
|
void Bone::updateDisplayedColor(const Color3B &parentColor)
|
||||||
{
|
{
|
||||||
NodeRGBA::updateDisplayedColor(parentColor);
|
NodeRGBA::updateDisplayedColor(parentColor);
|
||||||
updateColor();
|
updateColor();
|
||||||
|
@ -214,7 +214,7 @@ void Bone::updateColor()
|
||||||
RGBAProtocol *protocol = dynamic_cast<RGBAProtocol *>(display);
|
RGBAProtocol *protocol = dynamic_cast<RGBAProtocol *>(display);
|
||||||
if(protocol != NULL)
|
if(protocol != NULL)
|
||||||
{
|
{
|
||||||
protocol->setColor(ccc3(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
protocol->setColor(Color3B(_displayedColor.r * _tweenData->r / 255, _displayedColor.g * _tweenData->g / 255, _displayedColor.b * _tweenData->b / 255));
|
||||||
protocol->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
protocol->setOpacity(_displayedOpacity * _tweenData->a / 255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
|
|
||||||
void update(float delta);
|
void update(float delta);
|
||||||
|
|
||||||
void updateDisplayedColor(const ccColor3B &parentColor);
|
void updateDisplayedColor(const Color3B &parentColor);
|
||||||
void updateDisplayedOpacity(GLubyte parentOpacity);
|
void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||||
|
|
||||||
//! Update color to render display
|
//! Update color to render display
|
||||||
|
|
|
@ -394,9 +394,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ContourVertex2 : public Object
|
struct ContourVertex2F : public Object
|
||||||
{
|
{
|
||||||
ContourVertex2(float x, float y)
|
ContourVertex2F(float x, float y)
|
||||||
{
|
{
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
|
|
|
@ -33,8 +33,8 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
ShaderNode::ShaderNode()
|
ShaderNode::ShaderNode()
|
||||||
: _center(vertex2(0.0f, 0.0f))
|
: _center(Vertex2F(0.0f, 0.0f))
|
||||||
, _resolution(vertex2(0.0f, 0.0f))
|
, _resolution(Vertex2F(0.0f, 0.0f))
|
||||||
, _time(0.0f)
|
, _time(0.0f)
|
||||||
, _uniformCenter(0)
|
, _uniformCenter(0)
|
||||||
, _uniformResolution(0)
|
, _uniformResolution(0)
|
||||||
|
@ -57,7 +57,7 @@ bool ShaderNode::initWithVertex(const char *vert, const char *frag)
|
||||||
loadShaderVertex(vert, frag);
|
loadShaderVertex(vert, frag);
|
||||||
|
|
||||||
_time = 0;
|
_time = 0;
|
||||||
_resolution = vertex2(SIZE_X, SIZE_Y);
|
_resolution = Vertex2F(SIZE_X, SIZE_Y);
|
||||||
|
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
|
@ -95,15 +95,15 @@ void ShaderNode::translateFormOtherNode(AffineTransform &transform)
|
||||||
{
|
{
|
||||||
Node::setAdditionalTransform(transform);
|
Node::setAdditionalTransform(transform);
|
||||||
|
|
||||||
_center = vertex2(_additionalTransform.tx * CC_CONTENT_SCALE_FACTOR(), _additionalTransform.ty * CC_CONTENT_SCALE_FACTOR());
|
_center = Vertex2F(_additionalTransform.tx * CC_CONTENT_SCALE_FACTOR(), _additionalTransform.ty * CC_CONTENT_SCALE_FACTOR());
|
||||||
_resolution = vertex2( SIZE_X * _additionalTransform.a, SIZE_Y * _additionalTransform.d);
|
_resolution = Vertex2F( SIZE_X * _additionalTransform.a, SIZE_Y * _additionalTransform.d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderNode::setPosition(const Point &newPosition)
|
void ShaderNode::setPosition(const Point &newPosition)
|
||||||
{
|
{
|
||||||
Node::setPosition(newPosition);
|
Node::setPosition(newPosition);
|
||||||
Point position = getPosition();
|
Point position = getPosition();
|
||||||
_center = vertex2(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR());
|
_center = Vertex2F(position.x * CC_CONTENT_SCALE_FACTOR(), position.y * CC_CONTENT_SCALE_FACTOR());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderNode::draw()
|
void ShaderNode::draw()
|
||||||
|
|
|
@ -46,8 +46,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ccVertex2F _center;
|
Vertex2F _center;
|
||||||
ccVertex2F _resolution;
|
Vertex2F _resolution;
|
||||||
float _time;
|
float _time;
|
||||||
GLuint _uniformCenter, _uniformResolution, _uniformTime;
|
GLuint _uniformCenter, _uniformResolution, _uniformTime;
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,7 +89,7 @@ void Skin::draw()
|
||||||
// If it is not visible, or one of its ancestors is not visible, then do nothing:
|
// If it is not visible, or one of its ancestors is not visible, then do nothing:
|
||||||
if( !_visible)
|
if( !_visible)
|
||||||
{
|
{
|
||||||
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = vertex3(0, 0, 0);
|
_quad.br.vertices = _quad.tl.vertices = _quad.tr.vertices = _quad.bl.vertices = Vertex3F(0, 0, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -124,10 +124,10 @@ void Skin::draw()
|
||||||
float dx = x1 * cr - y2 * sr2 + x;
|
float dx = x1 * cr - y2 * sr2 + x;
|
||||||
float dy = x1 * sr + y2 * cr2 + y;
|
float dy = x1 * sr + y2 * cr2 + y;
|
||||||
|
|
||||||
_quad.bl.vertices = vertex3( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
_quad.bl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(ax), RENDER_IN_SUBPIXEL(ay), _vertexZ );
|
||||||
_quad.br.vertices = vertex3( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
_quad.br.vertices = Vertex3F( RENDER_IN_SUBPIXEL(bx), RENDER_IN_SUBPIXEL(by), _vertexZ );
|
||||||
_quad.tl.vertices = vertex3( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
_quad.tl.vertices = Vertex3F( RENDER_IN_SUBPIXEL(dx), RENDER_IN_SUBPIXEL(dy), _vertexZ );
|
||||||
_quad.tr.vertices = vertex3( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
_quad.tr.vertices = Vertex3F( RENDER_IN_SUBPIXEL(cx), RENDER_IN_SUBPIXEL(cy), _vertexZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
// MARMALADE CHANGE: ADDED CHECK FOR NULL, TO PERMIT SPRITES WITH NO BATCH NODE / TEXTURE ATLAS
|
||||||
|
|
|
@ -108,10 +108,10 @@ bool Texture2DMutable::initWithData(const void* data, Texture2DPixelFormat pixel
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccColor4B Texture2DMutable::pixelAt(const Point& pt)
|
Color4B Texture2DMutable::pixelAt(const Point& pt)
|
||||||
{
|
{
|
||||||
|
|
||||||
ccColor4B c = {0, 0, 0, 0};
|
Color4B c(0, 0, 0, 0);
|
||||||
if(!data_) return c;
|
if(!data_) return c;
|
||||||
if(pt.x < 0 || pt.y < 0) return c;
|
if(pt.x < 0 || pt.y < 0) return c;
|
||||||
if(pt.x >= _contentSize.width || pt.y >= _contentSize.height) return c;
|
if(pt.x >= _contentSize.width || pt.y >= _contentSize.height) return c;
|
||||||
|
@ -162,7 +162,7 @@ ccColor4B Texture2DMutable::pixelAt(const Point& pt)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Texture2DMutable::setPixelAt(const Point& pt, ccColor4B c)
|
bool Texture2DMutable::setPixelAt(const Point& pt, Color4B c)
|
||||||
{
|
{
|
||||||
if(!data_)return false;
|
if(!data_)return false;
|
||||||
if(pt.x < 0 || pt.y < 0) return false;
|
if(pt.x < 0 || pt.y < 0) return false;
|
||||||
|
@ -199,7 +199,7 @@ bool Texture2DMutable::setPixelAt(const Point& pt, ccColor4B c)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture2DMutable::fill(ccColor4B p)
|
void Texture2DMutable::fill(Color4B p)
|
||||||
{
|
{
|
||||||
for(int r = 0; r < _contentSize.height; ++r)
|
for(int r = 0; r < _contentSize.height; ++r)
|
||||||
for(int c = 0; c < _contentSize.width; ++c)
|
for(int c = 0; c < _contentSize.width; ++c)
|
||||||
|
|
|
@ -48,20 +48,20 @@ public:
|
||||||
bool initWithData(const void* data, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
|
bool initWithData(const void* data, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize);
|
||||||
|
|
||||||
|
|
||||||
cocos2d::ccColor4B pixelAt(const cocos2d::Point& pt);
|
cocos2d::Color4B pixelAt(const cocos2d::Point& pt);
|
||||||
|
|
||||||
///
|
///
|
||||||
// @param pt is a point to get a pixel (0,0) is top-left to (width,height) bottom-right
|
// @param pt is a point to get a pixel (0,0) is top-left to (width,height) bottom-right
|
||||||
// @param c is a ccColor4B which is a colour.
|
// @param c is a Color4B which is a colour.
|
||||||
// @returns if a pixel was set
|
// @returns if a pixel was set
|
||||||
// Remember to call apply to actually update the texture canvas.
|
// Remember to call apply to actually update the texture canvas.
|
||||||
///
|
///
|
||||||
bool setPixelAt(const cocos2d::Point& pt, cocos2d::ccColor4B c);
|
bool setPixelAt(const cocos2d::Point& pt, cocos2d::Color4B c);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Fill with specified colour
|
// Fill with specified colour
|
||||||
///
|
///
|
||||||
void fill(cocos2d::ccColor4B c);
|
void fill(cocos2d::Color4B c);
|
||||||
|
|
||||||
///
|
///
|
||||||
// @param textureToCopy is the texture image to copy over
|
// @param textureToCopy is the texture image to copy over
|
||||||
|
|
|
@ -101,7 +101,7 @@ void ColliderDetector::addContourData(ContourData *contourData)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
CCARRAY_FOREACH(array, object)
|
CCARRAY_FOREACH(array, object)
|
||||||
{
|
{
|
||||||
ContourVertex2 *v = (ContourVertex2 *)object;
|
ContourVertex2F *v = (ContourVertex2F *)object;
|
||||||
b2bv[i].Set(v->x / PT_RATIO, v->y / PT_RATIO);
|
b2bv[i].Set(v->x / PT_RATIO, v->y / PT_RATIO);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ void ColliderDetector::updateTransform(AffineTransform &t)
|
||||||
int i = 0;
|
int i = 0;
|
||||||
CCARRAY_FOREACH(array, object)
|
CCARRAY_FOREACH(array, object)
|
||||||
{
|
{
|
||||||
ContourVertex2 *cv = (ContourVertex2 *)object;
|
ContourVertex2F *cv = (ContourVertex2F *)object;
|
||||||
b2Vec2 &bv = shape->m_vertices[i];
|
b2Vec2 &bv = shape->m_vertices[i];
|
||||||
|
|
||||||
helpPoint.setPoint(cv->x, cv->y);
|
helpPoint.setPoint(cv->x, cv->y);
|
||||||
|
|
|
@ -778,7 +778,7 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML)
|
||||||
|
|
||||||
while (vertexDataXML)
|
while (vertexDataXML)
|
||||||
{
|
{
|
||||||
ContourVertex2 *vertex = new ContourVertex2(0, 0);
|
ContourVertex2F *vertex = new ContourVertex2F(0, 0);
|
||||||
vertex->autorelease();
|
vertex->autorelease();
|
||||||
|
|
||||||
vertexDataXML->QueryFloatAttribute(A_X, &vertex->x);
|
vertexDataXML->QueryFloatAttribute(A_X, &vertex->x);
|
||||||
|
@ -1096,7 +1096,7 @@ ContourData *DataReaderHelper::decodeContour(cs::CSJsonDictionary &json)
|
||||||
{
|
{
|
||||||
cs::CSJsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i);
|
cs::CSJsonDictionary *dic = json.getSubItemFromArray(VERTEX_POINT, i);
|
||||||
|
|
||||||
ContourVertex2 *vertex = new ContourVertex2(0, 0);
|
ContourVertex2F *vertex = new ContourVertex2F(0, 0);
|
||||||
|
|
||||||
vertex->x = dic->getItemFloatValue(A_X, 0);
|
vertex->x = dic->getItemFloatValue(A_X, 0);
|
||||||
vertex->y = dic->getItemFloatValue(A_Y, 0);
|
vertex->y = dic->getItemFloatValue(A_Y, 0);
|
||||||
|
|
|
@ -312,8 +312,8 @@ ActionInterval* CCBAnimationManager::getAction(CCBKeyframe *pKeyframe0, CCBKeyfr
|
||||||
}
|
}
|
||||||
else if (strcmp(pPropName, "color") == 0)
|
else if (strcmp(pPropName, "color") == 0)
|
||||||
{
|
{
|
||||||
ccColor3BWapper* color = (ccColor3BWapper*)pKeyframe1->getValue();
|
Color3BWapper* color = (Color3BWapper*)pKeyframe1->getValue();
|
||||||
ccColor3B c = color->getColor();
|
Color3B c = color->getColor();
|
||||||
|
|
||||||
return TintTo::create(duration, c.r, c.g, c.b);
|
return TintTo::create(duration, c.r, c.g, c.b);
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ void CCBAnimationManager::setAnimatedProperty(const char *pPropName, Node *pNode
|
||||||
}
|
}
|
||||||
else if (strcmp(pPropName, "color") == 0)
|
else if (strcmp(pPropName, "color") == 0)
|
||||||
{
|
{
|
||||||
ccColor3BWapper *color = (ccColor3BWapper*)pValue;
|
Color3BWapper *color = (Color3BWapper*)pValue;
|
||||||
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(color->getColor());
|
(dynamic_cast<RGBAProtocol*>(pNode))->setColor(color->getColor());
|
||||||
}
|
}
|
||||||
else if (strcmp(pPropName, "visible") == 0)
|
else if (strcmp(pPropName, "visible") == 0)
|
||||||
|
|
|
@ -790,8 +790,8 @@ CCBKeyframe* CCBReader::readKeyframe(int type)
|
||||||
int g = readByte();
|
int g = readByte();
|
||||||
int b = readByte();
|
int b = readByte();
|
||||||
|
|
||||||
ccColor3B c = ccc3(r,g,b);
|
Color3B c = Color3B(r,g,b);
|
||||||
value = ccColor3BWapper::create(c);
|
value = Color3BWapper::create(c);
|
||||||
}
|
}
|
||||||
else if (type == kCCBPropTypeDegrees)
|
else if (type == kCCBPropTypeDegrees)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,11 +4,11 @@ using namespace cocos2d;
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
// Implementation of ccColor3BWapper
|
// Implementation of Color3BWapper
|
||||||
|
|
||||||
ccColor3BWapper* ccColor3BWapper::create(const ccColor3B& color)
|
Color3BWapper* Color3BWapper::create(const Color3B& color)
|
||||||
{
|
{
|
||||||
ccColor3BWapper *ret = new ccColor3BWapper();
|
Color3BWapper *ret = new Color3BWapper();
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ret->color.r = color.r;
|
ret->color.r = color.r;
|
||||||
|
@ -21,7 +21,7 @@ ccColor3BWapper* ccColor3BWapper::create(const ccColor3B& color)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& ccColor3BWapper::getColor() const
|
const Color3B& Color3BWapper::getColor() const
|
||||||
{
|
{
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,20 @@
|
||||||
#include "ExtensionMacros.h"
|
#include "ExtensionMacros.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These classes are wrapper of basic types, such as ccColor3B
|
These classes are wrapper of basic types, such as Color3B
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
class ccColor3BWapper : public Object
|
class Color3BWapper : public Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ccColor3B color;
|
Color3B color;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ccColor3BWapper* create(const ccColor3B& color);
|
static Color3BWapper* create(const Color3B& color);
|
||||||
|
|
||||||
const ccColor3B& getColor() const;
|
const Color3B& getColor() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -100,7 +100,7 @@ void ControlButtonLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pPare
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void ControlButtonLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) {
|
||||||
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateNormal);
|
((ControlButton *)pNode)->setTitleColorForState(pColor3B, ControlStateNormal);
|
||||||
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
|
} else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class ControlButtonLoader : public ControlLoader {
|
||||||
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader);
|
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -10,7 +10,7 @@ NS_CC_EXT_BEGIN
|
||||||
#define PROPERTY_FNTFILE "fntFile"
|
#define PROPERTY_FNTFILE "fntFile"
|
||||||
#define PROPERTY_STRING "string"
|
#define PROPERTY_STRING "string"
|
||||||
|
|
||||||
void LabelBMFontLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void LabelBMFontLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||||
((LabelBMFont *)pNode)->setColor(pColor3B);
|
((LabelBMFont *)pNode)->setColor(pColor3B);
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,7 +26,7 @@ void LabelBMFontLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelBMFontLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void LabelBMFontLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((LabelBMFont *)pNode)->setBlendFunc(pBlendFunc);
|
((LabelBMFont *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,9 +16,9 @@ class LabelBMFontLoader : public NodeLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelBMFont);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelBMFont);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char * pPropertyName, const char* pFntFile, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char * pPropertyName, const char* pFntFile, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char* pText, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char* pText, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void LabelTTFLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||||
((LabelTTF *)pNode)->setColor(pColor3B);
|
((LabelTTF *)pNode)->setColor(pColor3B);
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,7 +30,7 @@ void LabelTTFLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void LabelTTFLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((LabelTTF *)pNode)->setBlendFunc(pBlendFunc);
|
((LabelTTF *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,9 +16,9 @@ class LabelTTFLoader : public NodeLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelTTF);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelTTF);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFontTTF(Node * pNode, Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFloatScale(Node * pNode, Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader);
|
||||||
|
|
|
@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN
|
||||||
#define PROPERTY_OPACITY "opacity"
|
#define PROPERTY_OPACITY "opacity"
|
||||||
#define PROPERTY_BLENDFUNC "blendFunc"
|
#define PROPERTY_BLENDFUNC "blendFunc"
|
||||||
|
|
||||||
void LayerColorLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void LayerColorLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||||
((LayerColor *)pNode)->setColor(pColor3B);
|
((LayerColor *)pNode)->setColor(pColor3B);
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,7 @@ void LayerColorLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerColorLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void LayerColorLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((LayerColor *)pNode)->setBlendFunc(pBlendFunc);
|
((LayerColor *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,9 +16,9 @@ class LayerColorLoader : public LayerLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LayerColor);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LayerColor);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
void LayerGradientLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void LayerGradientLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
||||||
((LayerGradient *)pNode)->setStartColor(pColor3B);
|
((LayerGradient *)pNode)->setStartColor(pColor3B);
|
||||||
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) {
|
} else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) {
|
||||||
|
@ -31,7 +31,7 @@ void LayerGradientLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((LayerGradient *)pNode)->setBlendFunc(pBlendFunc);
|
((LayerGradient *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,10 +16,10 @@ class LayerGradientLoader : public LayerLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LayerGradient);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LayerGradient);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader);
|
virtual void onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Point pPoint, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_EXT_END
|
NS_CC_EXT_END
|
||||||
|
|
|
@ -258,7 +258,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * pCCBR
|
||||||
}
|
}
|
||||||
case kCCBPropTypeColor3:
|
case kCCBPropTypeColor3:
|
||||||
{
|
{
|
||||||
ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader, propertyName.c_str());
|
Color3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader, propertyName.c_str());
|
||||||
if(setProp)
|
if(setProp)
|
||||||
{
|
{
|
||||||
this->onHandlePropTypeColor3(pNode, pParent, propertyName.c_str(), color3B, pCCBReader);
|
this->onHandlePropTypeColor3(pNode, pParent, propertyName.c_str(), color3B, pCCBReader);
|
||||||
|
@ -267,7 +267,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * pCCBR
|
||||||
}
|
}
|
||||||
case kCCBPropTypeColor4FVar:
|
case kCCBPropTypeColor4FVar:
|
||||||
{
|
{
|
||||||
ccColor4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader);
|
Color4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader);
|
||||||
if(setProp)
|
if(setProp)
|
||||||
{
|
{
|
||||||
this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName.c_str(), color4FVar, pCCBReader);
|
this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName.c_str(), color4FVar, pCCBReader);
|
||||||
|
@ -285,7 +285,7 @@ void NodeLoader::parseProperties(Node * pNode, Node * pParent, CCBReader * pCCBR
|
||||||
}
|
}
|
||||||
case kCCBPropTypeBlendmode:
|
case kCCBPropTypeBlendmode:
|
||||||
{
|
{
|
||||||
ccBlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader);
|
BlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader);
|
||||||
if(setProp)
|
if(setProp)
|
||||||
{
|
{
|
||||||
this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName.c_str(), blendFunc, pCCBReader);
|
this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName.c_str(), blendFunc, pCCBReader);
|
||||||
|
@ -642,21 +642,21 @@ unsigned char NodeLoader::parsePropTypeByte(Node * pNode, Node * pParent, CCBRea
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccColor3B NodeLoader::parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
Color3B NodeLoader::parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName) {
|
||||||
unsigned char red = pCCBReader->readByte();
|
unsigned char red = pCCBReader->readByte();
|
||||||
unsigned char green = pCCBReader->readByte();
|
unsigned char green = pCCBReader->readByte();
|
||||||
unsigned char blue = pCCBReader->readByte();
|
unsigned char blue = pCCBReader->readByte();
|
||||||
|
|
||||||
ccColor3B color = { red, green, blue };
|
Color3B color(red, green, blue);
|
||||||
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
if (pCCBReader->getAnimatedProperties()->find(pPropertyName) != pCCBReader->getAnimatedProperties()->end())
|
||||||
{
|
{
|
||||||
ccColor3BWapper *value = ccColor3BWapper::create(color);
|
Color3BWapper *value = Color3BWapper::create(color);
|
||||||
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
pCCBReader->getAnimationManager()->setBaseValue(value, pNode, pPropertyName);
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccColor4F * NodeLoader::parsePropTypeColor4FVar(Node * pNode, Node * pParent, CCBReader * pCCBReader) {
|
Color4F * NodeLoader::parsePropTypeColor4FVar(Node * pNode, Node * pParent, CCBReader * pCCBReader) {
|
||||||
float red = pCCBReader->readFloat();
|
float red = pCCBReader->readFloat();
|
||||||
float green = pCCBReader->readFloat();
|
float green = pCCBReader->readFloat();
|
||||||
float blue = pCCBReader->readFloat();
|
float blue = pCCBReader->readFloat();
|
||||||
|
@ -666,7 +666,7 @@ ccColor4F * NodeLoader::parsePropTypeColor4FVar(Node * pNode, Node * pParent, CC
|
||||||
float blueVar = pCCBReader->readFloat();
|
float blueVar = pCCBReader->readFloat();
|
||||||
float alphaVar = pCCBReader->readFloat();
|
float alphaVar = pCCBReader->readFloat();
|
||||||
|
|
||||||
ccColor4F * colors = new ccColor4F[2];
|
Color4F * colors = new Color4F[2];
|
||||||
colors[0].r = red;
|
colors[0].r = red;
|
||||||
colors[0].g = green;
|
colors[0].g = green;
|
||||||
colors[0].b = blue;
|
colors[0].b = blue;
|
||||||
|
@ -691,12 +691,12 @@ bool * NodeLoader::parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * p
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ccBlendFunc NodeLoader::parsePropTypeBlendFunc(Node * pNode, Node * pParent, CCBReader * pCCBReader)
|
BlendFunc NodeLoader::parsePropTypeBlendFunc(Node * pNode, Node * pParent, CCBReader * pCCBReader)
|
||||||
{
|
{
|
||||||
int source = pCCBReader->readInt(false);
|
int source = pCCBReader->readInt(false);
|
||||||
int destination = pCCBReader->readInt(false);
|
int destination = pCCBReader->readInt(false);
|
||||||
|
|
||||||
ccBlendFunc blendFunc;
|
BlendFunc blendFunc;
|
||||||
blendFunc.src = source;
|
blendFunc.src = source;
|
||||||
blendFunc.dst = destination;
|
blendFunc.dst = destination;
|
||||||
|
|
||||||
|
@ -1056,11 +1056,11 @@ void NodeLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char*
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void NodeLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char* pPropertyName, ccColor4F * pColor4FVar, CCBReader * pCCBReader) {
|
void NodeLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char* pPropertyName, Color4F * pColor4FVar, CCBReader * pCCBReader) {
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,7 +1068,7 @@ void NodeLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char*
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void NodeLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,10 @@ class NodeLoader : public Object {
|
||||||
virtual Animation * parsePropTypeAnimation(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual Animation * parsePropTypeAnimation(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual Texture2D * parsePropTypeTexture(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual Texture2D * parsePropTypeTexture(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual unsigned char parsePropTypeByte(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
virtual unsigned char parsePropTypeByte(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
||||||
virtual ccColor3B parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
virtual Color3B parsePropTypeColor3(Node * pNode, Node * pParent, CCBReader * pCCBReader, const char *pPropertyName);
|
||||||
virtual ccColor4F * parsePropTypeColor4FVar(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual Color4F * parsePropTypeColor4FVar(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual bool * parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual bool * parsePropTypeFlip(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual ccBlendFunc parsePropTypeBlendFunc(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual BlendFunc parsePropTypeBlendFunc(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual std::string parsePropTypeFntFile(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual std::string parsePropTypeFntFile(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual std::string parsePropTypeString(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual std::string parsePropTypeString(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
virtual std::string parsePropTypeText(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
virtual std::string parsePropTypeText(Node * pNode, Node * pParent, CCBReader * pCCBReader);
|
||||||
|
@ -104,10 +104,10 @@ class NodeLoader : public Object {
|
||||||
virtual void onHandlePropTypeAnimation(Node * pNode, Node * pParent, const char* pPropertyName, Animation * pAnimation, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeAnimation(Node * pNode, Node * pParent, const char* pPropertyName, Animation * pAnimation, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeTexture(Node * pNode, Node * pParent, const char* pPropertyName, Texture2D * pTexture2D, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeTexture(Node * pNode, Node * pParent, const char* pPropertyName, Texture2D * pTexture2D, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char* pPropertyName, ccColor4F * pColor4FVar, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char* pPropertyName, Color4F * pColor4FVar, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFlip(Node * pNode, Node * pParent, const char* pPropertyName, bool * pFlip, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFlip(Node * pNode, Node * pParent, const char* pPropertyName, bool * pFlip, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char* pPropertyName, const char * pFntFile, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFntFile(Node * pNode, Node * pParent, const char* pPropertyName, const char * pFntFile, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeString(Node * pNode, Node * pParent, const char* pPropertyName, const char * pString, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeString(Node * pNode, Node * pParent, const char* pPropertyName, const char * pString, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char* pPropertyName, const char * pText, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeText(Node * pNode, Node * pParent, const char* pPropertyName, const char * pText, CCBReader * pCCBReader);
|
||||||
|
|
|
@ -105,7 +105,7 @@ void ParticleSystemQuadLoader::onHandlePropTypeFloatVar(Node * pNode, Node * pPa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemQuadLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char * pPropertyName, ccColor4F * pColor4FVar, CCBReader * pCCBReader) {
|
void ParticleSystemQuadLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char * pPropertyName, Color4F * pColor4FVar, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) {
|
||||||
((ParticleSystemQuad *)pNode)->setStartColor(pColor4FVar[0]);
|
((ParticleSystemQuad *)pNode)->setStartColor(pColor4FVar[0]);
|
||||||
((ParticleSystemQuad *)pNode)->setStartColorVar(pColor4FVar[1]);
|
((ParticleSystemQuad *)pNode)->setStartColorVar(pColor4FVar[1]);
|
||||||
|
@ -117,7 +117,7 @@ void ParticleSystemQuadLoader::onHandlePropTypeColor4FVar(Node * pNode, Node * p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemQuadLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void ParticleSystemQuadLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((ParticleSystemQuad *)pNode)->setBlendFunc(pBlendFunc);
|
((ParticleSystemQuad *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,8 +21,8 @@ class ParticleSystemQuadLoader : public NodeLoader {
|
||||||
virtual void onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeInteger(Node * pNode, Node * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeInteger(Node * pNode, Node * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFloatVar(Node * pNode, Node * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFloatVar(Node * pNode, Node * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char * pPropertyName, ccColor4F * pColor4FVar, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor4FVar(Node * pNode, Node * pParent, const char * pPropertyName, Color4F * pColor4FVar, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeTexture(Node * pNode, Node * pParent, const char * pPropertyName, Texture2D * pTexture2D, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeTexture(Node * pNode, Node * pParent, const char * pPropertyName, Texture2D * pTexture2D, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ void Scale9SpriteLoader::onHandlePropTypeSpriteFrame(Node * pNode, Node * pParen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scale9SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void Scale9SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||||
((Scale9Sprite *)pNode)->setColor(pColor3B);
|
((Scale9Sprite *)pNode)->setColor(pColor3B);
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +39,7 @@ void Scale9SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, cons
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scale9SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void Scale9SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
// TODO Not exported by CocosBuilder yet!
|
// TODO Not exported by CocosBuilder yet!
|
||||||
// ((Scale9Sprite *)pNode)->setBlendFunc(pBlendFunc);
|
// ((Scale9Sprite *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
|
|
|
@ -18,9 +18,9 @@ class Scale9SpriteLoader : public NodeLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(Scale9Sprite);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(Scale9Sprite);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeSize(Node * pNode, Node * pParent, const char * pPropertyName, Size pSize, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFloat(Node * pNode, Node * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader);
|
||||||
|
|
|
@ -29,7 +29,7 @@ void SpriteLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader) {
|
void SpriteLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) {
|
||||||
((Sprite *)pNode)->setColor(pColor3B);
|
((Sprite *)pNode)->setColor(pColor3B);
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,7 +45,7 @@ void SpriteLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
void SpriteLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pBlendFunc, CCBReader * pCCBReader) {
|
||||||
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) {
|
||||||
((Sprite *)pNode)->setBlendFunc(pBlendFunc);
|
((Sprite *)pNode)->setBlendFunc(pBlendFunc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,9 +16,9 @@ class SpriteLoader : public NodeLoader {
|
||||||
protected:
|
protected:
|
||||||
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(Sprite);
|
CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(Sprite);
|
||||||
|
|
||||||
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, ccColor3B pColor3B, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeColor3(Node * pNode, Node * pParent, const char * pPropertyName, Color3B pColor3B, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeByte(Node * pNode, Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, ccBlendFunc pCCBBlendFunc, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char * pPropertyName, BlendFunc pCCBBlendFunc, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeSpriteFrame(Node * pNode, Node * pParent, const char * pPropertyName, SpriteFrame * pSpriteFrame, CCBReader * pCCBReader);
|
||||||
virtual void onHandlePropTypeFlip(Node * pNode, Node * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader);
|
virtual void onHandlePropTypeFlip(Node * pNode, Node * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader);
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,7 +44,7 @@ enum
|
||||||
|
|
||||||
ControlButton::ControlButton()
|
ControlButton::ControlButton()
|
||||||
: _currentTitle(NULL)
|
: _currentTitle(NULL)
|
||||||
, _currentTitleColor(ccWHITE)
|
, _currentTitleColor(Color3B::white)
|
||||||
, _doesAdjustBackgroundImage(false)
|
, _doesAdjustBackgroundImage(false)
|
||||||
, _titleLabel(NULL)
|
, _titleLabel(NULL)
|
||||||
, _backgroundSprite(NULL)
|
, _backgroundSprite(NULL)
|
||||||
|
@ -118,7 +118,7 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b
|
||||||
setBackgroundSprite(backgroundSprite);
|
setBackgroundSprite(backgroundSprite);
|
||||||
|
|
||||||
// Set the default color and opacity
|
// Set the default color and opacity
|
||||||
setColor(ccc3(255.0f, 255.0f, 255.0f));
|
setColor(Color3B(255.0f, 255.0f, 255.0f));
|
||||||
setOpacity(255.0f);
|
setOpacity(255.0f);
|
||||||
setOpacityModifyRGB(true);
|
setOpacityModifyRGB(true);
|
||||||
|
|
||||||
|
@ -321,9 +321,9 @@ void ControlButton::setTitleForState(String* title, ControlState state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ccColor3B ControlButton::getTitleColorForState(ControlState state)
|
const Color3B ControlButton::getTitleColorForState(ControlState state)
|
||||||
{
|
{
|
||||||
ccColor3B returnColor = ccWHITE;
|
Color3B returnColor = Color3B::white;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
CC_BREAK_IF(NULL == _titleColorDispatchTable);
|
CC_BREAK_IF(NULL == _titleColorDispatchTable);
|
||||||
|
@ -344,9 +344,9 @@ const ccColor3B ControlButton::getTitleColorForState(ControlState state)
|
||||||
return returnColor;
|
return returnColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlButton::setTitleColorForState(ccColor3B color, ControlState state)
|
void ControlButton::setTitleColorForState(Color3B color, ControlState state)
|
||||||
{
|
{
|
||||||
//ccColor3B* colorValue=&color;
|
//Color3B* colorValue=&color;
|
||||||
_titleColorDispatchTable->removeObjectForKey(state);
|
_titleColorDispatchTable->removeObjectForKey(state);
|
||||||
Color3bObject* pColor3bObject = new Color3bObject(color);
|
Color3bObject* pColor3bObject = new Color3bObject(color);
|
||||||
pColor3bObject->autorelease();
|
pColor3bObject->autorelease();
|
||||||
|
@ -729,7 +729,7 @@ GLubyte ControlButton::getOpacity() const
|
||||||
return _realOpacity;
|
return _realOpacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlButton::setColor(const ccColor3B & color)
|
void ControlButton::setColor(const Color3B & color)
|
||||||
{
|
{
|
||||||
Control::setColor(color);
|
Control::setColor(color);
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ void ControlButton::setColor(const ccColor3B & color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ccColor3B& ControlButton::getColor() const
|
const Color3B& ControlButton::getColor() const
|
||||||
{
|
{
|
||||||
return _realColor;
|
return _realColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
||||||
CC_SYNTHESIZE_READONLY(String*, _currentTitle, CurrentTitle);
|
CC_SYNTHESIZE_READONLY(String*, _currentTitle, CurrentTitle);
|
||||||
|
|
||||||
/** The current color used to display the title. */
|
/** The current color used to display the title. */
|
||||||
CC_SYNTHESIZE_READONLY_PASS_BY_REF(ccColor3B, _currentTitleColor, CurrentTitleColor);
|
CC_SYNTHESIZE_READONLY_PASS_BY_REF(Color3B, _currentTitleColor, CurrentTitleColor);
|
||||||
|
|
||||||
/** Adjust the background image. YES by default. If the property is set to NO, the
|
/** Adjust the background image. YES by default. If the property is set to NO, the
|
||||||
background will use the prefered size of the background image. */
|
background will use the prefered size of the background image. */
|
||||||
|
@ -93,8 +93,8 @@ protected:
|
||||||
/* Override setter to affect a background sprite too */
|
/* Override setter to affect a background sprite too */
|
||||||
virtual GLubyte getOpacity(void) const;
|
virtual GLubyte getOpacity(void) const;
|
||||||
virtual void setOpacity(GLubyte var);
|
virtual void setOpacity(GLubyte var);
|
||||||
virtual const ccColor3B& getColor(void) const;
|
virtual const Color3B& getColor(void) const;
|
||||||
virtual void setColor(const ccColor3B&);
|
virtual void setColor(const Color3B&);
|
||||||
|
|
||||||
/** Flag to know if the button is currently pushed. */
|
/** Flag to know if the button is currently pushed. */
|
||||||
protected:
|
protected:
|
||||||
|
@ -170,7 +170,7 @@ public:
|
||||||
* @return The color of the title for the specified state.
|
* @return The color of the title for the specified state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual const ccColor3B getTitleColorForState(ControlState state);
|
virtual const Color3B getTitleColorForState(ControlState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the color of the title to use for the specified state.
|
* Sets the color of the title to use for the specified state.
|
||||||
|
@ -179,7 +179,7 @@ public:
|
||||||
* @param state The state that uses the specified color. The values are described
|
* @param state The state that uses the specified color. The values are described
|
||||||
* in "CCControlState".
|
* in "CCControlState".
|
||||||
*/
|
*/
|
||||||
virtual void setTitleColorForState(ccColor3B color, ControlState state);
|
virtual void setTitleColorForState(Color3B color, ControlState state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the title label used for a state.
|
* Returns the title label used for a state.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue