Merge branch 'origin/develop'

Conflicts:
	cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj
	cocos2dx/proj.win32/cocos2d.vcxproj.filters
This commit is contained in:
Huabing.Xu 2013-07-02 13:47:02 +08:00
commit 041bef148a
254 changed files with 26591 additions and 6061 deletions

View File

@ -13,6 +13,10 @@ Developers:
Rolando Abarca Rolando Abarca
Javascript Binding and testjs Javascript Binding and testjs
Squallium
Added ccFPSImages entity as linked resource on linux eclipse project setting.
Added CocosDenshion dependency to libextension project for eclipse project of linux.
longlene longlene
Improve android project creation script Improve android project creation script
@ -362,7 +366,8 @@ Developers:
Refactoring emscripten building script. Refactoring emscripten building script.
Peter Young (young40) Peter Young (young40)
Implements setVisible() for CCEditBox Implements setVisible() for CCEditBox.
Fixing a bug that event will not be sent to server when paramMap parameter of logEvent function is nil in plugin-x.
csy1988525 csy1988525
Fixing a bug about display result is wrong when invoking CCControlButton:: setHighlighted. Fixing a bug about display result is wrong when invoking CCControlButton:: setHighlighted.

View File

@ -258,7 +258,6 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = "";
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = macosx; SDKROOT = macosx;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };

View File

@ -75,4 +75,49 @@
location = "group:scripting/lua/proj.ios/luabindings.xcodeproj"> location = "group:scripting/lua/proj.ios/luabindings.xcodeproj">
</FileRef> </FileRef>
</Group> </Group>
<Group
location = "container:"
name = "plugin-x">
<Group
location = "container:"
name = "plugins">
<Group
location = "container:"
name = "Share">
<FileRef
location = "group:plugin/plugins/twitter/proj.ios/PluginTwitter.xcodeproj">
</FileRef>
<FileRef
location = "group:plugin/plugins/weibo/proj.ios/PluginWeibo.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "Ads">
<FileRef
location = "group:plugin/plugins/admob/proj.ios/PluginAdmob.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "Analytics">
<FileRef
location = "group:plugin/plugins/flurry/proj.ios/PluginFlurry.xcodeproj">
</FileRef>
<FileRef
location = "group:plugin/plugins/umeng/proj.ios/PluginUmeng.xcodeproj">
</FileRef>
</Group>
<FileRef
location = "group:plugin/protocols/proj.ios/PluginProtocol.xcodeproj">
</FileRef>
</Group>
<Group
location = "container:"
name = "samples">
<FileRef
location = "group:plugin/samples/HelloPlugins/proj.ios/HelloPlugins.xcodeproj">
</FileRef>
</Group>
</Group>
</Workspace> </Workspace>

View File

@ -7,6 +7,9 @@
<Group <Group
location = "container:" location = "container:"
name = "Javascript"> name = "Javascript">
<FileRef
location = "group:samples/Javascript/TestJavascript/proj.mac/TestJavascript.xcodeproj">
</FileRef>
</Group> </Group>
<Group <Group
location = "container:" location = "container:"
@ -23,6 +26,9 @@
<Group <Group
location = "container:" location = "container:"
name = "libs"> name = "libs">
<FileRef
location = "group:scripting/javascript/bindings/proj.mac/jsbindings.xcodeproj">
</FileRef>
<FileRef <FileRef
location = "group:extensions/proj.mac/extensions.xcodeproj"> location = "group:extensions/proj.mac/extensions.xcodeproj">
</FileRef> </FileRef>

View File

@ -59,6 +59,7 @@ kazmath/src/GL/mat4stack.c \
kazmath/src/GL/matrix.c \ kazmath/src/GL/matrix.c \
keypad_dispatcher/CCKeypadDelegate.cpp \ keypad_dispatcher/CCKeypadDelegate.cpp \
keypad_dispatcher/CCKeypadDispatcher.cpp \ keypad_dispatcher/CCKeypadDispatcher.cpp \
keyboard_dispatcher/CCKeyboardDispatcher.cpp \
label_nodes/CCLabelAtlas.cpp \ label_nodes/CCLabelAtlas.cpp \
label_nodes/CCLabelBMFont.cpp \ label_nodes/CCLabelBMFont.cpp \
label_nodes/CCLabelTTF.cpp \ label_nodes/CCLabelTTF.cpp \

View File

@ -64,9 +64,7 @@ THE SOFTWARE.
#include "platform/CCImage.h" #include "platform/CCImage.h"
#include "CCEGLView.h" #include "CCEGLView.h"
#include "CCConfiguration.h" #include "CCConfiguration.h"
#ifdef KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#endif
/** /**
@ -154,10 +152,8 @@ bool Director::init(void)
_touchDispatcher = new TouchDispatcher(); _touchDispatcher = new TouchDispatcher();
_touchDispatcher->init(); _touchDispatcher->init();
#ifdef KEYBOARD_SUPPORT
// KeyboardDispatcher // KeyboardDispatcher
_keyboardDispatcher = new KeyboardDispatcher(); _keyboardDispatcher = new KeyboardDispatcher();
#endif
// KeypadDispatcher // KeypadDispatcher
_keypadDispatcher = new KeypadDispatcher(); _keypadDispatcher = new KeypadDispatcher();
@ -185,9 +181,7 @@ Director::~Director(void)
CC_SAFE_RELEASE(_scheduler); CC_SAFE_RELEASE(_scheduler);
CC_SAFE_RELEASE(_actionManager); CC_SAFE_RELEASE(_actionManager);
CC_SAFE_RELEASE(_touchDispatcher); CC_SAFE_RELEASE(_touchDispatcher);
#ifdef KEYBOARD_SUPPORT
CC_SAFE_RELEASE(_keyboardDispatcher); CC_SAFE_RELEASE(_keyboardDispatcher);
#endif
CC_SAFE_RELEASE(_keypadDispatcher); CC_SAFE_RELEASE(_keypadDispatcher);
CC_SAFE_DELETE(_accelerometer); CC_SAFE_DELETE(_accelerometer);
@ -1004,7 +998,6 @@ TouchDispatcher* Director::getTouchDispatcher()
return _touchDispatcher; return _touchDispatcher;
} }
#ifdef KEYBOARD_SUPPORT
void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher) void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher)
{ {
CC_SAFE_RETAIN(pKeyboardDispatcher); CC_SAFE_RETAIN(pKeyboardDispatcher);
@ -1016,7 +1009,6 @@ KeyboardDispatcher* Director::getKeyboardDispatcher()
{ {
return _keyboardDispatcher; return _keyboardDispatcher;
} }
#endif
void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher) void Director::setKeypadDispatcher(KeypadDispatcher* pKeypadDispatcher)
{ {

View File

@ -71,9 +71,7 @@ class Node;
class Scheduler; class Scheduler;
class ActionManager; class ActionManager;
class TouchDispatcher; class TouchDispatcher;
#ifdef KEYBOARD_SUPPORT
class KeyboardDispatcher; class KeyboardDispatcher;
#endif
class KeypadDispatcher; class KeypadDispatcher;
class Accelerometer; class Accelerometer;
@ -328,12 +326,12 @@ public:
*/ */
CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher); CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher);
#ifdef KEYBOARD_SUPPORT
/** KeyboardDispatcher associated with this director /** KeyboardDispatcher associated with this director
@since v?.? @note Supported on Mac and Linux only now.
@since v3.0
*/ */
CC_PROPERTY(KeyboardDispatcher*, _keyboardDispatcher, KeyboardDispatcher); CC_PROPERTY(KeyboardDispatcher*, _keyboardDispatcher, KeyboardDispatcher);
#endif
/** KeypadDispatcher associated with this director /** KeypadDispatcher associated with this director
@since v2.0 @since v2.0
*/ */

View File

@ -33,8 +33,8 @@ NS_CC_BEGIN
// //
//------------------------------------------------------------------ //------------------------------------------------------------------
KeyboardDispatcher::KeyboardDispatcher() KeyboardDispatcher::KeyboardDispatcher()
: _keyPressDelegate(NULL) : _keyPressDelegate(nullptr)
, _keyReleaseDelegate(NULL) , _keyReleaseDelegate(nullptr)
{ {
} }

View File

@ -38,9 +38,7 @@ THE SOFTWARE.
#include "support/TransformUtils.h" #include "support/TransformUtils.h"
// extern // extern
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"
#ifdef KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#endif
NS_CC_BEGIN NS_CC_BEGIN
@ -48,9 +46,7 @@ NS_CC_BEGIN
Layer::Layer() Layer::Layer()
: _touchEnabled(false) : _touchEnabled(false)
, _accelerometerEnabled(false) , _accelerometerEnabled(false)
#ifdef KEYBOARD_SUPPORT
, _keyboardEnabled(false) , _keyboardEnabled(false)
#endif
, _keypadEnabled(false) , _keypadEnabled(false)
, _scriptTouchHandlerEntry(NULL) , _scriptTouchHandlerEntry(NULL)
, _scriptKeypadHandlerEntry(NULL) , _scriptKeypadHandlerEntry(NULL)
@ -279,7 +275,6 @@ void Layer::unregisterScriptAccelerateHandler(void)
CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry); CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry);
} }
#ifdef KEYBOARD_SUPPORT
/// isKeyboardEnabled getter /// isKeyboardEnabled getter
bool Layer::isKeyboardEnabled() bool Layer::isKeyboardEnabled()
{ {
@ -300,12 +295,11 @@ void Layer::setKeyboardEnabled(bool enabled)
} }
else else
{ {
pDirector->getKeyboardDispatcher()->setKeyPressDelegate(NULL); pDirector->getKeyboardDispatcher()->setKeyPressDelegate(nullptr);
pDirector->getKeyboardDispatcher()->setKeyReleaseDelegate(NULL); pDirector->getKeyboardDispatcher()->setKeyReleaseDelegate(nullptr);
} }
} }
} }
#endif
/// isKeypadEnabled getter /// isKeypadEnabled getter
bool Layer::isKeypadEnabled() bool Layer::isKeypadEnabled()
@ -845,7 +839,6 @@ void LayerColor::setOpacity(GLubyte opacity)
// //
// LayerGradient // LayerGradient
// //
LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& end) LayerGradient* LayerGradient::create(const ccColor4B& start, const ccColor4B& end)
{ {
LayerGradient * pLayer = new LayerGradient(); LayerGradient * pLayer = new LayerGradient();

View File

@ -67,7 +67,7 @@ public:
virtual ~Layer(); virtual ~Layer();
virtual bool init(); virtual bool init();
/** create one layer */ /** creates a fullscreen black layer */
static Layer *create(void); static Layer *create(void);
virtual void onEnter(); virtual void onEnter();
@ -134,12 +134,12 @@ public:
You can enable / disable accelerometer events with this property. You can enable / disable accelerometer events with this property.
it's new in cocos2d-x it's new in cocos2d-x
*/ */
#ifdef KEYBOARD_SUPPORT
virtual bool isKeyboardEnabled(); virtual bool isKeyboardEnabled();
virtual void setKeyboardEnabled(bool value); virtual void setKeyboardEnabled(bool value);
virtual void keyPressed(int keyCode) {}; virtual void keyPressed(int keyCode) {};
virtual void keyReleased(int keyCode) {}; virtual void keyReleased(int keyCode) {};
#endif
virtual bool isKeypadEnabled(); virtual bool isKeypadEnabled();
virtual void setKeypadEnabled(bool value); virtual void setKeypadEnabled(bool value);
@ -157,9 +157,7 @@ public:
protected: protected:
bool _touchEnabled; bool _touchEnabled;
bool _accelerometerEnabled; bool _accelerometerEnabled;
#ifdef KEYBOARD_SUPPORT
bool _keyboardEnabled; bool _keyboardEnabled;
#endif
bool _keypadEnabled; bool _keypadEnabled;
private: private:
@ -243,7 +241,8 @@ public:
virtual void draw(); virtual void draw();
virtual void setContentSize(const Size & var); virtual void setContentSize(const Size & var);
/** creates a fullscreen black layer */
static LayerColor* create(); static LayerColor* create();
/** creates a Layer with color, width and height in Points */ /** creates a Layer with color, width and height in Points */
@ -304,6 +303,9 @@ class CC_DLL LayerGradient : public LayerColor
{ {
public: public:
/** Creates a fullscreen black layer */
static LayerGradient* create();
/** Creates a full-screen Layer with a gradient between start and end. */ /** Creates a full-screen Layer with a gradient between start and end. */
static LayerGradient* create(const ccColor4B& start, const ccColor4B& end); static LayerGradient* create(const ccColor4B& start, const ccColor4B& end);
@ -332,8 +334,6 @@ public:
virtual void setCompressedInterpolation(bool bCompressedInterpolation); virtual void setCompressedInterpolation(bool bCompressedInterpolation);
virtual bool isCompressedInterpolation(); virtual bool isCompressedInterpolation();
static LayerGradient* create();
protected: protected:
virtual void updateColor(); virtual void updateColor();
}; };

View File

@ -13,9 +13,7 @@
#include "touch_dispatcher/CCTouch.h" #include "touch_dispatcher/CCTouch.h"
#include "touch_dispatcher/CCTouchDispatcher.h" #include "touch_dispatcher/CCTouchDispatcher.h"
#include "text_input_node/CCIMEDispatcher.h" #include "text_input_node/CCIMEDispatcher.h"
#ifdef KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#endif
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL; PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL;
PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL; PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL;
@ -157,7 +155,6 @@ int closeEventHandle() {
return GL_TRUE; return GL_TRUE;
} }
#ifdef KEYBOARD_SUPPORT
void GLFWCALL keyboardEventHandle(int keyCode, int action) void GLFWCALL keyboardEventHandle(int keyCode, int action)
{ {
KeyboardDispatcher *kbDisp = Director::sharedDirector()->getKeyboardDispatcher(); KeyboardDispatcher *kbDisp = Director::sharedDirector()->getKeyboardDispatcher();
@ -172,7 +169,6 @@ void GLFWCALL keyboardEventHandle(int keyCode, int action)
break; break;
} }
} }
#endif
void EGLView::setFrameSize(float width, float height) void EGLView::setFrameSize(float width, float height)
{ {
@ -248,7 +244,7 @@ void EGLView::setFrameSize(float width, float height)
glfwSetMouseButtonCallback(mouseButtonEventHandle); glfwSetMouseButtonCallback(mouseButtonEventHandle);
//register the glfw mouse pos event //register the glfw mouse pos event
glfwSetMousePosCallback(mousePosEventHandle); glfwSetMousePosCallback(mousePosEventHandle);
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
//register the glfw keyboard event //register the glfw keyboard event
glfwSetKeyCallback(keyboardEventHandle); glfwSetKeyCallback(keyboardEventHandle);
#endif #endif

View File

@ -1 +1 @@
aa069b7e15b1c1a60eb701106de33aa81dca0f77 a44aca2820580a568d0cb92fb573086e1096d5e1

View File

@ -96,6 +96,16 @@
<type>1</type> <type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/CCConfiguration.h</locationURI> <locationURI>PARENT-1-PROJECT_LOC/CCConfiguration.h</locationURI>
</link> </link>
<link>
<name>ccFPSImages.c</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ccFPSImages.c</locationURI>
</link>
<link>
<name>ccFPSImages.h</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/ccFPSImages.h</locationURI>
</link>
<link> <link>
<name>CCDirector.cpp</name> <name>CCDirector.cpp</name>
<type>1</type> <type>1</type>

View File

@ -11,7 +11,7 @@ CCFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC
CXXFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC -std=gnu++0x CXXFLAGS += -MMD -Werror -Wno-deprecated-declarations -fPIC -std=gnu++0x
ARFLAGS = cr ARFLAGS = cr
DEFINES += -DLINUX -DKEYBOARD_SUPPORT DEFINES += -DLINUX -DCC_KEYBOARD_SUPPORT
ifdef USE_BOX2D ifdef USE_BOX2D
DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1 DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1

View File

@ -1 +1 @@
d0d80920ec6a91b8d245eb1905b39fe55135f362 1dc917cb6f1a62d8d7536db3c3db9f25562d59b7

View File

@ -109,6 +109,11 @@ files
"*.h" "*.h"
"*.cpp" "*.cpp"
("../keyboard_dispatcher")
[keyboard_dispatcher]
"*.h"
"*.cpp"
("../label_nodes") ("../label_nodes")
[label_nodes] [label_nodes]
"*.h" "*.h"

View File

@ -37,6 +37,7 @@ SOURCES = ../actions/CCAction.cpp \
../effects/CCGrid.cpp \ ../effects/CCGrid.cpp \
../keypad_dispatcher/CCKeypadDelegate.cpp \ ../keypad_dispatcher/CCKeypadDelegate.cpp \
../keypad_dispatcher/CCKeypadDispatcher.cpp \ ../keypad_dispatcher/CCKeypadDispatcher.cpp \
../keyboard_dispatcher/CCKeyboardDispatcher.cpp \
../label_nodes/CCLabelAtlas.cpp \ ../label_nodes/CCLabelAtlas.cpp \
../label_nodes/CCLabelBMFont.cpp \ ../label_nodes/CCLabelBMFont.cpp \
../label_nodes/CCLabelTTF.cpp \ ../label_nodes/CCLabelTTF.cpp \

View File

@ -172,6 +172,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClCompile Include="..\actions\CCActionProgressTimer.cpp" /> <ClCompile Include="..\actions\CCActionProgressTimer.cpp" />
<ClCompile Include="..\actions\CCActionTiledGrid.cpp" /> <ClCompile Include="..\actions\CCActionTiledGrid.cpp" />
<ClCompile Include="..\actions\CCActionTween.cpp" /> <ClCompile Include="..\actions\CCActionTween.cpp" />
<ClCompile Include="..\keyboard_dispatcher\CCKeyboardDispatcher.cpp" />
<ClCompile Include="..\label_nodes\CCLabelAtlas.cpp" /> <ClCompile Include="..\label_nodes\CCLabelAtlas.cpp" />
<ClCompile Include="..\label_nodes\CCLabelBMFont.cpp" /> <ClCompile Include="..\label_nodes\CCLabelBMFont.cpp" />
<ClCompile Include="..\label_nodes\CCLabelTTF.cpp" /> <ClCompile Include="..\label_nodes\CCLabelTTF.cpp" />
@ -313,6 +314,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
<ClInclude Include="..\include\CCProtocols.h" /> <ClInclude Include="..\include\CCProtocols.h" />
<ClInclude Include="..\include\ccTypes.h" /> <ClInclude Include="..\include\ccTypes.h" />
<ClInclude Include="..\include\cocos2d.h" /> <ClInclude Include="..\include\cocos2d.h" />
<ClInclude Include="..\keyboard_dispatcher\CCKeyboardDispatcher.h" />
<ClInclude Include="..\label_nodes\CCLabelAtlas.h" /> <ClInclude Include="..\label_nodes\CCLabelAtlas.h" />
<ClInclude Include="..\label_nodes\CCLabelBMFont.h" /> <ClInclude Include="..\label_nodes\CCLabelBMFont.h" />
<ClInclude Include="..\label_nodes\CCLabelTTF.h" /> <ClInclude Include="..\label_nodes\CCLabelTTF.h" />

File diff suppressed because it is too large Load Diff

View File

@ -516,7 +516,7 @@ bool Texture2D::initWithString(const char *text, ccFontDefinition *textDefinitio
#if CC_ENABLE_CACHE_TEXTURE_DATA #if CC_ENABLE_CACHE_TEXTURE_DATA
// cache the texture data // cache the texture data
VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); VolatileTexture::addStringTexture(this, text, textDefinition->_dimensions, textDefinition->_alignment, textDefinition->_vertAlignment, textDefinition->_fontName.c_str(), textDefinition->_fontSize);
#endif #endif
bool bRet = false; bool bRet = false;

View File

@ -23,6 +23,10 @@
#include "CCPhysicsSprite.h" #include "CCPhysicsSprite.h"
#include "support/CCPointExtension.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"
#endif
#if CC_ENABLE_CHIPMUNK_INTEGRATION #if CC_ENABLE_CHIPMUNK_INTEGRATION
#include "chipmunk.h" #include "chipmunk.h"
#elif CC_ENABLE_BOX2D_INTEGRATION #elif CC_ENABLE_BOX2D_INTEGRATION
@ -33,12 +37,9 @@ NS_CC_EXT_BEGIN
PhysicsSprite::PhysicsSprite() PhysicsSprite::PhysicsSprite()
: _ignoreBodyRotation(false) : _ignoreBodyRotation(false)
#if CC_ENABLE_CHIPMUNK_INTEGRATION
, _CPBody(NULL) , _CPBody(NULL)
#elif CC_ENABLE_BOX2D_INTEGRATION
, _pB2Body(NULL) , _pB2Body(NULL)
, _PTMRatio(0.0f) , _PTMRatio(0.0f)
#endif
{} {}
PhysicsSprite* PhysicsSprite::create() PhysicsSprite* PhysicsSprite::create()
@ -189,6 +190,10 @@ float PhysicsSprite::getPositionY()
return _position.y; return _position.y;
} }
//
// Chipmunk only
//
#if CC_ENABLE_CHIPMUNK_INTEGRATION #if CC_ENABLE_CHIPMUNK_INTEGRATION
cpBody* PhysicsSprite::getCPBody() const cpBody* PhysicsSprite::getCPBody() const
@ -201,56 +206,31 @@ void PhysicsSprite::setCPBody(cpBody *pBody)
_CPBody = pBody; _CPBody = pBody;
} }
void PhysicsSprite::updatePosFromPhysics() b2Body* PhysicsSprite::getB2Body() const
{ {
cpVect cpPos = cpBodyGetPos(_CPBody); CCAssert(false, "Can't call box2d methods when Chipmunk is enabled");
_position = ccp(cpPos.x, cpPos.y); return NULL;
} }
void PhysicsSprite::setPosition(const Point &pos) void PhysicsSprite::setB2Body(b2Body *pBody)
{ {
cpVect cpPos = cpv(pos.x, pos.y); CCAssert(false, "Can't call box2d methods when Chipmunk is enabled");
cpBodySetPos(_CPBody, cpPos);
} }
float PhysicsSprite::getRotation() float PhysicsSprite::getPTMRatio() const
{ {
return (_ignoreBodyRotation ? Sprite::getRotation() : -CC_RADIANS_TO_DEGREES(cpBodyGetAngle(_CPBody))); CCAssert(false, "Can't call box2d methods when Chipmunk is enabled");
return 0;
} }
void PhysicsSprite::setRotation(float fRotation) void PhysicsSprite::setPTMRatio(float fRatio)
{ {
if (_ignoreBodyRotation) CCAssert(false, "Can't call box2d methods when Chipmunk is enabled");
{
Sprite::setRotation(fRotation);
}
else
{
cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation));
}
}
// returns the transform matrix according the Chipmunk Body values
AffineTransform PhysicsSprite::nodeToParentTransform()
{
// Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions.
// For more info see: http://www.cocos2d-iphone.org/forum/topic/68990
cpVect rot = (_ignoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(_rotationX)) : _CPBody->rot);
float x = _CPBody->p.x + rot.x * -_anchorPointInPoints.x * _scaleX - rot.y * -_anchorPointInPoints.y * _scaleY;
float y = _CPBody->p.y + rot.y * -_anchorPointInPoints.x * _scaleX + rot.x * -_anchorPointInPoints.y * _scaleY;
if (_ignoreAnchorPointForPosition)
{
x += _anchorPointInPoints.x;
y += _anchorPointInPoints.y;
}
return (_transform = AffineTransformMake(rot.x * _scaleX, rot.y * _scaleX,
-rot.y * _scaleY, rot.x * _scaleY,
x, y));
} }
//
// Box2d only
//
#elif CC_ENABLE_BOX2D_INTEGRATION #elif CC_ENABLE_BOX2D_INTEGRATION
b2Body* PhysicsSprite::getB2Body() const b2Body* PhysicsSprite::getB2Body() const
@ -273,25 +253,68 @@ void PhysicsSprite::setPTMRatio(float fRatio)
_PTMRatio = fRatio; _PTMRatio = fRatio;
} }
// Override the setters and getters to always reflect the body's properties. cpBody* PhysicsSprite::getCPBody() const
{
CCAssert(false, "Can't call Chipmunk methods when Box2d is enabled");
return NULL;
}
void PhysicsSprite::setCPBody(cpBody *pBody)
{
CCAssert(false, "Can't call Chipmunk methods when Box2d is enabled");
}
#endif
//
// Common to Box2d and Chipmunk
//
void PhysicsSprite::updatePosFromPhysics() void PhysicsSprite::updatePosFromPhysics()
{ {
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect cpPos = cpBodyGetPos(_CPBody);
_position = ccp(cpPos.x, cpPos.y);
#elif CC_ENABLE_BOX2D_INTEGRATION
b2Vec2 pos = _pB2Body->GetPosition(); b2Vec2 pos = _pB2Body->GetPosition();
float x = pos.x * _PTMRatio; float x = pos.x * _PTMRatio;
float y = pos.y * _PTMRatio; float y = pos.y * _PTMRatio;
_position = ccp(x,y); _position = ccp(x,y);
#endif
} }
void PhysicsSprite::setPosition(const Point &pos) void PhysicsSprite::setPosition(const Point &pos)
{ {
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect cpPos = cpv(pos.x, pos.y);
cpBodySetPos(_CPBody, cpPos);
#elif CC_ENABLE_BOX2D_INTEGRATION
float angle = _pB2Body->GetAngle(); float angle = _pB2Body->GetAngle();
_pB2Body->SetTransform(b2Vec2(pos.x / _PTMRatio, pos.y / _PTMRatio), angle); _pB2Body->SetTransform(b2Vec2(pos.x / _PTMRatio, pos.y / _PTMRatio), angle);
#endif
} }
float PhysicsSprite::getRotation() float PhysicsSprite::getRotation()
{ {
#if CC_ENABLE_CHIPMUNK_INTEGRATION
return (_ignoreBodyRotation ? Sprite::getRotation() : -CC_RADIANS_TO_DEGREES(cpBodyGetAngle(_CPBody)));
#elif CC_ENABLE_BOX2D_INTEGRATION
return (_ignoreBodyRotation ? Sprite::getRotation() : return (_ignoreBodyRotation ? Sprite::getRotation() :
CC_RADIANS_TO_DEGREES(_pB2Body->GetAngle())); CC_RADIANS_TO_DEGREES(_pB2Body->GetAngle()));
#endif
} }
void PhysicsSprite::setRotation(float fRotation) void PhysicsSprite::setRotation(float fRotation)
@ -300,50 +323,79 @@ void PhysicsSprite::setRotation(float fRotation)
{ {
Sprite::setRotation(fRotation); Sprite::setRotation(fRotation);
} }
#if CC_ENABLE_CHIPMUNK_INTEGRATION
else
{
cpBodySetAngle(_CPBody, -CC_DEGREES_TO_RADIANS(fRotation));
}
#elif CC_ENABLE_BOX2D_INTEGRATION
else else
{ {
b2Vec2 p = _pB2Body->GetPosition(); b2Vec2 p = _pB2Body->GetPosition();
float radians = CC_DEGREES_TO_RADIANS(fRotation); float radians = CC_DEGREES_TO_RADIANS(fRotation);
_pB2Body->SetTransform(p, radians); _pB2Body->SetTransform(p, radians);
} }
#endif
} }
// returns the transform matrix according the Box2D Body values // returns the transform matrix according the Chipmunk Body values
AffineTransform PhysicsSprite::nodeToParentTransform() AffineTransform PhysicsSprite::nodeToParentTransform()
{ {
b2Vec2 pos = _pB2Body->GetPosition(); // Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions.
float x = pos.x * _PTMRatio; // For more info see: http://www.cocos2d-iphone.org/forum/topic/68990
float y = pos.y * _PTMRatio;
#if CC_ENABLE_CHIPMUNK_INTEGRATION
cpVect rot = (_ignoreBodyRotation ? cpvforangle(-CC_DEGREES_TO_RADIANS(_rotationX)) : _CPBody->rot);
float x = _CPBody->p.x + rot.x * -_anchorPointInPoints.x * _scaleX - rot.y * -_anchorPointInPoints.y * _scaleY;
float y = _CPBody->p.y + rot.y * -_anchorPointInPoints.x * _scaleX + rot.x * -_anchorPointInPoints.y * _scaleY;
if (_ignoreAnchorPointForPosition) if (_ignoreAnchorPointForPosition)
{ {
x += _anchorPointInPoints.x; x += _anchorPointInPoints.x;
y += _anchorPointInPoints.y; y += _anchorPointInPoints.y;
} }
return (_transform = AffineTransformMake(rot.x * _scaleX, rot.y * _scaleX,
-rot.y * _scaleY, rot.x * _scaleY,
x, y));
#elif CC_ENABLE_BOX2D_INTEGRATION
b2Vec2 pos = _pB2Body->GetPosition();
float x = pos.x * _PTMRatio;
float y = pos.y * _PTMRatio;
if (_ignoreAnchorPointForPosition)
{
x += _anchorPointInPoints.x;
y += _anchorPointInPoints.y;
}
// Make matrix // Make matrix
float radians = _pB2Body->GetAngle(); float radians = _pB2Body->GetAngle();
float c = cosf(radians); float c = cosf(radians);
float s = sinf(radians); float s = sinf(radians);
// Although scale is not used by physics engines, it is calculated just in case
// the sprite is animated (scaled up/down) using actions.
// For more info see: http://www.cocos2d-iphone.org/forum/topic/68990
if (!_anchorPointInPoints.equals(PointZero)) if (!_anchorPointInPoints.equals(PointZero))
{ {
x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY)); x += ((c * -_anchorPointInPoints.x * _scaleX) + (-s * -_anchorPointInPoints.y * _scaleY));
y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY)); y += ((s * -_anchorPointInPoints.x * _scaleX) + (c * -_anchorPointInPoints.y * _scaleY));
} }
// Rot, Translate Matrix // Rot, Translate Matrix
_transform = AffineTransformMake( c * _scaleX, s * _scaleX, _transform = AffineTransformMake( c * _scaleX, s * _scaleX,
-s * _scaleY, c * _scaleY, -s * _scaleY, c * _scaleY,
x, y ); x, y );
return _transform; return _transform;
#endif
} }
#endif
NS_CC_EXT_END NS_CC_EXT_END

View File

@ -25,13 +25,8 @@
#include "cocos2d.h" #include "cocos2d.h"
#include "ExtensionMacros.h" #include "ExtensionMacros.h"
#if CC_ENABLE_CHIPMUNK_INTEGRATION struct cpBody;
#include "chipmunk.h"
#elif CC_ENABLE_BOX2D_INTEGRATION
class b2Body; class b2Body;
#else // CC_ENABLE_BOX2D_INTEGRATION
#error "You must define either CC_ENABLE_CHIPMUNK_INTEGRATION or CC_ENABLE_BOX2D_INTEGRATION to use PhysicsSprite.h"
#endif
NS_CC_EXT_BEGIN NS_CC_EXT_BEGIN
/** A Sprite subclass that is bound to a physics body. /** A Sprite subclass that is bound to a physics body.
@ -50,15 +45,15 @@ class PhysicsSprite : public Sprite
{ {
protected: protected:
bool _ignoreBodyRotation; bool _ignoreBodyRotation;
#if CC_ENABLE_CHIPMUNK_INTEGRATION
// chipmunk specific
cpBody *_CPBody; cpBody *_CPBody;
#elif CC_ENABLE_BOX2D_INTEGRATION // box2d specific
b2Body *_pB2Body; b2Body *_pB2Body;
// Pixels to Meters ratio
float _PTMRatio; float _PTMRatio;
#endif // CC_ENABLE_CHIPMUNK_INTEGRATION
public: public:
PhysicsSprite(); PhysicsSprite();
@ -110,18 +105,22 @@ public:
virtual void setRotation(float fRotation); virtual void setRotation(float fRotation);
virtual AffineTransform nodeToParentTransform(); virtual AffineTransform nodeToParentTransform();
#if CC_ENABLE_CHIPMUNK_INTEGRATION //
// Chipmunk specific
//
/** Body accessor when using regular Chipmunk */ /** Body accessor when using regular Chipmunk */
cpBody* getCPBody() const; cpBody* getCPBody() const;
void setCPBody(cpBody *pBody); void setCPBody(cpBody *pBody);
#elif CC_ENABLE_BOX2D_INTEGRATION
//
// Box2d specific
//
/** Body accessor when using box2d */ /** Body accessor when using box2d */
b2Body* getB2Body() const; b2Body* getB2Body() const;
void setB2Body(b2Body *pBody); void setB2Body(b2Body *pBody);
float getPTMRatio() const; float getPTMRatio() const;
void setPTMRatio(float fPTMRatio); void setPTMRatio(float fPTMRatio);
#endif // CC_ENABLE_BOX2D_INTEGRATION
protected: protected:
void updatePosFromPhysics(); void updatePosFromPhysics();

View File

@ -40,6 +40,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -66,6 +67,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -133,6 +135,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -159,6 +162,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -218,6 +222,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -244,6 +249,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -312,6 +318,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>
@ -338,6 +345,7 @@
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libjpeg"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libtiff/include"/>
<listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/> <listOptionValue builtIn="false" value="../../../cocos2dx/platform/third_party/linux/libwebp"/>
<listOptionValue builtIn="false" value="../../../CocosDenshion/include"/>
<listOptionValue builtIn="false" value="../../../external"/> <listOptionValue builtIn="false" value="../../../external"/>
<listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/> <listOptionValue builtIn="false" value="../../../external/chipmunk/include/chipmunk"/>
<listOptionValue builtIn="false" value="../.."/> <listOptionValue builtIn="false" value="../.."/>

View File

@ -112,6 +112,8 @@
1A0C0D4F1777F9CD00838530 /* Slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE31777F9CD00838530 /* Slot.cpp */; }; 1A0C0D4F1777F9CD00838530 /* Slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE31777F9CD00838530 /* Slot.cpp */; };
1A0C0D501777F9CD00838530 /* SlotData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE51777F9CD00838530 /* SlotData.cpp */; }; 1A0C0D501777F9CD00838530 /* SlotData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE51777F9CD00838530 /* SlotData.cpp */; };
1A0C0D511777F9CD00838530 /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */; }; 1A0C0D511777F9CD00838530 /* spine-cocos2dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */; };
A05FCAE8177C1A1400BE600E /* libwebsockets.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAE7177C1A1400BE600E /* libwebsockets.a */; };
A05FCAEA177C1F8E00BE600E /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A05FCAE9177C1F8E00BE600E /* libcurl.dylib */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
@ -361,9 +363,9 @@
1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "spine-cocos2dx.cpp"; sourceTree = "<group>"; }; 1A0C0CE71777F9CD00838530 /* spine-cocos2dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "spine-cocos2dx.cpp"; sourceTree = "<group>"; };
1A0C0CE81777F9CD00838530 /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "spine-cocos2dx.h"; sourceTree = "<group>"; }; 1A0C0CE81777F9CD00838530 /* spine-cocos2dx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "spine-cocos2dx.h"; sourceTree = "<group>"; };
1A0C0CE91777F9CD00838530 /* spine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spine.h; sourceTree = "<group>"; }; 1A0C0CE91777F9CD00838530 /* spine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spine.h; sourceTree = "<group>"; };
1A0C0D551777FAAD00838530 /* libwebsockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libwebsockets.h; sourceTree = "<group>"; }; A05FCAE5177C1A1400BE600E /* libwebsockets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libwebsockets.h; sourceTree = "<group>"; };
1A0C0D571777FAAD00838530 /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = "<group>"; }; A05FCAE7177C1A1400BE600E /* libwebsockets.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwebsockets.a; sourceTree = "<group>"; };
1A0C0D591777FB1300838530 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = ../../cocos2dx/platform/third_party/ios/libraries/libcurl.a; sourceTree = "<group>"; }; A05FCAE9177C1F8E00BE600E /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -371,7 +373,9 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A05FCAEA177C1F8E00BE600E /* libcurl.dylib in Frameworks */,
1A0C0A7E1777F79700838530 /* Foundation.framework in Frameworks */, 1A0C0A7E1777F79700838530 /* Foundation.framework in Frameworks */,
A05FCAE8177C1A1400BE600E /* libwebsockets.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -409,8 +413,8 @@
1A0C0A7C1777F79700838530 /* Frameworks */ = { 1A0C0A7C1777F79700838530 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1A0C0D591777FB1300838530 /* libcurl.a */, A05FCAE9177C1F8E00BE600E /* libcurl.dylib */,
1A0C0D521777FAAD00838530 /* libwebsockets */, A05FCAE3177C1A1400BE600E /* libwebsockets */,
1A0C0A7D1777F79700838530 /* Foundation.framework */, 1A0C0A7D1777F79700838530 /* Foundation.framework */,
); );
name = Frameworks; name = Frameworks;
@ -805,36 +809,28 @@
path = ../spine; path = ../spine;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
1A0C0D521777FAAD00838530 /* libwebsockets */ = { A05FCAE3177C1A1400BE600E /* libwebsockets */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1A0C0D531777FAAD00838530 /* ios */, A05FCAE4177C1A1400BE600E /* include */,
A05FCAE6177C1A1400BE600E /* lib */,
); );
name = libwebsockets; name = libwebsockets;
path = ../../external/libwebsockets; path = ../../external/libwebsockets/mac;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
1A0C0D531777FAAD00838530 /* ios */ = { A05FCAE4177C1A1400BE600E /* include */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1A0C0D541777FAAD00838530 /* include */, A05FCAE5177C1A1400BE600E /* libwebsockets.h */,
1A0C0D561777FAAD00838530 /* lib */,
);
path = ios;
sourceTree = "<group>";
};
1A0C0D541777FAAD00838530 /* include */ = {
isa = PBXGroup;
children = (
1A0C0D551777FAAD00838530 /* libwebsockets.h */,
); );
path = include; path = include;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
1A0C0D561777FAAD00838530 /* lib */ = { A05FCAE6177C1A1400BE600E /* lib */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
1A0C0D571777FAAD00838530 /* libwebsockets.a */, A05FCAE7177C1A1400BE600E /* libwebsockets.a */,
); );
path = lib; path = lib;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1017,7 +1013,7 @@
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1", "DEBUG=1",
"$(inherited)", CC_KEYBOARD_SUPPORT,
CC_TARGET_OS_MAC, CC_TARGET_OS_MAC,
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
@ -1046,6 +1042,7 @@
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
NDEBUG, NDEBUG,
CC_TARGET_OS_MAC, CC_TARGET_OS_MAC,
CC_KEYBOARD_SUPPORT,
); );
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES;

View File

@ -0,0 +1,993 @@
/*
* libwebsockets - small server side websockets and web server implementation
*
* Copyright (C) 2010-2013 Andy Green <andy@warmcat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation:
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#ifndef __LIBWEBSOCKET_H__
#define __LIBWEBSOCKET_H__
#ifdef __cplusplus
extern "C" {
#include <cstddef>
#endif
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <ws2tcpip.h>
#include <stddef.h>
#include "../win32port/win32helpers/websock-w32.h"
#include "../win32port/win32helpers/gettimeofday.h"
#define strcasecmp stricmp
#define getdtablesize() 30000
typedef int ssize_t;
#define LWS_VISIBLE
#ifdef LWS_DLL
#ifdef LWS_INTERNAL
#define LWS_EXTERN extern __declspec(dllexport)
#else
#define LWS_EXTERN extern __declspec(dllimport)
#endif
#else
#define LWS_EXTERN
#endif
#else // NOT WIN32
#include <poll.h>
#include <unistd.h>
#if defined(__GNUC__)
#define LWS_VISIBLE __attribute__((visibility("default")))
#else
#define LWS_VISIBLE
#endif
#endif
#include <assert.h>
#ifndef LWS_EXTERN
#define LWS_EXTERN extern
#endif
#define CONTEXT_PORT_NO_LISTEN 0
#define MAX_MUX_RECURSION 2
enum lws_log_levels {
LLL_ERR = 1 << 0,
LLL_WARN = 1 << 1,
LLL_NOTICE = 1 << 2,
LLL_INFO = 1 << 3,
LLL_DEBUG = 1 << 4,
LLL_PARSER = 1 << 5,
LLL_HEADER = 1 << 6,
LLL_EXT = 1 << 7,
LLL_CLIENT = 1 << 8,
LLL_LATENCY = 1 << 9,
LLL_COUNT = 10 /* set to count of valid flags */
};
LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...);
/* notice, warn and log are always compiled in */
#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)
#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)
#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
/*
* weaker logging can be deselected at configure time using --disable-debug
* that gets rid of the overhead of checking while keeping _warn and _err
* active
*/
#ifdef _DEBUG
#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__)
#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__)
#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__)
#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__)
#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__)
#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)
#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)
LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
#else /* no debug */
#define lwsl_info(...)
#define lwsl_debug(...)
#define lwsl_parser(...)
#define lwsl_header(...)
#define lwsl_ext(...)
#define lwsl_client(...)
#define lwsl_latency(...)
#define lwsl_hexdump(a, b)
#endif
enum libwebsocket_context_options {
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4,
};
enum libwebsocket_callback_reasons {
LWS_CALLBACK_ESTABLISHED,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
LWS_CALLBACK_CLIENT_ESTABLISHED,
LWS_CALLBACK_CLOSED,
LWS_CALLBACK_RECEIVE,
LWS_CALLBACK_CLIENT_RECEIVE,
LWS_CALLBACK_CLIENT_RECEIVE_PONG,
LWS_CALLBACK_CLIENT_WRITEABLE,
LWS_CALLBACK_SERVER_WRITEABLE,
LWS_CALLBACK_HTTP,
LWS_CALLBACK_HTTP_FILE_COMPLETION,
LWS_CALLBACK_HTTP_WRITEABLE,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION,
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED,
LWS_CALLBACK_PROTOCOL_INIT,
LWS_CALLBACK_PROTOCOL_DESTROY,
/* external poll() management support */
LWS_CALLBACK_ADD_POLL_FD,
LWS_CALLBACK_DEL_POLL_FD,
LWS_CALLBACK_SET_MODE_POLL_FD,
LWS_CALLBACK_CLEAR_MODE_POLL_FD,
};
#ifndef LWS_NO_EXTENSIONS
enum libwebsocket_extension_callback_reasons {
LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT,
LWS_EXT_CALLBACK_CONSTRUCT,
LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE,
LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION,
LWS_EXT_CALLBACK_DESTROY,
LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING,
LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED,
LWS_EXT_CALLBACK_PACKET_RX_PREPARSE,
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
LWS_EXT_CALLBACK_PACKET_TX_DO_SEND,
LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX,
LWS_EXT_CALLBACK_FLUSH_PENDING_TX,
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
LWS_EXT_CALLBACK_1HZ,
LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE,
LWS_EXT_CALLBACK_IS_WRITEABLE,
LWS_EXT_CALLBACK_PAYLOAD_TX,
LWS_EXT_CALLBACK_PAYLOAD_RX,
};
#endif
enum libwebsocket_write_protocol {
LWS_WRITE_TEXT,
LWS_WRITE_BINARY,
LWS_WRITE_CONTINUATION,
LWS_WRITE_HTTP,
/* special 04+ opcodes */
LWS_WRITE_CLOSE,
LWS_WRITE_PING,
LWS_WRITE_PONG,
/* flags */
LWS_WRITE_NO_FIN = 0x40,
/*
* client packet payload goes out on wire unmunged
* only useful for security tests since normal servers cannot
* decode the content if used
*/
LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80
};
/*
* you need these to look at headers that have been parsed if using the
* LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum
* list below is absent, .token = NULL and token_len = 0. Otherwise .token
* points to .token_len chars containing that header content.
*/
struct lws_tokens {
char *token;
int token_len;
};
enum lws_token_indexes {
WSI_TOKEN_GET_URI,
WSI_TOKEN_HOST,
WSI_TOKEN_CONNECTION,
WSI_TOKEN_KEY1,
WSI_TOKEN_KEY2,
WSI_TOKEN_PROTOCOL,
WSI_TOKEN_UPGRADE,
WSI_TOKEN_ORIGIN,
WSI_TOKEN_DRAFT,
WSI_TOKEN_CHALLENGE,
/* new for 04 */
WSI_TOKEN_KEY,
WSI_TOKEN_VERSION,
WSI_TOKEN_SWORIGIN,
/* new for 05 */
WSI_TOKEN_EXTENSIONS,
/* client receives these */
WSI_TOKEN_ACCEPT,
WSI_TOKEN_NONCE,
WSI_TOKEN_HTTP,
WSI_TOKEN_MUXURL,
/* use token storage to stash these */
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS,
_WSI_TOKEN_CLIENT_PEER_ADDRESS,
_WSI_TOKEN_CLIENT_URI,
_WSI_TOKEN_CLIENT_HOST,
_WSI_TOKEN_CLIENT_ORIGIN,
/* always last real token index*/
WSI_TOKEN_COUNT,
/* parser state additions */
WSI_TOKEN_NAME_PART,
WSI_TOKEN_SKIPPING,
WSI_TOKEN_SKIPPING_SAW_CR,
WSI_PARSING_COMPLETE,
WSI_INIT_TOKEN_MUXURL,
};
/*
* From RFC 6455
1000
1000 indicates a normal closure, meaning that the purpose for
which the connection was established has been fulfilled.
1001
1001 indicates that an endpoint is "going away", such as a server
going down or a browser having navigated away from a page.
1002
1002 indicates that an endpoint is terminating the connection due
to a protocol error.
1003
1003 indicates that an endpoint is terminating the connection
because it has received a type of data it cannot accept (e.g., an
endpoint that understands only text data MAY send this if it
receives a binary message).
1004
Reserved. The specific meaning might be defined in the future.
1005
1005 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that no status
code was actually present.
1006
1006 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that the
connection was closed abnormally, e.g., without sending or
receiving a Close control frame.
1007
1007 indicates that an endpoint is terminating the connection
because it has received data within a message that was not
consistent with the type of the message (e.g., non-UTF-8 [RFC3629]
data within a text message).
1008
1008 indicates that an endpoint is terminating the connection
because it has received a message that violates its policy. This
is a generic status code that can be returned when there is no
other more suitable status code (e.g., 1003 or 1009) or if there
is a need to hide specific details about the policy.
1009
1009 indicates that an endpoint is terminating the connection
because it has received a message that is too big for it to
process.
1010
1010 indicates that an endpoint (client) is terminating the
connection because it has expected the server to negotiate one or
more extension, but the server didn't return them in the response
message of the WebSocket handshake. The list of extensions that
are needed SHOULD appear in the /reason/ part of the Close frame.
Note that this status code is not used by the server, because it
can fail the WebSocket handshake instead.
1011
1011 indicates that a server is terminating the connection because
it encountered an unexpected condition that prevented it from
fulfilling the request.
1015
1015 is a reserved value and MUST NOT be set as a status code in a
Close control frame by an endpoint. It is designated for use in
applications expecting a status code to indicate that the
connection was closed due to a failure to perform a TLS handshake
(e.g., the server certificate can't be verified).
*/
enum lws_close_status {
LWS_CLOSE_STATUS_NOSTATUS = 0,
LWS_CLOSE_STATUS_NORMAL = 1000,
LWS_CLOSE_STATUS_GOINGAWAY = 1001,
LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002,
LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003,
LWS_CLOSE_STATUS_RESERVED = 1004,
LWS_CLOSE_STATUS_NO_STATUS = 1005,
LWS_CLOSE_STATUS_ABNORMAL_CLOSE = 1006,
LWS_CLOSE_STATUS_INVALID_PAYLOAD = 1007,
LWS_CLOSE_STATUS_POLICY_VIOLATION = 1008,
LWS_CLOSE_STATUS_MESSAGE_TOO_LARGE = 1009,
LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010,
LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011,
LWS_CLOSE_STATUS_TLS_FAILURE = 1015,
};
struct libwebsocket;
struct libwebsocket_context;
/* needed even with extensions disabled for create context */
struct libwebsocket_extension;
/**
* callback_function() - User server actions
* @context: Websockets context
* @wsi: Opaque websocket instance pointer
* @reason: The reason for the call
* @user: Pointer to per-session user data allocated by library
* @in: Pointer used for some callback reasons
* @len: Length set for some callback reasons
*
* This callback is the way the user controls what is served. All the
* protocol detail is hidden and handled by the library.
*
* For each connection / session there is user data allocated that is
* pointed to by "user". You set the size of this user data area when
* the library is initialized with libwebsocket_create_server.
*
* You get an opportunity to initialize user data when called back with
* LWS_CALLBACK_ESTABLISHED reason.
*
* LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with
* an incoming client
*
* LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has
* been unable to complete a handshake with the remote server
*
* LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH: this is the last chance for the
* client user code to examine the http headers
* and decide to reject the connection. If the
* content in the headers is interesting to the
* client (url, etc) it needs to copy it out at
* this point since it will be destroyed before
* the CLIENT_ESTABLISHED call
*
* LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed
* a handshake with the remote server
*
* LWS_CALLBACK_CLOSED: when the websocket session ends
*
* LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a
* remote client, it can be found at *in and is
* len bytes long
*
* LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets,
* they appear with this callback reason. PONG
* packets only exist in 04+ protocol
*
* LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the
* client connection, it can be found at *in and
* is len bytes long
*
* LWS_CALLBACK_HTTP: an http request has come from a client that is not
* asking to upgrade the connection to a websocket
* one. This is a chance to serve http content,
* for example, to send a script to the client
* which will then open the websockets connection.
* @in points to the URI path requested and
* libwebsockets_serve_http_file() makes it very
* simple to send back a file to the client.
* Normally after sending the file you are done
* with the http connection, since the rest of the
* activity will come by websockets from the script
* that was delivered by http, so you will want to
* return 1; to close and free up the connection.
* That's important because it uses a slot in the
* total number of client connections allowed set
* by MAX_CLIENTS.
*
* LWS_CALLBACK_HTTP_WRITEABLE: you can write more down the http protocol
* link now.
*
* LWS_CALLBACK_HTTP_FILE_COMPLETION: a file requested to be send down
* http link has completed.
*
* LWS_CALLBACK_CLIENT_WRITEABLE:
* LWS_CALLBACK_SERVER_WRITEABLE: If you call
* libwebsocket_callback_on_writable() on a connection, you will
* get one of these callbacks coming when the connection socket
* is able to accept another write packet without blocking.
* If it already was able to take another packet without blocking,
* you'll get this callback at the next call to the service loop
* function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
* and servers get LWS_CALLBACK_SERVER_WRITEABLE.
*
* LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to
* the server at network level; the connection is accepted but then
* passed to this callback to decide whether to hang up immediately
* or not, based on the client IP. @in contains the connection
* socket's descriptor. Return non-zero to terminate
* the connection before sending or receiving anything.
* Because this happens immediately after the network connection
* from the client, there's no websocket protocol selected yet so
* this callback is issued only to protocol 0.
*
* LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has
* been received and parsed from the client, but the response is
* not sent yet. Return non-zero to disallow the connection.
* @user is a pointer to an array of struct lws_tokens, you can
* use the header enums lws_token_indexes from libwebsockets.h
* to check for and read the supported header presence and
* content before deciding to allow the handshake to proceed or
* to kill the connection.
*
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for
* including OpenSSL support, this callback allows your user code
* to perform extra SSL_CTX_load_verify_locations() or similar
* calls to direct OpenSSL where to find certificates the client
* can use to confirm the remote server identity. @user is the
* OpenSSL SSL_CTX*
*
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for
* including OpenSSL support, this callback allows your user code
* to load extra certifcates into the server which allow it to
* verify the validity of certificates returned by clients. @user
* is the server's OpenSSL SSL_CTX*
*
* LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the
* libwebsockets context was created with the option
* LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this
* callback is generated during OpenSSL verification of the cert
* sent from the client. It is sent to protocol[0] callback as
* no protocol has been negotiated on the connection yet.
* Notice that the libwebsockets context and wsi are both NULL
* during this callback. See
* http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
* to understand more detail about the OpenSSL callback that
* generates this libwebsockets callback and the meanings of the
* arguments passed. In this callback, @user is the x509_ctx,
* @in is the ssl pointer and @len is preverify_ok
* Notice that this callback maintains libwebsocket return
* conventions, return 0 to mean the cert is OK or 1 to fail it.
* This also means that if you don't handle this callback then
* the default callback action of returning 0 allows the client
* certificates.
*
* LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens
* when a client handshake is being compiled. @user is NULL,
* @in is a char **, it's pointing to a char * which holds the
* next location in the header buffer where you can add
* headers, and @len is the remaining space in the header buffer,
* which is typically some hundreds of bytes. So, to add a canned
* cookie, your handler code might look similar to:
*
* char **p = (char **)in;
*
* if (len < 100)
* return 1;
*
* *p += sprintf(*p, "Cookie: a=b\x0d\x0a");
*
* return 0;
*
* Notice if you add anything, you just have to take care about
* the CRLF on the line you added. Obviously this callback is
* optional, if you don't handle it everything is fine.
*
* Notice the callback is coming to protocols[0] all the time,
* because there is no specific protocol handshook yet.
*
* LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code
* sees that it does support a requested extension, before
* accepting the extension by additing to the list sent back to
* the client it gives this callback just to check that it's okay
* to use that extension. It calls back to the requested protocol
* and with @in being the extension name, @len is 0 and @user is
* valid. Note though at this time the ESTABLISHED callback hasn't
* happened yet so if you initialize @user content there, @user
* content during this callback might not be useful for anything.
* Notice this callback comes to protocols[0].
*
* LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client
* connection is being prepared to start a handshake to a server,
* each supported extension is checked with protocols[0] callback
* with this reason, giving the user code a chance to suppress the
* claim to support that extension by returning non-zero. If
* unhandled, by default 0 will be returned and the extension
* support included in the header to the server. Notice this
* callback comes to protocols[0].
*
* LWS_CALLBACK_PROTOCOL_INIT: One-time call per protocol so it can
* do initial setup / allocations etc
*
* LWS_CALLBACK_PROTOCOL_DESTROY: One-time call per protocol indicating
* this protocol won't get used at all after this callback, the
* context is getting destroyed. Take the opportunity to
* deallocate everything that was allocated by the protocol.
*
* The next four reasons are optional and only need taking care of if you
* will be integrating libwebsockets sockets into an external polling
* array.
*
* LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop
* internally, but in the case you are integrating with another
* server you will need to have libwebsocket sockets share a
* polling array with the other server. This and the other
* POLL_FD related callbacks let you put your specialized
* poll array interface code in the callback for protocol 0, the
* first protocol you support, usually the HTTP protocol in the
* serving case. This callback happens when a socket needs to be
* added to the polling loop: @in contains the fd, and
* @len is the events bitmap (like, POLLIN). If you are using the
* internal polling loop (the "service" callback), you can just
* ignore these callbacks.
*
* LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
* needs to be removed from an external polling array. @in is
* the socket desricptor. If you are using the internal polling
* loop, you can just ignore it.
*
* LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets
* wants to modify the events for the socket descriptor in @in.
* The handler should OR @len on to the events member of the pollfd
* struct for this socket descriptor. If you are using the
* internal polling loop, you can just ignore it.
*
* LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets
* wants to modify the events for the socket descriptor in @in.
* The handler should AND ~@len on to the events member of the
* pollfd struct for this socket descriptor. If you are using the
* internal polling loop, you can just ignore it.
*/
LWS_VISIBLE LWS_EXTERN int callback(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
typedef int (callback_function)(struct libwebsocket_context *context,
struct libwebsocket *wsi,
enum libwebsocket_callback_reasons reason, void *user,
void *in, size_t len);
#ifndef LWS_NO_EXTENSIONS
/**
* extension_callback_function() - Hooks to allow extensions to operate
* @context: Websockets context
* @ext: This extension
* @wsi: Opaque websocket instance pointer
* @reason: The reason for the call
* @user: Pointer to per-session user data allocated by library
* @in: Pointer used for some callback reasons
* @len: Length set for some callback reasons
*
* Each extension that is active on a particular connection receives
* callbacks during the connection lifetime to allow the extension to
* operate on websocket data and manage itself.
*
* Libwebsockets takes care of allocating and freeing "user" memory for
* each active extension on each connection. That is what is pointed to
* by the @user parameter.
*
* LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to
* select this extension from the list provided by the client,
* just before the server will send back the handshake accepting
* the connection with this extension active. This gives the
* extension a chance to initialize its connection context found
* in @user.
*
* LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT
* but called when client is instantiating this extension. Some
* extensions will work the same on client and server side and then
* you can just merge handlers for both CONSTRUCTS.
*
* LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was
* being used on is about to be closed and deallocated. It's the
* last chance for the extension to deallocate anything it has
* allocated in the user data (pointed to by @user) before the
* user data is deleted. This same callback is used whether you
* are in client or server instantiation context.
*
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on
* a connection, and a packet of data arrived at the connection,
* it is passed to this callback to give the extension a chance to
* change the data, eg, decompress it. @user is pointing to the
* extension's private connection context data, @in is pointing
* to an lws_tokens struct, it consists of a char * pointer called
* token, and an int called token_len. At entry, these are
* set to point to the received buffer and set to the content
* length. If the extension will grow the content, it should use
* a new buffer allocated in its private user context data and
* set the pointed-to lws_tokens members to point to its buffer.
*
* LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the
* extension a chance to change websocket data just before it will
* be sent out. Using the same lws_token pointer scheme in @in,
* the extension can change the buffer and the length to be
* transmitted how it likes. Again if it wants to grow the
* buffer safely, it should copy the data into its own buffer and
* set the lws_tokens token pointer to it.
*/
LWS_VISIBLE LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);
typedef int (extension_callback_function)(struct libwebsocket_context *context,
struct libwebsocket_extension *ext,
struct libwebsocket *wsi,
enum libwebsocket_extension_callback_reasons reason,
void *user, void *in, size_t len);
#endif
/**
* struct libwebsocket_protocols - List of protocols and handlers server
* supports.
* @name: Protocol name that must match the one given in the client
* Javascript new WebSocket(url, 'protocol') name
* @callback: The service callback used for this protocol. It allows the
* service action for an entire protocol to be encapsulated in
* the protocol-specific callback
* @per_session_data_size: Each new connection using this protocol gets
* this much memory allocated on connection establishment and
* freed on connection takedown. A pointer to this per-connection
* allocation is passed into the callback in the 'user' parameter
* @rx_buffer_size: if you want atomic frames delivered to the callback, you
* should set this to the size of the biggest legal frame that
* you support. If the frame size is exceeded, there is no
* error, but the buffer will spill to the user callback when
* full, which you can detect by using
* libwebsockets_remaining_packet_payload(). Notice that you
* just talk about frame size here, the LWS_SEND_BUFFER_PRE_PADDING
* and post-padding are automatically also allocated on top.
* @owning_server: the server init call fills in this opaque pointer when
* registering this protocol with the server.
* @protocol_index: which protocol we are starting from zero
*
* This structure represents one protocol supported by the server. An
* array of these structures is passed to libwebsocket_create_server()
* allows as many protocols as you like to be handled by one server.
*/
struct libwebsocket_protocols {
const char *name;
callback_function *callback;
size_t per_session_data_size;
size_t rx_buffer_size;
/*
* below are filled in on server init and can be left uninitialized,
* no need for user to use them directly either
*/
struct libwebsocket_context *owning_server;
int protocol_index;
};
#ifndef LWS_NO_EXTENSIONS
/**
* struct libwebsocket_extension - An extension we know how to cope with
*
* @name: Formal extension name, eg, "deflate-stream"
* @callback: Service callback
* @per_session_data_size: Libwebsockets will auto-malloc this much
* memory for the use of the extension, a pointer
* to it comes in the @user callback parameter
* @per_context_private_data: Optional storage for this extension that
* is per-context, so it can track stuff across
* all sessions, etc, if it wants
*/
struct libwebsocket_extension {
const char *name;
extension_callback_function *callback;
size_t per_session_data_size;
void *per_context_private_data;
};
#endif
/**
* struct lws_context_creation_info: parameters to create context with
*
* @port: Port to listen on... you can use 0 to suppress listening on
* any port, that's what you want if you are not running a
* websocket server at all but just using it as a client
* @iface: NULL to bind the listen socket to all interfaces, or the
* interface name, eg, "eth2"
* @protocols: Array of structures listing supported protocols and a protocol-
* specific callback for each one. The list is ended with an
* entry that has a NULL callback pointer.
* It's not const because we write the owning_server member
* @extensions: NULL or array of libwebsocket_extension structs listing the
* extensions this context supports. If you configured with
* --without-extensions, you should give NULL here.
* @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want
* to listen using SSL, set to the filepath to fetch the
* server cert from, otherwise NULL for unencrypted
* @ssl_private_key_filepath: filepath to private key if wanting SSL mode,
* else ignored
* @ssl_ca_filepath: CA certificate filepath or NULL
* @ssl_cipher_list: List of valid ciphers to use (eg,
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL"
* or you can leave it as NULL to get "DEFAULT"
* @gid: group id to change to after setting listen socket, or -1.
* @uid: user id to change to after setting listen socket, or -1.
* @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
* @user: optional user pointer that can be recovered via the context
* pointer using libwebsocket_context_user
* @ka_time: 0 for no keepalive, otherwise apply this keepalive timeout to
* all libwebsocket sockets, client or server
* @ka_probes: if ka_time was nonzero, after the timeout expires how many
* times to try to get a response from the peer before giving up
* and killing the connection
* @ka_interval: if ka_time was nonzero, how long to wait before each ka_probes
* attempt
*/
struct lws_context_creation_info {
int port;
const char *iface;
struct libwebsocket_protocols *protocols;
struct libwebsocket_extension *extensions;
const char *ssl_cert_filepath;
const char *ssl_private_key_filepath;
const char *ssl_ca_filepath;
const char *ssl_cipher_list;
int gid;
int uid;
unsigned int options;
void *user;
int ka_time;
int ka_probes;
int ka_interval;
};
LWS_VISIBLE LWS_EXTERN
void lws_set_log_level(int level,
void (*log_emit_function)(int level, const char *line));
LWS_VISIBLE LWS_EXTERN void
lwsl_emit_syslog(int level, const char *line);
LWS_VISIBLE LWS_EXTERN struct libwebsocket_context *
libwebsocket_create_context(struct lws_context_creation_info *info);
LWS_VISIBLE LWS_EXTERN void
libwebsocket_context_destroy(struct libwebsocket_context *context);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_service_fd(struct libwebsocket_context *context,
struct pollfd *pollfd);
LWS_VISIBLE LWS_EXTERN void *
libwebsocket_context_user(struct libwebsocket_context *context);
/*
* IMPORTANT NOTICE!
*
* When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY)
* the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE
* buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len).
*
* This allows us to add protocol info before and after the data, and send as
* one packet on the network without payload copying, for maximum efficiency.
*
* So for example you need this kind of code to use libwebsocket_write with a
* 128-byte payload
*
* char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING];
*
* // fill your part of the buffer... for example here it's all zeros
* memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
*
* libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128,
* LWS_WRITE_TEXT);
*
* When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
* use the whole buffer without taking care of the above.
*/
/*
* this is the frame nonce plus two header plus 8 length
* there's an additional two for mux extension per mux nesting level
* 2 byte prepend on close will already fit because control frames cannot use
* the big length style
*/
#define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION))
#define LWS_SEND_BUFFER_POST_PADDING 4
LWS_VISIBLE LWS_EXTERN int
libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
enum libwebsocket_write_protocol protocol);
LWS_VISIBLE LWS_EXTERN int
libwebsockets_serve_http_file(struct libwebsocket_context *context,
struct libwebsocket *wsi, const char *file,
const char *content_type);
LWS_VISIBLE LWS_EXTERN int
libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN const struct libwebsocket_protocols *
libwebsockets_get_protocol(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_callback_on_writable(struct libwebsocket_context *context,
struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_callback_on_writable_all_protocol(
const struct libwebsocket_protocols *protocol);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_get_socket_fd(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_is_final_fragment(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN unsigned char
libwebsocket_get_reserved_bits(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int
libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
LWS_VISIBLE LWS_EXTERN void
libwebsocket_rx_flow_allow_all_protocol(
const struct libwebsocket_protocols *protocol);
LWS_VISIBLE LWS_EXTERN size_t
libwebsockets_remaining_packet_payload(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect(struct libwebsocket_context *clients,
const char *address,
int port,
int ssl_connection,
const char *path,
const char *host,
const char *origin,
const char *protocol,
int ietf_version_or_minus_one);
LWS_VISIBLE LWS_EXTERN struct libwebsocket *
libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
const char *address,
int port,
int ssl_connection,
const char *path,
const char *host,
const char *origin,
const char *protocol,
int ietf_version_or_minus_one,
void *userdata);
LWS_VISIBLE LWS_EXTERN const char *
libwebsocket_canonical_hostname(struct libwebsocket_context *context);
LWS_VISIBLE LWS_EXTERN void
libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
struct libwebsocket *wsi, int fd, char *name, int name_len,
char *rip, int rip_len);
LWS_VISIBLE LWS_EXTERN int
libwebsockets_get_random(struct libwebsocket_context *context,
void *buf, int len);
LWS_VISIBLE LWS_EXTERN int
lws_daemonize(const char *_lock_path);
LWS_VISIBLE LWS_EXTERN int
lws_send_pipe_choked(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN int
lws_frame_is_binary(struct libwebsocket *wsi);
LWS_VISIBLE LWS_EXTERN unsigned char *
libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);
LWS_VISIBLE LWS_EXTERN int
lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
LWS_VISIBLE LWS_EXTERN int
lws_b64_decode_string(const char *in, char *out, int out_size);
LWS_VISIBLE LWS_EXTERN const char *
lws_get_library_version(void);
/* access to headers... only valid while headers valid */
LWS_VISIBLE LWS_EXTERN int
lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h);
LWS_VISIBLE LWS_EXTERN int
lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
enum lws_token_indexes h);
/*
* Note: this is not normally needed as a user api. It's provided in case it is
* useful when integrating with other app poll loop service code.
*/
LWS_VISIBLE LWS_EXTERN int
libwebsocket_read(struct libwebsocket_context *context,
struct libwebsocket *wsi,
unsigned char *buf, size_t len);
#ifndef LWS_NO_EXTENSIONS
LWS_VISIBLE LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions();
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1 @@
5d0743ce07a9c865d4367d8e3db161148676f2c8

View File

@ -212,7 +212,10 @@
FADC44B6176EA82000B2D5ED /* Debug */ = { FADC44B6176EA82000B2D5ED /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginAdmob.dst; DSTROOT = /tmp/PluginAdmob.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch"; GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
@ -229,7 +232,10 @@
FADC44B7176EA82000B2D5ED /* Release */ = { FADC44B7176EA82000B2D5ED /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginAdmob.dst; DSTROOT = /tmp/PluginAdmob.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch"; GCC_PREFIX_HEADER = "PluginAdmob-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";

View File

@ -102,7 +102,7 @@
FA09A369168AFD41008C1C7B /* Project object */ = { FA09A369168AFD41008C1C7B /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin; ORGANIZATIONNAME = zhangbin;
}; };
buildConfigurationList = FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */; buildConfigurationList = FA09A36C168AFD41008C1C7B /* Build configuration list for PBXProject "PluginFlurry" */;
@ -141,6 +141,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -167,6 +170,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -183,8 +189,10 @@
FA09A381168AFD41008C1C7B /* Debug */ = { FA09A381168AFD41008C1C7B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginFlurry.dst; DSTROOT = /tmp/libPluginFlurry.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
@ -202,8 +210,10 @@
FA09A382168AFD41008C1C7B /* Release */ = { FA09A382168AFD41008C1C7B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginFlurry.dst; DSTROOT = /tmp/libPluginFlurry.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch"; GCC_PREFIX_HEADER = "PluginFlurry-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";

View File

@ -179,7 +179,7 @@
FACAD87F1762C1B500D75ADE /* Project object */ = { FACAD87F1762C1B500D75ADE /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin; ORGANIZATIONNAME = zhangbin;
}; };
buildConfigurationList = FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */; buildConfigurationList = FACAD8821762C1B500D75ADE /* Build configuration list for PBXProject "PluginTwitter" */;
@ -226,6 +226,9 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -251,6 +254,9 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -267,8 +273,10 @@
FACAD8971762C1B500D75ADE /* Debug */ = { FACAD8971762C1B500D75ADE /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginTwitter.dst; DSTROOT = /tmp/PluginTwitter.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch"; GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
@ -281,8 +289,10 @@
FACAD8981762C1B500D75ADE /* Release */ = { FACAD8981762C1B500D75ADE /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginTwitter.dst; DSTROOT = /tmp/PluginTwitter.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch"; GCC_PREFIX_HEADER = "PluginTwitter-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";

View File

@ -74,7 +74,11 @@ THE SOFTWARE.
- (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
{ {
OUTPUT_LOG(@"Umeng logEventWithParam invoked"); OUTPUT_LOG(@"Umeng logEventWithParam invoked");
[MobClick event:eventId attributes:paramMap]; if (paramMap != nil) {
[MobClick event:eventId attributes:paramMap];
} else {
[MobClick event:eventId];
}
} }
- (void) logTimedEventBegin: (NSString*) eventId - (void) logTimedEventBegin: (NSString*) eventId

View File

@ -100,7 +100,7 @@
FA09A2F8168ADAEC008C1C7B /* Project object */ = { FA09A2F8168ADAEC008C1C7B /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin; ORGANIZATIONNAME = zhangbin;
}; };
buildConfigurationList = FA09A2FB168ADAEC008C1C7B /* Build configuration list for PBXProject "PluginUmeng" */; buildConfigurationList = FA09A2FB168ADAEC008C1C7B /* Build configuration list for PBXProject "PluginUmeng" */;
@ -139,6 +139,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -165,6 +168,9 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -181,8 +187,10 @@
FA09A310168ADAEC008C1C7B /* Debug */ = { FA09A310168ADAEC008C1C7B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginUmeng.dst; DSTROOT = /tmp/libPluginUmeng.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
@ -200,8 +208,10 @@
FA09A311168ADAEC008C1C7B /* Release */ = { FA09A311168ADAEC008C1C7B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/libPluginUmeng.dst; DSTROOT = /tmp/libPluginUmeng.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch"; GCC_PREFIX_HEADER = "PluginUmeng-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";

View File

@ -142,7 +142,7 @@
FAE27527175D9D2900F5DA8E /* Project object */ = { FAE27527175D9D2900F5DA8E /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0440; LastUpgradeCheck = 0460;
ORGANIZATIONNAME = zhangbin; ORGANIZATIONNAME = zhangbin;
}; };
buildConfigurationList = FAE2752A175D9D2900F5DA8E /* Build configuration list for PBXProject "PluginWeibo" */; buildConfigurationList = FAE2752A175D9D2900F5DA8E /* Build configuration list for PBXProject "PluginWeibo" */;
@ -184,6 +184,9 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -209,6 +212,9 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)"; ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@ -225,9 +231,10 @@
FAE2753F175D9D2B00F5DA8E /* Debug */ = { FAE2753F175D9D2B00F5DA8E /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginWeibo.dst; DSTROOT = /tmp/PluginWeibo.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";
@ -240,9 +247,10 @@
FAE27540175D9D2B00F5DA8E /* Release */ = { FAE27540175D9D2B00F5DA8E /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; CLANG_CXX_LANGUAGE_STANDARD = "compiler-default";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "compiler-default";
DSTROOT = /tmp/PluginWeibo.dst; DSTROOT = /tmp/PluginWeibo.dst;
GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch"; GCC_PREFIX_HEADER = "PluginWeibo-Prefix.pch";
HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios"; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../protocols/platform/ios";

View File

@ -1,35 +1,36 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org Copyright (c) 2012+2013 cocos2d+x.org
http://www.cocos2d-x.org http://www.cocos2d+x.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#import <UIKit/UIKit.h> @protocol InterfaceUser <NSObject>
@class RootViewController; - (void) configDeveloperInfo : (NSMutableDictionary*) cpInfo;
- (void) login;
@interface AppController : NSObject <UIApplicationDelegate> { - (void) logout;
UIWindow *window; - (BOOL) isLogined;
RootViewController *viewController; - (NSString*) getSessionID;
} - (void) setDebugMode: (BOOL) debug;
- (NSString*) getSDKVersion;
@end - (NSString*) getPluginVersion;
@end

View File

@ -0,0 +1,80 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "ProtocolUser.h"
#include "PluginUtilsIOS.h"
#import "InterfaceUser.h"
namespace cocos2d { namespace plugin {
ProtocolUser::ProtocolUser()
: _listener(NULL)
{
}
ProtocolUser::~ProtocolUser()
{
}
void ProtocolUser::configDeveloperInfo(TUserDeveloperInfo devInfo)
{
if (devInfo.empty())
{
PluginUtilsIOS::outputLog("The developer info is empty for %s!", this->getPluginName());
return;
}
else
{
PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this);
assert(pData != NULL);
id ocObj = pData->obj;
if ([ocObj conformsToProtocol:@protocol(InterfaceUser)]) {
NSObject<InterfaceUser>* curObj = ocObj;
NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo);
[curObj configDeveloperInfo:pDict];
}
}
}
void ProtocolUser::login()
{
PluginUtilsIOS::callOCFunctionWithName(this, "login");
}
void ProtocolUser::logout()
{
PluginUtilsIOS::callOCFunctionWithName(this, "logout");
}
bool ProtocolUser::isLogined()
{
return PluginUtilsIOS::callOCBoolFunctionWithName(this, "isLogined");
}
std::string ProtocolUser::getSessionID()
{
return PluginUtilsIOS::callOCStringFunctionWithName(this, "getSessionID");
}
}} // namespace cocos2d { namespace plugin {

View File

@ -1,32 +1,40 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org Copyright (c) 2012+2013 cocos2d+x.org
http://www.cocos2d-x.org http://www.cocos2d+x.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#import <UIKit/UIKit.h> #import <Foundation/Foundation.h>
typedef enum {
@interface RootViewController : UIViewController { kLoginSucceed = 0,
kLoginFailed,
} kLogoutSucceed,
} UserActionResult;
@end
@interface UserWrapper : NSObject
{
}
+ (void) onActionResult:(id) obj withRet:(UserActionResult) ret withMsg:(NSString*) msg;
@end

View File

@ -1,43 +1,53 @@
/**************************************************************************** /****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2012+2013 cocos2d+x.org
http://www.cocos2d-x.org http://www.cocos2d+x.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
package org.cocos2dx.helloIAP;
#import "UserWrapper.h"
import org.cocos2dx.lib.Cocos2dxActivity; #include "PluginUtilsIOS.h"
import org.cocos2dx.lib.Cocos2dxGLSurfaceView; #include "ProtocolUser.h"
import org.cocos2dx.plugin.PluginWrapper;
using namespace cocos2d::plugin;
import android.os.Bundle;
@implementation UserWrapper
public class HelloIAP extends Cocos2dxActivity{
+ (void) onActionResult:(id) obj withRet:(UserActionResult) ret withMsg:(NSString*) msg
protected void onCreate(Bundle savedInstanceState){ {
super.onCreate(savedInstanceState); PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj);
PluginWrapper.init(this); ProtocolUser* pUser = dynamic_cast<ProtocolUser*>(pPlugin);
PluginWrapper.setGLSurfaceView(Cocos2dxGLSurfaceView.getInstance()); if (pUser) {
} UserActionListener* listener = pUser->getActionListener();
if (NULL != listener)
static { {
System.loadLibrary("game"); const char* chMsg = [msg UTF8String];
} listener->onActionResult(pUser, (UserActionResultCode) ret, chMsg);
} }
else
{
PluginUtilsIOS::outputLog("Listener of plugin %s not set correctly", pPlugin->getPluginName());
}
} else {
PluginUtilsIOS::outputLog("Can't find the C++ object of the User plugin");
}
}
@end

View File

@ -19,6 +19,8 @@
FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF991755D93600C90D89 /* PluginProtocol.mm */; }; FAB6DF9A1755D93600C90D89 /* PluginProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAB6DF991755D93600C90D89 /* PluginProtocol.mm */; };
FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */; }; FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */; };
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */; }; FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */; };
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551D177D1FA900968F54 /* ProtocolUser.mm */; };
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FAD5551F177D1FA900968F54 /* UserWrapper.mm */; };
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; }; FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -63,6 +65,11 @@
FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolShare.mm; sourceTree = "<group>"; }; FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolShare.mm; sourceTree = "<group>"; };
FAC2A7F71777F8C200035D22 /* ShareWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareWrapper.h; sourceTree = "<group>"; }; FAC2A7F71777F8C200035D22 /* ShareWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareWrapper.h; sourceTree = "<group>"; };
FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShareWrapper.mm; sourceTree = "<group>"; }; FAC2A7F81777F8C200035D22 /* ShareWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShareWrapper.mm; sourceTree = "<group>"; };
FAD5551C177D1FA900968F54 /* InterfaceUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceUser.h; sourceTree = "<group>"; };
FAD5551D177D1FA900968F54 /* ProtocolUser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProtocolUser.mm; sourceTree = "<group>"; };
FAD5551E177D1FA900968F54 /* UserWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserWrapper.h; sourceTree = "<group>"; };
FAD5551F177D1FA900968F54 /* UserWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserWrapper.mm; sourceTree = "<group>"; };
FAD55522177D213F00968F54 /* ProtocolUser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProtocolUser.h; sourceTree = "<group>"; };
FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = "<group>"; }; FADC44C8176EABCF00B2D5ED /* AdsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdsWrapper.h; sourceTree = "<group>"; };
FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = "<group>"; }; FADC44C9176EABCF00B2D5ED /* AdsWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AdsWrapper.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -112,6 +119,7 @@
FA09A336168ADC05008C1C7B /* include */ = { FA09A336168ADC05008C1C7B /* include */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FAD55522177D213F00968F54 /* ProtocolUser.h */,
FAC2A7F41777F88700035D22 /* ProtocolShare.h */, FAC2A7F41777F88700035D22 /* ProtocolShare.h */,
FAB6DF931755D7D100C90D89 /* PluginFactory.h */, FAB6DF931755D7D100C90D89 /* PluginFactory.h */,
FAB6DF941755D7D100C90D89 /* PluginParam.h */, FAB6DF941755D7D100C90D89 /* PluginParam.h */,
@ -128,6 +136,10 @@
FA0CB8B5168D3CC200E36B11 /* ios */ = { FA0CB8B5168D3CC200E36B11 /* ios */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
FAD5551C177D1FA900968F54 /* InterfaceUser.h */,
FAD5551D177D1FA900968F54 /* ProtocolUser.mm */,
FAD5551E177D1FA900968F54 /* UserWrapper.h */,
FAD5551F177D1FA900968F54 /* UserWrapper.mm */,
FAC2A7F51777F8C200035D22 /* InterfaceShare.h */, FAC2A7F51777F8C200035D22 /* InterfaceShare.h */,
FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */, FAC2A7F61777F8C200035D22 /* ProtocolShare.mm */,
FAC2A7F71777F8C200035D22 /* ShareWrapper.h */, FAC2A7F71777F8C200035D22 /* ShareWrapper.h */,
@ -212,6 +224,8 @@
FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */, FADC44CA176EABCF00B2D5ED /* AdsWrapper.mm in Sources */,
FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */, FAC2A7F91777F8C200035D22 /* ProtocolShare.mm in Sources */,
FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */, FAC2A7FA1777F8C200035D22 /* ShareWrapper.mm in Sources */,
FAD55520177D1FA900968F54 /* ProtocolUser.mm in Sources */,
FAD55521177D1FA900968F54 /* UserWrapper.mm in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -273,8 +287,10 @@
FA09A330168ADBC2008C1C7B /* Debug */ = { FA09A330168ADBC2008C1C7B /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginProtocol.dst; DSTROOT = /tmp/PluginProtocol.dst;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch"; GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";
@ -286,8 +302,10 @@
FA09A331168ADBC2008C1C7B /* Release */ = { FA09A331168ADBC2008C1C7B /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++"; CLANG_CXX_LIBRARY = "libc++";
DSTROOT = /tmp/PluginProtocol.dst; DSTROOT = /tmp/PluginProtocol.dst;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch"; GCC_PREFIX_HEADER = "PluginProtocol-Prefix.pch";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = "-ObjC";

View File

@ -1,75 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "HelloWorldScene.h"
USING_NS_CC;
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
Director* pDirector = Director::sharedDirector();
EGLView* pEGLView = EGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
Director::sharedDirector()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
Director::sharedDirector()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -1,61 +0,0 @@
/****************************************************************************
Copyright (c) 2012-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.
****************************************************************************/
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "cocos2d.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
};
#endif // _APP_DELEGATE_H_

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
<classpathentry exported="true" kind="lib" path="plugin-x/protocols/android/libPluginProtocol.jar"/>
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/admob/android/GoogleAdMobAdsSdk.jar"/>
<classpathentry exported="true" kind="lib" path="plugin-x/plugins/admob/android/libPluginAdmob.jar"/>
</classpath>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloAds</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>Classes</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/Classes</locationURI>
</link>
<link>
<name>plugin-x</name>
<type>2</type>
<locationURI>PARENT-3-PROJECT_LOC/publish</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@ -1,21 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.cocos2dx.HelloAds" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" />
<uses-feature android:glEsVersion="0x00020000" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation" android:label="@string/app_name" android:name=".HelloAds" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.ads.AdActivity" />
</application>
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloAds" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,21 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static \
PluginProtocolStatic
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cocos2dx)
$(call import-module,protocols/android)

View File

@ -1,13 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-13
android.library.reference.1=../../../../cocos2dx/platform/android/java

View File

@ -1,155 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
#include "PluginManager.h"
#include "ProtocolAnalytics.h"
using namespace cocos2d::plugin;
USING_NS_CC;
// The app key of flurry
#define FLURRY_KEY_IOS "KMGG7CD9WPK2TW4X9VR8"
#define FLURRY_KEY_ANDROID "SPKFH8KMPGHMMBWRBT5W"
#define UMENG_KEY_IOS "50d2b18c5270152187000097"
#define UMENG_KEY_ANDROID "" // umeng key for android is setted in AndroidManifest.xml
ProtocolAnalytics* g_pAnalytics = NULL;
std::string s_strAppKey = "";
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
void AppDelegate::loadAnalyticsPlugin()
{
PluginProtocol* pPlugin = NULL;
ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage();
std::string umengKey = "";
std::string flurryKey = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
umengKey = UMENG_KEY_IOS;
flurryKey = FLURRY_KEY_IOS;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
umengKey = UMENG_KEY_ANDROID;
flurryKey = FLURRY_KEY_ANDROID;
#endif
if (kLanguageChinese == langType)
{
pPlugin = PluginManager::getInstance()->loadPlugin("AnalyticsUmeng");
s_strAppKey = umengKey;
}
else
{
pPlugin = PluginManager::getInstance()->loadPlugin("AnalyticsFlurry");
s_strAppKey = flurryKey;
}
g_pAnalytics = dynamic_cast<ProtocolAnalytics*>(pPlugin);
}
bool AppDelegate::applicationDidFinishLaunching()
{
loadAnalyticsPlugin();
g_pAnalytics->setDebugMode(true);
g_pAnalytics->startSession(s_strAppKey.c_str());
g_pAnalytics->setCaptureUncaughtException(true);
g_pAnalytics->setSessionContinueMillis(10000);
const char* sdkVer = g_pAnalytics->getSDKVersion().c_str();
CCLog("SDK version : %s", sdkVer);
g_pAnalytics->callFuncWithParam("updateOnlineConfig", NULL);
PluginParam pParam1(true);
g_pAnalytics->callFuncWithParam("setReportLocation", &pParam1, NULL);
g_pAnalytics->callFuncWithParam("logPageView", NULL);
PluginParam pParam2("1.1");
g_pAnalytics->callFuncWithParam("setVersionName", &pParam2, NULL);
PluginParam pParam3(20);
g_pAnalytics->callFuncWithParam("setAge", &pParam3, NULL);
PluginParam pParam4(1);
g_pAnalytics->callFuncWithParam("setGender", &pParam4, NULL);
PluginParam pParam5("123456");
g_pAnalytics->callFuncWithParam("setUserId", &pParam5, NULL);
PluginParam pParam6(false);
g_pAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL);
// initialize director
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
// turn on display FPS
//pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
Director::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
g_pAnalytics->stopSession();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::sharedDirector()->resume();
if (g_pAnalytics)
{
g_pAnalytics->startSession(s_strAppKey.c_str());
}
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -1,63 +0,0 @@
/****************************************************************************
Copyright (c) 2012-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.
****************************************************************************/
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
static void loadAnalyticsPlugin();
};
#endif // _APP_DELEGATE_H_

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="publish/protocols/android/libPluginProtocol.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/flurry/android/FlurryAgent.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/flurry/android/libPluginFlurry.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/umeng/android/libPluginUmeng.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/umeng/android/umeng_sdk.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloAnalytics</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>Classes</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/Classes</locationURI>
</link>
<link>
<name>publish</name>
<type>2</type>
<locationURI>PARENT-3-PROJECT_LOC/publish</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@ -1,57 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.helloanalytics"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9"/>
<application android:label="@string/app_name"
android:debuggable="true"
android:icon="@drawable/icon">
<activity android:name=".HelloAnalytics"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Caution! Do not change this app key. It is only for demo usage. -->
<meta-data android:value="50d2af93527015338b000052" android:name="UMENG_APPKEY"></meta-data>
<meta-data
android:name="UMENG_CHANNEL"
android:value="Umeng" >
</meta-data>
<service
android:name="com.umeng.common.net.DownloadingService"
android:exported="true"
android:process=":DownloadingService" >
</service>
</application>
<supports-screens android:largeScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:normalScreens="true"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!-- Permission for Unit Test -->
<uses-permission android:name="android.permission.GET_TASKS" />
</manifest>

View File

@ -1,17 +0,0 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloAnalytics" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,81 +0,0 @@
APPNAME="HelloAnalytics"
# options
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ code for $APPNAME using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "sh" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
# paths
if [ -z "${NDK_ROOT+aaa}" ];then
echo "please define NDK_ROOT"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
PLUGIN_ROOT="$DIR/../../.."
COCOS2DX_ROOT="$DIR/../../../.."
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
echo "PLUGIN_ROOT = $PLUGIN_ROOT"
echo "NDK_ROOT = $NDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
echo "---------------------------------------------------------"
# make sure assets is exist
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
rm -rf "$APP_ANDROID_ROOT"/assets
fi
mkdir "$APP_ANDROID_ROOT"/assets
# copy resources
for file in "$APP_ROOT"/Resources/*
do
if [ -d "$file" ]; then
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
fi
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/assets
fi
done
if [[ "$buildexternalsfromsource" ]]; then
echo "Building external dependencies from source"
set -x
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
else
echo "Using prebuilt externals"
set -x
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
fi

View File

@ -1,21 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \
PluginProtocolStatic
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cocos2dx) \
$(call import-module,protocols/android)

View File

@ -1,3 +0,0 @@
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,47 +0,0 @@
#include "AppDelegate.h"
#include "platform/android/jni/JniHelper.h"
#include "PluginJniHelper.h"
#include <jni.h>
#include <android/log.h>
#include "HelloWorldScene.h"
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
using namespace cocos2d;
extern "C"
{
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
PluginJniHelper::setJavaVM(vm);
return JNI_VERSION_1_4;
}
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!Director::sharedDirector()->getOpenGLView())
{
EGLView *view = EGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
Application::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
TextureCache::reloadAllTextures();
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::sharedDirector()->setGLDefaultValues();
}
}
}

View File

@ -1,47 +0,0 @@
APPNAME="HelloAnalytics"
APP_ANDROID_NAME="org.cocos2dx.helloanalytics"
if [ -z "${SDK_ROOT+aaa}" ]; then
# ... if SDK_ROOT is not set, use "$HOME/bin/android-sdk"
SDK_ROOT="$HOME/bin/android-sdk"
fi
if [ -z "${NDK_ROOT+aaa}" ]; then
# ... if NDK_ROOT is not set, use "$HOME/bin/android-ndk"
NDK_ROOT="$HOME/bin/android-ndk"
fi
if [ -z "${COCOS2DX_ROOT+aaa}" ]; then
# ... if COCOS2DX_ROOT is not set
# ... find current working directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
COCOS2DX_ROOT="$DIR/../.."
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
else
APP_ROOT="$COCOS2DX_ROOT/$APPNAME"
APP_ANDROID_ROOT="$COCOS2DX_ROOT/$APPNAME/proj.android"
fi
echo "NDK_ROOT = $NDK_ROOT"
echo "SDK_ROOT = $SDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
echo "APP_ANDROID_NAME = $APP_ANDROID_NAME"
echo
echo "Killing and restarting ${APP_ANDROID_NAME}"
echo
set -x
"${SDK_ROOT}"/platform-tools/adb shell am force-stop "${APP_ANDROID_NAME}"
NDK_MODULE_PATH="${COCOS2DX_ROOT}":"${COCOS2DX_ROOT}"/cocos2dx/platform/third_party/android/prebuilt \
"${NDK_ROOT}"/ndk-gdb \
--adb="${SDK_ROOT}"/platform-tools/adb \
--verbose \
--start \
--force

View File

@ -1,20 +0,0 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
android.library.reference.1=../../../../cocos2dx/platform/android/java

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloAnalytics</string>
</resources>

View File

@ -1,41 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2012 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.
****************************************************************************/
package org.cocos2dx.helloanalytics;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.plugin.PluginWrapper;
import android.os.Bundle;
public class HelloAnalytics extends Cocos2dxActivity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
PluginWrapper.init(this);
}
static {
System.loadLibrary("game");
}
}

View File

@ -1,134 +0,0 @@
/****************************************************************************
Copyright (c) 2010 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.
****************************************************************************/
#import <UIKit/UIKit.h>
#import "AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
CCEAGLView *__glView = [CCEAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH_COMPONENT16
preserveBackbuffer: NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
// Use RootViewController manage CCEAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:viewController];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::Application::sharedApplication()->run();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
cocos2d::Director::sharedDirector()->pause();
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
cocos2d::Director::sharedDirector()->resume();
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
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();
}
- (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();
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -1 +0,0 @@
66c6d1cead373b45218424f6a82f370897e443e4

View File

@ -1 +0,0 @@
84689888a14a2123d2b39f7f2f61be8c15207479

View File

@ -1,582 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; };
BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; };
BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; };
BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; };
BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF137426128A8E4600D9F789 /* QuartzCore.framework */; };
BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; };
BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; };
D446FD79161028E9000ADA7B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD78161028E9000ADA7B /* Default.png */; };
D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7A161028ED000ADA7B /* Default@2x.png */; };
D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D446FD7C161028F4000ADA7B /* Default-568h@2x.png */; };
D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; };
D4EF94E815BD319200D803EB /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E715BD319200D803EB /* Icon-57.png */; };
D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94E915BD319500D803EB /* Icon-114.png */; };
D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94EB15BD319B00D803EB /* Icon-72.png */; };
D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = D4EF94ED15BD319D00D803EB /* Icon-144.png */; };
FA0CB877168D2F5400E36B11 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */; };
FA0CB878168D2F5400E36B11 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */; };
FA0CB87E168D2FB200E36B11 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */; };
FA0CB8A6168D31EA00E36B11 /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */; };
FA0CB8A7168D31EA00E36B11 /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */; };
FA3FC131168D6AF400F56319 /* libPluginProtocol.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */; };
FA7C6D1817251CD5008A0ECC /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */; };
FA7C6D1917251CD5008A0ECC /* libPluginFlurry.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */; };
FA7C6D1A17251CD5008A0ECC /* libPluginUmeng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
FA3FC12D168D6ADD00F56319 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA09A321168ADBC2008C1C7B;
remoteInfo = PluginProtocol;
};
FA3FC12F168D6AEB00F56319 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = FA09A320168ADBC2008C1C7B;
remoteInfo = PluginProtocol;
};
FA7C6CF417251BEA008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 1551A33F158F2AB200E66CFE;
remoteInfo = cocos2dx;
};
FA7C6D0717251C10008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA09A372168AFD41008C1C7B;
remoteInfo = PluginFlurry;
};
FA7C6D1017251C17008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA09A301168ADAEC008C1C7B;
remoteInfo = PluginUmeng;
};
FA7C6D1217251C30008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = FA09A371168AFD41008C1C7B;
remoteInfo = PluginFlurry;
};
FA7C6D1417251C30008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = FA09A300168ADAEC008C1C7B;
remoteInfo = PluginUmeng;
};
FA7C6D1617251C30008A0ECC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 1551A33E158F2AB200E66CFE;
remoteInfo = cocos2dx;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloAnalytics.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
781C33B11547F06B00633F88 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
BF365AA612A103F70050DCF4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
BF365AA712A103F70050DCF4 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = "<group>"; };
BF492B6912891AC600A09262 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
BF492C21128924A800A09262 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = "<group>"; };
BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = "<group>"; };
D446FD78161028E9000ADA7B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ../proj.ios/Default.png; sourceTree = "<group>"; };
D446FD7A161028ED000ADA7B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "../proj.ios/Default@2x.png"; sourceTree = "<group>"; };
D446FD7C161028F4000ADA7B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../proj.ios/Default-568h@2x.png"; sourceTree = "<group>"; };
D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
D4EF94E715BD319200D803EB /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "../proj.ios/Icon-57.png"; sourceTree = "<group>"; };
D4EF94E915BD319500D803EB /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "../proj.ios/Icon-114.png"; sourceTree = "<group>"; };
D4EF94EB15BD319B00D803EB /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "../proj.ios/Icon-72.png"; sourceTree = "<group>"; };
D4EF94ED15BD319D00D803EB /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "../proj.ios/Icon-144.png"; sourceTree = "<group>"; };
FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
FA0CB874168D2F5400E36B11 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = "<group>"; };
FA0CB876168D2F5400E36B11 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = "<group>"; };
FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = "<group>"; };
FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = "<group>"; };
FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginProtocol.xcodeproj; path = ../../../protocols/proj.ios/PluginProtocol.xcodeproj; sourceTree = "<group>"; };
FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = "<group>"; };
FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginFlurry.xcodeproj; path = ../../../plugins/flurry/proj.ios/PluginFlurry.xcodeproj; sourceTree = "<group>"; };
FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = PluginUmeng.xcodeproj; path = ../../../plugins/umeng/proj.ios/PluginUmeng.xcodeproj; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA7C6D1817251CD5008A0ECC /* libcocos2dx.a in Frameworks */,
FA7C6D1917251CD5008A0ECC /* libPluginFlurry.a in Frameworks */,
FA7C6D1A17251CD5008A0ECC /* libPluginUmeng.a in Frameworks */,
FA3FC131168D6AF400F56319 /* libPluginProtocol.a in Frameworks */,
FA0CB87E168D2FB200E36B11 /* SystemConfiguration.framework in Frameworks */,
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */,
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */,
BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */,
BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */,
BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */,
);
name = Products;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
isa = PBXGroup;
children = (
FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */,
FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */,
FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */,
FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */,
FA0CB872168D2F5400E36B11 /* Classes */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
BF5681CC1313A84D0055EEAC /* ios */,
19C28FACFE9D520D11CA2CBB /* Products */,
784521C214EBA449009D533B /* Resources */,
);
name = CustomTemplate;
sourceTree = "<group>";
};
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
FA0CB87D168D2FB200E36B11 /* SystemConfiguration.framework */,
BF492B6912891AC600A09262 /* libz.dylib */,
BF137426128A8E4600D9F789 /* QuartzCore.framework */,
BF492D4B1289302400A09262 /* OpenGLES.framework */,
BF492C21128924A800A09262 /* libxml2.dylib */,
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */,
1D30AB110D05D00D00671497 /* Foundation.framework */,
288765A40DF7441C002DB57D /* CoreGraphics.framework */,
781C33B11547F06B00633F88 /* OpenAL.framework */,
781C33B31547F06B00633F88 /* AudioToolbox.framework */,
781C33B51547F06B00633F88 /* AVFoundation.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
784521C214EBA449009D533B /* Resources */ = {
isa = PBXGroup;
children = (
FA0CB8A3168D31EA00E36B11 /* CloseNormal.png */,
FA0CB8A4168D31EA00E36B11 /* CloseSelected.png */,
D4EF94ED15BD319D00D803EB /* Icon-144.png */,
D4EF94EB15BD319B00D803EB /* Icon-72.png */,
D4EF94E915BD319500D803EB /* Icon-114.png */,
D4EF94E715BD319200D803EB /* Icon-57.png */,
D446FD7C161028F4000ADA7B /* Default-568h@2x.png */,
D446FD7A161028ED000ADA7B /* Default@2x.png */,
D446FD78161028E9000ADA7B /* Default.png */,
);
name = Resources;
path = ../Resources;
sourceTree = "<group>";
};
BF5681CC1313A84D0055EEAC /* ios */ = {
isa = PBXGroup;
children = (
D4ABB4B213B4395300552E6E /* main.m */,
BF365AA612A103F70050DCF4 /* AppController.h */,
BF365AA712A103F70050DCF4 /* AppController.mm */,
BF4DE6AB138BB89600CF907D /* RootViewController.h */,
BF4DE6AC138BB89600CF907D /* RootViewController.mm */,
);
name = ios;
sourceTree = "<group>";
};
FA0CB872168D2F5400E36B11 /* Classes */ = {
isa = PBXGroup;
children = (
FA0CB873168D2F5400E36B11 /* AppDelegate.cpp */,
FA0CB874168D2F5400E36B11 /* AppDelegate.h */,
FA0CB875168D2F5400E36B11 /* HelloWorldScene.cpp */,
FA0CB876168D2F5400E36B11 /* HelloWorldScene.h */,
);
name = Classes;
path = ../Classes;
sourceTree = "<group>";
};
FA3FC127168D6ADC00F56319 /* Products */ = {
isa = PBXGroup;
children = (
FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */,
);
name = Products;
sourceTree = "<group>";
};
FA7C6CEE17251BEA008A0ECC /* Products */ = {
isa = PBXGroup;
children = (
FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */,
);
name = Products;
sourceTree = "<group>";
};
FA7C6D0117251C10008A0ECC /* Products */ = {
isa = PBXGroup;
children = (
FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */,
);
name = Products;
sourceTree = "<group>";
};
FA7C6D0A17251C16008A0ECC /* Products */ = {
isa = PBXGroup;
children = (
FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
1D6058900D05DD3D006BFB54 /* HelloAnalytics */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloAnalytics" */;
buildPhases = (
1D60588D0D05DD3D006BFB54 /* Resources */,
1D60588E0D05DD3D006BFB54 /* Sources */,
1D60588F0D05DD3D006BFB54 /* Frameworks */,
);
buildRules = (
);
dependencies = (
FA7C6D1317251C30008A0ECC /* PBXTargetDependency */,
FA7C6D1517251C30008A0ECC /* PBXTargetDependency */,
FA7C6D1717251C30008A0ECC /* PBXTargetDependency */,
FA3FC130168D6AEB00F56319 /* PBXTargetDependency */,
);
name = HelloAnalytics;
productName = HelloWorld;
productReference = 1D6058910D05DD3D006BFB54 /* HelloAnalytics.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloAnalytics" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Japanese,
French,
German,
);
mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = FA7C6CEE17251BEA008A0ECC /* Products */;
ProjectRef = FA7C6CED17251BEA008A0ECC /* cocos2dx.xcodeproj */;
},
{
ProductGroup = FA7C6D0117251C10008A0ECC /* Products */;
ProjectRef = FA7C6D0017251C10008A0ECC /* PluginFlurry.xcodeproj */;
},
{
ProductGroup = FA3FC127168D6ADC00F56319 /* Products */;
ProjectRef = FA3FC126168D6ADC00F56319 /* PluginProtocol.xcodeproj */;
},
{
ProductGroup = FA7C6D0A17251C16008A0ECC /* Products */;
ProjectRef = FA7C6D0917251C16008A0ECC /* PluginUmeng.xcodeproj */;
},
);
projectRoot = "";
targets = (
1D6058900D05DD3D006BFB54 /* HelloAnalytics */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
FA3FC12E168D6ADD00F56319 /* libPluginProtocol.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libPluginProtocol.a;
remoteRef = FA3FC12D168D6ADD00F56319 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FA7C6CF517251BEA008A0ECC /* libcocos2dx.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libcocos2dx.a;
remoteRef = FA7C6CF417251BEA008A0ECC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FA7C6D0817251C10008A0ECC /* libPluginFlurry.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libPluginFlurry.a;
remoteRef = FA7C6D0717251C10008A0ECC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FA7C6D1117251C17008A0ECC /* libPluginUmeng.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libPluginUmeng.a;
remoteRef = FA7C6D1017251C17008A0ECC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
1D60588D0D05DD3D006BFB54 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D4EF94E815BD319200D803EB /* Icon-57.png in Resources */,
D4EF94EA15BD319500D803EB /* Icon-114.png in Resources */,
D4EF94EC15BD319B00D803EB /* Icon-72.png in Resources */,
D4EF94EE15BD319D00D803EB /* Icon-144.png in Resources */,
D446FD79161028E9000ADA7B /* Default.png in Resources */,
D446FD7B161028ED000ADA7B /* Default@2x.png in Resources */,
D446FD7D161028F4000ADA7B /* Default-568h@2x.png in Resources */,
FA0CB8A6168D31EA00E36B11 /* CloseNormal.png in Resources */,
FA0CB8A7168D31EA00E36B11 /* CloseSelected.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1D60588E0D05DD3D006BFB54 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF365AA812A103F70050DCF4 /* AppController.mm in Sources */,
BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */,
D4ABB4B313B4395300552E6E /* main.m in Sources */,
FA0CB877168D2F5400E36B11 /* AppDelegate.cpp in Sources */,
FA0CB878168D2F5400E36B11 /* HelloWorldScene.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
FA3FC130168D6AEB00F56319 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = PluginProtocol;
targetProxy = FA3FC12F168D6AEB00F56319 /* PBXContainerItemProxy */;
};
FA7C6D1317251C30008A0ECC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = PluginFlurry;
targetProxy = FA7C6D1217251C30008A0ECC /* PBXContainerItemProxy */;
};
FA7C6D1517251C30008A0ECC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = PluginUmeng;
targetProxy = FA7C6D1417251C30008A0ECC /* PBXContainerItemProxy */;
};
FA7C6D1717251C30008A0ECC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = cocos2dx;
targetProxy = FA7C6D1617251C30008A0ECC /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
1D6058940D05DD3E006BFB54 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = HelloAnalytics_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
USE_FILE32API,
CC_TARGET_OS_IPHONE,
"COCOS2D_DEBUG=1",
);
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = "";
HEADER_SEARCH_PATHS = (
"\"$(SDKROOT)/usr/include/libxml2/\"",
"\"$(SRCROOT)/../../../../cocos2dx/include\"",
"\"$(SRCROOT)/../../../../cocos2dx\"",
"\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"",
"\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"",
"\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"",
"\"$(SRCROOT)/../../../protocols/include\"",
"\"$(SRCROOT)/../../../plugins/flurry/include\"",
"\"$(SRCROOT)/../../../plugins/umeng/include\"",
);
INFOPLIST_FILE = "HelloAnalytics-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"",
"\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"",
);
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
PRODUCT_NAME = HelloAnalytics;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "armv6 armv7 i386";
};
name = Debug;
};
1D6058950D05DD3E006BFB54 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = HelloAnalytics_Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
USE_FILE32API,
CC_TARGET_OS_IPHONE,
);
GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = "";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = "";
HEADER_SEARCH_PATHS = (
"\"$(SDKROOT)/usr/include/libxml2/\"",
"\"$(SRCROOT)/../../../../cocos2dx/include\"",
"\"$(SRCROOT)/../../../../cocos2dx\"",
"\"$(SRCROOT)/../../../../cocos2dx/platform/ios\"",
"\"$(SRCROOT)/../../../../cocos2dx/kazmath/include\"",
"\"$(SRCROOT)/../../../../external/chipmunk/include/chipmunk\"",
"\"$(SRCROOT)/../../../protocols/include\"",
"\"$(SRCROOT)/../../../plugins/flurry/include\"",
"\"$(SRCROOT)/../../../plugins/umeng/include\"",
);
INFOPLIST_FILE = "HelloAnalytics-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/../../../plugins/flurry/platform/ios\"",
"\"$(SRCROOT)/../../../plugins/umeng/platform/ios\"",
);
"OTHER_LDFLAGS[arch=*]" = "-ObjC";
PRODUCT_NAME = HelloAnalytics;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "armv6 armv7 i386";
};
name = Release;
};
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LIBRARY = "libc++";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
"INFOPLIST_PREFIX_HEADER[sdk=*]" = "";
SDKROOT = iphoneos;
VALID_ARCHS = "armv6 armv7 i386";
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_CXX_LIBRARY = "libc++";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
VALID_ARCHS = "armv6 armv7 i386";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloAnalytics" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1D6058940D05DD3E006BFB54 /* Debug */,
1D6058950D05DD3E006BFB54 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloAnalytics" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C01FCF4F08A954540054247B /* Debug */,
C01FCF5008A954540054247B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
}

View File

@ -1,8 +0,0 @@
//
// Prefix header for all source files of the 'HelloWorld' target in the 'HelloWorld' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

View File

@ -1,94 +0,0 @@
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
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.
****************************************************************************/
#import "RootViewController.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
// For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations
{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskAllButUpsideDown;
#endif
}
- (BOOL) shouldAutorotate {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -1,33 +0,0 @@
/****************************************************************************
Copyright (c) 2012-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.
****************************************************************************/
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return retVal;
}

View File

@ -1,83 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "cocos2d.h"
#include "HelloWorldScene.h"
#include "PluginManager.h"
#include "MyPurchase.h"
using namespace cocos2d::plugin;
USING_NS_CC;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching()
{
MyPurchase::sharedPurchase()->loadIAPPlugin();
// initialize director
Director *pDirector = Director::sharedDirector();
pDirector->setOpenGLView(EGLView::sharedOpenGLView());
EGLView* pEGLView = EGLView::sharedOpenGLView();
pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
Scene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
Director::sharedDirector()->pause();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::sharedDirector()->resume();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

View File

@ -1,62 +0,0 @@
/****************************************************************************
Copyright (c) 2012-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.
****************************************************************************/
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
static void loadAnalyticsPlugin();
};
#endif // _APP_DELEGATE_H_

View File

@ -1 +0,0 @@
db46ceaf2554c8d9e48cdaec3a4cdf5519bb8896

View File

@ -1 +0,0 @@
b2e4ae6ce873ef4a74cf0230693ef26e939d2778

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="publish/protocols/android/libPluginProtocol.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/alipay/android/alipay_plugin.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/alipay/android/libPluginAlipay.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/nd91/android/libPluginNd91.jar"/>
<classpathentry exported="true" kind="lib" path="publish/plugins/nd91/android/NdComPlatform.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloIAP</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>Classes</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/Classes</locationURI>
</link>
<link>
<name>publish</name>
<type>2</type>
<locationURI>PARENT-3-PROJECT_LOC/publish</locationURI>
</link>
</linkedResources>
</projectDescription>

View File

@ -1,85 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.helloIAP"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9"/>
<application android:label="@string/app_name"
android:debuggable="true"
android:icon="@drawable/icon">
<activity android:name=".HelloIAP"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- activity info for nd91 -->
<activity android:name="com.nd.commplatform.activity.SNSControlCenterActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustPan"
android:windowBackground="@null"
android:launchMode="singleTask"/>
<activity android:name="com.nd.commplatform.activity.SNSLoginActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustPan"
android:windowBackground="@null"
android:launchMode="singleTask"/>
<activity android:name="com.nd.commplatform.activity.SNSAppPromotionActivity"
android:configChanges="orientation|keyboardHidden|navigation"
android:windowSoftInputMode="adjustPan"
android:theme="@android:style/Theme.NoTitleBar"
android:windowBackground="@null"/>
<service android:name="com.nd.commplatform.service.NdDownloadService"
android:process=":com.nd.commplatform.download"
android:enabled="true"
android:exported="false"/>
<receiver android:name="com.nd.commplatform.versionupdate.ND2VersionUpdateNotify"
android:process="android.intent.nd.sns.commplatform.versionupdate"
android:exported="false"/>
<service android:name="com.nd.commplatform.versionupdate.ND2VersionUpdateService"
android:process="android.intent.nd.sns.commplatform.versionupdate"
android:exported="false"/>
<service android:name="com.nd.commplatform.service.NdNewMessageNotification"
android:enabled="true"
android:exported="false"/>
</application>
<supports-screens android:largeScreens="true"
android:smallScreens="true"
android:anyDensity="true"
android:normalScreens="true"/>
<!-- Alipay permission -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- nd91 permission -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
</manifest>

View File

@ -1,17 +0,0 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked into Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="HelloAnalytics" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,81 +0,0 @@
APPNAME="HelloAnalytics"
# options
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ code for $APPNAME using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "sh" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
# paths
if [ -z "${NDK_ROOT+aaa}" ];then
echo "please define NDK_ROOT"
exit 1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# ... use paths relative to current directory
PLUGIN_ROOT="$DIR/../../.."
COCOS2DX_ROOT="$DIR/../../../.."
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
echo "PLUGIN_ROOT = $PLUGIN_ROOT"
echo "NDK_ROOT = $NDK_ROOT"
echo "COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo "APP_ROOT = $APP_ROOT"
echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
echo "---------------------------------------------------------"
# make sure assets is exist
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
rm -rf "$APP_ANDROID_ROOT"/assets
fi
mkdir "$APP_ANDROID_ROOT"/assets
# copy resources
for file in "$APP_ROOT"/Resources/*
do
if [ -d "$file" ]; then
cp -rf "$file" "$APP_ANDROID_ROOT"/assets
fi
if [ -f "$file" ]; then
cp "$file" "$APP_ANDROID_ROOT"/assets
fi
done
if [[ "$buildexternalsfromsource" ]]; then
echo "Building external dependencies from source"
set -x
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source"
else
echo "Using prebuilt externals"
set -x
"$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${PLUGIN_ROOT}/publish:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
fi

View File

@ -1,22 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/MyPurchase.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static \
PluginProtocolStatic
include $(BUILD_SHARED_LIBRARY)
$(call import-module,cocos2dx) \
$(call import-module,protocols/android)

View File

@ -1,3 +0,0 @@
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti -std=c++11
NDK_TOOLCHAIN_VERSION=4.7

View File

@ -1,70 +0,0 @@
/****************************************************************************
Copyright (c) 2012-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "AppDelegate.h"
#include "platform/android/jni/JniHelper.h"
#include "PluginJniHelper.h"
#include <jni.h>
#include <android/log.h>
#include "HelloWorldScene.h"
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
using namespace cocos2d;
extern "C"
{
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
PluginJniHelper::setJavaVM(vm);
return JNI_VERSION_1_4;
}
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!Director::sharedDirector()->getOpenGLView())
{
EGLView *view = EGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
Application::sharedApplication()->run();
}
else
{
ccDrawInit();
ccGLInvalidateStateCache();
ShaderCache::sharedShaderCache()->reloadDefaultShaders();
TextureCache::reloadAllTextures();
NotificationCenter::sharedNotificationCenter()->postNotification(EVNET_COME_TO_FOREGROUND, NULL);
Director::sharedDirector()->setGLDefaultValues();
}
}
}

View File

@ -1,20 +0,0 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,16 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-10
android.library.reference.1=../../../../cocos2dx/platform/android/java
android.library.reference.2=../../../publish/plugins/nd91/android/DependProject

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">HelloIAP</string>
</resources>

View File

@ -1,6 +1,5 @@
#include "AppDelegate.h" #include "AppDelegate.h"
#include "HelloWorldScene.h" #include "HelloWorldScene.h"
#include "MyUserManager.h"
USING_NS_CC; USING_NS_CC;
@ -13,8 +12,6 @@ AppDelegate::~AppDelegate()
} }
bool AppDelegate::applicationDidFinishLaunching() { bool AppDelegate::applicationDidFinishLaunching() {
MyUserManager::sharedManager()->loadPlugin();
// initialize director // initialize director
Director* pDirector = Director::sharedDirector(); Director* pDirector = Director::sharedDirector();
EGLView* pEGLView = EGLView::sharedOpenGLView(); EGLView* pEGLView = EGLView::sharedOpenGLView();
@ -22,6 +19,7 @@ bool AppDelegate::applicationDidFinishLaunching() {
pDirector->setOpenGLView(pEGLView); pDirector->setOpenGLView(pEGLView);
pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder); pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder);
// turn on display FPS // turn on display FPS
pDirector->setDisplayStats(true); pDirector->setDisplayStats(true);

View File

@ -0,0 +1,115 @@
#include "HelloWorldScene.h"
#include "TestAdsScene.h"
#include "TestAnalyticsScene.h"
#include "TestShareScene.h"
#include "TestIAPScene.h"
#include "TestUserScene.h"
USING_NS_CC;
std::string g_testCases[] = {
"Test Ads",
"Test Analytics",
"Test Share",
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
"Test IAP",
"Test User",
#endif
};
Scene* HelloWorld::scene()
{
// 'scene' is an autorelease object
Scene *scene = Scene::create();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::sharedDirector()->getVisibleSize();
Point origin = Director::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL);
pMenu->setPosition(PointZero);
this->addChild(pMenu, 1);
Point beginPos = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 50);
float step = 60.0f;
int nCaseCount = sizeof(g_testCases) / sizeof(std::string);
for (int i = 0; i < nCaseCount; ++i) {
std::string caseName = g_testCases[i];
MenuItemFont *pItem = MenuItemFont::create(caseName.c_str(), CC_CALLBACK_1(HelloWorld::menuCallback, this));
pItem->setTag(i);
pItem->setPosition(ccp(beginPos.x, beginPos.y - i * step));
pMenu->addChild(pItem);
}
return true;
}
void HelloWorld::menuCallback(Object* pSender)
{
MenuItemFont *pItem = (MenuItemFont*) pSender;
Scene* newScene = NULL;
switch (pItem->getTag()) {
case 0:
newScene = TestAds::scene();
break;
case 1:
newScene = TestAnalytics::scene();
break;
case 2:
newScene = TestShare::scene();
break;
case 3:
newScene = TestIAP::scene();
break;
case 4:
newScene = TestUser::scene();
break;
default:
break;
}
if (newScene) {
Director::sharedDirector()->replaceScene(newScene);
}
}
void HelloWorld::menuCloseCallback(Object* pSender)
{
Director::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}

View File

@ -14,17 +14,10 @@ public:
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuCloseCallback(Object* pSender);
void testLogin(Object* pSender); void menuCallback(Object* pSender);
void testLogout(Object* pSender);
void caseChanged(Object* pSender);
// implement the "static node()" method manually // implement the "static node()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(HelloWorld);
private:
cocos2d::MenuItemToggle* _caseItem;
int _selectedCase;
}; };
#endif // __HELLOWORLD_SCENE_H__ #endif // __HELLOWORLD_SCENE_H__

View File

@ -21,8 +21,9 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "HelloWorldScene.h" #include "TestAdsScene.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "HelloWorldScene.h"
USING_NS_CC; USING_NS_CC;
using namespace cocos2d::plugin; using namespace cocos2d::plugin;
@ -47,13 +48,13 @@ const std::string s_aTestPoses[] = {
"Pos: BottomRight", "Pos: BottomRight",
}; };
Scene* HelloWorld::scene() Scene* TestAds::scene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
Scene *scene = Scene::create(); Scene *scene = Scene::create();
// 'layer' is an autorelease object // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create(); TestAds *layer = TestAds::create();
// add layer as a child to scene // add layer as a child to scene
scene->addChild(layer); scene->addChild(layer);
@ -63,7 +64,7 @@ Scene* HelloWorld::scene()
} }
// on "init" you need to initialize your instance // on "init" you need to initialize your instance
bool HelloWorld::init() bool TestAds::init()
{ {
////////////////////////////// //////////////////////////////
// 1. super init first // 1. super init first
@ -89,39 +90,36 @@ bool HelloWorld::init()
Size visibleSize = Director::sharedDirector()->getVisibleSize(); Size visibleSize = Director::sharedDirector()->getVisibleSize();
Point origin = Director::sharedDirector()->getVisibleOrigin(); Point origin = Director::sharedDirector()->getVisibleOrigin();
Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2);
Point posBR = ccp(origin.x + visibleSize.width, origin.y);
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object // add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create( MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this));
"CloseNormal.png", Size backSize = pBackItem->getContentSize();
"CloseSelected.png", pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
pMenu->setPosition(PointZero); pMenu->setPosition( PointZero );
LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24); LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24);
MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(HelloWorld::testShow, this)); MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this));
pItemShow->setAnchorPoint(ccp(0.5f, 0)); pItemShow->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pItemShow, 0); pMenu->addChild(pItemShow, 0);
pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120))); pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120)));
LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24); LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24);
MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(HelloWorld::testHide, this)); MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this));
pItemHide->setAnchorPoint(ccp(0.5f, 0)); pItemHide->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pItemHide, 0); pMenu->addChild(pItemHide, 0);
pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120))); pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120)));
// create optional menu // create optional menu
// cases item // cases item
_caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::caseChanged, this), _caseItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::caseChanged, this),
MenuItemFont::create( s_aTestCases[0].c_str() ), MenuItemFont::create( s_aTestCases[0].c_str() ),
NULL ); NULL );
int caseLen = sizeof(s_aTestCases) / sizeof(std::string); int caseLen = sizeof(s_aTestCases) / sizeof(std::string);
@ -133,7 +131,7 @@ bool HelloWorld::init()
pMenu->addChild(_caseItem); pMenu->addChild(_caseItem);
// type item // type item
_typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::typeChanged, this), _typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::typeChanged, this),
MenuItemFont::create( s_aTestTypes[0].c_str() ), MenuItemFont::create( s_aTestTypes[0].c_str() ),
NULL ); NULL );
int typeLen = sizeof(s_aTestTypes) / sizeof(std::string); int typeLen = sizeof(s_aTestTypes) / sizeof(std::string);
@ -145,7 +143,7 @@ bool HelloWorld::init()
pMenu->addChild(_typeItem); pMenu->addChild(_typeItem);
// poses item // poses item
_posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(HelloWorld::posChanged, this), _posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::posChanged, this),
MenuItemFont::create( s_aTestPoses[0].c_str() ), MenuItemFont::create( s_aTestPoses[0].c_str() ),
NULL ); NULL );
int posLen = sizeof(s_aTestPoses) / sizeof(std::string); int posLen = sizeof(s_aTestPoses) / sizeof(std::string);
@ -166,7 +164,7 @@ bool HelloWorld::init()
return true; return true;
} }
void HelloWorld::testShow(Object* pSender) void TestAds::testShow(Object* pSender)
{ {
int nSize = 0; int nSize = 0;
if (_ads == _admob) if (_ads == _admob)
@ -180,17 +178,18 @@ void HelloWorld::testShow(Object* pSender)
} }
} }
void HelloWorld::testHide(Object* pSender) void TestAds::testHide(Object* pSender)
{ {
_ads->hideAds(_type); _ads->hideAds(_type);
} }
void HelloWorld::menuCloseCallback(Object* pSender) void TestAds::menuBackCallback(Object* pSender)
{ {
Director::sharedDirector()->end();
if (_admob != NULL) if (_admob != NULL)
{ {
_admob->hideAds(ProtocolAds::kBannerAd);
_admob->hideAds(ProtocolAds::kFullScreenAd);
_admob->hideAds(ProtocolAds::kMoreApp);
PluginManager::getInstance()->unloadPlugin("AdsAdmob"); PluginManager::getInstance()->unloadPlugin("AdsAdmob");
_admob = NULL; _admob = NULL;
} }
@ -201,13 +200,11 @@ void HelloWorld::menuCloseCallback(Object* pSender)
_listener = NULL; _listener = NULL;
} }
PluginManager::end(); Scene* newScene = HelloWorld::scene();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) Director::sharedDirector()->replaceScene(newScene);
exit(0);
#endif
} }
void HelloWorld::caseChanged(Object* pSender) void TestAds::caseChanged(Object* pSender)
{ {
std::string strLog = ""; std::string strLog = "";
switch (_caseItem->getSelectedIndex()) switch (_caseItem->getSelectedIndex())
@ -222,14 +219,14 @@ void HelloWorld::caseChanged(Object* pSender)
CCLog("case selected change to : %s", strLog.c_str()); CCLog("case selected change to : %s", strLog.c_str());
} }
void HelloWorld::typeChanged(Object* pSender) void TestAds::typeChanged(Object* pSender)
{ {
int selectIndex = _typeItem->getSelectedIndex(); int selectIndex = _typeItem->getSelectedIndex();
_type = (ProtocolAds::AdsType) selectIndex; _type = (ProtocolAds::AdsType) selectIndex;
CCLog("type selected change to : %d", _type); CCLog("type selected change to : %d", _type);
} }
void HelloWorld::posChanged(Object* pSender) void TestAds::posChanged(Object* pSender)
{ {
int selectIndex = _posItem->getSelectedIndex(); int selectIndex = _posItem->getSelectedIndex();
_pos = (ProtocolAds::AdsPos) selectIndex; _pos = (ProtocolAds::AdsPos) selectIndex;

View File

@ -21,8 +21,8 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __HELLOWORLD_SCENE_H__ #ifndef __TEST_ADS_SCENE_H__
#define __HELLOWORLD_SCENE_H__ #define __TEST_ADS_SCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
#include "ProtocolAds.h" #include "ProtocolAds.h"
@ -34,7 +34,7 @@ public:
virtual void onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points); virtual void onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points);
}; };
class HelloWorld : public cocos2d::Layer class TestAds : public cocos2d::Layer
{ {
public: public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
@ -44,7 +44,7 @@ public:
static cocos2d::Scene* scene(); static cocos2d::Scene* scene();
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuBackCallback(Object* pSender);
void testShow(Object* pSender); void testShow(Object* pSender);
void testHide(Object* pSender); void testHide(Object* pSender);
@ -54,7 +54,7 @@ public:
void typeChanged(Object* pSender); void typeChanged(Object* pSender);
// implement the "static node()" method manually // implement the "static node()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(TestAds);
private: private:
cocos2d::plugin::ProtocolAds* _admob; cocos2d::plugin::ProtocolAds* _admob;
@ -69,4 +69,4 @@ private:
cocos2d::plugin::ProtocolAds::AdsType _type; cocos2d::plugin::ProtocolAds::AdsType _type;
}; };
#endif // __HELLOWORLD_SCENE_H__ #endif // __TEST_ADS_SCENE_H__

View File

@ -21,16 +21,18 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "HelloWorldScene.h" #include "TestAnalyticsScene.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "ProtocolAnalytics.h" #include "HelloWorldScene.h"
#include "AppDelegate.h"
using namespace cocos2d; using namespace cocos2d;
using namespace cocos2d::plugin; using namespace cocos2d::plugin;
extern ProtocolAnalytics* g_pAnalytics; // The app key of flurry
extern std::string s_strAppKey; #define FLURRY_KEY_IOS "KMGG7CD9WPK2TW4X9VR8"
#define FLURRY_KEY_ANDROID "SPKFH8KMPGHMMBWRBT5W"
#define UMENG_KEY_IOS "50d2b18c5270152187000097"
#define UMENG_KEY_ANDROID "" // umeng key for android is setted in AndroidManifest.xml
enum { enum {
TAG_LOG_EVENT_ID = 0, TAG_LOG_EVENT_ID = 0,
@ -57,13 +59,13 @@ static EventMenuItem s_EventMenuItem[] = {
{"MakeMeCrash", TAG_MAKE_ME_CRASH} {"MakeMeCrash", TAG_MAKE_ME_CRASH}
}; };
Scene* HelloWorld::scene() Scene* TestAnalytics::scene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
Scene *scene = Scene::create(); Scene *scene = Scene::create();
// 'layer' is an autorelease object // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create(); TestAnalytics *layer = TestAnalytics::create();
// add layer as a child to scene // add layer as a child to scene
scene->addChild(layer); scene->addChild(layer);
@ -73,7 +75,7 @@ Scene* HelloWorld::scene()
} }
// on "init" you need to initialize your instance // on "init" you need to initialize your instance
bool HelloWorld::init() bool TestAnalytics::init()
{ {
////////////////////////////// //////////////////////////////
// 1. super init first // 1. super init first
@ -82,60 +84,53 @@ bool HelloWorld::init()
return false; return false;
} }
Size size = Director::sharedDirector()->getWinSize(); _pluginAnalytics = NULL;
loadPlugins();
Size visibleSize = Director::sharedDirector()->getVisibleSize();
Point origin = Director::sharedDirector()->getVisibleOrigin();
Point posBR = ccp(origin.x + visibleSize.width, origin.y);
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object // add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create( MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this));
"CloseNormal.png", Size backSize = pBackItem->getContentSize();
"CloseSelected.png", pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(size.width - 20, 20) );
// create menu, it's an autorelease object // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
pMenu->setPosition( PointZero ); pMenu->setPosition( PointZero );
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
float yPos = 0; float yPos = 0;
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24); LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::eventMenuCallback)); MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
yPos = size.height - 35*i - 100; yPos = visibleSize.height - 35*i - 100;
pMenuItem->setPosition( ccp(size.width / 2, yPos)); pMenuItem->setPosition( ccp(visibleSize.width / 2, yPos));
} }
std::string strName = g_pAnalytics->getPluginName(); std::string strName = _pluginAnalytics->getPluginName();
std::string strVer = g_pAnalytics->getSDKVersion(); std::string strVer = _pluginAnalytics->getSDKVersion();
char ret[256] = { 0 }; char ret[256] = { 0 };
sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(size.width, 0), kTextAlignmentCenter); LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(visibleSize.width, 0), kTextAlignmentCenter);
pLabel->setPosition(ccp(size.width / 2, yPos - 80)); pLabel->setPosition(ccp(visibleSize.width / 2, yPos - 80));
addChild(pLabel); addChild(pLabel);
LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24);
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pMenuItem, 0);
pMenuItem->setPosition( ccp(size.width / 2, 0));
return true; return true;
} }
void HelloWorld::reloadPluginMenuCallback(Object* pSender) void TestAnalytics::onExit()
{ {
PluginManager::getInstance()->unloadPlugin("AnalyticsFlurry"); unloadPlugins();
PluginManager::getInstance()->unloadPlugin("AnalyticsUmeng");
AppDelegate::loadAnalyticsPlugin();
} }
void HelloWorld::eventMenuCallback(Object* pSender) void TestAnalytics::eventMenuCallback(Object* pSender)
{ {
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
@ -143,8 +138,8 @@ void HelloWorld::eventMenuCallback(Object* pSender)
{ {
case TAG_LOG_EVENT_ID: case TAG_LOG_EVENT_ID:
{ {
g_pAnalytics->logEvent("click"); _pluginAnalytics->logEvent("click");
g_pAnalytics->logEvent("music"); _pluginAnalytics->logEvent("music");
} }
break; break;
case TAG_LOG_EVENT_ID_KV: case TAG_LOG_EVENT_ID_KV:
@ -152,25 +147,25 @@ void HelloWorld::eventMenuCallback(Object* pSender)
LogEventParamMap paramMap; LogEventParamMap paramMap;
paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("type", "popular"));
paramMap.insert(LogEventParamPair("artist", "JJLin")); paramMap.insert(LogEventParamPair("artist", "JJLin"));
g_pAnalytics->logEvent("music", &paramMap); _pluginAnalytics->logEvent("music", &paramMap);
} }
break; break;
case TAG_LOG_ONLINE_CONFIG: case TAG_LOG_ONLINE_CONFIG:
{ {
PluginParam param("abc"); PluginParam param("abc");
CCLog("Online config = %s", g_pAnalytics->callStringFuncWithParam("getConfigParams", &param, NULL).c_str()); CCLog("Online config = %s", _pluginAnalytics->callStringFuncWithParam("getConfigParams", &param, NULL).c_str());
} }
break; break;
case TAG_LOG_EVENT_ID_DURATION: case TAG_LOG_EVENT_ID_DURATION:
{ {
PluginParam event1("book"); PluginParam event1("book");
PluginParam dura1(12000); PluginParam dura1(12000);
g_pAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL); _pluginAnalytics->callFuncWithParam("logEventWithDuration", &event1, &dura1, NULL);
PluginParam event2("book"); PluginParam event2("book");
PluginParam dura2(12000); PluginParam dura2(12000);
PluginParam label("chapter1"); PluginParam label("chapter1");
g_pAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL); _pluginAnalytics->callFuncWithParam("logEventWithDurationLabel", &event2, &dura2, &label, NULL);
PluginParam event3("music"); PluginParam event3("music");
PluginParam dura3(2330000); PluginParam dura3(2330000);
@ -178,16 +173,16 @@ void HelloWorld::eventMenuCallback(Object* pSender)
paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("type", "popular"));
paramMap.insert(LogEventParamPair("artist", "JJLin")); paramMap.insert(LogEventParamPair("artist", "JJLin"));
PluginParam mapValue(paramMap); PluginParam mapValue(paramMap);
g_pAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL); _pluginAnalytics->callFuncWithParam("logEventWithDurationParams", &event3, &dura3, &mapValue, NULL);
} }
break; break;
case TAG_LOG_EVENT_BEGIN: case TAG_LOG_EVENT_BEGIN:
{ {
g_pAnalytics->logTimedEventBegin("music"); _pluginAnalytics->logTimedEventBegin("music");
PluginParam event1("music"); PluginParam event1("music");
PluginParam label1("one"); PluginParam label1("one");
g_pAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL); _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelBegin", &event1, &label1, NULL);
PluginParam event2("music"); PluginParam event2("music");
PluginParam label2("flag0"); PluginParam label2("flag0");
@ -195,26 +190,26 @@ void HelloWorld::eventMenuCallback(Object* pSender)
paramMap.insert(LogEventParamPair("type", "popular")); paramMap.insert(LogEventParamPair("type", "popular"));
paramMap.insert(LogEventParamPair("artist", "JJLin")); paramMap.insert(LogEventParamPair("artist", "JJLin"));
PluginParam mapValue(paramMap); PluginParam mapValue(paramMap);
g_pAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL); _pluginAnalytics->callFuncWithParam("logTimedKVEventBegin", &event2, &label2, &mapValue, NULL);
PluginParam event3("music-kv"); PluginParam event3("music-kv");
g_pAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL); _pluginAnalytics->callFuncWithParam("logTimedEventBeginWithParams", &event3, &mapValue, NULL);
} }
break; break;
case TAG_LOG_EVENT_END: case TAG_LOG_EVENT_END:
{ {
g_pAnalytics->logTimedEventEnd("music"); _pluginAnalytics->logTimedEventEnd("music");
PluginParam event1("music"); PluginParam event1("music");
PluginParam label1("one"); PluginParam label1("one");
g_pAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL); _pluginAnalytics->callFuncWithParam("logTimedEventWithLabelEnd", &event1, &label1, NULL);
PluginParam event2("music"); PluginParam event2("music");
PluginParam label2("flag0"); PluginParam label2("flag0");
g_pAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL); _pluginAnalytics->callFuncWithParam("logTimedKVEventEnd", &event2, &label2, NULL);
PluginParam event3("music-kv"); PluginParam event3("music-kv");
g_pAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL); _pluginAnalytics->callFuncWithParam("logTimedEventEnd", &event3, NULL);
} }
break; break;
case TAG_MAKE_ME_CRASH: case TAG_MAKE_ME_CRASH:
@ -228,14 +223,81 @@ void HelloWorld::eventMenuCallback(Object* pSender)
} }
} }
void HelloWorld::menuCloseCallback(Object* pSender) void TestAnalytics::loadPlugins()
{ {
if (g_pAnalytics) ccLanguageType langType = Application::sharedApplication()->getCurrentLanguage();
g_pAnalytics->stopSession();
std::string umengKey = "";
PluginManager::end(); std::string flurryKey = "";
Director::sharedDirector()->end(); std::string pluginName = "";
std::string strAppKey = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0); umengKey = UMENG_KEY_IOS;
flurryKey = FLURRY_KEY_IOS;
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
umengKey = UMENG_KEY_ANDROID;
flurryKey = FLURRY_KEY_ANDROID;
#endif #endif
if (kLanguageChinese == langType)
{
pluginName = "AnalyticsUmeng";
strAppKey = umengKey;
}
else
{
pluginName = "AnalyticsFlurry";
strAppKey = flurryKey;
}
_pluginAnalytics = dynamic_cast<ProtocolAnalytics*> (PluginManager::getInstance()->loadPlugin(pluginName.c_str()));
_pluginAnalytics->setDebugMode(true);
_pluginAnalytics->startSession(strAppKey.c_str());
_pluginAnalytics->setCaptureUncaughtException(true);
_pluginAnalytics->setSessionContinueMillis(10000);
const char* sdkVer = _pluginAnalytics->getSDKVersion().c_str();
CCLog("SDK version : %s", sdkVer);
_pluginAnalytics->callFuncWithParam("updateOnlineConfig", NULL);
PluginParam pParam1(true);
_pluginAnalytics->callFuncWithParam("setReportLocation", &pParam1, NULL);
_pluginAnalytics->callFuncWithParam("logPageView", NULL);
PluginParam pParam2("1.1");
_pluginAnalytics->callFuncWithParam("setVersionName", &pParam2, NULL);
PluginParam pParam3(20);
_pluginAnalytics->callFuncWithParam("setAge", &pParam3, NULL);
PluginParam pParam4(1);
_pluginAnalytics->callFuncWithParam("setGender", &pParam4, NULL);
PluginParam pParam5("123456");
_pluginAnalytics->callFuncWithParam("setUserId", &pParam5, NULL);
PluginParam pParam6(false);
_pluginAnalytics->callFuncWithParam("setUseHttps", &pParam6, NULL);
}
void TestAnalytics::unloadPlugins()
{
if (NULL != _pluginAnalytics) {
_pluginAnalytics->stopSession();
std::string pluginName = _pluginAnalytics->getPluginName();
PluginManager::getInstance()->unloadPlugin(pluginName.c_str());
_pluginAnalytics = NULL;
}
}
void TestAnalytics::menuBackCallback(Object* pSender)
{
Scene* newScene = HelloWorld::scene();
Director::sharedDirector()->replaceScene(newScene);
} }

View File

@ -21,27 +21,34 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __HELLOWORLD_SCENE_H__ #ifndef __TEST_ANALYTICS_SCENE_H__
#define __HELLOWORLD_SCENE_H__ #define __TEST_ANALYTICS_SCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
#include "ProtocolAnalytics.h"
class HelloWorld : public cocos2d::Layer class TestAnalytics : public cocos2d::Layer
{ {
public: public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init(); virtual bool init();
virtual void onExit();
// there's no 'id' in cpp, so we recommand to return the exactly class pointer // there's no 'id' in cpp, so we recommand to return the exactly class pointer
static cocos2d::Scene* scene(); static cocos2d::Scene* scene();
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuBackCallback(Object* pSender);
void eventMenuCallback(Object* pSender); void eventMenuCallback(Object* pSender);
void reloadPluginMenuCallback(Object* pSender);
void loadPlugins();
void unloadPlugins();
// implement the "static node()" method manually // implement the "static node()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(TestAnalytics);
private:
cocos2d::plugin::ProtocolAnalytics* _pluginAnalytics;
}; };
#endif // __HELLOWORLD_SCENE_H__ #endif // __TEST_ANALYTICS_SCENE_H__

View File

@ -21,10 +21,11 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "HelloWorldScene.h" #include "TestIAPScene.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "AppDelegate.h" #include "AppDelegate.h"
#include "MyPurchase.h" #include "MyPurchase.h"
#include "HelloWorldScene.h"
using namespace cocos2d; using namespace cocos2d;
using namespace cocos2d::plugin; using namespace cocos2d::plugin;
@ -44,13 +45,13 @@ static EventMenuItem s_EventMenuItem[] = {
{"BtnND91.png", TAG_PAY_BY_ND91}, {"BtnND91.png", TAG_PAY_BY_ND91},
}; };
Scene* HelloWorld::scene() Scene* TestIAP::scene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
Scene *scene = Scene::create(); Scene *scene = Scene::create();
// 'layer' is an autorelease object // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create(); TestIAP *layer = TestIAP::create();
// add layer as a child to scene // add layer as a child to scene
scene->addChild(layer); scene->addChild(layer);
@ -60,7 +61,7 @@ Scene* HelloWorld::scene()
} }
// on "init" you need to initialize your instance // on "init" you need to initialize your instance
bool HelloWorld::init() bool TestIAP::init()
{ {
////////////////////////////// //////////////////////////////
// 1. super init first // 1. super init first
@ -69,11 +70,8 @@ bool HelloWorld::init()
return false; return false;
} }
Size size = Director::sharedDirector()->getWinSize(); MyPurchase::sharedPurchase()->loadIAPPlugin();
Sprite* pBackground = Sprite::create("background.png");
pBackground->setPosition(ccp(size.width / 2, size.height / 2));
addChild(pBackground);
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // you may modify it.
@ -83,15 +81,12 @@ bool HelloWorld::init()
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
// add a "close" icon to exit the progress. it's an autorelease object // add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create( MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this));
"CloseNormal.png", Size backSize = pBackItem->getContentSize();
"CloseSelected.png", pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) );
// create menu, it's an autorelease object // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
pMenu->setPosition( PointZero ); pMenu->setPosition( PointZero );
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
@ -101,7 +96,7 @@ bool HelloWorld::init()
int row = 0; int row = 0;
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
this, menu_selector(HelloWorld::eventMenuCallback)); CC_CALLBACK_1(TestIAP::eventMenuCallback, this));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
@ -116,22 +111,10 @@ bool HelloWorld::init()
pMenuItem->setPosition(pos); pMenuItem->setPosition(pos);
} }
LabelTTF* label = LabelTTF::create("reload all plugins", "Arial", 24);
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pMenuItem, 0);
pMenuItem->setPosition( ccp(size.width / 2, 0));
return true; return true;
} }
void HelloWorld::reloadPluginMenuCallback(Object* pSender) void TestIAP::eventMenuCallback(Object* pSender)
{
MyPurchase::sharedPurchase()->unloadIAPPlugin();
MyPurchase::sharedPurchase()->loadIAPPlugin();
}
void HelloWorld::eventMenuCallback(Object* pSender)
{ {
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
TProductInfo pInfo; TProductInfo pInfo;
@ -143,12 +126,10 @@ void HelloWorld::eventMenuCallback(Object* pSender)
MyPurchase::sharedPurchase()->payByMode(pInfo, mode); MyPurchase::sharedPurchase()->payByMode(pInfo, mode);
} }
void HelloWorld::menuCloseCallback(Object* pSender) void TestIAP::menuBackCallback(Object* pSender)
{ {
MyPurchase::purgePurchase(); MyPurchase::purgePurchase();
Director::sharedDirector()->end(); Scene* newScene = HelloWorld::scene();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) Director::sharedDirector()->replaceScene(newScene);
exit(0);
#endif
} }

View File

@ -21,12 +21,12 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __HELLOWORLD_SCENE_H__ #ifndef __TEST_IAP_SCENE_H__
#define __HELLOWORLD_SCENE_H__ #define __TEST_IAP_SCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
class HelloWorld : public cocos2d::Layer class TestIAP : public cocos2d::Layer
{ {
public: public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
@ -36,12 +36,11 @@ public:
static cocos2d::Scene* scene(); static cocos2d::Scene* scene();
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuBackCallback(Object* pSender);
void eventMenuCallback(Object* pSender); void eventMenuCallback(Object* pSender);
void reloadPluginMenuCallback(Object* pSender);
// implement the "static node()" method manually // implement the "static node()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(TestIAP);
}; };
#endif // __HELLOWORLD_SCENE_H__ #endif // __TEST_IAP_SCENE_H__

View File

@ -48,7 +48,7 @@ MyShareManager::~MyShareManager()
} }
} }
MyShareManager* MyShareManager::sharedShareManager() MyShareManager* MyShareManager::sharedManager()
{ {
if (s_pManager == NULL) { if (s_pManager == NULL) {
s_pManager = new MyShareManager(); s_pManager = new MyShareManager();

View File

@ -35,7 +35,7 @@ public:
class MyShareManager class MyShareManager
{ {
public: public:
static MyShareManager* sharedShareManager(); static MyShareManager* sharedManager();
static void purgeManager(); static void purgeManager();
typedef enum { typedef enum {

View File

@ -21,10 +21,11 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#include "HelloWorldScene.h" #include "TestShareScene.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "AppDelegate.h" #include "AppDelegate.h"
#include "MyShareManager.h" #include "MyShareManager.h"
#include "HelloWorldScene.h"
using namespace cocos2d; using namespace cocos2d;
using namespace cocos2d::plugin; using namespace cocos2d::plugin;
@ -44,13 +45,13 @@ static EventMenuItem s_EventMenuItem[] = {
{"weibo.png", TAG_SHARE_BY_WEIBO} {"weibo.png", TAG_SHARE_BY_WEIBO}
}; };
Scene* HelloWorld::scene() Scene* TestShare::scene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
Scene *scene = Scene::create(); Scene *scene = Scene::create();
// 'layer' is an autorelease object // 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create(); TestShare *layer = TestShare::create();
// add layer as a child to scene // add layer as a child to scene
scene->addChild(layer); scene->addChild(layer);
@ -60,7 +61,7 @@ Scene* HelloWorld::scene()
} }
// on "init" you need to initialize your instance // on "init" you need to initialize your instance
bool HelloWorld::init() bool TestShare::init()
{ {
////////////////////////////// //////////////////////////////
// 1. super init first // 1. super init first
@ -69,30 +70,23 @@ bool HelloWorld::init()
return false; return false;
} }
Size size = Director::sharedDirector()->getVisibleSize(); MyShareManager::sharedManager()->loadSharePlugin();
Sprite* pBackground = Sprite::create("background.png");
pBackground->setPosition(ccp(size.width / 2, size.height / 2));
addChild(pBackground);
///////////////////////////// /////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program // 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it. // you may modify it.
EGLView* pEGLView = EGLView::sharedOpenGLView(); EGLView* pEGLView = EGLView::sharedOpenGLView();
Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
Point posBC = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width/2, pEGLView->getVisibleOrigin().y);
Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);
// add a "close" icon to exit the progress. it's an autorelease object // add a "close" icon to exit the progress. it's an autorelease object
MenuItemImage *pCloseItem = MenuItemImage::create( MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestShare::menuBackCallback, this));
"CloseNormal.png", Size backSize = pBackItem->getContentSize();
"CloseSelected.png", pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2)));
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(posBR.x - 20, posBR.y + 20) );
// create menu, it's an autorelease object // create menu, it's an autorelease object
Menu* pMenu = Menu::create(pCloseItem, NULL); Menu* pMenu = Menu::create(pBackItem, NULL);
pMenu->setPosition( PointZero ); pMenu->setPosition( PointZero );
this->addChild(pMenu, 1); this->addChild(pMenu, 1);
@ -101,8 +95,7 @@ bool HelloWorld::init()
int line = 0; int line = 0;
int row = 0; int row = 0;
for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(), CC_CALLBACK_1(TestShare::eventMenuCallback, this));
this, menu_selector(HelloWorld::eventMenuCallback));
pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line));
@ -117,36 +110,22 @@ bool HelloWorld::init()
pMenuItem->setPosition(pos); pMenuItem->setPosition(pos);
} }
LabelTTF* label = LabelTTF::create("Reload all plugins", "Arial", 24);
MenuItemLabel* pMenuItem = MenuItemLabel::create(label, this, menu_selector(HelloWorld::reloadPluginMenuCallback));
pMenuItem->setAnchorPoint(ccp(0.5f, 0));
pMenu->addChild(pMenuItem, 0);
pMenuItem->setPosition(posBC);
return true; return true;
} }
void HelloWorld::reloadPluginMenuCallback(Object* pSender) void TestShare::eventMenuCallback(Object* pSender)
{
MyShareManager::sharedShareManager()->unloadSharePlugin();
MyShareManager::sharedShareManager()->loadSharePlugin();
}
void HelloWorld::eventMenuCallback(Object* pSender)
{ {
MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender; MenuItemLabel* pMenuItem = (MenuItemLabel*)pSender;
TShareInfo pInfo; TShareInfo pInfo;
pInfo["SharedText"] = "Share message : HelloShare!"; pInfo["SharedText"] = "Share message : HelloShare!";
// pInfo["SharedImagePath"] = "Full/path/to/image"; // pInfo["SharedImagePath"] = "Full/path/to/image";
MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1); MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1);
MyShareManager::sharedShareManager()->shareByMode(pInfo, mode); MyShareManager::sharedManager()->shareByMode(pInfo, mode);
} }
void HelloWorld::menuCloseCallback(Object* pSender) void TestShare::menuBackCallback(Object* pSender)
{ {
MyShareManager::purgeManager(); MyShareManager::purgeManager();
Director::sharedDirector()->end(); Scene* newScene = HelloWorld::scene();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) Director::sharedDirector()->replaceScene(newScene);
exit(0);
#endif
} }

View File

@ -21,12 +21,12 @@ 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#ifndef __HELLOWORLD_SCENE_H__ #ifndef __TEST_SHARE_SCENE_H__
#define __HELLOWORLD_SCENE_H__ #define __TEST_SHARE_SCENE_H__
#include "cocos2d.h" #include "cocos2d.h"
class HelloWorld : public cocos2d::Layer class TestShare : public cocos2d::Layer
{ {
public: public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
@ -36,12 +36,11 @@ public:
static cocos2d::Scene* scene(); static cocos2d::Scene* scene();
// a selector callback // a selector callback
void menuCloseCallback(Object* pSender); void menuBackCallback(Object* pSender);
void eventMenuCallback(Object* pSender); void eventMenuCallback(Object* pSender);
void reloadPluginMenuCallback(Object* pSender);
// implement the "static node()" method manually // implement the "static node()" method manually
CREATE_FUNC(HelloWorld); CREATE_FUNC(TestShare);
}; };
#endif // __HELLOWORLD_SCENE_H__ #endif // __TEST_SHARE_SCENE_H__

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