Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into deprecatedfunc

This commit is contained in:
samuele3hu 2013-07-18 23:29:41 +08:00
commit 236b675e21
97 changed files with 1442 additions and 963 deletions

View File

@ -443,6 +443,7 @@ Developers:
Explicitly initialising CCAcceleration structure.
Add support to save/retrieve CCData into/from CCUserDefault.
Text Shadows fix
Solving 'black screen' on android.
MarcelBloemendaal
Adding secureTextEntry property to CCTextFieldTTF.
@ -527,6 +528,7 @@ Developers:
Sam Gross (colesbury)
Ignoring formatting specifiers in JavaScript log messages.
Make bindings-generator supports to bind std::function argument.
James Munro (jdmunro)
Added JSB support for ccpDistanceSQ.

View File

@ -1 +1 @@
ca5e8099d358d62ed915a2d316a4a4545b61471d
f7781fbb67fc947c54f987d419593d211f6a4020

View File

@ -52,7 +52,7 @@ public:
virtual void startWithTarget(Node *pTarget);
/** initializes the action with size and duration */
virtual bool initWithDuration(float duration, const Size& gridSize);
bool initWithDuration(float duration, const Size& gridSize);
/** returns the grid */
virtual GridBase* getGrid(void);

View File

@ -68,7 +68,7 @@ class CC_DLL FlipX3D : public Grid3DAction
{
public:
/** initializes the action with duration */
virtual bool initWithDuration(float duration);
bool initWithDuration(float duration);
virtual bool initWithSize(const Size& gridSize, float duration);
/** returns a new clone of the action */

View File

@ -339,20 +339,6 @@ CallFunc * CallFunc::create(Object* pSelectorTarget, SEL_CallFunc selector)
return NULL;
}
CallFunc * CallFunc::create(int nHandler)
{
CallFunc *pRet = new CallFunc();
if (pRet) {
pRet->_scriptHandler = nHandler;
pRet->autorelease();
}
else{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
bool CallFunc::initWithFunction(const std::function<void()> &func)
{
_function = func;
@ -376,10 +362,6 @@ bool CallFunc::initWithTarget(Object* pSelectorTarget) {
CallFunc::~CallFunc(void)
{
if (_scriptHandler)
{
cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_scriptHandler);
}
CC_SAFE_RELEASE(_selectorTarget);
}
@ -394,10 +376,6 @@ CallFunc * CallFunc::clone() const
else if( _function ){
a->initWithFunction(_function);
}
else if (_scriptHandler > 0 ) {
a->_scriptHandler = cocos2d::ScriptEngineManager::sharedManager()->getScriptEngine()->reallocateScriptHandler(_scriptHandler);
}
a->autorelease();
return a;
@ -417,13 +395,9 @@ void CallFunc::update(float time) {
void CallFunc::execute() {
if (_callFunc) {
(_selectorTarget->*_callFunc)();
} else if( _function )
_function();
if (0 != _scriptHandler) {
BasicScriptData data((void*)this);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
} else if( _function ){
_function();
}
}
//
@ -458,21 +432,6 @@ CallFuncN * CallFuncN::create(Object* pSelectorTarget, SEL_CallFuncN selector)
return NULL;
}
CallFuncN * CallFuncN::create(int nHandler)
{
CallFuncN *pRet = new CallFuncN();
if (pRet) {
pRet->_scriptHandler = nHandler;
pRet->autorelease();
}
else{
CC_SAFE_DELETE(pRet);
}
return pRet;
}
void CallFuncN::execute() {
if (_callFuncN) {
(_selectorTarget->*_callFuncN)(_target);
@ -480,12 +439,6 @@ void CallFuncN::execute() {
else if (_functionN) {
_functionN(_target);
}
if (0 != _scriptHandler)
{
BasicScriptData data((void*)this,(void*)_target);
ScriptEvent event(kCallFuncEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
bool CallFuncN::initWithFunction(const std::function<void (Node *)> &func)

View File

@ -236,13 +236,9 @@ public:
*/
CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Object* pSelectorTarget, SEL_CallFunc selector);
/** creates the action with the handler script function */
static CallFunc * create(int nHandler);
public:
CallFunc()
: _selectorTarget(NULL)
, _scriptHandler(0)
, _callFunc(NULL)
, _function(nullptr)
{
@ -250,14 +246,14 @@ public:
virtual ~CallFunc();
/** initializes the action with the callback
typedef void (Object::*SEL_CallFunc)();
@deprecated Use the std::function API instead.
*/
virtual bool initWithTarget(Object* pSelectorTarget);
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget);
/** initializes the action with the std::function<void()>
*/
virtual bool initWithFunction(const std::function<void()>& func);
bool initWithFunction(const std::function<void()>& func);
/** executes the callback */
virtual void execute();
@ -276,9 +272,6 @@ public:
_selectorTarget = pSel;
}
}
inline int getScriptHandler() const { return _scriptHandler; };
//
// Overrides
//
@ -290,8 +283,6 @@ protected:
/** Target that will be called */
Object* _selectorTarget;
int _scriptHandler;
union
{
SEL_CallFunc _callFunc;
@ -320,23 +311,19 @@ public:
@deprecated Use the std::function API instead.
*/
CC_DEPRECATED_ATTRIBUTE static CallFuncN * create(Object* pSelectorTarget, SEL_CallFuncN selector);
/** creates the action with the handler script function */
static CallFuncN * create(int nHandler);
public:
CallFuncN():_functionN(nullptr){}
/** initializes the action with the std::function<void(Node*)>
*/
virtual bool initWithFunction(const std::function<void(Node*)>& func);
bool initWithFunction(const std::function<void(Node*)>& func);
/** initializes the action with the callback
typedef void (Object::*SEL_CallFuncN)(Node*);
@deprecated Use the std::function API instead.
*/
CC_DEPRECATED_ATTRIBUTE virtual bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector);
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(Object* pSelectorTarget, SEL_CallFuncN selector);
virtual long getClassTypeInfo() {
static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name());

View File

@ -266,7 +266,7 @@ public:
/** initializes the action */
bool initWithDuration(float fDuration, float fDeltaAngle);
virtual bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
bool initWithDuration(float fDuration, float fDeltaAngleX, float fDeltaAngleY);
//
// Overrides
@ -378,7 +378,7 @@ public:
static SkewTo* create(float t, float sx, float sy);
SkewTo();
virtual bool initWithDuration(float t, float sx, float sy);
bool initWithDuration(float t, float sx, float sy);
//
// Overrides
@ -408,7 +408,7 @@ public:
/** creates the action */
static SkewBy* create(float t, float deltaSkewX, float deltaSkewY);
virtual bool initWithDuration(float t, float sx, float sy);
bool initWithDuration(float t, float sx, float sy);
//
// Overrides

View File

@ -39,7 +39,7 @@ class CC_DLL ShakyTiles3D : public TiledGrid3DAction
{
public:
/** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */
virtual bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShakeZ);
bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShakeZ);
/** returns a new clone of the action */
virtual ShakyTiles3D* clone() const;
@ -61,7 +61,7 @@ class CC_DLL ShatteredTiles3D : public TiledGrid3DAction
{
public:
/** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */
virtual bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShatterZ);
bool initWithDuration(float duration, const Size& gridSize, int nRange, bool bShatterZ);
/** returns a new clone of the action */
virtual ShatteredTiles3D* clone() const;
@ -87,7 +87,7 @@ class CC_DLL ShuffleTiles : public TiledGrid3DAction
public:
~ShuffleTiles(void);
/** initializes the action with a random seed, the grid size and the duration */
virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
void shuffle(unsigned int *pArray, unsigned int nLen);
Size getDelta(const Size& pos) const;
void placeTile(const Point& pos, Tile *t);
@ -189,7 +189,7 @@ class CC_DLL TurnOffTiles : public TiledGrid3DAction
public:
~TurnOffTiles(void);
/** initializes the action with a random seed, the grid size and the duration */
virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
bool initWithDuration(float duration, const Size& gridSize, unsigned int seed);
void shuffle(unsigned int *pArray, unsigned int nLen);
void turnOnTile(const Point& pos);
void turnOffTile(const Point& pos);
@ -226,7 +226,7 @@ public:
inline void setAmplitudeRate(float fAmplitudeRate) { _amplitudeRate = fAmplitudeRate; }
/** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */
virtual bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
bool initWithDuration(float duration, const Size& gridSize, unsigned int waves, float amplitude);
/** returns a new clone of the action */
virtual WavesTiles3D* clone() const;
@ -279,7 +279,7 @@ class CC_DLL SplitRows : public TiledGrid3DAction
{
public :
/** initializes the action with the number of rows to split and the duration */
virtual bool initWithDuration(float duration, unsigned int nRows);
bool initWithDuration(float duration, unsigned int nRows);
/** returns a new clone of the action */
virtual SplitRows* clone() const;
@ -301,7 +301,7 @@ class CC_DLL SplitCols : public TiledGrid3DAction
{
public:
/** initializes the action with the number of columns to split and the duration */
virtual bool initWithDuration(float duration, unsigned int nCols);
bool initWithDuration(float duration, unsigned int nCols);
/** returns a new clone of the action */
virtual SplitCols* clone() const;

View File

@ -102,7 +102,7 @@ Node::Node(void)
_componentContainer = new ComponentContainer(this);
}
Node::~Node(void)
Node::~Node()
{
CCLOGINFO( "cocos2d: deallocing: %p", this );
@ -305,12 +305,12 @@ void Node::setPosition(float x, float y)
setPosition(Point(x, y));
}
float Node::getPositionX(void) const
float Node::getPositionX() const
{
return _position.x;
}
float Node::getPositionY(void) const
float Node::getPositionY() const
{
return _position.y;
}
@ -331,7 +331,7 @@ Array* Node::getChildren()
return _children;
}
unsigned int Node::getChildrenCount(void) const
unsigned int Node::getChildrenCount() const
{
return _children ? _children->count() : 0;
}
@ -513,12 +513,18 @@ void Node::setShaderProgram(GLProgram *pShaderProgram)
_shaderProgram = pShaderProgram;
}
Rect Node::boundingBox()
Rect Node::getBoundingBox() const
{
Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height);
return RectApplyAffineTransform(rect, nodeToParentTransform());
return RectApplyAffineTransform(rect, getNodeToParentTransform());
}
Rect Node::boundingBox() const
{
return getBoundingBox();
}
Node * Node::create(void)
{
Node * pRet = new Node();
@ -882,7 +888,7 @@ void Node::transform()
kmMat4 transfrom4x4;
// Convert 3x3 into 4x4 matrix
AffineTransform tmpAffine = this->nodeToParentTransform();
AffineTransform tmpAffine = this->getNodeToParentTransform();
CGAffineToGL(&tmpAffine, transfrom4x4.mat);
// Update Z vertex manually
@ -1149,7 +1155,7 @@ void Node::update(float fDelta)
}
}
AffineTransform Node::nodeToParentTransform(void)
AffineTransform Node::getNodeToParentTransform() const
{
if (_transformDirty)
{
@ -1225,6 +1231,12 @@ AffineTransform Node::nodeToParentTransform(void)
return _transform;
}
// XXX deprecated
AffineTransform Node::nodeToParentTransform() const
{
return getNodeToParentTransform();
}
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
{
_additionalTransform = additionalTransform;
@ -1232,68 +1244,86 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
_additionalTransformDirty = true;
}
AffineTransform Node::parentToNodeTransform(void)
AffineTransform Node::getParentToNodeTransform() const
{
if ( _inverseDirty ) {
_inverse = AffineTransformInvert(this->nodeToParentTransform());
_inverse = AffineTransformInvert(this->getNodeToParentTransform());
_inverseDirty = false;
}
return _inverse;
}
AffineTransform Node::nodeToWorldTransform()
// XXX deprecated
AffineTransform Node::parentToNodeTransform() const
{
AffineTransform t = this->nodeToParentTransform();
return getParentToNodeTransform();
}
AffineTransform Node::getNodeToWorldTransform() const
{
AffineTransform t = this->getNodeToParentTransform();
for (Node *p = _parent; p != NULL; p = p->getParent())
t = AffineTransformConcat(t, p->nodeToParentTransform());
t = AffineTransformConcat(t, p->getNodeToParentTransform());
return t;
}
AffineTransform Node::worldToNodeTransform(void)
// XXX deprecated
AffineTransform Node::nodeToWorldTransform() const
{
return AffineTransformInvert(this->nodeToWorldTransform());
return getNodeToWorldTransform();
}
Point Node::convertToNodeSpace(const Point& worldPoint)
AffineTransform Node::getWorldToNodeTransform() const
{
Point ret = PointApplyAffineTransform(worldPoint, worldToNodeTransform());
return AffineTransformInvert(this->getNodeToWorldTransform());
}
// XXX deprecated
AffineTransform Node::worldToNodeTransform() const
{
return getWorldToNodeTransform();
}
Point Node::convertToNodeSpace(const Point& worldPoint) const
{
Point ret = PointApplyAffineTransform(worldPoint, getWorldToNodeTransform());
return ret;
}
Point Node::convertToWorldSpace(const Point& nodePoint)
Point Node::convertToWorldSpace(const Point& nodePoint) const
{
Point ret = PointApplyAffineTransform(nodePoint, nodeToWorldTransform());
Point ret = PointApplyAffineTransform(nodePoint, getNodeToWorldTransform());
return ret;
}
Point Node::convertToNodeSpaceAR(const Point& worldPoint)
Point Node::convertToNodeSpaceAR(const Point& worldPoint) const
{
Point nodePoint = convertToNodeSpace(worldPoint);
return nodePoint - _anchorPointInPoints;
}
Point Node::convertToWorldSpaceAR(const Point& nodePoint)
Point Node::convertToWorldSpaceAR(const Point& nodePoint) const
{
Point pt = nodePoint + _anchorPointInPoints;
return convertToWorldSpace(pt);
}
Point Node::convertToWindowSpace(const Point& nodePoint)
Point Node::convertToWindowSpace(const Point& nodePoint) const
{
Point worldPoint = this->convertToWorldSpace(nodePoint);
return Director::getInstance()->convertToUI(worldPoint);
}
// convenience methods which take a Touch instead of Point
Point Node::convertTouchToNodeSpace(Touch *touch)
Point Node::convertTouchToNodeSpace(Touch *touch) const
{
Point point = touch->getLocation();
return this->convertToNodeSpace(point);
}
Point Node::convertTouchToNodeSpaceAR(Touch *touch)
Point Node::convertTouchToNodeSpaceAR(Touch *touch) const
{
Point point = touch->getLocation();
return this->convertToNodeSpaceAR(point);

View File

@ -464,7 +464,7 @@ public:
*
* @param fRotationX The X rotation in degrees which performs a horizontal rotational skew.
*/
virtual void setRotationX(float fRotaionX);
virtual void setRotationX(float rotaionX);
/**
* Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew.
*
@ -483,7 +483,7 @@ public:
*
* @param fRotationY The Y rotation in degrees.
*/
virtual void setRotationY(float fRotationY);
virtual void setRotationY(float rotationY);
/**
* Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
*
@ -504,7 +504,7 @@ public:
*
* @param uOrderOfArrival The arrival order.
*/
virtual void setOrderOfArrival(unsigned int uOrderOfArrival);
virtual void setOrderOfArrival(unsigned int orderOfArrival);
/**
* Returns the arrival order, indecates which children is added previously.
*
@ -520,7 +520,7 @@ public:
*
* @param glServerState The state of OpenGL server side.
*/
virtual void setGLServerState(ccGLServerState glServerState);
virtual void setGLServerState(ccGLServerState serverState);
/**
* Returns the state of OpenGL server side.
*
@ -612,7 +612,7 @@ public:
*
* @return The amount of children.
*/
unsigned int getChildrenCount(void) const;
unsigned int getChildrenCount() const;
/**
* Sets the parent node
@ -720,7 +720,7 @@ public:
*
* @param A Grid object that is used when applying effects
*/
virtual void setGrid(GridBase *pGrid);
virtual void setGrid(GridBase *grid);
/// @} end of Grid
@ -769,7 +769,7 @@ public:
*
* @param A interger that indentifies the node.
*/
virtual void setTag(int nTag);
virtual void setTag(int tag);
/**
* Returns a custom user data pointer
@ -788,7 +788,7 @@ public:
*
* @param A custom user data pointer
*/
virtual void setUserData(void *pUserData);
virtual void setUserData(void *userData);
/**
* Returns a user assigned Object
@ -808,7 +808,7 @@ public:
*
* @param A user assigned Object
*/
virtual void setUserObject(Object *pUserObject);
virtual void setUserObject(Object *userObject);
/// @} end of Tag & User Data
@ -832,7 +832,7 @@ public:
*
* @param The shader program which fetchs from ShaderCache.
*/
virtual void setShaderProgram(GLProgram *pShaderProgram);
virtual void setShaderProgram(GLProgram *shaderProgram);
/// @} end of Shader Program
@ -861,7 +861,7 @@ public:
/**
* Schedules for lua script.
*/
void scheduleUpdateWithPriorityLua(int nHandler, int priority);
void scheduleUpdateWithPriorityLua(int handler, int priority);
/// @} end Script Bindings
@ -903,7 +903,7 @@ public:
/**
* Stops all running actions and schedulers
*/
virtual void cleanup(void);
virtual void cleanup();
/**
* Override this method to draw your own node.
@ -915,12 +915,12 @@ public:
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
* But if you enable any other GL state, you should disable it after drawing your node.
*/
virtual void draw(void);
virtual void draw();
/**
* Visits this node's children and draw them recursively.
*/
virtual void visit(void);
virtual void visit();
/**
@ -932,7 +932,10 @@ public:
*
* @return A "local" axis aligned boudning box of the node.
*/
Rect boundingBox(void);
virtual Rect getBoundingBox() const;
/** @deprecated Use getBoundingBox instead */
CC_DEPRECATED_ATTRIBUTE Rect boundingBox() const;
/// @{
/// @name Actions
@ -965,7 +968,7 @@ public:
/**
* Stops and removes all actions from the running action list .
*/
void stopAllActions(void);
void stopAllActions();
/**
* Stops and removes an action from the running action list.
@ -1000,7 +1003,7 @@ public:
*
* @return The number of actions that are running plus the ones that are schedule to run
*/
unsigned int numberOfRunningActions(void);
unsigned int numberOfRunningActions();
/// @} end of Actions
@ -1136,13 +1139,13 @@ public:
/**
* Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
*/
void transform(void);
void transform();
/**
* Performs OpenGL view-matrix transformation of it's ancestors.
* Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
* It's necessary to transform the ancestors again.
*/
void transformAncestors(void);
void transformAncestors();
/**
* Calls children's updateTransform() method recursively.
*
@ -1150,29 +1153,41 @@ public:
* As the result, you apply SpriteBatchNode's optimization on your customed Node.
* e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before.
*/
virtual void updateTransform(void);
virtual void updateTransform();
/**
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
* The matrix is in Pixels.
*/
virtual AffineTransform nodeToParentTransform(void);
virtual AffineTransform getNodeToParentTransform() const;
/** @deprecated use getNodeToParentTransform() instead */
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToParentTransform() const;
/**
* Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
* The matrix is in Pixels.
*/
virtual AffineTransform parentToNodeTransform(void);
virtual AffineTransform getParentToNodeTransform() const;
/** @deprecated Use getParentToNodeTransform() instead */
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform parentToNodeTransform() const;
/**
* Returns the world affine transform matrix. The matrix is in Pixels.
*/
virtual AffineTransform nodeToWorldTransform(void);
virtual AffineTransform getNodeToWorldTransform() const;
/** @deprecated Use getNodeToWorldTransform() instead */
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToWorldTransform() const;
/**
* Returns the inverse world affine transform matrix. The matrix is in Pixels.
*/
virtual AffineTransform worldToNodeTransform(void);
virtual AffineTransform getWorldToNodeTransform() const;
/** @deprecated Use worldToNodeTransform() instead */
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform worldToNodeTransform() const;
/// @} end of Transformations
@ -1183,39 +1198,39 @@ public:
/**
* Converts a Point to node (local) space coordinates. The result is in Points.
*/
Point convertToNodeSpace(const Point& worldPoint);
Point convertToNodeSpace(const Point& worldPoint) const;
/**
* Converts a Point to world space coordinates. The result is in Points.
*/
Point convertToWorldSpace(const Point& nodePoint);
Point convertToWorldSpace(const Point& nodePoint) const;
/**
* Converts a Point to node (local) space coordinates. The result is in Points.
* treating the returned/received node point as anchor relative.
*/
Point convertToNodeSpaceAR(const Point& worldPoint);
Point convertToNodeSpaceAR(const Point& worldPoint) const;
/**
* Converts a local Point to world space coordinates.The result is in Points.
* treating the returned/received node point as anchor relative.
*/
Point convertToWorldSpaceAR(const Point& nodePoint);
Point convertToWorldSpaceAR(const Point& nodePoint) const;
/**
* convenience methods which take a Touch instead of Point
*/
Point convertTouchToNodeSpace(Touch * touch);
Point convertTouchToNodeSpace(Touch * touch) const;
/**
* converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
*/
Point convertTouchToNodeSpaceAR(Touch * touch);
Point convertTouchToNodeSpaceAR(Touch * touch) const;
/**
* Sets the additional transform.
*
* @note The additional transform will be concatenated at the end of nodeToParentTransform.
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
* @code
// create a batchNode
@ -1236,7 +1251,7 @@ public:
spriteA->setPosition(Point(200, 200));
// Gets the spriteA's transform.
AffineTransform t = spriteA->nodeToParentTransform();
AffineTransform t = spriteA->getNodeToParentTransform();
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
spriteB->setAdditionalTransform(t);
@ -1245,7 +1260,7 @@ public:
spriteA->setScale(2);
// Gets the spriteA's transform.
t = spriteA->nodeToParentTransform();
t = spriteA->getNodeToParentTransform();
// Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA.
spriteB->setAdditionalTransform(t);
@ -1254,7 +1269,7 @@ public:
spriteA->setRotation(20);
// Gets the spriteA's transform.
t = spriteA->nodeToParentTransform();
t = spriteA->getNodeToParentTransform();
// Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
spriteB->setAdditionalTransform(t);
@ -1298,7 +1313,7 @@ private:
void detachChild(Node *child, bool doCleanup);
/// Convert cocos2d coordinates to UI windows coordinate.
Point convertToWindowSpace(const Point& nodePoint);
Point convertToWindowSpace(const Point& nodePoint) const;
protected:
float _rotationX; ///< rotation angle on x-axis
@ -1319,11 +1334,14 @@ protected:
Size _contentSize; ///< untransformed size of the node
AffineTransform _additionalTransform; ///< transform
AffineTransform _transform; ///< transform
AffineTransform _inverse; ///< transform
// "cache" variables are allowed to be mutable
mutable AffineTransform _additionalTransform; ///< transform
mutable AffineTransform _transform; ///< transform
mutable AffineTransform _inverse; ///< inverse transform
mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty
mutable bool _transformDirty; ///< transform dirty flag
mutable bool _inverseDirty; ///< inverse transform dirty flag
Camera *_camera; ///< a camera
GridBase *_grid; ///< a grid
@ -1350,9 +1368,6 @@ protected:
bool _running; ///< is running
bool _transformDirty; ///< transform dirty flag
bool _inverseDirty; ///< transform dirty flag
bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty
bool _visible; ///< is this node visible
bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise.
@ -1387,23 +1402,24 @@ public:
virtual ~NodeRGBA();
virtual bool init();
// overrides
virtual GLubyte getOpacity() const override;
virtual GLubyte getDisplayedOpacity() const override;
virtual void setOpacity(GLubyte opacity) override;
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
virtual bool isCascadeOpacityEnabled() const override;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
virtual GLubyte getOpacity() const;
virtual GLubyte getDisplayedOpacity() const;
virtual void setOpacity(GLubyte opacity);
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
virtual bool isCascadeOpacityEnabled() const;
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
virtual const Color3B& getColor(void) const override;
virtual const Color3B& getDisplayedColor() const override;
virtual void setColor(const Color3B& color) override;
virtual void updateDisplayedColor(const Color3B& parentColor) override;
virtual bool isCascadeColorEnabled() const override;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
virtual const Color3B& getColor(void) const;
virtual const Color3B& getDisplayedColor() const;
virtual void setColor(const Color3B& color);
virtual void updateDisplayedColor(const Color3B& parentColor);
virtual bool isCascadeColorEnabled() const;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);};
virtual bool isOpacityModifyRGB() const { return false; };
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);};
virtual bool isOpacityModifyRGB() const override { return false; };
protected:
GLubyte _displayedOpacity;

View File

@ -23,6 +23,8 @@
#include "CCDrawNode.h"
#include "shaders/CCShaderCache.h"
#include "CCGL.h"
#include "support/CCNotificationCenter.h"
#include "CCEventType.h"
NS_CC_BEGIN
@ -118,6 +120,10 @@ DrawNode::~DrawNode()
ccGLBindVAO(0);
_vao = 0;
#endif
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
DrawNode* DrawNode::create()
@ -181,6 +187,14 @@ bool DrawNode::init()
_dirty = true;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(DrawNode::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
return true;
}
@ -196,6 +210,7 @@ void DrawNode::render()
ccGLBindVAO(_vao);
#else
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
@ -216,11 +231,9 @@ void DrawNode::render()
void DrawNode::draw()
{
CC_NODE_DRAW_SETUP();
ccGLBlendFunc(_blendFunc.src, _blendFunc.dst);
getShaderProgram()->use();
getShaderProgram()->setUniformsForBuiltins();
render();
}
@ -440,4 +453,11 @@ void DrawNode::setBlendFunc(const BlendFunc &blendFunc)
_blendFunc = blendFunc;
}
/** listen the event that coming to foreground on Android
*/
void DrawNode::listenBackToForeground(Object *obj)
{
init();
}
NS_CC_END

View File

@ -79,6 +79,10 @@ public:
DrawNode();
/** listen the event that coming to foreground on Android
*/
void listenBackToForeground(Object *obj);
private:
void ensureCapacity(unsigned int count);
void render();

View File

@ -32,7 +32,6 @@
#include "cocoa/CCGeometry.h"
#include "ccTypes.h"
NS_CC_BEGIN
/**
@ -391,13 +390,13 @@ CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, fl
}
CC_DEPRECATED_ATTRIBUTE const Point PointZero = Point::ZERO;
CC_DEPRECATED_ATTRIBUTE const Point CCPointZero = Point::ZERO;
/* The "zero" size -- equivalent to Size(0, 0). */
CC_DEPRECATED_ATTRIBUTE const Size SizeZero = Size::ZERO;
CC_DEPRECATED_ATTRIBUTE const Size CCSizeZero = Size::ZERO;
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
CC_DEPRECATED_ATTRIBUTE const Rect RectZero = Rect::ZERO;
CC_DEPRECATED_ATTRIBUTE const Rect CCRectZero = Rect::ZERO;
CC_DEPRECATED_ATTRIBUTE const Color3B ccWHITE = Color3B::WHITE;
@ -454,6 +453,460 @@ CC_DEPRECATED_ATTRIBUTE static inline bool ccc4FEqual(Color4F a, Color4F b)
return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;
}
CC_DEPRECATED_ATTRIBUTE static inline Vertex2F vertex2(const float x, const float y)
{
Vertex2F c(x, y);
return c;
}
CC_DEPRECATED_ATTRIBUTE static inline Vertex3F vertex3(const float x, const float y, const float z)
{
Vertex3F c(x, y, z);
return c;
}
CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v)
{
Tex2F t(u , v);
return t;
}
#define CCAffineTransformMake AffineTransformMake
#define CCPointApplyAffineTransform PointApplyAffineTransform
#define CCSizeApplyAffineTransform SizeApplyAffineTransform
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity()
{
return AffineTransformMakeIdentity();
}
CC_DEPRECATED_ATTRIBUTE static inline Rect CCRectApplyAffineTransform(const Rect& rect, const AffineTransform& anAffineTransform)
{
return RectApplyAffineTransform(rect, anAffineTransform);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformTranslate(const AffineTransform& t, float tx, float ty)
{
return AffineTransformTranslate(t, tx, ty);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformRotate(const AffineTransform& aTransform, float anAngle)
{
return AffineTransformRotate(aTransform, anAngle);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformScale(const AffineTransform& t, float sx, float sy)
{
return AffineTransformScale(t, sx, sy);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformConcat(const AffineTransform& t1, const AffineTransform& t2)
{
return AffineTransformConcat(t1, t2);
}
CC_DEPRECATED_ATTRIBUTE static inline bool CCAffineTransformEqualToTransform(const AffineTransform& t1, const AffineTransform& t2)
{
return AffineTransformEqualToTransform(t1, t2);
}
CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(const AffineTransform& t)
{
return AffineTransformInvert(t);
}
#define CCAffineTransformIdentity AffineTransformIdentity
// CC prefix compatibility
CC_DEPRECATED_ATTRIBUTE typedef Object CCObject;
CC_DEPRECATED_ATTRIBUTE typedef Event CCEvent;
CC_DEPRECATED_ATTRIBUTE typedef Integer CCInteger;
CC_DEPRECATED_ATTRIBUTE typedef String CCString;
CC_DEPRECATED_ATTRIBUTE typedef Bool CCBool;
CC_DEPRECATED_ATTRIBUTE typedef Float CCFloat;
CC_DEPRECATED_ATTRIBUTE typedef Double CCDouble;
CC_DEPRECATED_ATTRIBUTE typedef Data CCData;
CC_DEPRECATED_ATTRIBUTE typedef Set CCSet;
CC_DEPRECATED_ATTRIBUTE typedef Array CCArray;
CC_DEPRECATED_ATTRIBUTE typedef Dictionary CCDictionary;
CC_DEPRECATED_ATTRIBUTE typedef DataVisitor CCDataVisitor;
CC_DEPRECATED_ATTRIBUTE typedef PrettyPrinter CCPrettyPrinter;
CC_DEPRECATED_ATTRIBUTE typedef Acceleration CCAcceleration;
CC_DEPRECATED_ATTRIBUTE typedef TextureAtlas CCTextureAtlas;
CC_DEPRECATED_ATTRIBUTE typedef Configuration CCConfiguration;
CC_DEPRECATED_ATTRIBUTE typedef PointArray CCPointArray;
CC_DEPRECATED_ATTRIBUTE typedef SetIterator CCSetIterator;
CC_DEPRECATED_ATTRIBUTE typedef RemoveSelf CCRemoveSelf;
CC_DEPRECATED_ATTRIBUTE typedef IMEDelegate CCIMEDelegate;
CC_DEPRECATED_ATTRIBUTE typedef IMEKeyboardNotificationInfo CCIMEKeyboardNotificationInfo;
CC_DEPRECATED_ATTRIBUTE typedef TextFieldDelegate CCTextFieldDelegate;
CC_DEPRECATED_ATTRIBUTE typedef TextFieldTTF CCTextFieldTTF;
CC_DEPRECATED_ATTRIBUTE typedef NotificationCenter CCNotificationCenter;
CC_DEPRECATED_ATTRIBUTE typedef TargetedTouchDelegate CCTargetedTouchDelegate;
CC_DEPRECATED_ATTRIBUTE typedef StandardTouchDelegate CCStandardTouchDelegate;
CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate;
CC_DEPRECATED_ATTRIBUTE typedef Image CCImage;
CC_DEPRECATED_ATTRIBUTE typedef UserDefault CCUserDefault;
CC_DEPRECATED_ATTRIBUTE typedef Action CCAction;
CC_DEPRECATED_ATTRIBUTE typedef FiniteTimeAction CCFiniteTimeAction;
CC_DEPRECATED_ATTRIBUTE typedef Speed CCSpeed;
CC_DEPRECATED_ATTRIBUTE typedef Follow CCFollow;
CC_DEPRECATED_ATTRIBUTE typedef GLProgram CCGLProgram;
CC_DEPRECATED_ATTRIBUTE typedef Touch CCTouch;
CC_DEPRECATED_ATTRIBUTE typedef Set CCSet;
CC_DEPRECATED_ATTRIBUTE typedef Texture2D CCTexture2D;
CC_DEPRECATED_ATTRIBUTE typedef Node CCNode;
CC_DEPRECATED_ATTRIBUTE typedef NodeRGBA CCNodeRGBA;
CC_DEPRECATED_ATTRIBUTE typedef RGBAProtocol CCRGBAProtocol;
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrame CCSpriteFrame;
CC_DEPRECATED_ATTRIBUTE typedef AnimationFrame CCAnimationFrame;
CC_DEPRECATED_ATTRIBUTE typedef Animation CCAnimation;
CC_DEPRECATED_ATTRIBUTE typedef ActionInterval CCActionInterval;
CC_DEPRECATED_ATTRIBUTE typedef Sequence CCSequence;
CC_DEPRECATED_ATTRIBUTE typedef Repeat CCRepeat;
CC_DEPRECATED_ATTRIBUTE typedef RepeatForever CCRepeatForever;
CC_DEPRECATED_ATTRIBUTE typedef Spawn CCSpawn;
CC_DEPRECATED_ATTRIBUTE typedef RotateTo CCRotateTo;
CC_DEPRECATED_ATTRIBUTE typedef RotateBy CCRotateBy;
CC_DEPRECATED_ATTRIBUTE typedef MoveBy CCMoveBy;
CC_DEPRECATED_ATTRIBUTE typedef MoveTo CCMoveTo;
CC_DEPRECATED_ATTRIBUTE typedef SkewTo CCSkewTo;
CC_DEPRECATED_ATTRIBUTE typedef SkewBy CCSkewBy;
CC_DEPRECATED_ATTRIBUTE typedef JumpBy CCJumpBy;
CC_DEPRECATED_ATTRIBUTE typedef JumpTo CCJumpTo;
CC_DEPRECATED_ATTRIBUTE typedef BezierBy CCBezierBy;
CC_DEPRECATED_ATTRIBUTE typedef BezierTo CCBezierTo;
CC_DEPRECATED_ATTRIBUTE typedef ScaleTo CCScaleTo;
CC_DEPRECATED_ATTRIBUTE typedef ScaleBy CCScaleBy;
CC_DEPRECATED_ATTRIBUTE typedef Blink CCBlink;
CC_DEPRECATED_ATTRIBUTE typedef FadeIn CCFadeIn;
CC_DEPRECATED_ATTRIBUTE typedef FadeOut CCFadeOut;
CC_DEPRECATED_ATTRIBUTE typedef FadeTo CCFadeTo;
CC_DEPRECATED_ATTRIBUTE typedef TintTo CCTintTo;
CC_DEPRECATED_ATTRIBUTE typedef TintBy CCTintBy;
CC_DEPRECATED_ATTRIBUTE typedef DelayTime CCDelayTime;
CC_DEPRECATED_ATTRIBUTE typedef Animate CCAnimate;
CC_DEPRECATED_ATTRIBUTE typedef TargetedAction CCTargetedAction;
CC_DEPRECATED_ATTRIBUTE typedef ActionCamera CCActionCamera;
CC_DEPRECATED_ATTRIBUTE typedef OrbitCamera CCOrbitCamera;
CC_DEPRECATED_ATTRIBUTE typedef ActionManager CCActionManager;
CC_DEPRECATED_ATTRIBUTE typedef ActionEase CCActionEase;
CC_DEPRECATED_ATTRIBUTE typedef EaseRateAction CCEaseRateAction;
CC_DEPRECATED_ATTRIBUTE typedef EaseIn CCEaseIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseOut CCEaseOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseInOut CCEaseInOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialIn CCEaseExponentialIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialOut CCEaseExponentialOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseExponentialInOut CCEaseExponentialInOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseSineIn CCEaseSineIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseSineOut CCEaseSineOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseSineInOut CCEaseSineInOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseElastic CCEaseElastic;
CC_DEPRECATED_ATTRIBUTE typedef EaseElasticIn CCEaseElasticIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseElasticOut CCEaseElasticOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseElasticInOut CCEaseElasticInOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseBounce CCEaseBounce;
CC_DEPRECATED_ATTRIBUTE typedef EaseBounceIn CCEaseBounceIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseBounceOut CCEaseBounceOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseBounceInOut CCEaseBounceInOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseBackIn CCEaseBackIn;
CC_DEPRECATED_ATTRIBUTE typedef EaseBackOut CCEaseBackOut;
CC_DEPRECATED_ATTRIBUTE typedef EaseBackInOut CCEaseBackInOut;
CC_DEPRECATED_ATTRIBUTE typedef ActionInstant CCActionInstant;
CC_DEPRECATED_ATTRIBUTE typedef Show CCShow;
CC_DEPRECATED_ATTRIBUTE typedef Hide CCHide;
CC_DEPRECATED_ATTRIBUTE typedef ToggleVisibility CCToggleVisibility;
CC_DEPRECATED_ATTRIBUTE typedef FlipX CCFlipX;
CC_DEPRECATED_ATTRIBUTE typedef FlipY CCFlipY;
CC_DEPRECATED_ATTRIBUTE typedef Place CCPlace;
CC_DEPRECATED_ATTRIBUTE typedef CallFunc CCCallFunc;
CC_DEPRECATED_ATTRIBUTE typedef GridAction CCGridAction;
CC_DEPRECATED_ATTRIBUTE typedef Grid3DAction CCGrid3DAction;
CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3DAction CCTiledGrid3DAction;
CC_DEPRECATED_ATTRIBUTE typedef StopGrid CCStopGrid;
CC_DEPRECATED_ATTRIBUTE typedef ReuseGrid CCReuseGrid;
CC_DEPRECATED_ATTRIBUTE typedef Waves3D CCWaves3D;
CC_DEPRECATED_ATTRIBUTE typedef FlipX3D CCFlipX3D;
CC_DEPRECATED_ATTRIBUTE typedef FlipY3D CCFlipY3D;
CC_DEPRECATED_ATTRIBUTE typedef Lens3D CCLens3D;
CC_DEPRECATED_ATTRIBUTE typedef Ripple3D CCRipple3D;
CC_DEPRECATED_ATTRIBUTE typedef Shaky3D CCShaky3D;
CC_DEPRECATED_ATTRIBUTE typedef Liquid CCLiquid;
CC_DEPRECATED_ATTRIBUTE typedef Waves CCWaves;
CC_DEPRECATED_ATTRIBUTE typedef Twirl CCTwirl;
CC_DEPRECATED_ATTRIBUTE typedef PageTurn3D CCPageTurn3D;
CC_DEPRECATED_ATTRIBUTE typedef ProgressTo CCProgressTo;
CC_DEPRECATED_ATTRIBUTE typedef ProgressFromTo CCProgressFromTo;
CC_DEPRECATED_ATTRIBUTE typedef ShakyTiles3D CCShakyTiles3D;
CC_DEPRECATED_ATTRIBUTE typedef ShatteredTiles3D CCShatteredTiles3D;
CC_DEPRECATED_ATTRIBUTE typedef ShuffleTiles CCShuffleTiles;
CC_DEPRECATED_ATTRIBUTE typedef FadeOutTRTiles CCFadeOutTRTiles;
CC_DEPRECATED_ATTRIBUTE typedef FadeOutBLTiles CCFadeOutBLTiles;
CC_DEPRECATED_ATTRIBUTE typedef FadeOutUpTiles CCFadeOutUpTiles;
CC_DEPRECATED_ATTRIBUTE typedef FadeOutDownTiles CCFadeOutDownTiles;
CC_DEPRECATED_ATTRIBUTE typedef TurnOffTiles CCTurnOffTiles;
CC_DEPRECATED_ATTRIBUTE typedef WavesTiles3D CCWavesTiles3D;
CC_DEPRECATED_ATTRIBUTE typedef JumpTiles3D CCJumpTiles3D;
CC_DEPRECATED_ATTRIBUTE typedef SplitRows CCSplitRows;
CC_DEPRECATED_ATTRIBUTE typedef SplitCols CCSplitCols;
CC_DEPRECATED_ATTRIBUTE typedef ActionTween CCActionTween;
CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineTo CCCardinalSplineTo;
CC_DEPRECATED_ATTRIBUTE typedef CardinalSplineBy CCCardinalSplineBy;
CC_DEPRECATED_ATTRIBUTE typedef CatmullRomTo CCCatmullRomTo;
CC_DEPRECATED_ATTRIBUTE typedef CatmullRomBy CCCatmullRomBy;
CC_DEPRECATED_ATTRIBUTE typedef AtlasNode CCAtlasNode;
CC_DEPRECATED_ATTRIBUTE typedef TextureProtocol CCTextureProtocol;
CC_DEPRECATED_ATTRIBUTE typedef BlendProtocol CCBlendProtocol;
CC_DEPRECATED_ATTRIBUTE typedef DrawNode CCDrawNode;
CC_DEPRECATED_ATTRIBUTE typedef Camera CCCamera;
CC_DEPRECATED_ATTRIBUTE typedef LabelAtlas CCLabelAtlas;
CC_DEPRECATED_ATTRIBUTE typedef LabelProtocol CCLabelProtocol;
CC_DEPRECATED_ATTRIBUTE typedef Director CCDirector;
CC_DEPRECATED_ATTRIBUTE typedef GridBase CCGridBase;
CC_DEPRECATED_ATTRIBUTE typedef Grid3D CCGrid3D;
CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3D CCTiledGrid3D;
CC_DEPRECATED_ATTRIBUTE typedef Sprite CCSprite;
CC_DEPRECATED_ATTRIBUTE typedef LabelTTF CCLabelTTF;
CC_DEPRECATED_ATTRIBUTE typedef SpriteBatchNode CCSpriteBatchNode;
CC_DEPRECATED_ATTRIBUTE typedef LabelBMFont CCLabelBMFont;
CC_DEPRECATED_ATTRIBUTE typedef Layer CCLayer;
CC_DEPRECATED_ATTRIBUTE typedef TouchDelegate CCTouchDelegate;
CC_DEPRECATED_ATTRIBUTE typedef KeypadDelegate CCKeypadDelegate;
CC_DEPRECATED_ATTRIBUTE typedef LayerRGBA CCLayerRGBA;
CC_DEPRECATED_ATTRIBUTE typedef LayerColor CCLayerColor;
CC_DEPRECATED_ATTRIBUTE typedef LayerGradient CCLayerGradient;
CC_DEPRECATED_ATTRIBUTE typedef LayerMultiplex CCLayerMultiplex;
CC_DEPRECATED_ATTRIBUTE typedef Scene CCScene;
CC_DEPRECATED_ATTRIBUTE typedef TransitionEaseScene CCTransitionEaseScene;
CC_DEPRECATED_ATTRIBUTE typedef TransitionScene CCTransitionScene;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSceneOriented CCTransitionSceneOriented;
CC_DEPRECATED_ATTRIBUTE typedef TransitionRotoZoom CCTransitionRotoZoom;
CC_DEPRECATED_ATTRIBUTE typedef TransitionJumpZoom CCTransitionJumpZoom;
CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInL CCTransitionMoveInL;
CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInR CCTransitionMoveInR;
CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInT CCTransitionMoveInT;
CC_DEPRECATED_ATTRIBUTE typedef TransitionMoveInB CCTransitionMoveInB;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInL CCTransitionSlideInL;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInR CCTransitionSlideInR;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInB CCTransitionSlideInB;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSlideInT CCTransitionSlideInT;
CC_DEPRECATED_ATTRIBUTE typedef TransitionShrinkGrow CCTransitionShrinkGrow;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipX CCTransitionFlipX;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipY CCTransitionFlipY;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFlipAngular CCTransitionFlipAngular;
CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipX CCTransitionZoomFlipX;
CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipY CCTransitionZoomFlipY;
CC_DEPRECATED_ATTRIBUTE typedef TransitionZoomFlipAngular CCTransitionZoomFlipAngular;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFade CCTransitionFade;
CC_DEPRECATED_ATTRIBUTE typedef TransitionCrossFade CCTransitionCrossFade;
CC_DEPRECATED_ATTRIBUTE typedef TransitionTurnOffTiles CCTransitionTurnOffTiles;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitCols CCTransitionSplitCols;
CC_DEPRECATED_ATTRIBUTE typedef TransitionSplitRows CCTransitionSplitRows;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeTR CCTransitionFadeTR;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeBL CCTransitionFadeBL;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeUp CCTransitionFadeUp;
CC_DEPRECATED_ATTRIBUTE typedef TransitionFadeDown CCTransitionFadeDown;
CC_DEPRECATED_ATTRIBUTE typedef TransitionPageTurn CCTransitionPageTurn;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgress CCTransitionProgress;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCCW CCTransitionProgressRadialCCW;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressRadialCW CCTransitionProgressRadialCW;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressHorizontal CCTransitionProgressHorizontal;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressVertical CCTransitionProgressVertical;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressInOut CCTransitionProgressInOut;
CC_DEPRECATED_ATTRIBUTE typedef TransitionProgressOutIn CCTransitionProgressOutIn;
CC_DEPRECATED_ATTRIBUTE typedef MenuItem CCMenuItem;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemLabel CCMenuItemLabel;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemAtlasFont CCMenuItemAtlasFont;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemFont CCMenuItemFont;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemSprite CCMenuItemSprite;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemImage CCMenuItemImage;
CC_DEPRECATED_ATTRIBUTE typedef MenuItemToggle CCMenuItemToggle;
CC_DEPRECATED_ATTRIBUTE typedef Menu CCMenu;
CC_DEPRECATED_ATTRIBUTE typedef ClippingNode CCClippingNode;
CC_DEPRECATED_ATTRIBUTE typedef MotionStreak CCMotionStreak;
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer CCProgressTimer;
CC_DEPRECATED_ATTRIBUTE typedef RenderTexture CCRenderTexture;
CC_DEPRECATED_ATTRIBUTE typedef ParticleBatchNode CCParticleBatchNode;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem CCParticleSystem;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSystemQuad CCParticleSystemQuad;
CC_DEPRECATED_ATTRIBUTE typedef ParticleFire CCParticleFire;
CC_DEPRECATED_ATTRIBUTE typedef ParticleFireworks CCParticleFireworks;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSun CCParticleSun;
CC_DEPRECATED_ATTRIBUTE typedef ParticleGalaxy CCParticleGalaxy;
CC_DEPRECATED_ATTRIBUTE typedef ParticleFlower CCParticleFlower;
CC_DEPRECATED_ATTRIBUTE typedef ParticleMeteor CCParticleMeteor;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSpiral CCParticleSpiral;
CC_DEPRECATED_ATTRIBUTE typedef ParticleExplosion CCParticleExplosion;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSmoke CCParticleSmoke;
CC_DEPRECATED_ATTRIBUTE typedef ParticleSnow CCParticleSnow;
CC_DEPRECATED_ATTRIBUTE typedef ParticleRain CCParticleRain;
CC_DEPRECATED_ATTRIBUTE typedef FileUtils CCFileUtils;
CC_DEPRECATED_ATTRIBUTE typedef Application CCApplication;
CC_DEPRECATED_ATTRIBUTE typedef ShaderCache CCShaderCache;
CC_DEPRECATED_ATTRIBUTE typedef AnimationCache CCAnimationCache;
CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCache CCSpriteFrameCache;
CC_DEPRECATED_ATTRIBUTE typedef TextureCache CCTextureCache;
CC_DEPRECATED_ATTRIBUTE typedef ParallaxNode CCParallaxNode;
CC_DEPRECATED_ATTRIBUTE typedef TMXObjectGroup CCTMXObjectGroup;
CC_DEPRECATED_ATTRIBUTE typedef TMXLayerInfo CCTMXLayerInfo;
CC_DEPRECATED_ATTRIBUTE typedef TMXTilesetInfo CCTMXTilesetInfo;
CC_DEPRECATED_ATTRIBUTE typedef TMXMapInfo CCTMXMapInfo;
CC_DEPRECATED_ATTRIBUTE typedef TMXLayer CCTMXLayer;
CC_DEPRECATED_ATTRIBUTE typedef TMXTiledMap CCTMXTiledMap;
CC_DEPRECATED_ATTRIBUTE typedef TileMapAtlas CCTileMapAtlas;
CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer;
CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler;
CC_DEPRECATED_ATTRIBUTE typedef EGLView CCEGLView;
CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform;
CC_DEPRECATED_ATTRIBUTE typedef Point CCPoint;
CC_DEPRECATED_ATTRIBUTE typedef Size CCSize;
CC_DEPRECATED_ATTRIBUTE typedef Rect CCRect;
CC_DEPRECATED_ATTRIBUTE typedef Color3B ccColor3B;
CC_DEPRECATED_ATTRIBUTE typedef Color4F ccColor4F;
CC_DEPRECATED_ATTRIBUTE typedef Color4B ccColor4B;
CC_DEPRECATED_ATTRIBUTE typedef Vertex2F ccVertex2F;
CC_DEPRECATED_ATTRIBUTE typedef Vertex3F ccVertex3F;
CC_DEPRECATED_ATTRIBUTE typedef Tex2F ccTex2F;
CC_DEPRECATED_ATTRIBUTE typedef PointSprite ccPointSprite;
CC_DEPRECATED_ATTRIBUTE typedef Quad2 ccQuad2;
CC_DEPRECATED_ATTRIBUTE typedef Quad3 ccQuad3;
CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F ccV2F_C4B_T2F;
CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F ccV2F_C4F_T2F;
CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F ccV3F_C4B_T2F;
CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Triangle ccV2F_C4B_T2F_Triangle;
CC_DEPRECATED_ATTRIBUTE typedef V2F_C4B_T2F_Quad ccV2F_C4B_T2F_Quad;
CC_DEPRECATED_ATTRIBUTE typedef V3F_C4B_T2F_Quad ccV3F_C4B_T2F_Quad;
CC_DEPRECATED_ATTRIBUTE typedef V2F_C4F_T2F_Quad ccV2F_C4F_T2F_Quad;
CC_DEPRECATED_ATTRIBUTE typedef BlendFunc ccBlendFunc;
CC_DEPRECATED_ATTRIBUTE typedef T2F_Quad ccT2F_Quad;
CC_DEPRECATED_ATTRIBUTE typedef AnimationFrameData ccAnimationFrameData;
CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow;
CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke;
CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition;
CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment;
CC_DEPRECATED_ATTRIBUTE typedef ProgressTimerType CCProgressTimerType;
CC_DEPRECATED_ATTRIBUTE typedef void* CCZone;
#define kCCVertexAttrib_Position kVertexAttrib_Position
#define kCCVertexAttrib_Color kVertexAttrib_Color
#define kCCVertexAttrib_TexCoords kVertexAttrib_TexCoords
#define kCCVertexAttrib_MAX kVertexAttrib_MAX
#define kCCUniformPMatrix kUniformPMatrix
#define kCCUniformMVMatrix kUniformMVMatrix
#define kCCUniformMVPMatrix kUniformMVPMatrix
#define kCCUniformTime kUniformTime
#define kCCUniformSinTime kUniformSinTime
#define kCCUniformCosTime kUniformCosTime
#define kCCUniformRandom01 kUniformRandom01
#define kCCUniformSampler kUniformSampler
#define kCCUniform_MAX kUniform_MAX
#define kCCShader_PositionTextureColor kShader_PositionTextureColor
#define kCCShader_PositionTextureColorAlphaTest kShader_PositionTextureColorAlphaTest
#define kCCShader_PositionColor kShader_PositionColor
#define kCCShader_PositionTexture kShader_PositionTexture
#define kCCShader_PositionTexture_uColor kShader_PositionTexture_uColor
#define kCCShader_PositionTextureA8Color kShader_PositionTextureA8Color
#define kCCShader_Position_uColor kShader_Position_uColor
#define kCCShader_PositionLengthTexureColor kShader_PositionLengthTexureColor
// uniform names
#define kCCUniformPMatrix_s kUniformPMatrix_s
#define kCCUniformMVMatrix_s kUniformMVMatrix_s
#define kCCUniformMVPMatrix_s kUniformMVPMatrix_s
#define kCCUniformTime_s kUniformTime_s
#define kCCUniformSinTime_s kUniformSinTime_s
#define kCCUniformCosTime_s kUniformCosTime_s
#define kCCUniformRandom01_s kUniformRandom01_s
#define kCCUniformSampler_s kUniformSampler_s
#define kCCUniformAlphaTestValue kUniformAlphaTestValue
// Attribute names
#define kCCAttributeNameColor kAttributeNameColor
#define kCCAttributeNamePosition kAttributeNamePosition
#define kCCAttributeNameTexCoord kAttributeNameTexCoord
#define kCCVertexAttribFlag_None kVertexAttribFlag_None
#define kCCVertexAttribFlag_Position kVertexAttribFlag_Position
#define kCCVertexAttribFlag_Color kVertexAttribFlag_Color
#define kCCVertexAttribFlag_TexCoords kVertexAttribFlag_TexCoords
#define kCCVertexAttribFlag_PosColorTex kVertexAttribFlag_PosColorTex
#define kCCProgressTimerTypeRadial kProgressTimerTypeRadial
#define kCCProgressTimerTypeBar kProgressTimerTypeBar
#define kCCDirectorProjection2D kDirectorProjection2D
#define kCCDirectorProjection3D kDirectorProjection3D
#define kCCDirectorProjectionCustom kDirectorProjectionCustom
#define kCCDirectorProjectionDefault kDirectorProjectionDefault
#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop
#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter
#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom
#define kCCTextAlignmentLeft kTextAlignmentLeft
#define kCCTextAlignmentCenter kTextAlignmentCenter
#define kCCTextAlignmentRight kTextAlignmentRight
#define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888
#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888
#define kCCTexture2DPixelFormat_RGB565 kTexture2DPixelFormat_RGB565
#define kCCTexture2DPixelFormat_A8 kTexture2DPixelFormat_A8
#define kCCTexture2DPixelFormat_I8 kTexture2DPixelFormat_I8
#define kCCTexture2DPixelFormat_AI88 kTexture2DPixelFormat_AI88
#define kCCTexture2DPixelFormat_RGBA4444 kTexture2DPixelFormat_RGBA4444
#define kCCTexture2DPixelFormat_RGB5A1 kTexture2DPixelFormat_RGB5A1
#define kCCTexture2DPixelFormat_PVRTC4 kTexture2DPixelFormat_PVRTC4
#define kCCTexture2DPixelFormat_PVRTC2 kTexture2DPixelFormat_PVRTC2
#define kCCTexture2DPixelFormat_Default kTexture2DPixelFormat_Default
#define kCCLabelAutomaticWidth kLabelAutomaticWidth
#define kCCParticleDurationInfinity kParticleDurationInfinity
#define kCCParticleStartSizeEqualToEndSize kParticleStartSizeEqualToEndSize
#define kCCParticleStartRadiusEqualToEndRadius kParticleStartRadiusEqualToEndRadius
#define kCCParticleModeGravity kParticleModeGravity
#define kCCParticleModeRadius kParticleModeRadius
#define kCCPositionTypeFree kPositionTypeFree
#define kCCPositionTypeRelative kPositionTypeRelative
#define kCCPositionTypeGrouped kPositionTypeGrouped
#define kCCBlendFuncDisable kBlendFuncDisable
#define kCCMenuHandlerPriority kMenuHandlerPriority
#define kCCMenuStateWaiting kMenuStateWaiting
#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch
#define kCCTouchesOneByOne kTouchesOneByOne
#define kCCTouchesAllAtOnce kTouchesAllAtOnce
#define kCCImageFormatPNG kImageFormatPNG
#define kCCImageFormatJPEG kImageFormatJPEG
#define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver
#define kCCTransitionOrientationRightOver kTransitionOrientationRightOver
#define kCCTransitionOrientationUpOver kTransitionOrientationUpOver
#define kCCTransitionOrientationDownOver kTransitionOrientationDownOver
#define kCCPrioritySystem kPrioritySystem
#define kCCPriorityNonSystemMin kPriorityNonSystemMin
#define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag
#define kCCTMXTileVerticalFlag kTMXTileVerticalFlag
#define kCCTMXTileDiagonalFlag kTMXTileDiagonalFlag
#define kCCFlipedAll kFlipedAll
#define kCCFlippedMask kFlippedMask
// end of data_structures group
/// @}

View File

@ -85,7 +85,7 @@ THE SOFTWARE.
#include "ccConfig.h"
#include "ccMacros.h"
#include "ccTypes.h"
#include "CCDeprecated.h"
// kazmath
#include "kazmath/include/kazmath/kazmath.h"
@ -276,6 +276,9 @@ THE SOFTWARE.
#include "support/component/CCComponent.h"
#include "support/component/CCComponentContainer.h"
// Deprecated include
#include "CCDeprecated.h"
NS_CC_BEGIN
CC_DLL const char* cocos2dVersion();

View File

@ -237,9 +237,9 @@ public:
virtual bool init();
/** initializes a Layer with color, width and height in Points */
virtual bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
bool initWithColor(const Color4B& color, GLfloat width, GLfloat height);
/** initializes a Layer with color. Width and height are the window size. */
virtual bool initWithColor(const Color4B& color);
bool initWithColor(const Color4B& color);
/** change width in Points*/
void changeWidth(GLfloat w);
@ -300,10 +300,10 @@ public:
virtual bool init();
/** Initializes the Layer with a gradient between start and end. */
virtual bool initWithColor(const Color4B& start, const Color4B& end);
bool initWithColor(const Color4B& start, const Color4B& end);
/** Initializes the Layer with a gradient between start and end in the direction of v. */
virtual bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
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
Default: YES

View File

@ -88,7 +88,7 @@ public:
virtual ~TransitionScene();
/** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(float t,Scene* scene);
bool initWithDuration(float t,Scene* scene);
/** called after the transition finishes */
void finish(void);
@ -131,7 +131,7 @@ public:
virtual ~TransitionSceneOriented();
/** initializes a transition with duration and incoming scene */
virtual bool initWithDuration(float t,Scene* scene,tOrientation orientation);
bool initWithDuration(float t,Scene* scene,tOrientation orientation);
protected:
tOrientation _orientation;
@ -468,12 +468,12 @@ public:
virtual ~TransitionFade();
/** initializes the transition with a duration and with an RGB color */
virtual bool initWithDuration(float t, Scene*scene ,const Color3B& color);
bool initWithDuration(float t, Scene*scene ,const Color3B& color);
//
// Overrides
//
virtual bool initWithDuration(float t,Scene* scene);
bool initWithDuration(float t,Scene* scene);
virtual void onEnter();
virtual void onExit();

View File

@ -64,7 +64,7 @@ public:
* If back is true then the effect is reversed to appear as if the incoming
* scene is being turned from left over the outgoing scene.
*/
virtual bool initWithDuration(float t,Scene* scene,bool backwards);
bool initWithDuration(float t,Scene* scene,bool backwards);
ActionInterval* actionWithSize(const Size& vector);

View File

@ -65,13 +65,14 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor));
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(ParticleSystemQuad::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
return true;
}
return false;
@ -100,7 +101,9 @@ ParticleSystemQuad::~ParticleSystemQuad()
#endif
}
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
// implementation ParticleSystemQuad

View File

@ -668,6 +668,7 @@ const char* FileUtils::fullPathFromRelativeFile(const char *pszFilename, const c
void FileUtils::setSearchResolutionsOrder(const std::vector<std::string>& searchResolutionsOrder)
{
bool bExistDefault = false;
_fullPathCache.clear();
_searchResolutionsOrderArray.clear();
for (std::vector<std::string>::const_iterator iter = searchResolutionsOrder.begin(); iter != searchResolutionsOrder.end(); ++iter)
{
@ -709,6 +710,7 @@ void FileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
{
bool bExistDefaultRootPath = false;
_fullPathCache.clear();
_searchPathArray.clear();
for (std::vector<std::string>::const_iterator iter = searchPaths.begin(); iter != searchPaths.end(); ++iter)
{
@ -755,6 +757,7 @@ void FileUtils::addSearchPath(const char* path_)
void FileUtils::setFilenameLookupDictionary(Dictionary* pFilenameLookupDict)
{
_fullPathCache.clear();
CC_SAFE_RELEASE(_filenameLookupDict);
_filenameLookupDict = pFilenameLookupDict;
CC_SAFE_RETAIN(_filenameLookupDict);

View File

@ -81,7 +81,7 @@ to be different from other platforms unless there's a good reason.
It's new in cocos2d-x since v0.99.5
*/
#if 0
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#define CC_ENABLE_CACHE_TEXTURE_DATA 1
#else
#define CC_ENABLE_CACHE_TEXTURE_DATA 0

View File

@ -33,6 +33,8 @@ THE SOFTWARE.
#include <stdio.h>
#include <unistd.h>
NS_CC_BEGIN
typedef struct
{
unsigned int height;
@ -54,28 +56,6 @@ static unsigned int nextPOT(unsigned int x)
return x + 1;
}
typedef enum {
kTexture2DPixelFormat_Automatic = 0,
//! 32-bit texture: RGBA8888
kTexture2DPixelFormat_RGBA8888,
//! 24-bit texture: RGBA888
kTexture2DPixelFormat_RGB888,
//! 16-bit texture without Alpha channel
kTexture2DPixelFormat_RGB565,
//! 8-bit textures used as masks
kTexture2DPixelFormat_A8,
//! 16-bit textures: RGBA4444
kTexture2DPixelFormat_RGBA4444,
//! 16-bit textures: RGB5A1
kTexture2DPixelFormat_RGB5A1,
//! Default texture format: RGBA8888
kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888,
// backward compatibility stuff
} Texture2DPixelFormat;
static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POTWide, NSUInteger POTHigh, tImageInfo *pImageInfo)
{
NSUInteger i;
@ -481,7 +461,6 @@ static bool _initWithString(const char * pText, cocos2d::Image::ETextAlign eAlig
return bRet;
}
NS_CC_BEGIN
static bool _enabledScale = true;

View File

@ -241,7 +241,7 @@ bool GLProgram::link()
_vertShader = _fragShader = 0;
#if DEBUG
#if COCOS2D_DEBUG
glGetProgramiv(_program, GL_LINK_STATUS, &status);
if (status == GL_FALSE)

View File

@ -219,7 +219,7 @@ void ShaderCache::reloadDefaultShaders()
//
p = programForKey(kShader_PositionLengthTexureColor);
p->reset();
loadDefaultShader(p, kShaderType_Position_uColor);
loadDefaultShader(p, kShaderType_PositionLengthTexureColor);
}
void ShaderCache::loadDefaultShader(GLProgram *p, int type)
@ -297,7 +297,7 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type)
GLProgram* ShaderCache::programForKey(const char* key)
{
return (GLProgram*)_programs->objectForKey(key);
return static_cast<GLProgram*>(_programs->objectForKey(key));
}
void ShaderCache::addProgram(GLProgram* program, const char* key)

View File

@ -76,7 +76,11 @@ void ccGLInvalidateStateCache( void )
s_eBlendingSource = -1;
s_eBlendingDest = -1;
s_eGLServerState = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
s_uVAO = 0;
#endif
#endif // CC_ENABLE_GL_STATE_CACHE
}
void ccGLDeleteProgram( GLuint program )

View File

@ -465,12 +465,12 @@ void Sprite::updateTransform(void)
if( ! _parent || _parent == _batchNode )
{
_transformToBatch = nodeToParentTransform();
_transformToBatch = getNodeToParentTransform();
}
else
{
CCAssert( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
_transformToBatch = AffineTransformConcat( nodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch );
_transformToBatch = AffineTransformConcat( getNodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch );
}
//

View File

@ -442,181 +442,140 @@ bool Texture2D::initWithString(const char *text, const char *fontName, float fon
bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions, TextAlignment hAlignment, VerticalTextAlignment vAlignment)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
FontDefinition tempDef;
FontDefinition tempDef;
tempDef._shadow._shadowEnabled = false;
tempDef._stroke._strokeEnabled = false;
tempDef._fontName = std::string(fontName);
tempDef._fontSize = fontSize;
tempDef._dimensions = dimensions;
tempDef._alignment = hAlignment;
tempDef._vertAlignment = vAlignment;
tempDef._fontFillColor = Color3B::WHITE;
return initWithString(text, tempDef);
#else
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignTop
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == vAlignment)
{
eAlign = (kTextAlignmentCenter == hAlignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == hAlignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
do
{
Image* pImage = new Image();
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
CC_SAFE_RELEASE(pImage);
} while (0);
return bRet;
#endif
tempDef._shadow._shadowEnabled = false;
tempDef._stroke._strokeEnabled = false;
tempDef._fontName = std::string(fontName);
tempDef._fontSize = fontSize;
tempDef._dimensions = dimensions;
tempDef._alignment = hAlignment;
tempDef._vertAlignment = vAlignment;
tempDef._fontFillColor = Color3B::WHITE;
return initWithString(text, tempDef);
}
bool Texture2D::initWithString(const char *text, const FontDefinition& textDefinition)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, textDefinition);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
#if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data
VolatileTexture::addStringTexture(this, text, textDefinition._dimensions, textDefinition._alignment, textDefinition._vertAlignment, textDefinition._fontName.c_str(), textDefinition._fontSize);
#endif
bool bRet = false;
Image::ETextAlign eAlign;
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
// handle shadow parameters
bool shadowEnabled = false;
float shadowDX = 0.0f;
float shadowDY = 0.0f;
float shadowBlur = 0.0f;
float shadowOpacity = 0.0f;
if ( textDefinition._shadow._shadowEnabled )
{
shadowEnabled = true;
shadowDX = textDefinition._shadow._shadowOffset.width;
shadowDY = textDefinition._shadow._shadowOffset.height;
shadowBlur = textDefinition._shadow._shadowBlur;
shadowOpacity = textDefinition._shadow._shadowOpacity;
}
// handle stroke parameters
bool strokeEnabled = false;
float strokeColorR = 0.0f;
float strokeColorG = 0.0f;
float strokeColorB = 0.0f;
float strokeSize = 0.0f;
if ( textDefinition._stroke._strokeEnabled )
{
strokeEnabled = true;
strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
strokeSize = textDefinition._stroke._strokeSize;
}
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithStringShadowStroke(text,
(int)textDefinition._dimensions.width,
(int)textDefinition._dimensions.height,
eAlign,
textDefinition._fontName.c_str(),
textDefinition._fontSize,
textDefinition._fontFillColor.r / 255.0f,
textDefinition._fontFillColor.g / 255.0f,
textDefinition._fontFillColor.b / 255.0f,
shadowEnabled,
shadowDX,
shadowDY,
shadowOpacity,
shadowBlur,
strokeEnabled,
strokeColorR,
strokeColorG,
strokeColorB,
strokeSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#else
CCAssert(false, "Currently only supported on iOS and Android!");
if (kVerticalTextAlignmentTop == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight;
}
else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight;
}
else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment)
{
eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom
: (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight;
}
else
{
CCAssert(false, "Not supported alignment format!");
return false;
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
// handle shadow parameters
bool shadowEnabled = false;
float shadowDX = 0.0f;
float shadowDY = 0.0f;
float shadowBlur = 0.0f;
float shadowOpacity = 0.0f;
if ( textDefinition._shadow._shadowEnabled )
{
shadowEnabled = true;
shadowDX = textDefinition._shadow._shadowOffset.width;
shadowDY = textDefinition._shadow._shadowOffset.height;
shadowBlur = textDefinition._shadow._shadowBlur;
shadowOpacity = textDefinition._shadow._shadowOpacity;
}
// handle stroke parameters
bool strokeEnabled = false;
float strokeColorR = 0.0f;
float strokeColorG = 0.0f;
float strokeColorB = 0.0f;
float strokeSize = 0.0f;
if ( textDefinition._stroke._strokeEnabled )
{
strokeEnabled = true;
strokeColorR = textDefinition._stroke._strokeColor.r / 255.0f;
strokeColorG = textDefinition._stroke._strokeColor.g / 255.0f;
strokeColorB = textDefinition._stroke._strokeColor.b / 255.0f;
strokeSize = textDefinition._stroke._strokeSize;
}
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithStringShadowStroke(text,
(int)textDefinition._dimensions.width,
(int)textDefinition._dimensions.height,
eAlign,
textDefinition._fontName.c_str(),
textDefinition._fontSize,
textDefinition._fontFillColor.r / 255.0f,
textDefinition._fontFillColor.g / 255.0f,
textDefinition._fontFillColor.b / 255.0f,
shadowEnabled,
shadowDX,
shadowDY,
shadowOpacity,
shadowBlur,
strokeEnabled,
strokeColorR,
strokeColorG,
strokeColorB,
strokeSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#else
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled;
CCAssert(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
Image* pImage = new Image();
do
{
CC_BREAK_IF(NULL == pImage);
bRet = pImage->initWithString(text, (int)textDefinition._dimensions.width, (int)textDefinition._dimensions.height, eAlign, textDefinition._fontName.c_str(), (int)textDefinition._fontSize);
CC_BREAK_IF(!bRet);
bRet = initWithImage(pImage);
} while (0);
CC_SAFE_RELEASE(pImage);
return bRet;
#endif
}
@ -624,7 +583,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
void Texture2D::drawAtPoint(const Point& point)
{
GLfloat coordinates[] = {
GLfloat coordinates[] = {
0.0f, _maxT,
_maxS,_maxT,
0.0f, 0.0f,

View File

@ -66,7 +66,9 @@ TextureAtlas::~TextureAtlas()
#endif
CC_SAFE_RELEASE(_texture);
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
#endif
}
unsigned int TextureAtlas::getTotalQuads() const
@ -176,12 +178,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, unsigned int capacity)
memset( _quads, 0, _capacity * sizeof(V3F_C4B_T2F_Quad) );
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
#if CC_ENABLE_CACHE_TEXTURE_DATA
// listen the event when app go to background
NotificationCenter::getInstance()->addObserver(this,
callfuncO_selector(TextureAtlas::listenBackToForeground),
EVNET_COME_TO_FOREGROUND,
NULL);
#endif
this->setupIndices();
#if CC_TEXTURE_ATLAS_USE_VAO

View File

@ -138,7 +138,7 @@ void TextureCache::addImageAsync(const char *path, Object *target, SEL_CallFuncO
std::string pathKey = path;
pathKey = FileUtils::getInstance()->fullPathForFilename(pathKey.c_str());
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
texture = static_cast<Texture2D*>(_textures->objectForKey(pathKey.c_str()));
std::string fullpath = pathKey;
if (texture != NULL)
@ -354,7 +354,7 @@ Texture2D * TextureCache::addImage(const char * path)
{
return NULL;
}
texture = (Texture2D*)_textures->objectForKey(pathKey.c_str());
texture = static_cast<Texture2D*>(_textures->objectForKey(pathKey.c_str()));
std::string fullpath = pathKey;
if (! texture)
@ -576,7 +576,7 @@ void TextureCache::removeUnusedTextures()
}
// remove elements
for (list<DictElement*>::iterator iter = elementToRemove.begin(); iter != elementToRemove.end(); ++iter)
for (auto iter = elementToRemove.begin(); iter != elementToRemove.end(); ++iter)
{
CCLOG("cocos2d: TextureCache: removing unused texture: %s", (*iter)->getStrKey());
_textures->removeObjectForElememt(*iter);
@ -647,40 +647,35 @@ void TextureCache::dumpCachedTextureInfo()
#if CC_ENABLE_CACHE_TEXTURE_DATA
std::list<VolatileTexture*> VolatileTexture::textures;
bool VolatileTexture::isReloading = false;
std::list<VolatileTexture*> VolatileTexture::_textures;
bool VolatileTexture::_isReloading = false;
VolatileTexture::VolatileTexture(Texture2D *t)
: texture(t)
: _texture(t)
, _cashedImageType(kInvalid)
, _textureData(NULL)
, _pixelFormat(kTexture2DPixelFormat_RGBA8888)
, _fileName("")
, _fmtImage(Image::kFmtPng)
, _alignment(kTextAlignmentCenter)
, _vAlignment(kVerticalTextAlignmentCenter)
, _fontName("")
, _text("")
, uiImage(NULL)
, _fontSize(0.0f)
, _uiImage(NULL)
{
_size = Size(0, 0);
_texParams.minFilter = GL_LINEAR;
_texParams.magFilter = GL_LINEAR;
_texParams.wrapS = GL_CLAMP_TO_EDGE;
_texParams.wrapT = GL_CLAMP_TO_EDGE;
textures.push_back(this);
_textures.push_back(this);
}
VolatileTexture::~VolatileTexture()
{
textures.remove(this);
CC_SAFE_RELEASE(uiImage);
_textures.remove(this);
CC_SAFE_RELEASE(_uiImage);
}
void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -697,18 +692,18 @@ void VolatileTexture::addImage(Texture2D *tt, Image *image)
{
VolatileTexture *vt = findVolotileTexture(tt);
image->retain();
vt->uiImage = image;
vt->_uiImage = image;
vt->_cashedImageType = kImage;
}
VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
{
VolatileTexture *vt = 0;
std::list<VolatileTexture *>::iterator i = textures.begin();
while (i != textures.end())
auto i = _textures.begin();
while (i != _textures.end())
{
VolatileTexture *v = *i++;
if (v->texture == tt)
if (v->_texture == tt)
{
vt = v;
break;
@ -725,7 +720,7 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt)
void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -738,10 +733,9 @@ void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFo
vt->_textureSize = contentSize;
}
void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment,
VerticalTextAlignment vAlignment, const char *fontName, float fontSize)
void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition)
{
if (isReloading)
if (_isReloading)
{
return;
}
@ -749,12 +743,8 @@ void VolatileTexture::addStringTexture(Texture2D *tt, const char* text, const Si
VolatileTexture *vt = findVolotileTexture(tt);
vt->_cashedImageType = kString;
vt->_size = dimensions;
vt->_fontName = fontName;
vt->_alignment = alignment;
vt->_vAlignment = vAlignment;
vt->_fontSize = fontSize;
vt->_text = text;
vt->_fontDefinition = fontDefinition;
}
void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParams)
@ -773,12 +763,11 @@ void VolatileTexture::setTexParameters(Texture2D *t, const ccTexParams &texParam
void VolatileTexture::removeTexture(Texture2D *t)
{
std::list<VolatileTexture *>::iterator i = textures.begin();
while (i != textures.end())
auto i = _textures.begin();
while (i != _textures.end())
{
VolatileTexture *vt = *i++;
if (vt->texture == t)
if (vt->_texture == t)
{
delete vt;
break;
@ -788,12 +777,12 @@ void VolatileTexture::removeTexture(Texture2D *t)
void VolatileTexture::reloadAllTextures()
{
isReloading = true;
_isReloading = true;
CCLOG("reload all texture");
std::list<VolatileTexture *>::iterator iter = textures.begin();
auto iter = _textures.begin();
while (iter != textures.end())
while (iter != _textures.end())
{
VolatileTexture *vt = *iter++;
@ -812,7 +801,7 @@ void VolatileTexture::reloadAllTextures()
Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->texture->initWithPVRFile(vt->_fileName.c_str());
vt->_texture->initWithPVRFile(vt->_fileName.c_str());
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
}
else
@ -825,7 +814,7 @@ void VolatileTexture::reloadAllTextures()
{
Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat();
Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat);
vt->texture->initWithImage(pImage);
vt->_texture->initWithImage(pImage);
Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat);
}
@ -836,7 +825,7 @@ void VolatileTexture::reloadAllTextures()
break;
case kImageData:
{
vt->texture->initWithData(vt->_textureData,
vt->_texture->initWithData(vt->_textureData,
vt->_pixelFormat,
vt->_textureSize.width,
vt->_textureSize.height,
@ -845,27 +834,21 @@ void VolatileTexture::reloadAllTextures()
break;
case kString:
{
vt->texture->initWithString(vt->_text.c_str(),
vt->_fontName.c_str(),
vt->_fontSize,
vt->_size,
vt->_alignment,
vt->_vAlignment
);
vt->_texture->initWithString(vt->_text.c_str(), vt->_fontDefinition);
}
break;
case kImage:
{
vt->texture->initWithImage(vt->uiImage);
vt->_texture->initWithImage(vt->_uiImage);
}
break;
default:
break;
}
vt->texture->setTexParameters(vt->_texParams);
vt->_texture->setTexParameters(vt->_texParams);
}
isReloading = false;
_isReloading = false;
}
#endif // CC_ENABLE_CACHE_TEXTURE_DATA

View File

@ -219,8 +219,7 @@ public:
~VolatileTexture();
static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format);
static void addStringTexture(Texture2D *tt, const char* text, const Size& dimensions, TextAlignment alignment,
VerticalTextAlignment vAlignment, const char *fontName, float fontSize);
static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition);
static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize);
static void addImage(Texture2D *tt, Image *image);
@ -229,8 +228,8 @@ public:
static void reloadAllTextures();
public:
static std::list<VolatileTexture*> textures;
static bool isReloading;
static std::list<VolatileTexture*> _textures;
static bool _isReloading;
private:
// find VolatileTexture by Texture2D*
@ -238,9 +237,9 @@ private:
static VolatileTexture* findVolotileTexture(Texture2D *tt);
protected:
Texture2D *texture;
Texture2D *_texture;
Image *uiImage;
Image *_uiImage;
ccCachedImageType _cashedImageType;
@ -251,13 +250,9 @@ protected:
std::string _fileName;
Image::EImageFormat _fmtImage;
ccTexParams _texParams;
Size _size;
TextAlignment _alignment;
VerticalTextAlignment _vAlignment;
std::string _fontName;
std::string _text;
float _fontSize;
ccTexParams _texParams;
std::string _text;
FontDefinition _fontDefinition;
};
#endif

View File

@ -72,14 +72,15 @@ ParallaxNode * ParallaxNode::create()
return pRet;
}
void ParallaxNode::addChild(Node * child, unsigned int zOrder, int tag)
void ParallaxNode::addChild(Node * child, int zOrder, int tag)
{
CC_UNUSED_PARAM(zOrder);
CC_UNUSED_PARAM(child);
CC_UNUSED_PARAM(tag);
CCAssert(0,"ParallaxNode: use addChild:z:parallaxRatio:positionOffset instead");
}
void ParallaxNode::addChild(Node *child, unsigned int z, const Point& ratio, const Point& offset)
void ParallaxNode::addChild(Node *child, int z, const Point& ratio, const Point& offset)
{
CCAssert( child != NULL, "Argument must be non-nil");
PointObject *obj = PointObject::pointWithPoint(ratio, offset);

View File

@ -45,10 +45,10 @@ The children will be moved faster / slower than the parent according the the par
*/
class CC_DLL ParallaxNode : public Node
{
/** array that holds the offset / ratio of the children */
CC_SYNTHESIZE(struct _ccArray *, _parallaxArray, ParallaxArray)
public:
// Create a Parallax node
static ParallaxNode * create();
/** Adds a child to the container with a z-order, a parallax ratio and a position offset
It returns self, so you can chain several addChilds.
@since v0.8
@ -56,17 +56,21 @@ public:
ParallaxNode();
virtual ~ParallaxNode();
static ParallaxNode * create();
virtual void addChild(Node * child, unsigned int z, const Point& parallaxRatio, const Point& positionOffset);
// super methods
virtual void addChild(Node * child, unsigned int zOrder, int tag);
virtual void removeChild(Node* child, bool cleanup);
virtual void removeAllChildrenWithCleanup(bool cleanup);
virtual void visit(void);
void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset);
//
// Overrides
//
virtual void addChild(Node * child, int zOrder, int tag) override;
virtual void removeChild(Node* child, bool cleanup) override;
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
virtual void visit(void) override;
private:
Point absolutePosition();
protected:
Point _lastPosition;
/** array that holds the offset / ratio of the children */
CC_SYNTHESIZE(struct _ccArray *, _parallaxArray, ParallaxArray)
};
// end of tilemap_parallax_nodes group

View File

@ -60,7 +60,7 @@ public:
void setEnalbedSelectors(int nValue);
/** initializes a TouchHandler with a delegate and a priority */
virtual bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
public:
/** allocates a TouchHandler with a delegate and a priority */
@ -79,7 +79,7 @@ class CC_DLL StandardTouchHandler : public TouchHandler
{
public:
/** initializes a TouchHandler with a delegate and a priority */
virtual bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
bool initWithDelegate(TouchDelegate *pDelegate, int nPriority);
public:
/** allocates a TouchHandler with a delegate and a priority */

View File

@ -323,7 +323,7 @@ Dictionary *Armature::getBoneDic()
return _boneDic;
}
AffineTransform Armature::nodeToParentTransform()
AffineTransform Armature::getNodeToParentTransform() const
{
if (_transformDirty)
{
@ -404,7 +404,7 @@ AffineTransform Armature::nodeToParentTransform()
void Armature::updateOffsetPoint()
{
// Set contentsize and Calculate anchor point.
Rect rect = boundingBox();
Rect rect = getBoundingBox();
setContentSize(rect.size);
_offsetPoint = Point(-rect.origin.x, -rect.origin.y);
setAnchorPoint(Point(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
@ -523,7 +523,7 @@ void Armature::visit()
kmGLPopMatrix();
}
Rect Armature::boundingBox()
Rect Armature::getBoundingBox() const
{
float minx, miny, maxx, maxy = 0;

View File

@ -54,7 +54,7 @@ public:
public:
Armature();
~Armature(void);
virtual ~Armature(void);
/**
* Init the empty armature
@ -101,27 +101,24 @@ public:
* @return Armature's bone dictionary
*/
Dictionary *getBoneDic();
/**
* This boundingBox will calculate all bones' boundingBox every time
*/
virtual Rect boundingBox();
Bone *getBoneAtPoint(float x, float y);
virtual void visit();
virtual void update(float dt);
virtual void draw();
virtual AffineTransform nodeToParentTransform();
/**
* Set contentsize and Calculate anchor point.
*/
virtual void updateOffsetPoint();
inline void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; }
inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; }
// overrides
virtual void visit() override;
virtual void update(float dt) override;
virtual void draw() override;
virtual AffineTransform getNodeToParentTransform() const override;
/** This boundingBox will calculate all bones' boundingBox every time */
virtual Rect getBoundingBox() const override;
inline void setBlendFunc(const BlendFunc& blendFunc) override { _blendFunc = blendFunc; }
inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; }
protected:

View File

@ -303,7 +303,7 @@ Size DisplayManager::getContentSize()
Rect DisplayManager::getBoundingBox()
{
CS_RETURN_IF(!_displayRenderNode) Rect(0, 0, 0, 0);
return _displayRenderNode->boundingBox();
return _displayRenderNode->getBoundingBox();
}

View File

@ -71,7 +71,7 @@ void Skin::setSkinData(const BaseData &var)
setRotation(CC_RADIANS_TO_DEGREES(_skinData.skewX));
setPosition(Point(_skinData.x, _skinData.y));
_skinTransform = nodeToParentTransform();
_skinTransform = getNodeToParentTransform();
}
const BaseData &Skin::getSkinData() const

View File

@ -260,7 +260,7 @@ bool Control::isTouchInside(Touch* touch)
{
Point touchLocation = touch->getLocation(); // Get the touch position
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
Rect bBox=boundingBox();
Rect bBox = getBoundingBox();
return bBox.containsPoint(touchLocation);
}

View File

@ -568,7 +568,7 @@ void ControlButton::needsLayout()
Size titleLabelSize;
if (_titleLabel != NULL)
{
titleLabelSize = _titleLabel->boundingBox().size;
titleLabelSize = _titleLabel->getBoundingBox().size;
}
// Adjust the background image if necessary
@ -603,12 +603,12 @@ void ControlButton::needsLayout()
Rect rectTitle;
if (_titleLabel != NULL)
{
rectTitle = _titleLabel->boundingBox();
rectTitle = _titleLabel->getBoundingBox();
}
Rect rectBackground;
if (_backgroundSprite != NULL)
{
rectBackground = _backgroundSprite->boundingBox();
rectBackground = _backgroundSprite->getBoundingBox();
}
Rect maxRect = ControlUtils::RectUnion(rectTitle, rectBackground);

View File

@ -67,7 +67,7 @@ bool ControlHuePicker::initWithTargetAndPos(Node* target, Point pos)
this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Point(0.0f, 0.0f)));
this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Point(0.5f, 0.5f)));
_slider->setPosition(Point(pos.x, pos.y + _background->boundingBox().size.height * 0.5f));
_slider->setPosition(Point(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f));
_startPos=pos;
// Sets the default value
@ -96,7 +96,7 @@ void ControlHuePicker::setHuePercentage(float hueValueInPercent)
_hue=_huePercentage*360.0f;
// Clamp the position of the icon within the circle
Rect backgroundBox=_background->boundingBox();
Rect backgroundBox=_background->getBoundingBox();
// Get the center point of the background image
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;
@ -129,7 +129,7 @@ void ControlHuePicker::updateSliderPosition(Point location)
{
// Clamp the position of the icon within the circle
Rect backgroundBox=_background->boundingBox();
Rect backgroundBox=_background->getBoundingBox();
// Get the center point of the background image
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;

View File

@ -121,8 +121,8 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio
// Clamp the position of the icon within the circle
// Get the center point of the bkgd image
float centerX = _startPos.x + _background->boundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->boundingBox().size.height*0.5f;
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
// Work out the distance difference between the location and center
float dx = sliderPosition.x - centerX;
@ -133,7 +133,7 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio
float angle = atan2f(dy, dx);
// Set the limit to the slider movement within the colour picker
float limit = _background->boundingBox().size.width*0.5f;
float limit = _background->getBoundingBox().size.width*0.5f;
// Check distance doesn't exceed the bounds of the circle
if (dist > limit)
@ -162,8 +162,8 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
// Clamp the position of the icon within the circle
// get the center point of the bkgd image
float centerX = _startPos.x + _background->boundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->boundingBox().size.height*0.5f;
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
// work out the distance difference between the location and center
float dx = location.x - centerX;
@ -171,7 +171,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
float dist = sqrtf(dx*dx+dy*dy);
// check that the touch location is within the bounding rectangle before sending updates
if (dist <= _background->boundingBox().size.width*0.5f)
if (dist <= _background->getBoundingBox().size.width*0.5f)
{
updateSliderPosition(location);
sendActionsForControlEvents(ControlEventValueChanged);

View File

@ -91,7 +91,7 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS
this->setThumbSprite(thumbSprite);
// Defines the content size
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->boundingBox(), thumbSprite->boundingBox());
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox());
setContentSize(Size(maxRect.size.width, maxRect.size.height));
@ -179,7 +179,7 @@ bool ControlSlider::isTouchInside(Touch * touch)
Point touchLocation = touch->getLocation();
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
Rect rect = this->boundingBox();
Rect rect = this->getBoundingBox();
rect.size.width += _thumbSprite->getContentSize().width;
rect.origin.x -= _thumbSprite->getContentSize().width / 2;

View File

@ -108,7 +108,7 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
_plusSprite->addChild(_plusLabel);
// Defines the content size
Rect maxRect = ControlUtils::RectUnion(_minusSprite->boundingBox(), _plusSprite->boundingBox());
Rect maxRect = ControlUtils::RectUnion(_minusSprite->getBoundingBox(), _plusSprite->getBoundingBox());
this->setContentSize( Size(_minusSprite->getContentSize().width + _plusSprite->getContentSize().height, maxRect.size.height) );
return true;
}

View File

@ -145,7 +145,7 @@ bool ScrollView::isNodeVisible(Node* node)
viewRect = Rect(-offset.x/scale, -offset.y/scale, size.width/scale, size.height/scale);
return viewRect.intersectsRect(node->boundingBox());
return viewRect.intersectsRect(node->getBoundingBox());
}
void ScrollView::pause(Object* sender)

View File

@ -566,7 +566,7 @@ void TableView::ccTouchEnded(Touch *pTouch, Event *pEvent)
}
if (_touchedCell){
Rect bb = this->boundingBox();
Rect bb = this->getBoundingBox();
bb.origin = _parent->convertToWorldSpace(bb.origin);
if (bb.containsPoint(pTouch->getLocation()) && _tableViewDelegate != NULL)

View File

@ -148,7 +148,7 @@ PhysicsSprite* PhysicsSprite::create(const char *pszFileName, const Rect& rect)
// this method will only get called if the sprite is batched.
// return YES if the physic's values (angles, position ) changed.
// If you return NO, then nodeToParentTransform won't be called.
// If you return NO, then getNodeToParentTransform won't be called.
bool PhysicsSprite::isDirty() const
{
return true;
@ -342,7 +342,7 @@ void PhysicsSprite::setRotation(float fRotation)
}
// returns the transform matrix according the Chipmunk Body values
AffineTransform PhysicsSprite::nodeToParentTransform()
AffineTransform PhysicsSprite::getNodeToParentTransform() const
{
// Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions.

View File

@ -96,15 +96,6 @@ public:
bool isIgnoreBodyRotation() const;
void setIgnoreBodyRotation(bool bIgnoreBodyRotation);
virtual const Point& getPosition() const;
virtual void getPosition(float* x, float* y) const;
virtual float getPositionX() const;
virtual float getPositionY() const;
virtual void setPosition(const Point &position);
virtual float getRotation() const;
virtual void setRotation(float fRotation);
virtual AffineTransform nodeToParentTransform();
//
// Chipmunk specific
//
@ -122,6 +113,16 @@ public:
float getPTMRatio() const;
void setPTMRatio(float fPTMRatio);
// overrides
virtual const Point& getPosition() const override;
virtual void getPosition(float* x, float* y) const override;
virtual float getPositionX() const override;
virtual float getPositionY() const override;
virtual void setPosition(const Point &position) override;
virtual float getRotation() const override;
virtual void setRotation(float fRotation) override;
virtual AffineTransform getNodeToParentTransform() const override;
protected:
const Point& getPosFromPhysics() const;
};

View File

@ -91,7 +91,7 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
edge->m_radius = m_radius;
edge->m_vertex1 = m_vertices[index + 0];
edge->m_Vertex2F = m_vertices[index + 1];
edge->m_vertex2 = m_vertices[index + 1];
if (index > 0)
{
@ -106,13 +106,13 @@ void b2ChainShape::GetChildEdge(b2EdgeShape* edge, int32 index) const
if (index < m_count - 2)
{
edge->m_Vertex3F = m_vertices[index + 2];
edge->m_hasVertex3F = true;
edge->m_vertex3 = m_vertices[index + 2];
edge->m_hasVertex3 = true;
}
else
{
edge->m_Vertex3F = m_nextVertex;
edge->m_hasVertex3F = m_hasNextVertex;
edge->m_vertex3 = m_nextVertex;
edge->m_hasVertex3 = m_hasNextVertex;
}
}
@ -138,7 +138,7 @@ bool b2ChainShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
}
edgeShape.m_vertex1 = m_vertices[i1];
edgeShape.m_Vertex2F = m_vertices[i2];
edgeShape.m_vertex2 = m_vertices[i2];
return edgeShape.RayCast(output, input, xf, 0);
}

View File

@ -23,9 +23,9 @@ using namespace std;
void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2)
{
m_vertex1 = v1;
m_Vertex2F = v2;
m_vertex2 = v2;
m_hasVertex0 = false;
m_hasVertex3F = false;
m_hasVertex3 = false;
}
b2Shape* b2EdgeShape::Clone(b2BlockAllocator* allocator) const
@ -63,7 +63,7 @@ bool b2EdgeShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input,
b2Vec2 d = p2 - p1;
b2Vec2 v1 = m_vertex1;
b2Vec2 v2 = m_Vertex2F;
b2Vec2 v2 = m_vertex2;
b2Vec2 e = v2 - v1;
b2Vec2 normal(e.y, -e.x);
normal.Normalize();
@ -119,7 +119,7 @@ void b2EdgeShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf, int32 childIn
B2_NOT_USED(childIndex);
b2Vec2 v1 = b2Mul(xf, m_vertex1);
b2Vec2 v2 = b2Mul(xf, m_Vertex2F);
b2Vec2 v2 = b2Mul(xf, m_vertex2);
b2Vec2 lower = b2Min(v1, v2);
b2Vec2 upper = b2Max(v1, v2);
@ -134,6 +134,6 @@ void b2EdgeShape::ComputeMass(b2MassData* massData, float32 density) const
B2_NOT_USED(density);
massData->mass = 0.0f;
massData->center = 0.5f * (m_vertex1 + m_Vertex2F);
massData->center = 0.5f * (m_vertex1 + m_vertex2);
massData->I = 0.0f;
}

View File

@ -52,11 +52,11 @@ public:
void ComputeMass(b2MassData* massData, float32 density) const;
/// These are the edge vertices
b2Vec2 m_vertex1, m_Vertex2F;
b2Vec2 m_vertex1, m_vertex2;
/// Optional adjacent vertices. These are used for smooth collision.
b2Vec2 m_vertex0, m_Vertex3F;
bool m_hasVertex0, m_hasVertex3F;
b2Vec2 m_vertex0, m_vertex3;
bool m_hasVertex0, m_hasVertex3;
};
inline b2EdgeShape::b2EdgeShape()
@ -65,10 +65,10 @@ inline b2EdgeShape::b2EdgeShape()
m_radius = b2_polygonRadius;
m_vertex0.x = 0.0f;
m_vertex0.y = 0.0f;
m_Vertex3F.x = 0.0f;
m_Vertex3F.y = 0.0f;
m_vertex3.x = 0.0f;
m_vertex3.y = 0.0f;
m_hasVertex0 = false;
m_hasVertex3F = false;
m_hasVertex3 = false;
}
#endif

View File

@ -33,7 +33,7 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold,
// Compute circle in frame of edge
b2Vec2 Q = b2MulT(xfA, b2Mul(xfB, circleB->m_p));
b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_Vertex2F;
b2Vec2 A = edgeA->m_vertex1, B = edgeA->m_vertex2;
b2Vec2 e = B - A;
// Barycentric coordinates
@ -96,9 +96,9 @@ void b2CollideEdgeAndCircle(b2Manifold* manifold,
}
// Is there an edge connected to B?
if (edgeA->m_hasVertex3F)
if (edgeA->m_hasVertex3)
{
b2Vec2 B2 = edgeA->m_Vertex3F;
b2Vec2 B2 = edgeA->m_vertex3;
b2Vec2 A2 = B;
b2Vec2 e2 = B2 - A2;
float32 v2 = b2Dot(e2, Q - A2);
@ -236,11 +236,11 @@ void b2EPCollider::Collide(b2Manifold* manifold, const b2EdgeShape* edgeA, const
m_v0 = edgeA->m_vertex0;
m_v1 = edgeA->m_vertex1;
m_v2 = edgeA->m_Vertex2F;
m_v3 = edgeA->m_Vertex3F;
m_v2 = edgeA->m_vertex2;
m_v3 = edgeA->m_vertex3;
bool hasVertex0 = edgeA->m_hasVertex0;
bool hasVertex3F = edgeA->m_hasVertex3F;
bool hasVertex3F = edgeA->m_hasVertex3;
b2Vec2 edge1 = m_v2 - m_v1;
edge1.Normalize();

View File

@ -255,10 +255,10 @@ void b2Fixture::Dump(int32 bodyIndex)
b2Log(" shape.m_radius = %.15lef;\n", s->m_radius);
b2Log(" shape.m_vertex0.Set(%.15lef, %.15lef);\n", s->m_vertex0.x, s->m_vertex0.y);
b2Log(" shape.m_vertex1.Set(%.15lef, %.15lef);\n", s->m_vertex1.x, s->m_vertex1.y);
b2Log(" shape.m_Vertex2F.Set(%.15lef, %.15lef);\n", s->m_Vertex2F.x, s->m_Vertex2F.y);
b2Log(" shape.m_Vertex3F.Set(%.15lef, %.15lef);\n", s->m_Vertex3F.x, s->m_Vertex3F.y);
b2Log(" shape.m_vertex2.Set(%.15lef, %.15lef);\n", s->m_vertex2.x, s->m_vertex2.y);
b2Log(" shape.m_vertex3.Set(%.15lef, %.15lef);\n", s->m_vertex3.x, s->m_vertex3.y);
b2Log(" shape.m_hasVertex0 = bool(%d);\n", s->m_hasVertex0);
b2Log(" shape.m_hasVertex3F = bool(%d);\n", s->m_hasVertex3F);
b2Log(" shape.m_hasVertex3 = bool(%d);\n", s->m_hasVertex3);
}
break;

View File

@ -1048,7 +1048,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
{
b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
b2Vec2 v1 = b2Mul(xf, edge->m_vertex1);
b2Vec2 v2 = b2Mul(xf, edge->m_Vertex2F);
b2Vec2 v2 = b2Mul(xf, edge->m_vertex2);
m_debugDraw->DrawSegment(v1, v2, color);
}
break;

View File

@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -34,10 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -31,18 +31,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -28,18 +28,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -836,7 +836,7 @@ void ActionCallFuncND::onEnter()
auto action = Sequence::create(
MoveBy::create(2.0f, Point(200,0)),
CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::removeFromParentAndCleanup, this, true)),
CallFuncN::create( CC_CALLBACK_1(ActionCallFuncND::doRemoveFromParentAndCleanup, this, true)),
NULL);
_grossini->runAction(action);
@ -852,7 +852,7 @@ std::string ActionCallFuncND::subtitle()
return "simulates CallFuncND with std::bind()";
}
void ActionCallFuncND::removeFromParentAndCleanup(Node* pSender, bool cleanup)
void ActionCallFuncND::doRemoveFromParentAndCleanup(Node* pSender, bool cleanup)
{
_grossini->removeFromParentAndCleanup(cleanup);
}

View File

@ -249,7 +249,7 @@ public:
virtual void onEnter();
virtual std::string title();
virtual std::string subtitle();
void removeFromParentAndCleanup(Node* pSender, bool cleanup);
void doRemoveFromParentAndCleanup(Node* pSender, bool cleanup);
};
class ActionCallFuncO : public ActionsDemo

View File

@ -5,17 +5,6 @@
#include "Box2D/Box2D.h"
#include "../testBasic.h"
class PhysicsSprite : public Sprite
{
public:
PhysicsSprite();
void setPhysicsBody(b2Body * body);
virtual bool isDirty(void);
virtual AffineTransform nodeToParentTransform(void);
private:
b2Body* _body; // strong ref
};
class Box2DTestLayer : public Layer
{
Texture2D* _spriteTexture; // weak ref

View File

@ -140,10 +140,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*));
shape.m_radius = 9.999999776482582e-03f;
shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex1.Set(4.452173995971680e+01f, 1.669565200805664e+01f);
shape.m_Vertex2F.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_hasVertex0 = bool(0);
shape.m_hasVertex3F = bool(0);
shape.m_hasVertex3 = bool(0);
fd.shape = &shape;
@ -162,10 +162,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*));
shape.m_radius = 9.999999776482582e-03f;
shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f);
shape.m_Vertex2F.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex2.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_hasVertex0 = bool(0);
shape.m_hasVertex3F = bool(0);
shape.m_hasVertex3 = bool(0);
fd.shape = &shape;
@ -184,10 +184,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*));
shape.m_radius = 9.999999776482582e-03f;
shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex1.Set(0.000000000000000e+00f, 1.669565200805664e+01f);
shape.m_Vertex2F.Set(4.452173995971680e+01f, 1.669565200805664e+01f);
shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex2.Set(4.452173995971680e+01f, 1.669565200805664e+01f);
shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_hasVertex0 = bool(0);
shape.m_hasVertex3F = bool(0);
shape.m_hasVertex3 = bool(0);
fd.shape = &shape;
@ -206,10 +206,10 @@ b2Joint** joints = (b2Joint**)b2Alloc(2 * sizeof(b2Joint*));
shape.m_radius = 9.999999776482582e-03f;
shape.m_vertex0.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex1.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_Vertex2F.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
shape.m_Vertex3F.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_vertex2.Set(4.452173995971680e+01f, 0.000000000000000e+00f);
shape.m_vertex3.Set(0.000000000000000e+00f, 0.000000000000000e+00f);
shape.m_hasVertex0 = bool(0);
shape.m_hasVertex3F = bool(0);
shape.m_hasVertex3 = bool(0);
fd.shape = &shape;

View File

@ -35,36 +35,36 @@ public:
b2EdgeShape shape;
shape.Set(v1, v2);
shape.m_hasVertex3F = true;
shape.m_Vertex3F = v3;
shape.m_hasVertex3 = true;
shape.m_vertex3 = v3;
ground->CreateFixture(&shape, 0.0f);
shape.Set(v2, v3);
shape.m_hasVertex0 = true;
shape.m_hasVertex3F = true;
shape.m_hasVertex3 = true;
shape.m_vertex0 = v1;
shape.m_Vertex3F = v4;
shape.m_vertex3 = v4;
ground->CreateFixture(&shape, 0.0f);
shape.Set(v3, v4);
shape.m_hasVertex0 = true;
shape.m_hasVertex3F = true;
shape.m_hasVertex3 = true;
shape.m_vertex0 = v2;
shape.m_Vertex3F = v5;
shape.m_vertex3 = v5;
ground->CreateFixture(&shape, 0.0f);
shape.Set(v4, v5);
shape.m_hasVertex0 = true;
shape.m_hasVertex3F = true;
shape.m_hasVertex3 = true;
shape.m_vertex0 = v3;
shape.m_Vertex3F = v6;
shape.m_vertex3 = v6;
ground->CreateFixture(&shape, 0.0f);
shape.Set(v5, v6);
shape.m_hasVertex0 = true;
shape.m_hasVertex3F = true;
shape.m_hasVertex3 = true;
shape.m_vertex0 = v4;
shape.m_Vertex3F = v7;
shape.m_vertex3 = v7;
ground->CreateFixture(&shape, 0.0f);
shape.Set(v6, v7);

View File

@ -132,7 +132,7 @@ public:
_lens3D->setPosition(var);
}
virtual const Point& getPosition()
virtual const Point& getPosition() const
{
return _lens3D->getPosition();
}

View File

@ -579,7 +579,7 @@ void TestBoundingBox::draw()
{
CC_NODE_DRAW_SETUP();
rect = RectApplyAffineTransform(armature->boundingBox(), armature->nodeToParentTransform());
rect = RectApplyAffineTransform(armature->getBoundingBox(), armature->getNodeToParentTransform());
ccDrawColor4B(100, 100, 100, 255);
ccDrawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY()));

View File

@ -1276,7 +1276,7 @@ void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *pTouches, cocos2
Touch *touch = (Touch *)pTouches->anyObject();
Point location = touch->getLocationInView();
if (this->_arrowsShouldRetain->boundingBox().containsPoint(location))
if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location))
{
_drag = true;
this->_arrowsBarShouldRetain->setVisible(true);

View File

@ -1 +1 @@
31da76f078d1058b703cd45135e59ad906994e9b
963dd3732308b99e5251cb07db6e2260d3574e29

View File

@ -39,7 +39,7 @@ void TextureAtlasEncryptionDemo::onEnter()
this->addChild(nonencryptedSprite);
LabelTTF* nonencryptedSpriteLabel = LabelTTF::create("non-encrypted", "Arial", 28);
nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->boundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2));
nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2));
this->addChild(nonencryptedSpriteLabel, 1);
// Load the encrypted atlas
@ -66,7 +66,7 @@ void TextureAtlasEncryptionDemo::onEnter()
this->addChild(encryptedSprite);
LabelTTF* encryptedSpriteLabel = LabelTTF::create("encrypted", "Arial", 28);
encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->boundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2));
encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2));
this->addChild(encryptedSpriteLabel, 1);
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -31,10 +31,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -3,13 +3,6 @@
#include "AppDelegate.h"
#include "CCLuaEngine.h"
#include "SimpleAudioEngine.h"
#include "Lua_extensions_CCB.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "Lua_web_socket.h"
#endif
#include "LuaOpengl.h"
#include "LuaScrollView.h"
#include "LuaScriptHandlerMgr.h"
using namespace CocosDenshion;
@ -57,16 +50,6 @@ bool AppDelegate::applicationDidFinishLaunching()
LuaEngine* pEngine = LuaEngine::defaultEngine();
ScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
LuaStack *pStack = pEngine->getLuaStack();
lua_State *tolua_s = pStack->getLuaState();
tolua_extensions_ccb_open(tolua_s);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
tolua_web_socket_open(tolua_s);
#endif
tolua_opengl_open(tolua_s);
tolua_scroll_view_open(tolua_s);
tolua_script_handler_mgr_open(tolua_s);
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
searchPaths.push_back("cocosbuilderRes");
@ -76,7 +59,6 @@ bool AppDelegate::applicationDidFinishLaunching()
#endif
FileUtils::getInstance()->setSearchPaths(searchPaths);
pEngine->extendLuaObject();
pEngine->executeScriptFile("luaScript/controller.lua");
return true;

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -1 +1 @@
8f559196b6c86636a662d7655fa1edbe6002a438
32e637c6b271e1eea27e207c13116f43c310c0d4

View File

@ -310,6 +310,34 @@ private:
JSStringWrapper &operator=(const JSStringWrapper &another);
};
// wraps a function and "this" object
class JSFunctionWrapper
{
JSContext *_cx;
JSObject *_jsthis;
jsval _fval;
public:
JSFunctionWrapper(JSContext* cx, JSObject *jsthis, jsval fval)
: _cx(cx)
, _jsthis(jsthis)
, _fval(fval)
{
JS_AddNamedValueRoot(cx, &this->_fval, "JSFunctionWrapper");
JS_AddNamedObjectRoot(cx, &this->_jsthis, "JSFunctionWrapper");
}
~JSFunctionWrapper() {
JS_RemoveValueRoot(this->_cx, &this->_fval);
JS_RemoveObjectRoot(this->_cx, &this->_jsthis);
}
JSBool invoke(unsigned int argc, jsval *argv, jsval &rval) {
return JS_CallFunctionValue(this->_cx, this->_jsthis, this->_fval, argc, argv, &rval);
}
private:
/* Copy and assignment are not supported. */
JSFunctionWrapper(const JSFunctionWrapper &another);
JSFunctionWrapper &operator=(const JSFunctionWrapper &another);
};
JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value);
JSBool jsb_get_reserved_slot(JSObject *obj, uint32_t idx, jsval& ret);

@ -1 +1 @@
Subproject commit 6f8b3fcb81a96054903ab7361354a288f837b1a6
Subproject commit 940dd71e0e43fad42a00ae6fb5cdf5c20e7c0bbf

View File

@ -25,4 +25,24 @@ var cc = cc || {};
return cc.Animation.prototype.clone.apply(this, arguments);
};
cc.Node.prototype.nodeToWorldTransform = function() {
logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform");
return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments);
};
cc.Node.prototype.nodeToParentTransform = function() {
logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform");
return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments);
};
cc.Node.prototype.worldToNodeTransform = function() {
logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform");
return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments);
};
cc.Node.prototype.parentToNodeTransform = function() {
logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform");
return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments);
};
})();

View File

@ -53,6 +53,7 @@ bool LuaEngine::init(void)
{
_stack = LuaStack::create();
_stack->retain();
extendLuaObject();
executeScriptFile("Deprecated.lua");
return true;
}
@ -566,6 +567,9 @@ void LuaEngine::extendLuaObject()
extendMenuItem(lua_S);
extendLayer(lua_S);
extendControl(lua_S);
extendWebsocket(lua_S);
extendGLNode(lua_S);
extendScrollView(lua_S);
_stack->clean();
}
@ -653,4 +657,60 @@ void LuaEngine::extendControl(lua_State* lua_S)
lua_rawset(lua_S,-3);
}
}
void LuaEngine::extendWebsocket(lua_State* lua_S)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
if (NULL == lua_S)
return;
lua_pushstring(lua_S,"WebSocket");
lua_rawget(lua_S,LUA_REGISTRYINDEX);
if (lua_istable(lua_S,-1))
{
lua_pushstring(lua_S,"registerScriptHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_WebSocket_registerScriptHandler00);
lua_rawset(lua_S,-3);
lua_pushstring(lua_S,"unregisterScriptHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_WebSocket_unregisterScriptHandler00);
lua_rawset(lua_S,-3);
}
#endif
}
void LuaEngine::extendGLNode(lua_State* lua_S)
{
if (NULL == lua_S)
return;
lua_pushstring(lua_S,"GLNode");
lua_rawget(lua_S,LUA_REGISTRYINDEX);
if (lua_istable(lua_S,-1))
{
lua_pushstring(lua_S,"registerScriptDrawHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_GLNode_registerScriptDrawHandler00);
lua_rawset(lua_S,-3);
lua_pushstring(lua_S,"unregisterScriptDrawHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00);
lua_rawset(lua_S,-3);
}
}
void LuaEngine::extendScrollView(lua_State* lua_S)
{
if (NULL == lua_S)
return;
lua_pushstring(lua_S,"CCScrollView");
lua_rawget(lua_S,LUA_REGISTRYINDEX);
if (lua_istable(lua_S,-1))
{
lua_pushstring(lua_S,"registerScriptHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_ScrollView_registerScriptHandler00);
lua_rawset(lua_S,-3);
lua_pushstring(lua_S,"unregisterScriptHandler");
lua_pushcfunction(lua_S,tolua_Cocos2d_ScrollView_unregisterScriptHandler00);
lua_rawset(lua_S,-3);
}
}
NS_CC_END

View File

@ -121,6 +121,11 @@ public:
virtual int sendEvent(ScriptEvent* message);
void extendLuaObject();
private:
LuaEngine(void)
: _stack(NULL)
{
}
bool init(void);
int handleNodeEvent(void* data);
int handleMenuClickedEvent(void* data);
int handleNotificationEvent(void* data);
@ -135,14 +140,10 @@ private:
void extendMenuItem(lua_State* lua_S);
void extendLayer(lua_State* lua_S);
void extendControl(lua_State* lua_S);
void extendWebsocket(lua_State* lua_S);
void extendGLNode(lua_State* lua_S);
void extendScrollView(lua_State* lua_S);
private:
LuaEngine(void)
: _stack(NULL)
{
}
bool init(void);
static LuaEngine* _defaultEngine;
LuaStack *_stack;
};

View File

@ -39,6 +39,14 @@ extern "C" {
#include "platform/ios/CCLuaObjcBridge.h"
#endif
#include "Lua_extensions_CCB.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "Lua_web_socket.h"
#endif
#include "LuaOpengl.h"
#include "LuaScrollView.h"
#include "LuaScriptHandlerMgr.h"
namespace {
int lua_print(lua_State * luastate)
{
@ -118,6 +126,13 @@ bool LuaStack::init(void)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
LuaObjcBridge::luaopen_luaoc(_state);
#endif
tolua_extensions_ccb_open(_state);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
tolua_web_socket_open(_state);
#endif
tolua_opengl_open(_state);
tolua_scroll_view_open(_state);
tolua_script_handler_mgr_open(_state);
// add cocos2dx loader
addLuaLoader(cocos2dx_lua_loader);

View File

@ -1 +1 @@
9fac9e19f8a57d40eb90b02c0be6e9f8e20e0d22
31f6e535b10b0e282216d54533c9cae806c34d8e

View File

@ -9,6 +9,12 @@ extern "C" {
}
#endif
#include "base_nodes/CCNode.h"
class GLNode:public cocos2d::Node
{
virtual void draw();
};
TOLUA_API int tolua_opengl_open(lua_State* tolua_S);

View File

@ -14,6 +14,9 @@ extern "C" {
#include "CCLuaStack.h"
#include "CCLuaValue.h"
#include "CCLuaEngine.h"
#include "Lua_web_socket.h"
#include "LuaOpengl.h"
#include "LuaScrollView.h"
using namespace cocos2d;
using namespace cocos2d::extension;
@ -467,7 +470,7 @@ int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S)
{
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
int controlevent = ((ControlEvent) (int) tolua_tonumber(tolua_S,3,0));
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,3,0);
for (int i = 0; i < kControlEventTotalNumber; i++)
{
if ((controlevent & (1 << i)))
@ -499,8 +502,16 @@ int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S)
#endif
{
Control* control = (Control*) tolua_tousertype(tolua_S,1,0);
int handlerEvent = (int)tolua_tonumber(tolua_S,2,0);
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)control,handlerEvent);
ControlEvent controlevent = (ControlEvent)tolua_tonumber(tolua_S,2,0);
for (int i = 0; i < kControlEventTotalNumber; i++)
{
if ((controlevent & (1 << i)))
{
int handlerevent = ScriptHandlerMgr::kControlTouchDownHandler + i;
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)control, handlerevent);
break;
}
}
}
return 0;
#ifndef TOLUA_RELEASE
@ -510,6 +521,163 @@ tolua_lerror:
#endif
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
int handler = ( toluafix_ref_function(tolua_S,2,0));
ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType)((int)tolua_tonumber(tolua_S,3,0) + ScriptHandlerMgr::kWebSocketScriptHandlerOpen);
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType)((int)tolua_tonumber(tolua_S,2,0) + ScriptHandlerMgr::kWebSocketScriptHandlerOpen);
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
return 0;
#endif
}
#endif
int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"GLNode",0,&tolua_err) ||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err)) ||
!tolua_isnoobj(tolua_S,3,&tolua_err))
goto tolua_lerror;
else
#endif
{
GLNode* glNode = (GLNode*) tolua_tousertype(tolua_S,1,0);
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)glNode, handler, ScriptHandlerMgr::kGLNodeDrawHandler);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptDrawHandler'.",&tolua_err);
return 0;
#endif
}
int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"GLNode",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err))
goto tolua_lerror;
else
#endif
{
GLNode* glNode = (GLNode*)tolua_tousertype(tolua_S,1,0);
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)glNode,ScriptHandlerMgr::kGLNodeDrawHandler);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'unregisterScriptDrawHandler'.",&tolua_err);
return 0;
#endif
}
int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0);
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0));
ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,3,0) + ScriptHandlerMgr::kScrollViewScrollHandler);
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, handlerType);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0);
ScriptHandlerMgr::HandlerEventType handlerType = (ScriptHandlerMgr::HandlerEventType) ((int)tolua_tonumber(tolua_S,2,0) + ScriptHandlerMgr::kScrollViewScrollHandler);
ScriptHandlerMgr::getInstance()->removeObjectHandler((void*)self, handlerType);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
return 0;
#endif
}
static void tolua_reg_script_handler_mgr_type(lua_State* tolua_S)
{
tolua_usertype(tolua_S, "CCCallFunc");
@ -603,6 +771,13 @@ TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S)
tolua_constant(tolua_S,"kControlTouchUpOutsideHandler",ScriptHandlerMgr::kControlTouchUpOutsideHandler);
tolua_constant(tolua_S,"kControlTouchCancelHandler",ScriptHandlerMgr::kControlTouchCancelHandler);
tolua_constant(tolua_S,"kControlValueChangedHandler",ScriptHandlerMgr::kControlValueChangedHandler);
tolua_constant(tolua_S,"kWebSocketScriptHandlerOpen",ScriptHandlerMgr::kWebSocketScriptHandlerOpen);
tolua_constant(tolua_S,"kWebSocketScriptHandlerMessage",ScriptHandlerMgr::kWebSocketScriptHandlerMessage);
tolua_constant(tolua_S,"kWebSocketScriptHandlerClose",ScriptHandlerMgr::kWebSocketScriptHandlerClose);
tolua_constant(tolua_S,"kWebSocketScriptHandlerError",ScriptHandlerMgr::kWebSocketScriptHandlerError);
tolua_constant(tolua_S,"kGLNodeDrawHandler",ScriptHandlerMgr::kGLNodeDrawHandler);
tolua_constant(tolua_S,"kScrollViewScrollHandler",ScriptHandlerMgr::kScrollViewScrollHandler);
tolua_constant(tolua_S,"kScrollViewZoomHandler",ScriptHandlerMgr::kScrollViewZoomHandler);
tolua_function(tolua_S, "getInstance", tolua_Cocos2d_ScriptHandlerMgr_getInstance00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);

View File

@ -90,6 +90,16 @@ public:
kControlTouchUpOutsideHandler,
kControlTouchCancelHandler,
kControlValueChangedHandler,
kWebSocketScriptHandlerOpen,
kWebSocketScriptHandlerMessage,
kWebSocketScriptHandlerClose,
kWebSocketScriptHandlerError,
kGLNodeDrawHandler,
kScrollViewScrollHandler,
kScrollViewZoomHandler,
};
@ -119,6 +129,17 @@ TOLUA_API int tolua_Cocos2d_unregisterScriptAccelerateHandler00(lua_State* tolua
TOLUA_API int tolua_Cocos2d_registerControlEventHandler00(lua_State* tolua_S);
TOLUA_API int tolua_Cocos2d_unregisterControlEventHandler00(lua_State* tolua_S);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
TOLUA_API int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S);
TOLUA_API int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S);
#endif
TOLUA_API int tolua_Cocos2d_GLNode_registerScriptDrawHandler00(lua_State* tolua_S);
TOLUA_API int tolua_Cocos2d_GLNode_unregisterScriptDrawHandler00(lua_State* tolua_S);
TOLUA_API int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S);
TOLUA_API int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S);
TOLUA_API int tolua_script_handler_mgr_open(lua_State* tolua_S);
#endif //__LUA_SCRIPT_HANDLER_MGR_H__

View File

@ -14,87 +14,47 @@ extern "C" {
#include "CCLuaStack.h"
#include "CCLuaValue.h"
#include "CCLuaEngine.h"
#include "LuaScriptHandlerMgr.h"
using namespace cocos2d;
using namespace cocos2d::extension;
class LuaScrollView:public ScrollView,public ScrollViewDelegate
LuaScrollView::~LuaScrollView()
{
public:
virtual ~LuaScrollView()
{
unregisterScriptHandler(LuaScrollView::kScrollViewScriptScroll);
unregisterScriptHandler(LuaScrollView::kScrollViewScriptZoom);
}
}
virtual void scrollViewDidScroll(ScrollView* view)
void LuaScrollView::scrollViewDidScroll(ScrollView* view)
{
LuaScrollView* luaView = dynamic_cast<LuaScrollView*>(view);
if (NULL != luaView)
{
LuaScrollView* luaView = dynamic_cast<LuaScrollView*>(view);
if (NULL != luaView)
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)luaView, ScriptHandlerMgr::kScrollViewScrollHandler);
if (0 != handler)
{
int nHandler = luaView->getScriptHandler(LuaScrollView::kScrollViewScriptScroll);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
CommonScriptData data(handler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
}
virtual void scrollViewDidZoom(ScrollView* view)
void LuaScrollView::scrollViewDidZoom(ScrollView* view)
{
LuaScrollView* luaView = dynamic_cast<LuaScrollView*>(view);
if (NULL != luaView)
{
LuaScrollView* luaView = dynamic_cast<LuaScrollView*>(view);
if (NULL != luaView)
int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)luaView, ScriptHandlerMgr::kScrollViewZoomHandler);
if (0 != handler)
{
int nHandler = luaView->getScriptHandler(LuaScrollView::kScrollViewScriptZoom);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
CommonScriptData data(handler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
void initLuaScrollView()
{
_mapScriptHandler.clear();
}
enum ScrollViewScriptHandlerType
{
kScrollViewScriptScroll = 0,
kScrollViewScriptZoom,
};
void registerScriptHandler(int nFunID,ScrollViewScriptHandlerType scriptHandlerType)
{
unregisterScriptHandler(scriptHandlerType);
_mapScriptHandler[scriptHandlerType] = nFunID;
}
void unregisterScriptHandler(ScrollViewScriptHandlerType scriptHandlerType)
{
std::map<int,int>::iterator Iter = _mapScriptHandler.find(scriptHandlerType);
if (_mapScriptHandler.end() != Iter)
{
_mapScriptHandler.erase(Iter);
}
}
int getScriptHandler(ScrollViewScriptHandlerType scriptHandlerType)
{
std::map<int,int>::iterator Iter = _mapScriptHandler.find(scriptHandlerType);
if (_mapScriptHandler.end() != Iter)
return Iter->second;
return 0;
}
private:
std::map<int,int> _mapScriptHandler;
};
}
#ifdef __cplusplus
static int tolua_collect_ScrollView (lua_State* tolua_S)
@ -223,7 +183,6 @@ static int tolua_Cocos2d_ScrollView_create00(lua_State* tolua_S)
LuaScrollView* tolua_ret = new LuaScrollView();
if (NULL != tolua_ret && tolua_ret->initWithViewSize(size,container) )
{
tolua_ret->initLuaScrollView();
tolua_ret->autorelease();
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
@ -260,7 +219,6 @@ static int tolua_Cocos2d_ScrollView_create01(lua_State* tolua_S)
LuaScrollView* tolua_ret = new LuaScrollView();
if (NULL != tolua_ret && tolua_ret->init() )
{
tolua_ret->initLuaScrollView();
tolua_ret->autorelease();
int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
@ -1597,68 +1555,6 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: registerScriptHandler of class ScrollView */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_ScrollView_registerScriptHandler00
static int tolua_Cocos2d_ScrollView_registerScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
int nFunID = ( toluafix_ref_function(tolua_S,2,0));
LuaScrollView::ScrollViewScriptHandlerType handlerType = ((LuaScrollView::ScrollViewScriptHandlerType) (int) tolua_tonumber(tolua_S,3,0));
self->registerScriptHandler(nFunID, handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: unregisterScriptHandler of class ScrollView */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_ScrollView_unregisterScriptHandler00
static int tolua_Cocos2d_ScrollView_unregisterScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCScrollView",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaScrollView* self = (LuaScrollView*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
LuaScrollView::ScrollViewScriptHandlerType handlerType = ((LuaScrollView::ScrollViewScriptHandlerType) (int) tolua_tonumber(tolua_S,2,0));
self->unregisterScriptHandler(handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S)
{
@ -1723,8 +1619,6 @@ TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S)
tolua_function(tolua_S,"setZoomScale",tolua_Cocos2d_ScrollView_setZoomScale00);
tolua_function(tolua_S,"setZoomScale",tolua_Cocos2d_ScrollView_setZoomScale01);
tolua_function(tolua_S, "setDelegate", tolua_Cocos2d_ScrollView_setDelegate00);
tolua_function(tolua_S, "registerScriptHandler", tolua_Cocos2d_ScrollView_registerScriptHandler00);
tolua_function(tolua_S, "unregisterScriptHandler", tolua_Cocos2d_ScrollView_unregisterScriptHandler00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;

View File

@ -8,6 +8,21 @@ extern "C" {
#ifdef __cplusplus
}
#endif
#include "GUI/CCScrollView/CCScrollView.h"
class LuaScrollView:public cocos2d::extension::ScrollView,public cocos2d::extension::ScrollViewDelegate
{
public:
virtual ~LuaScrollView();
virtual void scrollViewDidScroll(ScrollView* view);
virtual void scrollViewDidZoom(ScrollView* view);
enum ScrollViewScriptHandlerType
{
kScrollViewScriptScroll = 0,
kScrollViewScriptZoom,
};
};
TOLUA_API int tolua_scroll_view_open(lua_State* tolua_S);

View File

@ -1,3 +1,6 @@
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#ifdef __cplusplus
extern "C" {
#endif
@ -10,10 +13,10 @@ extern "C" {
#include <string>
#include "Lua_web_socket.h"
#include "cocos2d.h"
#include "WebSocket.h"
#include "CCLuaStack.h"
#include "CCLuaValue.h"
#include "CCLuaEngine.h"
#include "LuaScriptHandlerMgr.h"
using namespace cocos2d;
using namespace cocos2d::extension;
@ -52,131 +55,77 @@ static int SendBinaryMessageToLua(int nHandler,const unsigned char* pTable,int n
return nRet;
}
class LuaWebSocket: public WebSocket,public WebSocket::Delegate
LuaWebSocket::~LuaWebSocket()
{
public:
virtual ~LuaWebSocket()
{
this->unregisterScriptHandler(kWebSocketScriptHandlerOpen);
this->unregisterScriptHandler(kWebSocketScriptHandlerMessage);
this->unregisterScriptHandler(kWebSocketScriptHandlerClose);
this->unregisterScriptHandler(kWebSocketScriptHandlerError);
}
/*
* @brief delegate event enum,for lua register handler
*/
enum WebSocketScriptHandlerType
{
kWebSocketScriptHandlerOpen = 0,
kWebSocketScriptHandlerMessage,
kWebSocketScriptHandlerClose,
kWebSocketScriptHandlerError,
};
/**
* @brief Add Handler of DelegateEvent
*/
void registerScriptHandler(int nFunID,WebSocketScriptHandlerType scriptHandlerType)
{
this->unregisterScriptHandler(scriptHandlerType);
_mapScriptHandler[scriptHandlerType] = nFunID;
}
/**
* @brief Remove Handler of DelegateEvent
*/
void unregisterScriptHandler(WebSocketScriptHandlerType scriptHandlerType)
{
std::map<int,int>::iterator Iter = _mapScriptHandler.find(scriptHandlerType);
if (_mapScriptHandler.end() != Iter)
{
_mapScriptHandler.erase(Iter);
ScriptHandlerMgr::getInstance()->removeObjectAllHandlers((void*)this);
}
void LuaWebSocket::onOpen(WebSocket* ws)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerOpen);
if (0 != nHandler) {
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
/**
* @brief Get Handler By DelegateEvent Type
*/
int getScriptHandler(WebSocketScriptHandlerType scriptHandlerType)
{
std::map<int,int>::iterator Iter = _mapScriptHandler.find(scriptHandlerType);
if (_mapScriptHandler.end() != Iter)
return Iter->second;
return 0;
}
}
void InitScriptHandleMap()
{
_mapScriptHandler.clear();
}
virtual void onOpen(WebSocket* ws)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerOpen);
void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
if (data.isBinary) {
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerMessage);
if (0 != nHandler) {
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len);
}
}
}
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
if (data.isBinary) {
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage);
if (0 != nHandler) {
SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len);
}
}
else{
else{
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage);
if (0 != nHandler) {
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerMessage);
if (0 != nHandler) {
CommonScriptData commonData(nHandler,data.bytes);
ScriptEvent event(kCommonEvent,(void*)&commonData);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
}
}
}
virtual void onClose(WebSocket* ws)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerClose);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
void LuaWebSocket::onClose(WebSocket* ws)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::kWebSocketScriptHandlerClose);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
}
virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerError);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
void LuaWebSocket::onError(WebSocket* ws, const WebSocket::ErrorCode& error)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
int nHandler = 0;//luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerError);
if (0 != nHandler)
{
CommonScriptData data(nHandler,"");
ScriptEvent event(kCommonEvent,(void*)&data);
ScriptEngineManager::sharedManager()->getScriptEngine()->sendEvent(&event);
}
}
}
private:
std::map<int,int> _mapScriptHandler;
};
#ifdef __cplusplus
static int tolua_collect_WebSocket (lua_State* tolua_S)
@ -388,68 +337,6 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: addHandlerOfDelegateEvent of class WebSocket */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_registerScriptHandler00
static int tolua_Cocos2d_WebSocket_registerScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
int nFunID = ( toluafix_ref_function(tolua_S,2,0));
LuaWebSocket::WebSocketScriptHandlerType handlerType = ((LuaWebSocket::WebSocketScriptHandlerType) (int) tolua_tonumber(tolua_S,3,0));
self->registerScriptHandler(nFunID, handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: removeHandlerOfDelegateEvent of class WebSocket */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_unregisterScriptHandler00
static int tolua_Cocos2d_WebSocket_unregisterScriptHandler00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"WebSocket",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
LuaWebSocket* self = (LuaWebSocket*) tolua_tousertype(tolua_S,1,0);
if (NULL != self ) {
LuaWebSocket::WebSocketScriptHandlerType handlerType = ((LuaWebSocket::WebSocketScriptHandlerType) (int) tolua_tonumber(tolua_S,2,0));
self->unregisterScriptHandler(handlerType);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'unregisterScriptHandler'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: sendBinaryMsg of class WebSocket */
#ifndef TOLUA_DISABLE_tolua_Cocos2d_WebSocket_sendBinaryMsg00
static int tolua_Cocos2d_WebSocket_sendBinaryMsg00(lua_State* tolua_S)
@ -503,6 +390,7 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){
tolua_constant(tolua_S,"kWebSocketScriptHandlerMessage",LuaWebSocket::kWebSocketScriptHandlerMessage);
tolua_constant(tolua_S,"kWebSocketScriptHandlerClose",LuaWebSocket::kWebSocketScriptHandlerClose);
tolua_constant(tolua_S,"kWebSocketScriptHandlerError",LuaWebSocket::kWebSocketScriptHandlerError);
#ifdef __cplusplus
tolua_cclass(tolua_S,"WebSocket","WebSocket","",tolua_collect_WebSocket);
#else
@ -515,10 +403,10 @@ TOLUA_API int tolua_web_socket_open(lua_State* tolua_S){
tolua_function(tolua_S, "getReadyState", tolua_Cocos2d_WebSocket_getReadyState00);
tolua_function(tolua_S, "sendTextMsg", tolua_Cocos2d_WebSocket_sendTextMsg00);
tolua_function(tolua_S, "close", tolua_Cocos2d_WebSocket_close00);
tolua_function(tolua_S, "registerScriptHandler", tolua_Cocos2d_WebSocket_registerScriptHandler00);
tolua_function(tolua_S, "unregisterScriptHandler", tolua_Cocos2d_WebSocket_unregisterScriptHandler00);
tolua_function(tolua_S, "sendBinaryMsg", tolua_Cocos2d_WebSocket_sendBinaryMsg00);
tolua_endmodule(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
#endif//(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ...

View File

@ -1,6 +1,8 @@
#ifndef __LUA_WEB_SOCKET_H__
#define __LUA_WEB_SOCKET_H__
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#ifdef __cplusplus
extern "C" {
#endif
@ -9,6 +11,27 @@ extern "C" {
}
#endif
#include "network/WebSocket.h"
class LuaWebSocket: public cocos2d::extension::WebSocket,public cocos2d::extension::WebSocket::Delegate
{
public:
virtual ~LuaWebSocket();
virtual void onOpen(WebSocket* ws);
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data);
virtual void onClose(WebSocket* ws);
virtual void onError(WebSocket* ws, const WebSocket::ErrorCode& error);
enum WebSocketScriptHandlerType
{
kWebSocketScriptHandlerOpen,
kWebSocketScriptHandlerMessage,
kWebSocketScriptHandlerClose,
kWebSocketScriptHandlerError,
};
};
TOLUA_API int tolua_web_socket_open(lua_State* tolua_S);
#endif //(CC_TARGET_PLATFORM == CC_PLATFORM_IOS ...
#endif //__LUA_WEB_SOCKET_H__

View File

@ -30,18 +30,15 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
AppDelegate *pAppDelegate = new AppDelegate();
Application::getInstance()->run();
}
/*
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();
}
*/
}
}

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

View File

@ -32,10 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::getInstance()->reloadDefaultShaders();
ccDrawInit();
TextureCache::reloadAllTextures();
NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::getInstance()->setGLDefaultValues();

@ -1 +1 @@
Subproject commit 6612820da6286ffb45ddaec16b75f1624624b88c
Subproject commit 69bd274bd551d22e198afa5fca782fb520dcfad7

View File

@ -43,7 +43,7 @@ skip = Node::[^setPosition$ getGrid setGLServerState description getUserObject .
ParticleBatchNode::[getBlendFunc setBlendFunc],
LayerColor::[getBlendFunc setBlendFunc],
ParticleSystem::[getBlendFunc setBlendFunc],
DrawNode::[getBlendFunc setBlendFunc drawPolygon],
DrawNode::[getBlendFunc setBlendFunc drawPolygon listenBackToForeground],
Director::[getAccelerometer (g|s)et.*Dispatcher getOpenGLView getProjection getClassTypeInfo],
Layer.*::[didAccelerate (g|s)etBlendFunc keyPressed keyReleased],
Menu.*::[.*Target getSubItems create initWithItems alignItemsInRows alignItemsInColumns],
@ -113,7 +113,7 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames sp
LayerGradient::[initWithColor=init],
LayerColor::[initWithColor=init],
GLProgram::[fragmentShaderLog=getFragmentShaderLog initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init programLog=getProgramLog setUniformLocationWith1i=setUniformLocationI32 vertexShaderLog=getVertexShaderLog],
Node::[boundingBox=getBoundingBox removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
LabelAtlas::[create=_create],
TMXLayer::[tileAt=getTileAt tileGIDAt=getTileGIDAt propertyNamed=getProperty positionAt=getPositionAt],
TileMapAtlas::[tileAt=getTileAt],