cocos2d-x in Mac:

Works as expected. All the projects defines CC_KEYBOARD_SUPPORT.
Either all of them should define them, or none, otherwise the vtable
will be broken
This commit is contained in:
Ricardo Quesada 2013-06-28 19:02:10 -07:00
parent 41a6a51208
commit b846a3060e
17 changed files with 95 additions and 29 deletions

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

@ -64,7 +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 #ifdef CC_KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#endif #endif
@ -154,7 +154,7 @@ bool Director::init(void)
_touchDispatcher = new TouchDispatcher(); _touchDispatcher = new TouchDispatcher();
_touchDispatcher->init(); _touchDispatcher->init();
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
// KeyboardDispatcher // KeyboardDispatcher
_keyboardDispatcher = new KeyboardDispatcher(); _keyboardDispatcher = new KeyboardDispatcher();
#endif #endif
@ -185,7 +185,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 #ifdef CC_KEYBOARD_SUPPORT
CC_SAFE_RELEASE(_keyboardDispatcher); CC_SAFE_RELEASE(_keyboardDispatcher);
#endif #endif
CC_SAFE_RELEASE(_keypadDispatcher); CC_SAFE_RELEASE(_keypadDispatcher);
@ -1004,7 +1004,7 @@ TouchDispatcher* Director::getTouchDispatcher()
return _touchDispatcher; return _touchDispatcher;
} }
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher) void Director::setKeyboardDispatcher(KeyboardDispatcher* pKeyboardDispatcher)
{ {
CC_SAFE_RETAIN(pKeyboardDispatcher); CC_SAFE_RETAIN(pKeyboardDispatcher);

View File

@ -71,7 +71,7 @@ class Node;
class Scheduler; class Scheduler;
class ActionManager; class ActionManager;
class TouchDispatcher; class TouchDispatcher;
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
class KeyboardDispatcher; class KeyboardDispatcher;
#endif #endif
class KeypadDispatcher; class KeypadDispatcher;
@ -328,7 +328,7 @@ public:
*/ */
CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher); CC_PROPERTY(TouchDispatcher*, _touchDispatcher, TouchDispatcher);
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
/** KeyboardDispatcher associated with this director /** KeyboardDispatcher associated with this director
@since v?.? @since v?.?
*/ */

View File

@ -38,7 +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 #ifdef CC_KEYBOARD_SUPPORT
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#endif #endif
@ -48,7 +48,7 @@ NS_CC_BEGIN
Layer::Layer() Layer::Layer()
: _touchEnabled(false) : _touchEnabled(false)
, _accelerometerEnabled(false) , _accelerometerEnabled(false)
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
, _keyboardEnabled(false) , _keyboardEnabled(false)
#endif #endif
, _keypadEnabled(false) , _keypadEnabled(false)
@ -279,7 +279,7 @@ void Layer::unregisterScriptAccelerateHandler(void)
CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry); CC_SAFE_RELEASE_NULL(_scriptAccelerateHandlerEntry);
} }
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
/// isKeyboardEnabled getter /// isKeyboardEnabled getter
bool Layer::isKeyboardEnabled() bool Layer::isKeyboardEnabled()
{ {
@ -845,7 +845,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,7 +134,7 @@ 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 #ifdef CC_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) {};
@ -157,7 +157,7 @@ public:
protected: protected:
bool _touchEnabled; bool _touchEnabled;
bool _accelerometerEnabled; bool _accelerometerEnabled;
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
bool _keyboardEnabled; bool _keyboardEnabled;
#endif #endif
bool _keypadEnabled; bool _keypadEnabled;
@ -243,7 +243,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 +305,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 +336,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

@ -1 +1 @@
14f06ca9e6652e501a7f9709b6ef7a2ed52a35b1 1dc917cb6f1a62d8d7536db3c3db9f25562d59b7

View File

@ -1013,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;
@ -1042,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

@ -1,6 +1,6 @@
#include "KeyboardTest.h" #include "KeyboardTest.h"
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
KeyboardTest::KeyboardTest() KeyboardTest::KeyboardTest()
{ {

View File

@ -1,7 +1,7 @@
#ifndef _KEYBOARD_TEST_H_ #ifndef _KEYBOARD_TEST_H_
#define _KEYBOARD_TEST_H_ #define _KEYBOARD_TEST_H_
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
#include "cocos2d.h" #include "cocos2d.h"
#include "../testBasic.h" #include "../testBasic.h"

View File

@ -16,7 +16,9 @@ static std::function<Layer*()> createFunctions[] = {
CL(LayerTest1), CL(LayerTest1),
CL(LayerTest2), CL(LayerTest2),
CL(LayerTestBlend), CL(LayerTestBlend),
CL(LayerGradient), CL(LayerGradientTest),
CL(LayerGradientTest2),
CL(LayerGradientTest3),
CL(LayerIgnoreAnchorPointPos), CL(LayerIgnoreAnchorPointPos),
CL(LayerIgnoreAnchorPointRot), CL(LayerIgnoreAnchorPointRot),
CL(LayerIgnoreAnchorPointScale), CL(LayerIgnoreAnchorPointScale),
@ -581,7 +583,7 @@ std::string LayerTestBlend::title()
//------------------------------------------------------------------ //------------------------------------------------------------------
// //
// LayerGradient // LayerGradientTest
// //
//------------------------------------------------------------------ //------------------------------------------------------------------
LayerGradientTest::LayerGradientTest() LayerGradientTest::LayerGradientTest()
@ -633,6 +635,51 @@ string LayerGradientTest::subtitle()
return "Touch the screen and move your finger"; return "Touch the screen and move your finger";
} }
//------------------------------------------------------------------
//
// LayerGradientTest2
//
//------------------------------------------------------------------
LayerGradientTest2::LayerGradientTest2()
{
LayerGradient* layer = new LayerGradient;
layer->initWithColor(ccc4(255,0,0,255), ccc4(255,255,0,255));
layer->autorelease();
addChild(layer);
}
std::string LayerGradientTest2::title()
{
return "LayerGradientTest 2";
}
string LayerGradientTest2::subtitle()
{
return "You should see a gradient";
}
//------------------------------------------------------------------
//
// LayerGradientTest3
//
//------------------------------------------------------------------
LayerGradientTest3::LayerGradientTest3()
{
LayerGradient* layer1 = LayerGradient::create(ccc4(255,0,0,255), ccc4(255,255,0,255));
addChild(layer1);
}
std::string LayerGradientTest3::title()
{
return "LayerGradientTest 3";
}
string LayerGradientTest3::subtitle()
{
return "You should see a gradient";
}
// LayerIgnoreAnchorPointPos // LayerIgnoreAnchorPointPos
#define kLayerIgnoreAnchorPoint 1000 #define kLayerIgnoreAnchorPoint 1000

View File

@ -105,6 +105,22 @@ public:
void toggleItem(cocos2d::Object *sender); void toggleItem(cocos2d::Object *sender);
}; };
class LayerGradientTest2 : public LayerTest
{
public:
LayerGradientTest2();
virtual std::string title();
virtual std::string subtitle();
};
class LayerGradientTest3 : public LayerTest
{
public:
LayerGradientTest3();
virtual std::string title();
virtual std::string subtitle();
};
class LayerIgnoreAnchorPointPos : public LayerTest class LayerIgnoreAnchorPointPos : public LayerTest
{ {
public: public:

View File

@ -49,7 +49,7 @@ struct {
{ "FileUtilsTest", []() { return new FileUtilsTestScene(); } }, { "FileUtilsTest", []() { return new FileUtilsTestScene(); } },
{ "FontTest", []() { return new FontTestScene(); } }, { "FontTest", []() { return new FontTestScene(); } },
{ "IntervalTest", [](){return new IntervalTestScene(); } }, { "IntervalTest", [](){return new IntervalTestScene(); } },
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
{ "KeyboardTest", []() { return new KeyboardTestScene(); } }, { "KeyboardTest", []() { return new KeyboardTestScene(); } },
#endif #endif
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)

View File

@ -29,7 +29,7 @@
#include "EffectsAdvancedTest/EffectsAdvancedTest.h" #include "EffectsAdvancedTest/EffectsAdvancedTest.h"
#include "AccelerometerTest/AccelerometerTest.h" #include "AccelerometerTest/AccelerometerTest.h"
#include "KeypadTest/KeypadTest.h" #include "KeypadTest/KeypadTest.h"
#ifdef KEYBOARD_SUPPORT #ifdef CC_KEYBOARD_SUPPORT
#include "KeyboardTest/KeyboardTest.h" #include "KeyboardTest/KeyboardTest.h"
#endif #endif
#include "PerformanceTest/PerformanceTest.h" #include "PerformanceTest/PerformanceTest.h"

View File

@ -1 +1 @@
a1c526dca23c3ded2ceec95cfd144e0e99c49b79 71bef727d03198fd6e3a9fe575af0d7c7c3e5449

View File

@ -639,6 +639,7 @@
CC_ENABLE_CHIPMUNK_INTEGRATION, CC_ENABLE_CHIPMUNK_INTEGRATION,
CC_TARGET_OS_MAC, CC_TARGET_OS_MAC,
DEBUG, DEBUG,
CC_KEYBOARD_SUPPORT,
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
@ -678,6 +679,7 @@
CC_ENABLE_CHIPMUNK_INTEGRATION, CC_ENABLE_CHIPMUNK_INTEGRATION,
CC_TARGET_OS_MAC, CC_TARGET_OS_MAC,
NDEBUG, NDEBUG,
CC_KEYBOARD_SUPPORT,
); );
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
@ -698,7 +700,6 @@
"\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac/libraries\"", "\"$(SRCROOT)/../../../../cocos2dx/platform/third_party/mac/libraries\"",
"\"$(SRCROOT)/../../../../external/libwebsockets/mac/lib\"", "\"$(SRCROOT)/../../../../external/libwebsockets/mac/lib\"",
); );
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = macosx; SDKROOT = macosx;
}; };
name = Release; name = Release;

@ -1 +1 @@
Subproject commit 1629fa860dd1c378c0c1d2d39463d796e51f0043 Subproject commit 0e511fd6d1f9ff3117b27c4ebc40c4b01f296437

View File

@ -511,9 +511,9 @@
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
"DEBUG=1", "DEBUG=1",
CC_TARGET_OS_MAC, CC_TARGET_OS_MAC,
CC_KEYBOARD_SUPPORT,
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
@ -541,6 +541,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;