issue #2377:Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into ScriptHandlerMgr

This commit is contained in:
samuele3hu 2013-07-16 12:47:40 +08:00
commit 1761669832
210 changed files with 2151 additions and 779 deletions

View File

@ -514,9 +514,14 @@ Developers:
hannon235 (Chris)
Fixing a bug that the submenu of ExtensionTest in TestCpp can't scroll.
Implements a socket.io client extension and adds a test case.
pktangyue
Fixing a bug that CCScale9Sprite::setInsetLeft/XXX can't work for rotated sprite frame.
Fixing a bug that Color and Opacity of Scale9Sprite will not be changed when it's added to NodeRGBA and run with FadeIn/Out actions.
jllust
Fixing a bug that CCLabelBMFont crashes in glDrawElements of CCTextureAtlas::drawNumberOfQuads sometimes.
Retired Core Developers:
WenSheng Yang
@ -529,6 +534,9 @@ Retired Core Developers:
RongHong Huang (flyingpaper)
Author of cocos2d-xna and spent all his time on wp7.
michaelcontento
[Android] use onWindowFocusChanged(bool) instead of onResume()/onPause()
Cocos2d-x can not grow so fast without the active community.

View File

@ -1 +1 @@
52abc5a83d3eb466ded1fe2459f4d7185d50aea0
1ab0fd6fdad74af8ce054c089d8571a05a7a04d8

View File

@ -113,7 +113,6 @@ sprite_nodes/CCSpriteFrameCache.cpp \
support/ccUTF8.cpp \
support/CCNotificationCenter.cpp \
support/CCProfiling.cpp \
support/CCPointExtension.cpp \
support/TransformUtils.cpp \
support/user_default/CCUserDefaultAndroid.cpp \
support/base64.cpp \

View File

@ -38,7 +38,6 @@ THE SOFTWARE.
#include "CCScheduler.h"
#include "ccMacros.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "support/CCPointExtension.h"
#include "support/CCNotificationCenter.h"
#include "layers_scenes_transitions_nodes/CCTransition.h"
#include "textures/CCTextureCache.h"
@ -1058,7 +1057,7 @@ void DisplayLinkDirector::startAnimation(void)
_invalid = false;
#ifndef EMSCRIPTEN
Application::sharedApplication()->setAnimationInterval(_animationInterval);
Application::getInstance()->setAnimationInterval(_animationInterval);
#endif // EMSCRIPTEN
}

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#include "CCAction.h"
#include "CCActionInterval.h"
#include "base_nodes/CCNode.h"
#include "support/CCPointExtension.h"
#include "CCDirector.h"
NS_CC_BEGIN

View File

@ -33,7 +33,6 @@
* Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada
*/
#include "ccMacros.h"
#include "support/CCPointExtension.h"
#include "CCActionCatmullRom.h"
using namespace std;

View File

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCActionGrid3D.h"
#include "support/CCPointExtension.h"
#include "CCDirector.h"
#include <stdlib.h>

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#include "CCActionInterval.h"
#include "sprite_nodes/CCSprite.h"
#include "base_nodes/CCNode.h"
#include "support/CCPointExtension.h"
#include "CCStdC.h"
#include "CCActionInstant.h"
#include <stdarg.h>

View File

@ -23,7 +23,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCActionPageTurn3D.h"
#include "support/CCPointExtension.h"
NS_CC_BEGIN

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
#include "CCActionTiledGrid.h"
#include "CCDirector.h"
#include "ccMacros.h"
#include "support/CCPointExtension.h"
#include "effects/CCGrid.h"
#include <stdlib.h>

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
****************************************************************************/
#include "cocoa/CCString.h"
#include "CCNode.h"
#include "support/CCPointExtension.h"
#include "support/TransformUtils.h"
#include "CCCamera.h"
#include "effects/CCGrid.h"

View File

@ -1401,7 +1401,7 @@ public:
virtual bool isCascadeColorEnabled() const;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
virtual void setOpacityModifyRGB(bool bValue) {};
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);};
virtual bool isOpacityModifyRGB() const { return false; };
protected:

View File

@ -334,31 +334,6 @@ public:
static const Rect ZERO;
};
CC_DEPRECATED_ATTRIBUTE inline Point CCPointMake(float x, float y)
{
return Point(x, y);
}
CC_DEPRECATED_ATTRIBUTE inline Size CCSizeMake(float width, float height)
{
return Size(width, height);
}
CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, float height)
{
return Rect(x, y, width, height);
}
CC_DEPRECATED_ATTRIBUTE const Point PointZero = Point::ZERO;
/* The "zero" size -- equivalent to Size(0, 0). */
CC_DEPRECATED_ATTRIBUTE const Size SizeZero = Size::ZERO;
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
CC_DEPRECATED_ATTRIBUTE const Rect RectZero = Rect::ZERO;
// end of data_structure group
/// @}

View File

@ -21,7 +21,6 @@
*/
#include "CCDrawNode.h"
#include "support/CCPointExtension.h"
#include "shaders/CCShaderCache.h"
#include "CCGL.h"
@ -116,6 +115,7 @@ DrawNode::~DrawNode()
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_vao);
ccGLBindVAO(0);
_vao = 0;
#endif
}

View File

@ -44,7 +44,6 @@ THE SOFTWARE.
#include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h"
#include "actions/CCActionCatmullRom.h"
#include "support/CCPointExtension.h"
#include <string.h>
#include <cmath>

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
#include "shaders/CCShaderCache.h"
#include "shaders/ccGLStateCache.h"
#include "CCGL.h"
#include "support/CCPointExtension.h"
#include "support/TransformUtils.h"
#include "kazmath/kazmath.h"
#include "kazmath/GL/matrix.h"

View File

@ -0,0 +1,463 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
/** Add deprecated global functions and variables here
*/
#ifndef __COCOS2D_CCDEPRECATED_H__
#define __COCOS2D_CCDEPRECATED_H__
#include <math.h>
#include "cocoa/CCGeometry.h"
#include "ccTypes.h"
NS_CC_BEGIN
/**
* @addtogroup data_structures
* @{
*/
/** Helper macro that creates a Point
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE inline Point ccp(float x, float y)
{
return Point(x, y);
}
/** Returns opposite of point.
@return Point
@since v0.7.2
@deprecated please use Point::-, for example: -v1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpNeg(const Point& v)
{
return -v;
}
/** Calculates sum of two points.
@return Point
@since v0.7.2
@deprecated please use Point::+, for example: v1 + v2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpAdd(const Point& v1, const Point& v2)
{
return v1 + v2;
}
/** Calculates difference of two points.
@return Point
@since v0.7.2
@deprecated please use Point::-, for example: v1 - v2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpSub(const Point& v1, const Point& v2)
{
return v1 - v2;
}
/** Returns point multiplied by given factor.
@return Point
@since v0.7.2
@deprecated please use Point::*, for example: v1 * v2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpMult(const Point& v, const float s)
{
return v * s;
}
/** Calculates midpoint between two points.
@return Point
@since v0.7.2
@deprecated please use it like (v1 + v2) / 2.0f
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpMidpoint(const Point& v1, const Point& v2)
{
return v1.getMidpoint(v2);
}
/** Calculates dot product of two points.
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float
ccpDot(const Point& v1, const Point& v2)
{
return v1.dot(v2);
}
/** Calculates cross product of two points.
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float
ccpCross(const Point& v1, const Point& v2)
{
return v1.cross(v2);
}
/** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpPerp(const Point& v)
{
return v.getPerp();
}
/** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpRPerp(const Point& v)
{
return v.getRPerp();
}
/** Calculates the projection of v1 over v2.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpProject(const Point& v1, const Point& v2)
{
return v1.project(v2);
}
/** Rotates two points.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpRotate(const Point& v1, const Point& v2)
{
return v1.rotate(v2);
}
/** Unrotates two points.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point
ccpUnrotate(const Point& v1, const Point& v2)
{
return v1.unrotate(v2);
}
/** Calculates the square length of a Point (not calling sqrt() )
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float
ccpLengthSQ(const Point& v)
{
return v.getLengthSq();
}
/** Calculates the square distance between two points (not calling sqrt() )
@return float
@since v1.1
*/
CC_DEPRECATED_ATTRIBUTE static inline float
ccpDistanceSQ(const Point p1, const Point p2)
{
return (p1 - p2).getLengthSq();
}
/** Calculates distance between point an origin
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float ccpLength(const Point& v)
{
return v.getLength();
}
/** Calculates the distance between two points
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float ccpDistance(const Point& v1, const Point& v2)
{
return v1.getDistance(v2);
}
/** Returns point multiplied to a length of 1.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpNormalize(const Point& v)
{
return v.normalize();
}
/** Converts radians to a normalized vector.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpForAngle(const float a)
{
return Point::forAngle(a);
}
/** Converts a vector to radians.
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE static inline float ccpToAngle(const Point& v)
{
return v.getAngle();
}
/** Clamp a point between from and to.
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpClamp(const Point& p, const Point& from, const Point& to)
{
return p.getClampPoint(from, to);
}
/** Quickly convert Size to a Point
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpFromSize(const Size& s)
{
return Point(s);
}
/** Run a math operation function on each point component
* absf, fllorf, ceilf, roundf
* any function that has the signature: float func(float);
* For example: let's try to take the floor of x,y
* ccpCompOp(p,floorf);
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpCompOp(const Point& p, float (*opFunc)(float))
{
return p.compOp(opFunc);
}
/** Linear Interpolation between two points a and b
@returns
alpha == 0 ? a
alpha == 1 ? b
otherwise a value between a..b
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpLerp(const Point& a, const Point& b, float alpha)
{
return a.lerp(b, alpha);
}
/** @returns if points have fuzzy equality which means equal with some degree of variance.
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline bool ccpFuzzyEqual(const Point& a, const Point& b, float variance)
{
return a.fuzzyEquals(b, variance);
}
/** Multiplies a and b components, a.x*b.x, a.y*b.y
@returns a component-wise multiplication
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpCompMult(const Point& a, const Point& b)
{
return Point(a.x * b.x, a.y * b.y);
}
/** @returns the signed angle in radians between two vector directions
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline float ccpAngleSigned(const Point& a, const Point& b)
{
return a.getAngle(b);
}
/** @returns the angle in radians between two vector directions
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline float ccpAngle(const Point& a, const Point& b)
{
return a.getAngle(b);
}
/** Rotates a point counter clockwise by the angle around a pivot
@param v is the point to rotate
@param pivot is the pivot, naturally
@param angle is the angle of rotation cw in radians
@returns the rotated point
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpRotateByAngle(const Point& v, const Point& pivot, float angle)
{
return v.rotateByAngle(pivot, angle);
}
/** A general line-line intersection test
@param p1
is the startpoint for the first line P1 = (p1 - p2)
@param p2
is the endpoint for the first line P1 = (p1 - p2)
@param p3
is the startpoint for the second line P2 = (p3 - p4)
@param p4
is the endpoint for the second line P2 = (p3 - p4)
@param s
is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1))
@param t
is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3))
@return bool
indicating successful intersection of a line
note that to truly test intersection for segments we have to make
sure that s & t lie within [0..1] and for rays, make sure s & t > 0
the hit point is p3 + t * (p4 - p3);
the hit point also is p1 + s * (p2 - p1);
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE static inline bool ccpLineIntersect(const Point& p1, const Point& p2,
const Point& p3, const Point& p4,
float *s, float *t)
{
return Point::isLineIntersect(p1, p2, p3, p4, s, t);
}
/*
ccpSegmentIntersect returns YES if Segment A-B intersects with segment C-D
@since v1.0.0
*/
CC_DEPRECATED_ATTRIBUTE static inline bool ccpSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D)
{
return Point::isSegmentIntersect(A, B, C, D);
}
/*
ccpIntersectPoint returns the intersection point of line A-B, C-D
@since v1.0.0
*/
CC_DEPRECATED_ATTRIBUTE static inline Point ccpIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D)
{
return Point::getIntersectPoint(A, B, C, D);
}
CC_DEPRECATED_ATTRIBUTE inline Point CCPointMake(float x, float y)
{
return Point(x, y);
}
CC_DEPRECATED_ATTRIBUTE inline Size CCSizeMake(float width, float height)
{
return Size(width, height);
}
CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, float height)
{
return Rect(x, y, width, height);
}
CC_DEPRECATED_ATTRIBUTE const Point PointZero = Point::ZERO;
/* The "zero" size -- equivalent to Size(0, 0). */
CC_DEPRECATED_ATTRIBUTE const Size SizeZero = Size::ZERO;
/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */
CC_DEPRECATED_ATTRIBUTE const Rect RectZero = Rect::ZERO;
CC_DEPRECATED_ATTRIBUTE const Color3B ccWHITE = Color3B::WHITE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccYELLOW = Color3B::YELLOW;
CC_DEPRECATED_ATTRIBUTE const Color3B ccGREEN = Color3B::GREEN;
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLUE = Color3B::BLUE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccRED = Color3B::RED;
CC_DEPRECATED_ATTRIBUTE const Color3B ccMAGENTA = Color3B::MAGENTA;
CC_DEPRECATED_ATTRIBUTE const Color3B ccBLACK = Color3B::BLACK;
CC_DEPRECATED_ATTRIBUTE const Color3B ccORANGE = Color3B::ORANGE;
CC_DEPRECATED_ATTRIBUTE const Color3B ccGRAY = Color3B::GRAY;
CC_DEPRECATED_ATTRIBUTE const BlendFunc kBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE;
CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b)
{
return Color3B(r, g, b);
}
CC_DEPRECATED_ATTRIBUTE static inline bool ccc3BEqual(const Color3B &col1, const Color3B &col2)
{
return col1.r == col2.r && col1.g == col2.g && col1.b == col2.b;
}
CC_DEPRECATED_ATTRIBUTE static inline Color4B
ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)
{
return Color4B(r, g, b, o);
}
CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc3B(Color3B c)
{
return Color4F(c.r/255.f, c.g/255.f, c.b/255.f, 1.f);
}
CC_DEPRECATED_ATTRIBUTE static inline Color4F
ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)
{
return Color4F(r, g, b, a);
}
CC_DEPRECATED_ATTRIBUTE static inline Color4F ccc4FFromccc4B(Color4B c)
{
return Color4F(c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f);
}
CC_DEPRECATED_ATTRIBUTE static inline Color4B ccc4BFromccc4F(Color4F c)
{
return Color4B((GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255));
}
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;
}
// end of data_structures group
/// @}
NS_CC_END
#endif // __COCOS2D_CCDEPRECATED_H__

View File

@ -85,6 +85,7 @@ THE SOFTWARE.
#include "ccConfig.h"
#include "ccMacros.h"
#include "ccTypes.h"
#include "CCDeprecated.h"
// kazmath
#include "kazmath/include/kazmath/kazmath.h"
@ -235,7 +236,6 @@ THE SOFTWARE.
// support
#include "support/ccUTF8.h"
#include "support/CCNotificationCenter.h"
#include "support/CCPointExtension.h"
#include "support/CCProfiling.h"
#include "support/user_default/CCUserDefault.h"
#include "support/CCVertex.h"

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "CCLabelAtlas.h"
#include "textures/CCTextureAtlas.h"
#include "textures/CCTextureCache.h"
#include "support/CCPointExtension.h"
#include "draw_nodes/CCDrawingPrimitives.h"
#include "ccConfig.h"
#include "shaders/CCShaderCache.h"

View File

@ -37,7 +37,6 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
#include "CCConfiguration.h"
#include "draw_nodes/CCDrawingPrimitives.h"
#include "sprite_nodes/CCSprite.h"
#include "support/CCPointExtension.h"
#include "platform/CCFileUtils.h"
#include "CCDirector.h"
#include "textures/CCTextureCache.h"

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "keypad_dispatcher/CCKeypadDispatcher.h"
#include "CCAccelerometer.h"
#include "CCDirector.h"
#include "support/CCPointExtension.h"
#include "script_support/CCScriptSupport.h"
#include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h"

View File

@ -188,7 +188,7 @@ public:
virtual bool isCascadeColorEnabled() const;
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
virtual void setOpacityModifyRGB(bool bValue) {}
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB() const { return false; }
protected:
GLubyte _displayedOpacity, _realOpacity;
@ -247,8 +247,6 @@ public:
/** BlendFunction. Conforms to BlendProtocol protocol */
CC_PROPERTY_PASS_BY_REF(BlendFunc, _blendFunc, BlendFunc)
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) const { return false;}
virtual void setColor(const Color3B &color);
virtual void setOpacity(GLubyte opacity);

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
****************************************************************************/
#include "CCScene.h"
#include "support/CCPointExtension.h"
#include "CCDirector.h"
NS_CC_BEGIN

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "CCTransition.h"
#include "CCCamera.h"
#include "support/CCPointExtension.h"
#include "CCDirector.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "actions/CCActionInterval.h"

View File

@ -32,7 +32,6 @@ THE SOFTWARE.
#include "CCLayer.h"
#include "actions/CCActionInstant.h"
#include "actions/CCActionProgressTimer.h"
#include "support/CCPointExtension.h"
NS_CC_BEGIN

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
#include "CCMenu.h"
#include "CCDirector.h"
#include "CCApplication.h"
#include "support/CCPointExtension.h"
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "touch_dispatcher/CCTouch.h"
#include "CCStdC.h"

View File

@ -25,7 +25,6 @@ THE SOFTWARE.
****************************************************************************/
#include "CCMenuItem.h"
#include "support/CCPointExtension.h"
#include "actions/CCActionInterval.h"
#include "sprite_nodes/CCSprite.h"
#include "label_nodes/CCLabelAtlas.h"

View File

@ -91,9 +91,6 @@ public:
virtual void setEnabled(bool value);
virtual bool isSelected() const;
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) const { return false;}
/** set the target/selector of the menu item*/
CC_DEPRECATED_ATTRIBUTE void setTarget(Object *rec, SEL_MenuHandler selector);
/** set the callback to the menu item */
@ -284,8 +281,6 @@ public:
virtual void unselected();
virtual void setEnabled(bool bEnabled);
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) const { return false;}
protected:
virtual void updateImagesVisibility();
};
@ -390,9 +385,6 @@ public:
virtual void selected();
virtual void unselected();
virtual void setEnabled(bool var);
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) const { return false;}
};

View File

@ -30,7 +30,6 @@
#include "shaders/CCGLProgram.h"
#include "shaders/CCShaderCache.h"
#include "CCDirector.h"
#include "support/CCPointExtension.h"
#include "draw_nodes/CCDrawingPrimitives.h"
NS_CC_BEGIN

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "support/CCVertex.h"
#include "support/CCPointExtension.h"
NS_CC_BEGIN

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "textures/CCTextureCache.h"
#include "support/CCPointExtension.h"
#include "shaders/CCGLProgram.h"
#include "shaders/CCShaderCache.h"
#include "shaders/ccGLStateCache.h"
@ -149,14 +148,26 @@ void ProgressTimer::setReverseProgress(bool reverse)
}
}
void ProgressTimer::setOpacityModifyRGB(bool bValue)
void ProgressTimer::setColor(const Color3B& color)
{
CC_UNUSED_PARAM(bValue);
_sprite->setColor(color);
updateColor();
}
bool ProgressTimer::isOpacityModifyRGB(void) const
const Color3B& ProgressTimer::getColor() const
{
return false;
return _sprite->getColor();
}
void ProgressTimer::setOpacity(GLubyte opacity)
{
_sprite->setOpacity(opacity);
updateColor();
}
GLubyte ProgressTimer::getOpacity() const
{
return _sprite->getOpacity();
}
// Interval

View File

@ -82,8 +82,10 @@ public:
virtual void draw(void);
void setAnchorPoint(const Point& anchorPoint);
virtual void setOpacityModifyRGB(bool bValue);
virtual bool isOpacityModifyRGB(void) const;
virtual void setColor(const Color3B& color);
virtual const Color3B& getColor() const;
virtual GLubyte getOpacity() const;
virtual void setOpacity(GLubyte opacity);
inline bool isReverseDirection() { return _reverseDirection; };
inline void setReverseDirection(bool value) { _reverseDirection = value; };

View File

@ -33,7 +33,6 @@
#include "ccConfig.h"
#include "ccMacros.h"
#include "effects/CCGrid.h"
#include "support/CCPointExtension.h"
#include "CCParticleSystem.h"
#include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h"

View File

@ -26,7 +26,6 @@ THE SOFTWARE.
#include "CCParticleExamples.h"
#include "CCDirector.h"
#include "textures/CCTextureCache.h"
#include "support/CCPointExtension.h"
#include "firePngData.h"
#include "platform/CCImage.h"

View File

@ -47,7 +47,6 @@ THE SOFTWARE.
#include "textures/CCTextureCache.h"
#include "textures/CCTextureAtlas.h"
#include "support/base64.h"
#include "support/CCPointExtension.h"
#include "platform/CCFileUtils.h"
#include "platform/CCImage.h"
#include "platform/platform.h"

View File

@ -96,6 +96,7 @@ ParticleSystemQuad::~ParticleSystemQuad()
glDeleteBuffers(2, &_buffersVBO[0]);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
ccGLBindVAO(0);
#endif
}
@ -470,6 +471,7 @@ void ParticleSystemQuad::setupVBOandVAO()
// clean VAO
glDeleteBuffers(2, &_buffersVBO[0]);
glDeleteVertexArrays(1, &_VAOname);
ccGLBindVAO(0);
glGenVertexArrays(1, &_VAOname);
ccGLBindVAO(_VAOname);
@ -593,6 +595,7 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
glDeleteBuffers(2, &_buffersVBO[0]);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
ccGLBindVAO(0);
#endif
}
}

View File

@ -55,12 +55,18 @@ void Application::setAnimationInterval(double interval)
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CCAssert(sm_pSharedApplication, "");
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
std::string languageName = getCurrentLanguageJNI();

View File

@ -29,7 +29,10 @@ public:
@brief Get current application instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config

View File

@ -77,19 +77,15 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// ===========================================================
@Override
protected void onResume() {
super.onResume();
Cocos2dxHelper.onResume();
this.mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
super.onPause();
Cocos2dxHelper.onPause();
this.mGLSurfaceView.onPause();
public void onWindowFocusChanged(final boolean hasWindowFocus) {
super.onWindowFocusChanged(hasWindowFocus);
if (hasWindowFocus) {
Cocos2dxHelper.onResume();
this.mGLSurfaceView.onResume();
} else {
Cocos2dxHelper.onPause();
this.mGLSurfaceView.onPause();
}
}
@Override

View File

@ -15,14 +15,14 @@ extern "C" {
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() {
Application::sharedApplication()->applicationDidEnterBackground();
Application::getInstance()->applicationDidEnterBackground();
NotificationCenter::getInstance()->postNotification(EVENT_COME_TO_BACKGROUND, NULL);
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
if (Director::getInstance()->getOpenGLView()) {
Application::sharedApplication()->applicationWillEnterForeground();
Application::getInstance()->applicationWillEnterForeground();
}
}

View File

@ -101,12 +101,18 @@ TargetPlatform Application::getTargetPlatform()
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
ccLanguageType ret_language = kLanguageEnglish;

View File

@ -29,8 +29,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config
@return Current language config

View File

@ -625,7 +625,7 @@ bool EGLView::handleEvents()
case NAVIGATOR_WINDOW_INACTIVE:
if (_isWindowActive)
{
Application::sharedApplication()->applicationDidEnterBackground();
Application::getInstance()->applicationDidEnterBackground();
_isWindowActive = false;
}
break;
@ -633,7 +633,7 @@ bool EGLView::handleEvents()
case NAVIGATOR_WINDOW_ACTIVE:
if (!_isWindowActive)
{
Application::sharedApplication()->applicationWillEnterForeground();
Application::getInstance()->applicationWillEnterForeground();
_isWindowActive = true;
}
break;
@ -645,14 +645,14 @@ bool EGLView::handleEvents()
case NAVIGATOR_WINDOW_FULLSCREEN:
if (!_isWindowActive)
{
Application::sharedApplication()->applicationWillEnterForeground();
Application::getInstance()->applicationWillEnterForeground();
_isWindowActive = true;
}
break;
case NAVIGATOR_WINDOW_THUMBNAIL:
if (_isWindowActive)
{
Application::sharedApplication()->applicationDidEnterBackground();
Application::getInstance()->applicationDidEnterBackground();
_isWindowActive = false;
}
break;

View File

@ -93,12 +93,18 @@ TargetPlatform Application::getTargetPlatform()
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
return kLanguageEnglish;

View File

@ -29,8 +29,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config
@return Current language config

View File

@ -47,7 +47,10 @@ public:
@brief Get the current application instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Callback by Director for limit FPS.

View File

@ -63,12 +63,18 @@ void Application::setAnimationInterval(double interval)
// static member function
//////////////////////////////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
// get the current language and country config

View File

@ -92,12 +92,18 @@ TargetPlatform Application::getTargetPlatform()
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
char *pLanguageName = getenv("LANG");

View File

@ -36,8 +36,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/* override functions */
virtual ccLanguageType getCurrentLanguage();

View File

@ -56,8 +56,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config
@return Current language config

View File

@ -69,12 +69,18 @@ TargetPlatform Application::getTargetPlatform()
// static member function
//////////////////////////////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CCAssert(sm_pSharedApplication, "sm_pSharedApplication not set");
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
// get the current language and country config

View File

@ -130,12 +130,18 @@ void Application::ccAccelerationUpdate()
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication() // MH Cocos2dx Director class expects this to return a pointer and not a reference
Application* Application::getInstance() // MH Cocos2dx Director class expects this to return a pointer and not a reference
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication; // MH Cocos2dx Director class expects this to return a pointer and not a reference
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
int nLanguageIdx;

View File

@ -77,8 +77,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication(); // MH Cocos2dx Director class expects this to return a pointer and not a reference
static Application* getInstance(); // MH Cocos2dx Director class expects this to return a pointer and not a reference
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config
@return Current language config

View File

@ -95,12 +95,18 @@ TargetPlatform Application::getTargetPlatform()
return kTargetNaCl;
}
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
ccLanguageType ret = kLanguageEnglish;

View File

@ -52,8 +52,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/* override functions */
virtual ccLanguageType getCurrentLanguage();

View File

@ -72,12 +72,18 @@ long Application::getAnimationInterval()
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CCAssert(sm_pSharedApplication, "");
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
result r = E_SUCCESS;

View File

@ -57,8 +57,11 @@ public:
@brief Get current application instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/**
@brief Get current language config
@return Current language config

View File

@ -128,7 +128,7 @@ EGLView::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
{
return;
}
__pTimer->Start(Application::sharedApplication()->getAnimationInterval());
__pTimer->Start(Application::getInstance()->getAnimationInterval());
Director::getInstance()->mainLoop();
}

View File

@ -139,12 +139,12 @@ OspApplication::OnForeground(void)
if (timer != null)
{
timer->Start(cocos2d::Application::sharedApplication()->getAnimationInterval());
timer->Start(cocos2d::Application::getInstance()->getAnimationInterval());
}
if (Director::getInstance()->getOpenGLView())
{
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::getInstance()->applicationWillEnterForeground();
}
}
@ -158,7 +158,7 @@ OspApplication::OnBackground(void)
timer->Cancel();
}
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::getInstance()->applicationDidEnterBackground();
}
void

View File

@ -100,12 +100,18 @@ void Application::setAnimationInterval(double interval)
//////////////////////////////////////////////////////////////////////////
// static member function
//////////////////////////////////////////////////////////////////////////
Application* Application::sharedApplication()
Application* Application::getInstance()
{
CC_ASSERT(sm_pSharedApplication);
return sm_pSharedApplication;
}
// @deprecated Use getInstance() instead
Application* Application::sharedApplication()
{
return Application::getInstance();
}
ccLanguageType Application::getCurrentLanguage()
{
ccLanguageType ret = kLanguageEnglish;

View File

@ -25,8 +25,11 @@ public:
@brief Get current applicaiton instance.
@return Current application instance pointer.
*/
static Application* sharedApplication();
static Application* getInstance();
/** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication();
/* override functions */
virtual void setAnimationInterval(double interval);
virtual ccLanguageType getCurrentLanguage();

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "touch_dispatcher/CCTouchDispatcher.h"
#include "text_input_node/CCIMEDispatcher.h"
#include "keypad_dispatcher/CCKeypadDispatcher.h"
#include "support/CCPointExtension.h"
#include "CCApplication.h"
#ifdef CC_KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
@ -352,8 +351,8 @@ LRESULT EGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
Point pt(point.x, point.y);
pt.x /= _frameZoomFactor;
pt.y /= _frameZoomFactor;
Point tmp = ccp(pt.x, _screenSize.height - pt.y);
if (_viewPortRect.equals(RectZero) || _viewPortRect.containsPoint(tmp))
Point tmp = Point(pt.x, _screenSize.height - pt.y);
if (_viewPortRect.equals(Rect::ZERO) || _viewPortRect.containsPoint(tmp))
{
_captured = true;
SetCapture(_wnd);
@ -415,8 +414,8 @@ LRESULT EGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
input.y = TOUCH_COORD_TO_PIXEL(ti.y);
ScreenToClient(_wnd, &input);
Point pt(input.x, input.y);
Point tmp = ccp(pt.x, _screenSize.height - pt.y);
if (_viewPortRect.equals(RectZero) || _viewPortRect.containsPoint(tmp))
Point tmp = Point(pt.x, _screenSize.height - pt.y);
if (_viewPortRect.equals(Rect::ZERO) || _viewPortRect.containsPoint(tmp))
{
pt.x /= _frameZoomFactor;
pt.y /= _frameZoomFactor;
@ -444,10 +443,10 @@ LRESULT EGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
switch (wParam)
{
case SIZE_RESTORED:
Application::sharedApplication()->applicationWillEnterForeground();
Application::getInstance()->applicationWillEnterForeground();
break;
case SIZE_MINIMIZED:
Application::sharedApplication()->applicationDidEnterBackground();
Application::getInstance()->applicationDidEnterBackground();
break;
}
break;

View File

@ -82,7 +82,6 @@ SOURCES = ../actions/CCAction.cpp \
../sprite_nodes/CCSpriteFrame.cpp \
../sprite_nodes/CCSpriteFrameCache.cpp \
../support/ccUTF8.cpp \
../support/CCPointExtension.cpp \
../support/CCProfiling.cpp \
../support/user_default/CCUserDefault.cpp \
../support/TransformUtils.cpp \

View File

@ -76,7 +76,6 @@ SOURCES = ../actions/CCAction.cpp \
../sprite_nodes/CCSpriteFrame.cpp \
../sprite_nodes/CCSpriteFrameCache.cpp \
../support/tinyxml2/tinyxml2.cpp \
../support/CCPointExtension.cpp \
../support/CCProfiling.cpp \
../support/user_default/CCUserDefault.cpp \
../support/TransformUtils.cpp \

View File

@ -217,7 +217,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClCompile Include="..\sprite_nodes\CCSpriteFrameCache.cpp" />
<ClCompile Include="..\support\base64.cpp" />
<ClCompile Include="..\support\CCNotificationCenter.cpp" />
<ClCompile Include="..\support\CCPointExtension.cpp" />
<ClCompile Include="..\support\CCProfiling.cpp" />
<ClCompile Include="..\support\ccUTF8.cpp" />
<ClCompile Include="..\support\ccUtils.cpp" />
@ -308,6 +307,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClInclude Include="..\actions\CCActionTiledGrid.h" />
<ClInclude Include="..\actions\CCActionTween.h" />
<ClInclude Include="..\include\ccConfig.h" />
<ClInclude Include="..\include\CCDeprecated.h" />
<ClInclude Include="..\include\CCEventType.h" />
<ClInclude Include="..\include\ccMacros.h" />
<ClInclude Include="..\include\CCProtocols.h" />
@ -379,7 +379,6 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClInclude Include="..\sprite_nodes\CCSpriteFrameCache.h" />
<ClInclude Include="..\support\base64.h" />
<ClInclude Include="..\support\CCNotificationCenter.h" />
<ClInclude Include="..\support\CCPointExtension.h" />
<ClInclude Include="..\support\CCProfiling.h" />
<ClInclude Include="..\support\ccUTF8.h" />
<ClInclude Include="..\support\ccUtils.h" />

View File

@ -297,9 +297,6 @@
<ClCompile Include="..\support\CCNotificationCenter.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="..\support\CCPointExtension.cpp">
<Filter>support</Filter>
</ClCompile>
<ClCompile Include="..\support\CCProfiling.cpp">
<Filter>support</Filter>
</ClCompile>
@ -720,9 +717,6 @@
<ClInclude Include="..\support\CCNotificationCenter.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="..\support\CCPointExtension.h">
<Filter>support</Filter>
</ClInclude>
<ClInclude Include="..\support\CCProfiling.h">
<Filter>support</Filter>
</ClInclude>
@ -971,5 +965,8 @@
<ClInclude Include="..\keyboard_dispatcher\CCKeyboardDispatcher.h">
<Filter>keyboard_dispatcher</Filter>
</ClInclude>
<ClInclude Include="..\include\CCDeprecated.h">
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -37,7 +37,6 @@ THE SOFTWARE.
#include "shaders/ccGLStateCache.h"
#include "shaders/CCGLProgram.h"
#include "CCDirector.h"
#include "support/CCPointExtension.h"
#include "cocoa/CCGeometry.h"
#include "textures/CCTexture2D.h"
#include "cocoa/CCAffineTransform.h"

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "effects/CCGrid.h"
#include "draw_nodes/CCDrawingPrimitives.h"
#include "textures/CCTextureCache.h"
#include "support/CCPointExtension.h"
#include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h"
#include "shaders/ccGLStateCache.h"

View File

@ -1,128 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2007 Scott Lembcke
Copyright (c) 2010 Lam Pham
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCPointExtension.h"
#include "ccMacros.h" // FLT_EPSILON
#include <stdio.h>
NS_CC_BEGIN
#define kPointEpsilon FLT_EPSILON
float
ccpLength(const Point& v)
{
return v.getLength();
}
float
ccpDistance(const Point& v1, const Point& v2)
{
return v1.getDistance(v2);
}
Point
ccpNormalize(const Point& v)
{
return v.normalize();
}
Point
ccpForAngle(const float a)
{
return Point::forAngle(a);
}
float
ccpToAngle(const Point& v)
{
return v.getAngle();
}
Point ccpLerp(const Point& a, const Point& b, float alpha)
{
return a.lerp(b, alpha);
}
Point ccpClamp(const Point& p, const Point& min_inclusive, const Point& max_inclusive)
{
return p.getClampPoint(min_inclusive, max_inclusive);
}
Point ccpFromSize(const Size& s)
{
return Point(s);
}
Point ccpCompOp(const Point& p, float (*opFunc)(float))
{
return p.compOp(opFunc);
}
bool ccpFuzzyEqual(const Point& a, const Point& b, float var)
{
return a.fuzzyEquals(b, var);
}
Point ccpCompMult(const Point& a, const Point& b)
{
return Point(a.x * b.x, a.y * b.y);
}
float ccpAngleSigned(const Point& a, const Point& b)
{
return a.getAngle(b);
}
Point ccpRotateByAngle(const Point& v, const Point& pivot, float angle)
{
return v.rotateByAngle(pivot, angle);
}
bool ccpSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D)
{
return Point::isSegmentIntersect(A, B, C, D);
}
Point ccpIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D)
{
return Point::getIntersectPoint(A, B, C, D);
}
bool ccpLineIntersect(const Point& A, const Point& B,
const Point& C, const Point& D,
float *S, float *T)
{
return Point::isLineIntersect(A, B, C, D, S, T);
}
float ccpAngle(const Point& a, const Point& b)
{
return a.getAngle(b);
}
NS_CC_END

View File

@ -1,346 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2007 Scott Lembcke
Copyright (c) 2010 Lam Pham
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __SUPPORT_CGPOINTEXTENSION_H__
#define __SUPPORT_CGPOINTEXTENSION_H__
/**
@file
Point extensions based on Chipmunk's cpVect file.
These extensions work both with Point and cpVect.
The "ccp" prefix means: "CoCos2d Point"
Examples:
- ccpAdd( Point(1,1), Point(2,2) ); // preferred cocos2d way
- ccpAdd( Point(1,1), Point(2,2) ); // also ok but more verbose
- cpvadd( cpv(1,1), cpv(2,2) ); // way of the chipmunk
- ccpAdd( cpv(1,1), cpv(2,2) ); // mixing chipmunk and cocos2d (avoid)
- cpvadd( Point(1,1), Point(2,2) ); // mixing chipmunk and CG (avoid)
*/
#include "cocoa/CCGeometry.h"
#include <math.h>
NS_CC_BEGIN
/**
* @addtogroup data_structures
* @{
*/
/** Helper macro that creates a Point
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE inline Point ccp(float x, float y)
{
return Point(x, y);
}
/** Returns opposite of point.
@return Point
@since v0.7.2
@deprecated please use Point::-, for example: -v1
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpNeg(const Point& v)
{
return -v;
}
/** Calculates sum of two points.
@return Point
@since v0.7.2
@deprecated please use Point::+, for example: v1 + v2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpAdd(const Point& v1, const Point& v2)
{
return v1 + v2;
}
/** Calculates difference of two points.
@return Point
@since v0.7.2
@deprecated please use Point::-, for example: v1 - v2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpSub(const Point& v1, const Point& v2)
{
return v1 - v2;
}
/** Returns point multiplied by given factor.
@return Point
@since v0.7.2
@deprecated please use Point::*, for example: v1 * v2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpMult(const Point& v, const float s)
{
return v * s;
}
/** Calculates midpoint between two points.
@return Point
@since v0.7.2
@deprecated please use it like (v1 + v2) / 2.0f
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpMidpoint(const Point& v1, const Point& v2)
{
return v1.getMidpoint(v2);
}
/** Calculates dot product of two points.
@return float
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE float
ccpDot(const Point& v1, const Point& v2)
{
return v1.dot(v2);
}
/** Calculates cross product of two points.
@return float
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE float
ccpCross(const Point& v1, const Point& v2)
{
return v1.cross(v2);
}
/** Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0
@return Point
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpPerp(const Point& v)
{
return v.getPerp();
}
/** Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0
@return Point
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpRPerp(const Point& v)
{
return v.getRPerp();
}
/** Calculates the projection of v1 over v2.
@return Point
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpProject(const Point& v1, const Point& v2)
{
return v1.project(v2);
}
/** Rotates two points.
@return Point
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpRotate(const Point& v1, const Point& v2)
{
return v1.rotate(v2);
}
/** Unrotates two points.
@return Point
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE Point
ccpUnrotate(const Point& v1, const Point& v2)
{
return v1.unrotate(v2);
}
/** Calculates the square length of a Point (not calling sqrt() )
@return float
@since v0.7.2
*/
static inline CC_DEPRECATED_ATTRIBUTE float
ccpLengthSQ(const Point& v)
{
return v.getLengthSq();
}
/** Calculates the square distance between two points (not calling sqrt() )
@return float
@since v1.1
*/
static inline CC_DEPRECATED_ATTRIBUTE float
ccpDistanceSQ(const Point p1, const Point p2)
{
return (p1 - p2).getLengthSq();
}
/** Calculates distance between point an origin
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE float CC_DLL ccpLength(const Point& v);
/** Calculates the distance between two points
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE float CC_DLL ccpDistance(const Point& v1, const Point& v2);
/** Returns point multiplied to a length of 1.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpNormalize(const Point& v);
/** Converts radians to a normalized vector.
@return Point
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpForAngle(const float a);
/** Converts a vector to radians.
@return float
@since v0.7.2
*/
CC_DEPRECATED_ATTRIBUTE float CC_DLL ccpToAngle(const Point& v);
/** Clamp a point between from and to.
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpClamp(const Point& p, const Point& from, const Point& to);
/** Quickly convert Size to a Point
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpFromSize(const Size& s);
/** Run a math operation function on each point component
* absf, fllorf, ceilf, roundf
* any function that has the signature: float func(float);
* For example: let's try to take the floor of x,y
* ccpCompOp(p,floorf);
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpCompOp(const Point& p, float (*opFunc)(float));
/** Linear Interpolation between two points a and b
@returns
alpha == 0 ? a
alpha == 1 ? b
otherwise a value between a..b
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpLerp(const Point& a, const Point& b, float alpha);
/** @returns if points have fuzzy equality which means equal with some degree of variance.
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE bool CC_DLL ccpFuzzyEqual(const Point& a, const Point& b, float variance);
/** Multiplies a and b components, a.x*b.x, a.y*b.y
@returns a component-wise multiplication
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpCompMult(const Point& a, const Point& b);
/** @returns the signed angle in radians between two vector directions
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE float CC_DLL ccpAngleSigned(const Point& a, const Point& b);
/** @returns the angle in radians between two vector directions
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE float CC_DLL ccpAngle(const Point& a, const Point& b);
/** Rotates a point counter clockwise by the angle around a pivot
@param v is the point to rotate
@param pivot is the pivot, naturally
@param angle is the angle of rotation cw in radians
@returns the rotated point
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpRotateByAngle(const Point& v, const Point& pivot, float angle);
/** A general line-line intersection test
@param p1
is the startpoint for the first line P1 = (p1 - p2)
@param p2
is the endpoint for the first line P1 = (p1 - p2)
@param p3
is the startpoint for the second line P2 = (p3 - p4)
@param p4
is the endpoint for the second line P2 = (p3 - p4)
@param s
is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1))
@param t
is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3))
@return bool
indicating successful intersection of a line
note that to truly test intersection for segments we have to make
sure that s & t lie within [0..1] and for rays, make sure s & t > 0
the hit point is p3 + t * (p4 - p3);
the hit point also is p1 + s * (p2 - p1);
@since v0.99.1
*/
CC_DEPRECATED_ATTRIBUTE bool CC_DLL ccpLineIntersect(const Point& p1, const Point& p2,
const Point& p3, const Point& p4,
float *s, float *t);
/*
ccpSegmentIntersect returns YES if Segment A-B intersects with segment C-D
@since v1.0.0
*/
CC_DEPRECATED_ATTRIBUTE bool CC_DLL ccpSegmentIntersect(const Point& A, const Point& B, const Point& C, const Point& D);
/*
ccpIntersectPoint returns the intersection point of line A-B, C-D
@since v1.0.0
*/
CC_DEPRECATED_ATTRIBUTE Point CC_DLL ccpIntersectPoint(const Point& A, const Point& B, const Point& C, const Point& D);
// end of data_structures group
/// @}
NS_CC_END
#endif // __SUPPORT_CGPOINTEXTENSION_H__

View File

@ -24,7 +24,6 @@
****************************************************************************/
#include "CCVertex.h"
#include "CCPointExtension.h"
#include "ccMacros.h"
NS_CC_BEGIN

View File

@ -62,6 +62,7 @@ TextureAtlas::~TextureAtlas()
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
ccGLBindVAO(0);
#endif
CC_SAFE_RELEASE(_texture);

View File

@ -24,7 +24,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCParallaxNode.h"
#include "support/CCPointExtension.h"
#include "support/data_support/ccCArray.h"
NS_CC_BEGIN

View File

@ -30,7 +30,6 @@ THE SOFTWARE.
#include "textures/CCTextureCache.h"
#include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h"
#include "support/CCPointExtension.h"
#include "support/data_support/ccCArray.h"
#include "CCDirector.h"

View File

@ -27,7 +27,6 @@ THE SOFTWARE.
#include "CCTMXXMLParser.h"
#include "CCTMXLayer.h"
#include "sprite_nodes/CCSprite.h"
#include "support/CCPointExtension.h"
NS_CC_BEGIN

View File

@ -32,7 +32,6 @@ THE SOFTWARE.
#include "ccMacros.h"
#include "platform/CCFileUtils.h"
#include "support/zip_support/ZipUtils.h"
#include "support/CCPointExtension.h"
#include "support/base64.h"
#include "platform/platform.h"

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
#include "cocoa/CCDictionary.h"
#include "cocoa/CCInteger.h"
#include "CCDirector.h"
#include "support/CCPointExtension.h"
NS_CC_BEGIN

View File

@ -22,7 +22,6 @@
THE SOFTWARE.
****************************************************************************/
#include "support/CCPointExtension.h"
#include "CCTouch.h"
#include "CCDirector.h"

View File

@ -78,6 +78,7 @@ GUI/CCEditBox/CCEditBox.cpp \
GUI/CCEditBox/CCEditBoxImplAndroid.cpp \
network/HttpClient.cpp \
network/WebSocket.cpp \
network/SocketIO.cpp \
physics_nodes/CCPhysicsDebugNode.cpp \
physics_nodes/CCPhysicsSprite.cpp \
LocalStorage/LocalStorageAndroid.cpp \

View File

@ -27,7 +27,6 @@
#include "CCControlButton.h"
#include "CCScale9Sprite.h"
#include "support/CCPointExtension.h"
#include "label_nodes/CCLabelTTF.h"
#include "label_nodes/CCLabelBMFont.h"
#include "actions/CCAction.h"

View File

@ -30,7 +30,6 @@
*/
#include "CCControlColourPicker.h"
#include "support/CCPointExtension.h"
#include "sprite_nodes/CCSpriteFrameCache.h"
#include "sprite_nodes/CCSpriteBatchNode.h"

View File

@ -30,7 +30,6 @@
*/
#include "CCControlHuePicker.h"
#include "support/CCPointExtension.h"
NS_CC_EXT_BEGIN

View File

@ -30,7 +30,6 @@
*/
#include "CCControlSaturationBrightnessPicker.h"
#include "support/CCPointExtension.h"
NS_CC_EXT_BEGIN

View File

@ -28,7 +28,6 @@
*/
#include "CCControlSlider.h"
#include "support/CCPointExtension.h"
#include "touch_dispatcher/CCTouch.h"
#include "CCDirector.h"

View File

@ -23,7 +23,6 @@ THE SOFTWARE.
****************************************************************************/
#include "CCControlUtils.h"
#include "support/CCPointExtension.h"
NS_CC_EXT_BEGIN

View File

@ -61,8 +61,6 @@ Scale9Sprite::Scale9Sprite()
, _bottom(NULL)
, _bottomRight(NULL)
, _opacityModifyRGB(false)
, _opacity(255)
, _color(Color3B::WHITE)
{
}
@ -774,8 +772,7 @@ void Scale9Sprite::visit()
void Scale9Sprite::setColor(const Color3B& color)
{
_color = color;
NodeRGBA::setColor(color);
Object* child;
Array* children = _scale9Image->getChildren();
CCARRAY_FOREACH(children, child)
@ -790,13 +787,12 @@ void Scale9Sprite::setColor(const Color3B& color)
const Color3B& Scale9Sprite::getColor() const
{
return _color;
return _realColor;
}
void Scale9Sprite::setOpacity(GLubyte opacity)
{
_opacity = opacity;
NodeRGBA::setOpacity(opacity);
Object* child;
Array* children = _scale9Image->getChildren();
CCARRAY_FOREACH(children, child)
@ -811,7 +807,37 @@ void Scale9Sprite::setOpacity(GLubyte opacity)
GLubyte Scale9Sprite::getOpacity() const
{
return _opacity;
return _realOpacity;
}
void Scale9Sprite::updateDisplayedColor(const cocos2d::Color3B &parentColor)
{
NodeRGBA::updateDisplayedColor(parentColor);
Object* child;
Array* children = _scale9Image->getChildren();
CCARRAY_FOREACH(children, child)
{
RGBAProtocol* pNode = dynamic_cast<RGBAProtocol*>(child);
if (pNode)
{
pNode->updateDisplayedColor(parentColor);
}
}
}
void Scale9Sprite::updateDisplayedOpacity(GLubyte parentOpacity)
{
NodeRGBA::updateDisplayedOpacity(parentOpacity);
Object* child;
Array* children = _scale9Image->getChildren();
CCARRAY_FOREACH(children, child)
{
RGBAProtocol* pNode = dynamic_cast<RGBAProtocol*>(child);
if (pNode)
{
pNode->updateDisplayedOpacity(parentOpacity);
}
}
}
NS_CC_EXT_END

View File

@ -97,8 +97,6 @@ protected:
Sprite* _bottomRight;
bool _opacityModifyRGB;
GLubyte _opacity;
Color3B _color;
void updateCapInset();
void updatePositions();
@ -312,6 +310,9 @@ public:
virtual GLubyte getOpacity() const;
virtual void setColor(const Color3B& color);
virtual const Color3B& getColor() const;
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
virtual void updateDisplayedColor(const Color3B& parentColor);
virtual bool updateWithBatchNode(SpriteBatchNode* batchnode, Rect rect, bool rotated, Rect capInsets);

View File

@ -349,7 +349,7 @@ NSPoint EditBoxImplMac::convertDesignCoordToScreenCoord(const Point& designCoord
EGLViewProtocol* eglView = EGLView::getInstance();
Point visiblePos = Point(designCoord.x * eglView->getScaleX(), designCoord.y * eglView->getScaleY());
Point screenGLPos = ccpAdd(visiblePos, eglView->getViewPortRect().origin);
Point screenGLPos = visiblePos + eglView->getViewPortRect().origin;
//TODO: I don't know why here needs to substract `height`.
NSPoint screenPos = NSMakePoint(screenGLPos.x, screenGLPos.y-height);

View File

@ -27,7 +27,6 @@
#include "CCTableView.h"
#include "CCTableViewCell.h"
#include "menu_nodes/CCMenu.h"
#include "support/CCPointExtension.h"
#include "CCSorting.h"
#include "layers_scenes_transitions_nodes/CCLayer.h"

View File

@ -0,0 +1,715 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013 Chris Hannon
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*based on the SocketIO library created by LearnBoost at http://socket.io
*using spec version 1 found at https://github.com/LearnBoost/socket.io-spec
****************************************************************************/
#include "SocketIO.h"
#include "cocos-ext.h"
#include "network/WebSocket.h"
#include <algorithm>
NS_CC_EXT_BEGIN
//class declarations
/**
* @brief The implementation of the socket.io connection
* Clients/endpoints may share the same impl to accomplish multiplexing on the same websocket
*/
class SIOClientImpl :
public Object,
public WebSocket::Delegate
{
private:
int _port, _heartbeat, _timeout;
std::string _host, _sid, _uri;
bool _connected;
WebSocket *_ws;
Dictionary* _clients;
public:
SIOClientImpl(const std::string& host, int port);
virtual ~SIOClientImpl(void);
static SIOClientImpl* create(const std::string& host, int port);
virtual void onOpen(cocos2d::extension::WebSocket* ws);
virtual void onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data);
virtual void onClose(cocos2d::extension::WebSocket* ws);
virtual void onError(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::ErrorCode& error);
void connect();
void disconnect();
bool init();
void handshake();
void handshakeResponse(HttpClient *sender, HttpResponse *response);
void openSocket();
void heartbeat(float dt);
SIOClient* getClient(const std::string& endpoint);
void addClient(const std::string& endpoint, SIOClient* client);
void connectToEndpoint(const std::string& endpoint);
void disconnectFromEndpoint(const std::string& endpoint);
void send(std::string endpoint, std::string s);
void emit(std::string endpoint, std::string eventname, std::string args);
};
//method implementations
//begin SIOClientImpl methods
SIOClientImpl::SIOClientImpl(const std::string& host, int port) :
_port(port),
_host(host),
_connected(false)
{
_clients = Dictionary::create();
_clients->retain();
std::stringstream s;
s << host << ":" << port;
_uri = s.str();
_ws = NULL;
}
SIOClientImpl::~SIOClientImpl() {
if(_connected) disconnect();
CC_SAFE_DELETE(_clients);
CC_SAFE_DELETE(_ws);
}
void SIOClientImpl::handshake() {
CCLog("SIOClientImpl::handshake() called");
std::stringstream pre;
pre << "http://" << _uri << "/socket.io/1";
HttpRequest* request = new HttpRequest();
request->setUrl(pre.str().c_str());
request->setRequestType(HttpRequest::kHttpGet);
request->setResponseCallback(this, httpresponse_selector(SIOClientImpl::handshakeResponse));
request->setTag("handshake");
CCLog("SIOClientImpl::handshake() waiting");
HttpClient::getInstance()->send(request);
request->release();
return;
}
void SIOClientImpl::handshakeResponse(HttpClient *sender, HttpResponse *response) {
CCLog("SIOClientImpl::handshakeResponse() called");
if (0 != strlen(response->getHttpRequest()->getTag()))
{
CCLog("%s completed", response->getHttpRequest()->getTag());
}
int statusCode = response->getResponseCode();
char statusString[64] = {};
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
CCLog("response code: %d", statusCode);
if (!response->isSucceed())
{
CCLog("SIOClientImpl::handshake() failed");
CCLog("error buffer: %s", response->getErrorBuffer());
DictElement* el = NULL;
CCDICT_FOREACH(_clients, el) {
SIOClient* c = static_cast<SIOClient*>(el->getObject());
c->getDelegate()->onError(c, response->getErrorBuffer());
}
return;
}
CCLog("SIOClientImpl::handshake() succeeded");
std::vector<char> *buffer = response->getResponseData();
std::stringstream s;
for (unsigned int i = 0; i < buffer->size(); i++)
{
s << (*buffer)[i];
}
CCLog("SIOClientImpl::handshake() dump data: %s", s.str().c_str());
std::string res = s.str();
std::string sid;
int pos = 0;
int heartbeat = 0, timeout = 0;
pos = res.find(":");
if(pos >= 0) {
sid = res.substr(0, pos);
res.erase(0, pos+1);
}
pos = res.find(":");
if(pos >= 0){
heartbeat = atoi(res.substr(pos+1, res.size()).c_str());
}
pos = res.find(":");
if(pos >= 0){
timeout = atoi(res.substr(pos+1, res.size()).c_str());
}
_sid = sid;
_heartbeat = heartbeat;
_timeout = timeout;
openSocket();
return;
}
void SIOClientImpl::openSocket() {
CCLog("SIOClientImpl::openSocket() called");
std::stringstream s;
s << _uri << "/socket.io/1/websocket/" << _sid;
_ws = new WebSocket();
if(!_ws->init(*this, s.str()))
{
CC_SAFE_DELETE(_ws);
}
return;
}
bool SIOClientImpl::init() {
CCLog("SIOClientImpl::init() successful");
return true;
}
void SIOClientImpl::connect() {
this->handshake();
}
void SIOClientImpl::disconnect() {
if(_ws->getReadyState() == WebSocket::kStateOpen) {
std::string s = "0::";
_ws->send(s);
CCLog("Disconnect sent");
_ws->close();
}
Director::getInstance()->getScheduler()->unscheduleAllForTarget(this);
_connected = false;
SocketIO::instance()->removeSocket(_uri);
}
SIOClientImpl* SIOClientImpl::create(const std::string& host, int port) {
SIOClientImpl *s = new SIOClientImpl(host, port);
if(s && s->init()) {
return s;
}
return NULL;
}
SIOClient* SIOClientImpl::getClient(const std::string& endpoint) {
return static_cast<SIOClient*>(_clients->objectForKey(endpoint));
}
void SIOClientImpl::addClient(const std::string& endpoint, SIOClient* client) {
_clients->setObject(client, endpoint);
}
void SIOClientImpl::connectToEndpoint(const std::string& endpoint) {
std::string path = endpoint == "/" ? "" : endpoint;
std::string s = "1::" + path;
_ws->send(s);
}
void SIOClientImpl::disconnectFromEndpoint(const std::string& endpoint) {
_clients->removeObjectForKey(endpoint);
if(_clients->count() == 0 || endpoint == "/") {
CCLog("SIOClientImpl::disconnectFromEndpoint out of endpoints, checking for disconnect");
if(_connected) this->disconnect();
} else {
std::string path = endpoint == "/" ? "" : endpoint;
std::string s = "0::" + path;
_ws->send(s);
}
}
void SIOClientImpl::heartbeat(float dt) {
std::string s = "2::";
_ws->send(s);
CCLog("Heartbeat sent");
}
void SIOClientImpl::send(std::string endpoint, std::string s) {
std::stringstream pre;
std::string path = endpoint == "/" ? "" : endpoint;
pre << "3::" << path << ":" << s;
std::string msg = pre.str();
CCLog("sending message: %s", msg.c_str());
_ws->send(msg);
}
void SIOClientImpl::emit(std::string endpoint, std::string eventname, std::string args) {
std::stringstream pre;
std::string path = endpoint == "/" ? "" : endpoint;
pre << "5::" << path << ":{\"name\":\"" << eventname << "\",\"args\":" << args << "}";
std::string msg = pre.str();
CCLog("emitting event with data: %s", msg.c_str());
_ws->send(msg);
}
void SIOClientImpl::onOpen(cocos2d::extension::WebSocket* ws) {
_connected = true;
SocketIO::instance()->addSocket(_uri, this);
DictElement* e = NULL;
CCDICT_FOREACH(_clients, e) {
SIOClient *c = static_cast<SIOClient*>(e->getObject());
c->onOpen();
}
Director::getInstance()->getScheduler()->scheduleSelector(schedule_selector(SIOClientImpl::heartbeat), this, (_heartbeat * .9), false);
CCLog("SIOClientImpl::onOpen socket connected!");
}
void SIOClientImpl::onMessage(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::Data& data) {
CCLog("SIOClientImpl::onMessage received: %s", data.bytes);
int control = atoi(&data.bytes[0]);
std::string payload, msgid, endpoint, s_data, eventname;
payload = data.bytes;
int pos, pos2;
pos = payload.find(":");
if(pos >=0 ) {
payload.erase(0, pos+1);
}
pos = payload.find(":");
if(pos > 0 ) {
msgid = atoi(payload.substr(0, pos+1).c_str());
}
payload.erase(0, pos+1);
pos = payload.find(":");
if(pos >= 0) {
endpoint = payload.substr(0, pos);
payload.erase(0, pos+1);
} else {
endpoint = payload;
}
if(endpoint == "") endpoint = "/";
s_data = payload;
SIOClient *c = NULL;
c = getClient(endpoint);
if(c == NULL) CCLog("SIOClientImpl::onMessage client lookup returned NULL");
switch(control) {
case 0:
CCLog("Received Disconnect Signal for Endpoint: %s\n", endpoint.c_str());
if(c) c->receivedDisconnect();
disconnectFromEndpoint(endpoint);
break;
case 1:
CCLog("Connected to endpoint: %s \n",endpoint.c_str());
if(c) c->onConnect();
break;
case 2:
CCLog("Heartbeat received\n");
break;
case 3:
CCLog("Message received: %s \n", s_data.c_str());
if(c) c->getDelegate()->onMessage(c, s_data);
break;
case 4:
CCLog("JSON Message Received: %s \n", s_data.c_str());
if(c) c->getDelegate()->onMessage(c, s_data);
break;
case 5:
CCLog("Event Received with data: %s \n", s_data.c_str());
if(c) {
eventname = "";
pos = s_data.find(":");
pos2 = s_data.find(",");
if(pos2 > pos) {
s_data = s_data.substr(pos+1, pos2-pos-1);
std::remove_copy(s_data.begin(), s_data.end(),
std::back_inserter(eventname), '"');
}
c->fireEvent(eventname, payload);
}
break;
case 6:
CCLog("Message Ack\n");
break;
case 7:
CCLog("Error\n");
if(c) c->getDelegate()->onError(c, s_data);
break;
case 8:
CCLog("Noop\n");
break;
}
return;
}
void SIOClientImpl::onClose(cocos2d::extension::WebSocket* ws) {
if(_clients->count() > 0) {
DictElement *e;
CCDICT_FOREACH(_clients, e) {
SIOClient *c = static_cast<SIOClient *>(e->getObject());
c->receivedDisconnect();
}
}
this->release();
}
void SIOClientImpl::onError(cocos2d::extension::WebSocket* ws, const cocos2d::extension::WebSocket::ErrorCode& error) {
}
//begin SIOClient methods
SIOClient::SIOClient(const std::string& host, int port, const std::string& path, SIOClientImpl* impl, SocketIO::SIODelegate& delegate)
: _host(host)
, _port(port)
, _path(path)
, _socket(impl)
, _connected(false)
, _delegate(&delegate)
{
}
SIOClient::~SIOClient(void) {
if(_connected) {
_socket->disconnectFromEndpoint(_path);
}
}
void SIOClient::onOpen() {
if(_path != "/") {
_socket->connectToEndpoint(_path);
}
}
void SIOClient::onConnect() {
_connected = true;
_delegate->onConnect(this);
}
void SIOClient::send(std::string s) {
if(_connected) {
_socket->send(_path, s);
} else {
_delegate->onError(this, "Client not yet connected");
}
}
void SIOClient::emit(std::string eventname, std::string args) {
if(_connected) {
_socket->emit(_path, eventname, args);
} else {
_delegate->onError(this, "Client not yet connected");
}
}
void SIOClient::disconnect() {
_connected = false;
_socket->disconnectFromEndpoint(_path);
_delegate->onClose(this);
this->release();
}
void SIOClient::receivedDisconnect() {
_connected = false;
_delegate->onClose(this);
this->release();
}
void SIOClient::on(const std::string& eventName, SIOEvent e) {
_eventRegistry[eventName] = e;
}
void SIOClient::fireEvent(const std::string& eventName, const std::string& data) {
CCLog("SIOClient::fireEvent called with event name: %s and data: %s", eventName.c_str(), data.c_str());
if(_eventRegistry[eventName]) {
SIOEvent e = _eventRegistry[eventName];
e(this, data);
return;
}
CCLog("SIOClient::fireEvent no event with name %s found", eventName.c_str());
}
//begin SocketIO methods
SocketIO *SocketIO::_inst = NULL;
SocketIO::SocketIO() {
_sockets = Dictionary::create();
_sockets->retain();
}
SocketIO::~SocketIO(void) {
CC_SAFE_DELETE(_sockets);
delete _inst;
}
SocketIO* SocketIO::instance() {
if(!_inst)
_inst = new SocketIO();
return _inst;
}
SIOClient* SocketIO::connect(SocketIO::SIODelegate& delegate, const std::string& uri) {
std::string host = uri;
int port = 0;
int pos = 0;
pos = host.find("//");
if(pos >= 0) {
host.erase(0, pos+2);
}
pos = host.find(":");
if(pos >= 0){
port = atoi(host.substr(pos+1, host.size()).c_str());
}
pos = host.find("/", 0);
std::string path = "/";
if(pos >= 0){
path += host.substr(pos + 1, host.size());
}
pos = host.find(":");
if(pos >= 0){
host.erase(pos, host.size());
}else if((pos = host.find("/"))>=0) {
host.erase(pos, host.size());
}
std::stringstream s;
s << host << ":" << port;
SIOClientImpl* socket = NULL;
SIOClient *c = NULL;
socket = SocketIO::instance()->getSocket(s.str());
if(socket == NULL) {
//create a new socket, new client, connect
socket = SIOClientImpl::create(host, port);
c = new SIOClient(host, port, path, socket, delegate);
socket->addClient(path, c);
socket->connect();
} else {
//check if already connected to endpoint, handle
c = socket->getClient(path);
if(c == NULL) {
c = new SIOClient(host, port, path, socket, delegate);
socket->addClient(path, c);
socket->connectToEndpoint(path);
}
}
return c;
}
SIOClientImpl* SocketIO::getSocket(const std::string& uri) {
return static_cast<SIOClientImpl*>(_sockets->objectForKey(uri));
}
void SocketIO::addSocket(const std::string& uri, SIOClientImpl* socket) {
_sockets->setObject(socket, uri);
}
void SocketIO::removeSocket(const std::string& uri) {
_sockets->removeObjectForKey(uri);
}
NS_CC_EXT_END

View File

@ -0,0 +1,187 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013 Chris Hannon http://www.channon.us
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*based on the SocketIO library created by LearnBoost at http://socket.io
*using spec version 1 found at https://github.com/LearnBoost/socket.io-spec
Usage is described below, a full working example can be found in TestCpp under ExtionsTest/NetworkTest/SocketIOTest
creating a new connection to a socket.io server running at localhost:3000
SIOClient *client = SocketIO::connect(*delegate, "ws://localhost:3000");
the connection process will begin and if successful delegate::onOpen will be called
if the connection process results in an error, delegate::onError will be called with the err msg
sending a message to the server
client->send("Hello!");
emitting an event to be handled by the server, argument json formatting is up to you
client->emit("eventname", "[{\"arg\":\"value\"}]");
registering an event callback, target should be a member function in a subclass of SIODelegate
CC_CALLBACK_2 is used to wrap the callback with std::bind and store as an SIOEvent
client->on("eventname", CC_CALLBACK_2(TargetClass::targetfunc, *targetclass_instance));
event target function should match this pattern, *this pointer will be made available
void TargetClass::targetfunc(SIOClient *, const std::string&)
disconnect from the endpoint by calling disconnect(), onClose will be called on the delegate once complete
in the onClose method the pointer should be set to NULL or used to connect to a new endpoint
client->disconnect();
****************************************************************************/
#ifndef __CC_SOCKETIO_H__
#define __CC_SOCKETIO_H__
#include "ExtensionMacros.h"
#include "cocos2d.h"
NS_CC_EXT_BEGIN
//forward declarations
class SIOClientImpl;
class SIOClient;
/**
* @brief Singleton and wrapper class to provide static creation method as well as registry of all sockets
*/
class SocketIO
{
public:
SocketIO();
virtual ~SocketIO(void);
static SocketIO *instance();
/**
* @brief The delegate class to process socket.io events
*/
class SIODelegate
{
public:
virtual ~SIODelegate() {}
virtual void onConnect(SIOClient* client) = 0;
virtual void onMessage(SIOClient* client, const std::string& data) = 0;
virtual void onClose(SIOClient* client) = 0;
virtual void onError(SIOClient* client, const std::string& data) = 0;
};
/**
* @brief Static client creation method, similar to socketio.connect(uri) in JS
* @param delegate The delegate which want to receive events from the socket.io client
* @param uri The URI of the socket.io server
* @return An initialized SIOClient if connected successfully, otherwise NULL
*/
static SIOClient* connect(SocketIO::SIODelegate& delegate, const std::string& uri);
private:
static SocketIO *_inst;
Dictionary* _sockets;
SIOClientImpl* getSocket(const std::string& uri);
void addSocket(const std::string& uri, SIOClientImpl* socket);
void removeSocket(const std::string& uri);
friend SIOClientImpl;
};
//c++11 style callbacks entities will be created using CC_CALLBACK (which uses std::bind)
typedef std::function<void(SIOClient*, const std::string&)> SIOEvent;
//c++11 map to callbacks
typedef std::map<std::string, SIOEvent> EventRegistry;
/**
* @brief A single connection to a socket.io endpoint
*/
class SIOClient
: public Object
{
private:
int _port;
std::string _host, _path, _tag;
bool _connected;
SIOClientImpl* _socket;
SocketIO::SIODelegate* _delegate;
EventRegistry _eventRegistry;
void fireEvent(const std::string& eventName, const std::string& data);
void onOpen();
void onConnect();
void receivedDisconnect();
friend class SIOClientImpl;
public:
SIOClient(const std::string& host, int port, const std::string& path, SIOClientImpl* impl, SocketIO::SIODelegate& delegate);
virtual ~SIOClient(void);
/**
* @brief Returns the delegate for the client
*/
SocketIO::SIODelegate* getDelegate() { return _delegate; };
/**
* @brief Disconnect from the endpoint, onClose will be called on the delegate when comlpete
*/
void disconnect();
/**
* @brief Send a message to the socket.io server
*/
void send(std::string s);
/**
* @brief The delegate class to process socket.io events
*/
void emit(std::string eventname, std::string args);
/**
* @brief Used to resgister a socket.io event callback
* Event argument should be passed using CC_CALLBACK2(&Base::function, this)
*/
void on(const std::string& eventName, SIOEvent e);
inline void setTag(const char* tag)
{
_tag = tag;
};
inline const char* getTag()
{
return _tag.c_str();
};
};
NS_CC_EXT_END
#endif /* defined(__CC_JSB_SOCKETIO_H__) */

View File

@ -21,7 +21,6 @@
*/
#include "CCPhysicsSprite.h"
#include "support/CCPointExtension.h"
#if defined(CC_ENABLE_CHIPMUNK_INTEGRATION) && defined(CC_ENABLE_BOX2D_INTEGRATION)
#error "Either Chipmunk or Box2d should be enabled, but not both at the same time"

View File

@ -166,6 +166,7 @@
<ClCompile Include="..\GUI\CCScrollView\CCTableViewCell.cpp" />
<ClCompile Include="..\LocalStorage\LocalStorage.cpp" />
<ClCompile Include="..\network\HttpClient.cpp" />
<ClCompile Include="..\network\SocketIO.cpp" />
<ClCompile Include="..\network\Websocket.cpp" />
<ClCompile Include="..\physics_nodes\CCPhysicsDebugNode.cpp" />
<ClCompile Include="..\physics_nodes\CCPhysicsSprite.cpp" />
@ -287,6 +288,7 @@
<ClInclude Include="..\network\HttpClient.h" />
<ClInclude Include="..\network\HttpRequest.h" />
<ClInclude Include="..\network\HttpResponse.h" />
<ClInclude Include="..\network\SocketIO.h" />
<ClInclude Include="..\network\Websocket.h" />
<ClInclude Include="..\physics_nodes\CCPhysicsDebugNode.h" />
<ClInclude Include="..\physics_nodes\CCPhysicsSprite.h" />

View File

@ -354,6 +354,9 @@
<ClCompile Include="..\CCArmature\external_tool\Json\lib_json\json_writer.cpp">
<Filter>CCArmature\external_tool</Filter>
</ClCompile>
<ClCompile Include="..\network\SocketIO.cpp">
<Filter>network</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\GUI\CCScrollView\CCScrollView.h">
@ -712,6 +715,9 @@
<ClInclude Include="..\CCArmature\external_tool\Json\lib_json\writer.h">
<Filter>CCArmature\external_tool</Filter>
</ClInclude>
<ClInclude Include="..\network\SocketIO.h">
<Filter>network</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\CCArmature\external_tool\Json\lib_json\json_internalarray.inl">

View File

@ -26,5 +26,5 @@ int main(int argc, char **argv)
CCEGLView& eglView = CCEGLView::getInstance();
eglView.setSize(width, height);
return CCApplication::sharedApplication().run();
return CCApplication::getInstance().run();
}

View File

@ -30,7 +30,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
Application::sharedApplication()->run();
Application::getInstance()->run();
}
else
{

View File

@ -30,7 +30,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
Application::sharedApplication()->run();
Application::getInstance()->run();
}
else
{

View File

@ -225,7 +225,7 @@ void TestAnalytics::eventMenuCallback(Object* pSender)
void TestAnalytics::loadPlugins()
{
ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage();
ccLanguageType langType = Application::getInstance()->getCurrentLanguage();
std::string umengKey = "";
std::string flurryKey = "";

View File

@ -29,7 +29,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
Application::sharedApplication()->run();
Application::getInstance()->run();
}
/*
else

View File

@ -49,7 +49,7 @@ static AppDelegate s_sharedApplication;
[[UIApplication sharedApplication] setStatusBarHidden:true];
cocos2d::Application::sharedApplication()->run();
cocos2d::Application::getInstance()->run();
return YES;
}
@ -75,14 +75,14 @@ static AppDelegate s_sharedApplication;
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
cocos2d::Application::sharedApplication()->applicationDidEnterBackground();
cocos2d::Application::getInstance()->applicationDidEnterBackground();
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
cocos2d::Application::sharedApplication()->applicationWillEnterForeground();
cocos2d::Application::getInstance()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication *)application {

Some files were not shown because too many files have changed in this diff Show More