diff --git a/AUTHORS b/AUTHORS index dba42eb2d2..e09e11d178 100644 --- a/AUTHORS +++ b/AUTHORS @@ -414,6 +414,9 @@ Developers: Added some guards to prevent Eclipse to compile twice the same class. Linux Eclipse projects updates Refactored emscripten-build.sh, it's no longer need to be edited to make emscripten work. + Creation of CCDeprecated-ext.h + Use of a single emscripten HTML template file. + Added some guards in fileutils. Fixed a bug in emscripten file utils. elmiro Correction of passed buffer size to readlink and verification of result return by readlink. @@ -537,6 +540,9 @@ Developers: Rafael (rafaelx) A warning fix of AL_INVALID_NAME and AL_INVALID_OPERATION in SimpleAudioEngineOpenAL.cpp. + + metalbass + Fixing an issue that sigslot::_connection_base# (from 0 to 8) don't have virtual destructors. Retired Core Developers: WenSheng Yang diff --git a/CocosDenshion/proj.win32/CocosDenshion.vcxproj b/CocosDenshion/proj.win32/CocosDenshion.vcxproj index 3cc784a2a4..c5738cf5a2 100644 --- a/CocosDenshion/proj.win32/CocosDenshion.vcxproj +++ b/CocosDenshion/proj.win32/CocosDenshion.vcxproj @@ -66,7 +66,7 @@ Disabled $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;"$(ProjectDir)..\..\cocos2dx";"$(ProjectDir)..\..\cocos2dx\include";"$(ProjectDir)..\..\cocos2dx\kazmath\include";"$(ProjectDir)..\..\cocos2dx\platform\win32";"$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES";%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOSDENSHIONWIN32_EXPORTS;_EXPORT_DLL_;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -90,7 +90,7 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;"$(ProjectDir)..\..\cocos2dx";"$(ProjectDir)..\..\cocos2dx\include";"$(ProjectDir)..\..\cocos2dx\kazmath\include";"$(ProjectDir)..\..\cocos2dx\platform\win32";"$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES";%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOSDENSHIONWIN32_EXPORTS;_EXPORT_DLL_;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 1a6f3b07e4..d4449e9706 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b58c6efb737f16d40b382a25cea15fdb09764372 \ No newline at end of file +a30cd2dad1df734bd988309d3b344ff946601cb4 \ No newline at end of file diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 39fb290244..d3b26b7a6d 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -8,6 +8,7 @@ LOCAL_MODULE_FILENAME := libcocos2d LOCAL_SRC_FILES := \ CCConfiguration.cpp \ +CCDeprecated.cpp \ CCScheduler.cpp \ CCCamera.cpp \ ccFPSImages.c \ @@ -170,8 +171,8 @@ LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static # define the macro to compile through support/zip_support/ioapi.c -LOCAL_CFLAGS := -Wno-psabi -Wno-deprecated-declarations -DUSE_FILE32API -LOCAL_EXPORT_CFLAGS := -Wno-psabi -Wno-deprecated-declarations -DUSE_FILE32API +LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API +LOCAL_EXPORT_CFLAGS := -Wno-psabi -DUSE_FILE32API include $(BUILD_STATIC_LIBRARY) diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index dc6eadaf95..86c296d9e0 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -35,15 +35,6 @@ THE SOFTWARE. NS_CC_BEGIN -typedef enum _ccConfigurationType { - ConfigurationError, - ConfigurationString, - ConfigurationInt, - ConfigurationDouble, - ConfigurationBoolean -} ccConfigurationType; - - /** * @addtogroup global * @{ @@ -55,6 +46,7 @@ typedef enum _ccConfigurationType { class CC_DLL Configuration : public Object { public: + /** returns a shared instance of Configuration */ static Configuration *getInstance(); diff --git a/cocos2dx/CCDeprecated.cpp b/cocos2dx/CCDeprecated.cpp new file mode 100644 index 0000000000..5daeecff64 --- /dev/null +++ b/cocos2dx/CCDeprecated.cpp @@ -0,0 +1,299 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "cocos2d.h" + +NS_CC_BEGIN + +const Point CCPointZero = Point::ZERO; + +/* The "zero" size -- equivalent to Size(0, 0). */ +const Size CCSizeZero = Size::ZERO; + +/* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ +const Rect CCRectZero = Rect::ZERO; + + +const Color3B ccWHITE = Color3B::WHITE; +const Color3B ccYELLOW = Color3B::YELLOW; +const Color3B ccGREEN = Color3B::GREEN; +const Color3B ccBLUE = Color3B::BLUE; +const Color3B ccRED = Color3B::RED; +const Color3B ccMAGENTA = Color3B::MAGENTA; +const Color3B ccBLACK = Color3B::BLACK; +const Color3B ccORANGE = Color3B::ORANGE; +const Color3B ccGRAY = Color3B::GRAY; + +const BlendFunc kCCBlendFuncDisable = BlendFunc::DISABLE; + +const int kCCVertexAttrib_Position = GLProgram::VERTEX_ATTRIB_POSITION; +const int kCCVertexAttrib_Color = GLProgram::VERTEX_ATTRIB_COLOR; +const int kCCVertexAttrib_TexCoords = GLProgram::VERTEX_ATTRIB_TEX_COORDS; +const int kCCVertexAttrib_MAX = GLProgram::VERTEX_ATTRIB_MAX; + +const int kCCUniformPMatrix = GLProgram::UNIFORM_P_MATRIX; +const int kCCUniformMVMatrix = GLProgram::UNIFORM_MV_MATRIX; +const int kCCUniformMVPMatrix = GLProgram::UNIFORM_MVP_MATRIX; +const int kCCUniformTime = GLProgram::UNIFORM_TIME; +const int kCCUniformSinTime = GLProgram::UNIFORM_SIN_TIME; +const int kCCUniformCosTime = GLProgram::UNIFORM_COS_TIME; +const int kCCUniformRandom01 = GLProgram::UNIFORM_RANDOM01; +const int kCCUniformSampler = GLProgram::UNIFORM_SAMPLER; +const int kCCUniform_MAX = GLProgram::UNIFORM_MAX; + +const char* kCCShader_PositionTextureColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR; +const char* kCCShader_PositionTextureColorAlphaTest = GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; +const char* kCCShader_PositionColor = GLProgram::SHADER_NAME_POSITION_COLOR; +const char* kCCShader_PositionTexture = GLProgram::SHADER_NAME_POSITION_TEXTURE; +const char* kCCShader_PositionTexture_uColor = GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR; +const char* kCCShader_PositionTextureA8Color = GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR; +const char* kCCShader_Position_uColor = GLProgram::SHADER_NAME_POSITION_U_COLOR; +const char* kCCShader_PositionLengthTexureColor = GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR; + +// uniform names +const char* kCCUniformPMatrix_s = GLProgram::UNIFORM_NAME_P_MATRIX; +const char* kCCUniformMVMatrix_s = GLProgram::UNIFORM_NAME_MV_MATRIX; +const char* kCCUniformMVPMatrix_s = GLProgram::UNIFORM_NAME_MVP_MATRIX; +const char* kCCUniformTime_s = GLProgram::UNIFORM_NAME_TIME; +const char* kCCUniformSinTime_s = GLProgram::UNIFORM_NAME_SIN_TIME; +const char* kCCUniformCosTime_s = GLProgram::UNIFORM_NAME_COS_TIME; +const char* kCCUniformRandom01_s = GLProgram::UNIFORM_NAME_RANDOM01; +const char* kCCUniformSampler_s = GLProgram::UNIFORM_NAME_SAMPLER; +const char* kCCUniformAlphaTestValue = GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE; + +// Attribute names +const char* kCCAttributeNameColor = GLProgram::ATTRIBUTE_NAME_COLOR; +const char* kCCAttributeNamePosition = GLProgram::ATTRIBUTE_NAME_POSITION; +const char* kCCAttributeNameTexCoord = GLProgram::ATTRIBUTE_NAME_TEX_COORD; + +const int kCCVertexAttribFlag_None = GL::VERTEX_ATTRIB_FLAT_NONE; +const int kCCVertexAttribFlag_Position = GL::VERTEX_ATTRIB_FLAG_POSITION; +const int kCCVertexAttribFlag_Color = GL::VERTEX_ATTRIB_FLAG_COLOR; +const int kCCVertexAttribFlag_TexCoords = GL::VERTEX_ATTRIB_FLAG_TEX_COORDS; +const int kCCVertexAttribFlag_PosColorTex = GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX; + +const ProgressTimer::Type kCCProgressTimerTypeRadial = ProgressTimer::Type::RADIAL; +const ProgressTimer::Type kCCProgressTimerTypeBar = ProgressTimer::Type::BAR; + +const Director::Projection kCCDirectorProjection2D = Director::Projection::_2D; +const Director::Projection kCCDirectorProjection3D = Director::Projection::_3D; +const Director::Projection kCCDirectorProjectionCustom = Director::Projection::CUSTOM; +const Director::Projection kCCDirectorProjectionDefault = Director::Projection::DEFAULT; + +const int kCCParticleDurationInfinity = ParticleSystem::DURATION_INFINITY; +const int kCCParticleStartSizeEqualToEndSize = ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE; +const int kCCParticleStartRadiusEqualToEndRadius = ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS; + +const ParticleSystem::Mode kCCParticleModeGravity = ParticleSystem::Mode::GRAVITY; +const ParticleSystem::Mode kCCParticleModeRadius = ParticleSystem::Mode::RADIUS; +const int kCCParticleDefaultCapacity = kParticleDefaultCapacity; + +const ParticleSystem::PositionType kCCPositionTypeFree = ParticleSystem::PositionType::FREE; +const ParticleSystem::PositionType kCCPositionTypeRelative = ParticleSystem::PositionType::RELATIVE; +const ParticleSystem::PositionType kCCPositionTypeGrouped = ParticleSystem::PositionType::GROUPED; + +const Label::VAlignment kCCVerticalTextAlignmentTop = Label::VAlignment::TOP; +const Label::VAlignment kCCVerticalTextAlignmentCenter = Label::VAlignment::CENTER; +const Label::VAlignment kCCVerticalTextAlignmentBottom = Label::VAlignment::BOTTOM; + +const Label::HAlignment kCCTextAlignmentLeft = Label::HAlignment::LEFT; +const Label::HAlignment kCCTextAlignmentCenter = Label::HAlignment::CENTER; +const Label::HAlignment kCCTextAlignmentRight = Label::HAlignment::RIGHT; + +const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888 = Texture2D::PixelFormat::RGBA8888; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888 = Texture2D::PixelFormat::RGB888; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565 = Texture2D::PixelFormat::RGB565; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8 = Texture2D::PixelFormat::A8; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8 = Texture2D::PixelFormat::I8; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88 = Texture2D::PixelFormat::AI88; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444 = Texture2D::PixelFormat::RGBA4444; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1 = Texture2D::PixelFormat::RGB5A1; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4 = Texture2D::PixelFormat::PRVTC4; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2 = Texture2D::PixelFormat::PRVTC2; +const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default = Texture2D::PixelFormat::DEFAULT; + +const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY; +const Menu::State kCCMenuStateWaiting = Menu::State::WAITING; +const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH; + +const Touch::DispatchMode kCCTouchesOneByOne = Touch::DispatchMode::ONE_BY_ONE; +const Touch::DispatchMode kCCTouchesAllAtOnce = Touch::DispatchMode::ALL_AT_ONCE; + +const Image::Format kCCImageFormatPNG = Image::Format::PNG; +const Image::Format kCCImageFormatJPEG = Image::Format::JPG; + +const TransitionScene::Orientation kCCTransitionOrientationLeftOver = TransitionScene::Orientation::LEFT_OVER; +const TransitionScene::Orientation kCCTransitionOrientationRightOver = TransitionScene::Orientation::RIGHT_OVER; +const TransitionScene::Orientation kCCTransitionOrientationUpOver = TransitionScene::Orientation::UP_OVER; +const TransitionScene::Orientation kCCTransitionOrientationDownOver = TransitionScene::Orientation::DOWN_OVER; + +const int kCCPrioritySystem = Scheduler::PRIORITY_SYSTEM; +const int kCCPriorityNonSystemMin = Scheduler::PRIORITY_NON_SYSTEM_MIN; + +const int kCCActionTagInvalid = kActionTagInvalid; + +const int kCCNodeTagInvalid = kNodeTagInvalid; + +const int kCCNodeOnEnter = kNodeOnEnter; +const int kCCNodeOnExit = kNodeOnExit; +const int kCCNodeOnEnterTransitionDidFinish = kNodeOnEnterTransitionDidFinish; +const int kCCNodeOnExitTransitionDidStart = kNodeOnExitTransitionDidStart; +const int kCCNodeOnCleanup = kNodeOnCleanup; + +const LanguageType kLanguageEnglish = LanguageType::ENGLISH; +const LanguageType kLanguageChinese = LanguageType::CHINESE; +const LanguageType kLanguageFrench = LanguageType::FRENCH; +const LanguageType kLanguageItalian = LanguageType::ITALIAN; +const LanguageType kLanguageGerman = LanguageType::GERMAN; +const LanguageType kLanguageSpanish = LanguageType::SPANISH; +const LanguageType kLanguageRussian = LanguageType::RUSSIAN; +const LanguageType kLanguageKorean = LanguageType::KOREAN; +const LanguageType kLanguageJapanese = LanguageType::JAPANESE; +const LanguageType kLanguageHungarian = LanguageType::HUNGARIAN; +const LanguageType kLanguagePortuguese = LanguageType::PORTUGUESE; +const LanguageType kLanguageArabic = LanguageType::ARABIC; +const LanguageType kLanguageNorwegian = LanguageType::NORWEGIAN; +const LanguageType kLanguagePolish = LanguageType::POLISH; + + + +const Application::Platform kTargetWindows = Application::Platform::OS_WINDOWS; +const Application::Platform kTargetLinux = Application::Platform::OS_LINUX; +const Application::Platform kTargetMacOS = Application::Platform::OS_MAC; +const Application::Platform kTargetAndroid = Application::Platform::OS_ANDROID; +const Application::Platform kTargetIphone = Application::Platform::OS_IPHONE; +const Application::Platform kTargetIpad = Application::Platform::OS_IPAD; +const Application::Platform kTargetBlackBerry = Application::Platform::OS_BLACKBERRY; +const Application::Platform kTargetNaCl = Application::Platform::OS_NACL; +const Application::Platform kTargetEmscripten = Application::Platform::OS_EMSCRIPTEN; +const Application::Platform kTargetTizen = Application::Platform::OS_TIZEN; + +const ResolutionPolicy kResolutionExactFit = ResolutionPolicy::EXACT_FIT; +const ResolutionPolicy kResolutionNoBorder = ResolutionPolicy::NO_BORDER; +const ResolutionPolicy kResolutionShowAll = ResolutionPolicy::SHOW_ALL; +const ResolutionPolicy kResolutionFixedHeight = ResolutionPolicy::FIXED_HEIGHT; +const ResolutionPolicy kResolutionFixedWidth = ResolutionPolicy::FIXED_WIDTH; +const ResolutionPolicy kResolutionUnKnown = ResolutionPolicy::UNKNOWN; + +void ccDrawInit() +{ + DrawPrimitives::init(); +} + +void ccDrawFree() +{ + DrawPrimitives::free(); +} + +void ccDrawPoint( const Point& point ) +{ + DrawPrimitives::drawPoint(point); +} + +void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) +{ + DrawPrimitives::drawPoints(points, numberOfPoints); +} + +void ccDrawLine( const Point& origin, const Point& destination ) +{ + DrawPrimitives::drawLine(origin, destination); +} + +void ccDrawRect( Point origin, Point destination ) +{ + DrawPrimitives::drawRect(origin, destination); +} + +void ccDrawSolidRect( Point origin, Point destination, Color4F color ) +{ + DrawPrimitives::drawSolidRect(origin, destination, color); +} + +void ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ) +{ + DrawPrimitives::drawPoly(vertices, numOfVertices, closePolygon); +} + +void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ) +{ + DrawPrimitives::drawSolidPoly(poli, numberOfPoints, color); +} + +void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) +{ + DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY); +} + +void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) +{ + DrawPrimitives::drawCircle(center, radius, angle, segments, drawLineToCenter); +} + +void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) +{ + DrawPrimitives::drawSolidCircle(center, radius, angle, segments, scaleX, scaleY); +} + +void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments) +{ + DrawPrimitives::drawSolidCircle(center, radius, angle, segments); +} + +void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments) +{ + DrawPrimitives::drawQuadBezier(origin, control, destination, segments); +} + +void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments) +{ + DrawPrimitives::drawCubicBezier(origin, control1, control2, destination, segments); +} + +void ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ) +{ + DrawPrimitives::drawCatmullRom(arrayOfControlPoints, segments); +} + +void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ) +{ + DrawPrimitives::drawCardinalSpline(config, tension, segments); +} + +void ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) +{ + DrawPrimitives::setDrawColor4B(r, g, b, a); +} + +void ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) +{ + DrawPrimitives::setDrawColor4F(r, g, b, a); +} + +void ccPointSize( GLfloat pointSize ) +{ + DrawPrimitives::setPointSize(pointSize); +} + +NS_CC_END diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5a916fe678..2bad5e77ca 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -146,7 +146,7 @@ bool Director::init(void) _scheduler = new Scheduler(); // action manager _actionManager = new ActionManager(); - _scheduler->scheduleUpdateForTarget(_actionManager, kPrioritySystem, false); + _scheduler->scheduleUpdateForTarget(_actionManager, Scheduler::PRIORITY_SYSTEM, false); // touchDispatcher _touchDispatcher = new TouchDispatcher(); _touchDispatcher->init(); @@ -210,22 +210,22 @@ void Director::setDefaultValues(void) // GL projection const char *projection = conf->getCString("cocos2d.x.gl.projection", "3d"); if( strcmp(projection, "3d") == 0 ) - _projection = kDirectorProjection3D; + _projection = Projection::_3D; else if (strcmp(projection, "2d") == 0) - _projection = kDirectorProjection2D; + _projection = Projection::_2D; else if (strcmp(projection, "custom") == 0) - _projection = kDirectorProjectionCustom; + _projection = Projection::CUSTOM; else CCASSERT(false, "Invalid projection value"); // Default pixel format for PNG images with alpha const char *pixel_format = conf->getCString("cocos2d.x.texture.pixel_format_for_png", "rgba8888"); if( strcmp(pixel_format, "rgba8888") == 0 ) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); else if( strcmp(pixel_format, "rgba4444") == 0 ) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); else if( strcmp(pixel_format, "rgba5551") == 0 ) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); // PVR v2 has alpha premultiplied ? bool pvr_alpha_premultipled = conf->getBool("cocos2d.x.texture.pvrv2_has_alpha_premultiplied", false); @@ -385,16 +385,15 @@ void Director::setNextDeltaTimeZero(bool bNextDeltaTimeZero) _nextDeltaTimeZero = bNextDeltaTimeZero; } -void Director::setProjection(ccDirectorProjection kProjection) +void Director::setProjection(Projection projection) { Size size = _winSizeInPoints; setViewport(); - switch (kProjection) + switch (projection) { - case kDirectorProjection2D: - { + case Projection::_2D: kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4 orthoMatrix; @@ -402,10 +401,9 @@ void Director::setProjection(ccDirectorProjection kProjection) kmGLMultMatrix(&orthoMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); - } - break; + break; - case kDirectorProjection3D: + case Projection::_3D: { float zeye = this->getZEye(); @@ -428,23 +426,21 @@ void Director::setProjection(ccDirectorProjection kProjection) kmVec3Fill( &up, 0.0f, 1.0f, 0.0f); kmMat4LookAt(&matrixLookup, &eye, ¢er, &up); kmGLMultMatrix(&matrixLookup); + break; } - break; - case kDirectorProjectionCustom: - if (_projectionDelegate) - { - _projectionDelegate->updateProjection(); - } - break; + case Projection::CUSTOM: + if (_projectionDelegate) + _projectionDelegate->updateProjection(); + break; - default: - CCLOG("cocos2d: Director: unrecognized projection"); - break; + default: + CCLOG("cocos2d: Director: unrecognized projection"); + break; } - _projection = kProjection; - ccSetProjectionMatrixDirty(); + _projection = projection; + GL::setProjectionMatrixDirty(); } void Director::purgeCachedData(void) @@ -467,11 +463,11 @@ void Director::setAlphaBlending(bool bOn) { if (bOn) { - ccGLBlendFunc(CC_BLEND_SRC, CC_BLEND_DST); + GL::blendFunc(CC_BLEND_SRC, CC_BLEND_DST); } else { - ccGLBlendFunc(GL_ONE, GL_ZERO); + GL::blendFunc(GL_ONE, GL_ZERO); } CHECK_GL_ERROR_DEBUG(); @@ -705,7 +701,7 @@ void Director::purgeDirector() LabelBMFont::purgeCachedData(); // purge all managed caches - ccDrawFree(); + DrawPrimitives::free(); AnimationCache::destroyInstance(); SpriteFrameCache::destroyInstance(); TextureCache::destroyInstance(); @@ -717,7 +713,7 @@ void Director::purgeDirector() UserDefault::destroyInstance(); NotificationCenter::destroyInstance(); - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); CHECK_GL_ERROR_DEBUG(); @@ -864,8 +860,8 @@ void Director::createStatsLabel() FileUtils::getInstance()->purgeCachedEntries(); } - Texture2DPixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat(); - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::PixelFormat currentFormat = Texture2D::getDefaultAlphaPixelFormat(); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); unsigned char *data = NULL; unsigned int data_len = 0; getFPSImageData(&data, &data_len); diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 3def5eac2a..2ad40f4d7e 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -46,23 +46,6 @@ NS_CC_BEGIN * @{ */ -/** @typedef ccDirectorProjection - Possible OpenGL projections used by director - */ -typedef enum { - /// sets a 2D projection (orthogonal projection) - kDirectorProjection2D, - - /// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. - kDirectorProjection3D, - - /// it calls "updateProjection" on the projection delegate. - kDirectorProjectionCustom, - - /// Default projection is 3D projection - kDirectorProjectionDefault = kDirectorProjection3D, -} ccDirectorProjection; - /* Forward declarations. */ class LabelAtlas; class Scene; @@ -99,6 +82,24 @@ and when to execute the Scenes. class CC_DLL Director : public Object, public TypeInfo { public: + /** @typedef ccDirectorProjection + Possible OpenGL projections used by director + */ + enum class Projection + { + /// sets a 2D projection (orthogonal projection) + _2D, + + /// sets a 3D projection with a fovy=60, znear=0.5f and zfar=1500. + _3D, + + /// it calls "updateProjection" on the projection delegate. + CUSTOM, + + /// Default projection is 3D projection + DEFAULT = _3D, + }; + /** returns a shared instance of the director */ static Director* getInstance(); @@ -126,7 +127,7 @@ public: /** Whether or not to display the FPS on the bottom-left corner */ inline bool isDisplayStats(void) { return _displayStats; } /** Display the FPS on the bottom-left corner */ - inline void setDisplayStats(bool bDisplayStats) { _displayStats = bDisplayStats; } + inline void setDisplayStats(bool displayStats) { _displayStats = displayStats; } /** seconds per frame */ inline float getSecondsPerFrame() { return _secondsPerFrame; } @@ -136,7 +137,7 @@ public: void setOpenGLView(EGLView *pobOpenGLView); inline bool isNextDeltaTimeZero(void) { return _nextDeltaTimeZero; } - void setNextDeltaTimeZero(bool bNextDeltaTimeZero); + void setNextDeltaTimeZero(bool nextDeltaTimeZero); /** Whether or not the Director is paused */ inline bool isPaused(void) { return _paused; } @@ -147,8 +148,8 @@ public: /** Sets an OpenGL projection @since v0.8.2 */ - inline ccDirectorProjection getProjection(void) { return _projection; } - void setProjection(ccDirectorProjection kProjection); + inline Projection getProjection(void) { return _projection; } + void setProjection(Projection projection); /** Sets the glViewport*/ void setViewport(); @@ -200,12 +201,12 @@ public: /** converts a UIKit coordinate to an OpenGL coordinate Useful to convert (multi) touch coordinates to the current layout (portrait or landscape) */ - Point convertToGL(const Point& obPoint); + Point convertToGL(const Point& point); /** converts an OpenGL coordinate to a UIKit coordinate Useful to convert node points to window points for calls such as glScissor */ - Point convertToUI(const Point& obPoint); + Point convertToUI(const Point& point); /// XXX: missing description float getZEye(void) const; @@ -218,14 +219,14 @@ public: * * It will call pushScene: and then it will call startAnimation */ - void runWithScene(Scene *pScene); + void runWithScene(Scene *scene); /** Suspends the execution of the running scene, pushing it on the stack of suspended scenes. * The new scene will be executed. * Try to avoid big stacks of pushed scenes to reduce memory allocation. * ONLY call it if there is a running scene. */ - void pushScene(Scene *pScene); + void pushScene(Scene *scene); /** Pops out a scene from the queue. * This scene will replace the running one. @@ -250,7 +251,7 @@ public: /** Replaces the running scene with a new one. The running scene is terminated. * ONLY call it if there is a running scene. */ - void replaceScene(Scene *pScene); + void replaceScene(Scene *scene); /** Ends the execution, releases the running scene. It doesn't remove the OpenGL view from its parent. You have to do it manually. @@ -477,7 +478,7 @@ protected: bool _nextDeltaTimeZero; /* projection used */ - ccDirectorProjection _projection; + Projection _projection; /* window size in points */ Size _winSizeInPoints; diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 935a2b4683..fbfcc3b529 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -240,6 +240,12 @@ SEL_SCHEDULE Timer::getSelector() const // implementation of Scheduler +// Priority level reserved for system services. +const int Scheduler::PRIORITY_SYSTEM = INT_MIN; + +// Minimum priority level for user scheduling. +const int Scheduler::PRIORITY_NON_SYSTEM_MIN = PRIORITY_SYSTEM + 1; + Scheduler::Scheduler(void) : _timeScale(1.0f) , _updatesNegList(NULL) @@ -577,7 +583,7 @@ void Scheduler::unscheduleUpdateForTarget(const Object *target) void Scheduler::unscheduleAll(void) { - unscheduleAllWithMinPriority(kPrioritySystem); + unscheduleAllWithMinPriority(PRIORITY_SYSTEM); } void Scheduler::unscheduleAllWithMinPriority(int nMinPriority) @@ -759,7 +765,7 @@ bool Scheduler::isTargetPaused(Object *target) Set* Scheduler::pauseAllTargets() { - return pauseAllTargetsWithMinPriority(kPrioritySystem); + return pauseAllTargetsWithMinPriority(PRIORITY_SYSTEM); } Set* Scheduler::pauseAllTargetsWithMinPriority(int nMinPriority) diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index 4a5d1c9628..3df5cd96ec 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -37,12 +37,6 @@ NS_CC_BEGIN * @{ */ -// Priority level reserved for system services. -#define kPrioritySystem INT_MIN - -// Minimum priority level for user scheduling. -#define kPriorityNonSystemMin (kPrioritySystem+1) - class Set; // // Timer @@ -121,6 +115,12 @@ The 'custom selectors' should be avoided when possible. It is faster, and consum class CC_DLL Scheduler : public Object { public: + // Priority level reserved for system services. + static const int PRIORITY_SYSTEM; + + // Minimum priority level for user scheduling. + static const int PRIORITY_NON_SYSTEM_MIN; + Scheduler(); ~Scheduler(void); diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index ec38f59c83..82830fcd83 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -201,8 +201,11 @@ Instead of using Camera as a "follower", use this action instead. class CC_DLL Follow : public Action { public: - /** creates the action with a set boundary, - It will work with no boundary if @param rect is equal to Rect::ZERO. + /** + * Creates the action with a set boundary or with no boundary. + * + * @param rect The boundary. If \p rect is equal to Rect::ZERO, it'll work + * with no boundary. */ static Follow* create(Node *pFollowedNode, const Rect& rect = Rect::ZERO); @@ -222,7 +225,12 @@ public: /** alter behavior - turn on/off boundary */ inline void setBoudarySet(bool bValue) { _boundarySet = bValue; } - /** initializes the action with a set boundary */ + /** + * Initializes the action with a set boundary or with no boundary. + * + * @param rect The boundary. If \p rect is equal to Rect::ZERO, it'll work + * with no boundary. + */ bool initWithTarget(Node *pFollowedNode, const Rect& rect = Rect::ZERO); // diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 0ea7a89576..b08af1d1e2 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -29,6 +29,13 @@ #include "sprite_nodes/CCSprite.h" #include "script_support/CCScriptSupport.h" +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif + NS_CC_BEGIN // // InstantAction @@ -473,5 +480,137 @@ CallFuncN * CallFuncN::clone() const return a; } +// +// CallFuncND +// + +__CCCallFuncND * __CCCallFuncND::create(Object* selectorTarget, SEL_CallFuncND selector, void* d) +{ + __CCCallFuncND* pRet = new __CCCallFuncND(); + + if (pRet && pRet->initWithTarget(selectorTarget, selector, d)) { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return NULL; +} + +bool __CCCallFuncND::initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d) +{ + if (CallFunc::initWithTarget(selectorTarget)) + { + _data = d; + _callFuncND = selector; + return true; + } + + return false; +} + +void __CCCallFuncND::execute() +{ + if (_callFuncND) + { + (_selectorTarget->*_callFuncND)(_target, _data); + } +} + +__CCCallFuncND * __CCCallFuncND::clone() const +{ + // no copy constructor + auto a = new __CCCallFuncND(); + + if( _selectorTarget) + { + a->initWithTarget(_selectorTarget, _callFuncND, _data); + } + + a->autorelease(); + return a; +} + +// +// CallFuncO +// +__CCCallFuncO::__CCCallFuncO() : +_object(NULL) +{ +} + +__CCCallFuncO::~__CCCallFuncO() +{ + CC_SAFE_RELEASE(_object); +} + +void __CCCallFuncO::execute() +{ + if (_callFuncO) { + (_selectorTarget->*_callFuncO)(_object); + } +} + +__CCCallFuncO * __CCCallFuncO::create(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +{ + __CCCallFuncO *pRet = new __CCCallFuncO(); + + if (pRet && pRet->initWithTarget(selectorTarget, selector, object)) { + pRet->autorelease(); + return pRet; + } + + CC_SAFE_DELETE(pRet); + return NULL; +} + +bool __CCCallFuncO::initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object) +{ + if (CallFunc::initWithTarget(selectorTarget)) + { + _object = object; + CC_SAFE_RETAIN(_object); + + _callFuncO = selector; + return true; + } + + return false; +} + +__CCCallFuncO * __CCCallFuncO::clone() const +{ + // no copy constructor + auto a = new __CCCallFuncO(); + + if( _selectorTarget) + { + a->initWithTarget(_selectorTarget, _callFuncO, _object); + } + + a->autorelease(); + return a; +} + +Object* __CCCallFuncO::getObject() const +{ + return _object; +} + +void __CCCallFuncO::setObject(Object* obj) +{ + if (obj != _object) + { + CC_SAFE_RELEASE(_object); + _object = obj; + CC_SAFE_RETAIN(_object); + } +} NS_CC_END + +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (pop) +#endif diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index ce494cc635..aaf8998dda 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -341,6 +341,87 @@ protected: std::function _functionN; }; +/** + @deprecated Please use CallFuncN instead. + @brief Calls a 'callback' with the node as the first argument and the 2nd argument is data + * ND means: Node and Data. Data is void *, so it could be anything. + */ + +class CC_DLL __CCCallFuncND : public CallFunc +{ +public: + /** creates the action with the callback and the data to pass as an argument */ + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncND * create(Object* selectorTarget, SEL_CallFuncND selector, void* d); + + virtual long getClassTypeInfo() { + static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); + return id; + } + +protected: + /** initializes the action with the callback and the data to pass as an argument */ + bool initWithTarget(Object* selectorTarget, SEL_CallFuncND selector, void* d); + +public: + // + // Overrides + // + virtual __CCCallFuncND* clone() const override; + virtual void execute() override; + +protected: + SEL_CallFuncND _callFuncND; + void* _data; +}; + + +/** + @deprecated Please use CallFuncN instead. + @brief Calls a 'callback' with an object as the first argument. + O means Object. + @since v0.99.5 + */ + +class CC_DLL __CCCallFuncO : public CallFunc, public TypeInfo +{ +public: + /** creates the action with the callback + + typedef void (Object::*SEL_CallFuncO)(Object*); + */ + CC_DEPRECATED_ATTRIBUTE static __CCCallFuncO * create(Object* selectorTarget, SEL_CallFuncO selector, Object* object); + + __CCCallFuncO(); + virtual ~__CCCallFuncO(); + + virtual long getClassTypeInfo() { + static const long id = cocos2d::getHashCodeByString(typeid(cocos2d::CallFunc).name()); + return id; + } + +protected: + /** initializes the action with the callback + + typedef void (Object::*SEL_CallFuncO)(Object*); + */ + bool initWithTarget(Object* selectorTarget, SEL_CallFuncO selector, Object* object); + +public: + // + // Overrides + // + virtual __CCCallFuncO* clone() const override; + virtual void execute() override; + + Object* getObject() const; + void setObject(Object* obj); + +protected: + /** object to be passed as argument */ + Object* _object; + SEL_CallFuncO _callFuncO; +}; + // end of actions group /// @} diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index b82a2bb06c..0971abd779 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -90,8 +90,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi _colorUnmodified = Color3B::WHITE; _isOpacityModifyRGB = true; - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _textureAtlas = new TextureAtlas(); _textureAtlas->initWithTexture(texture, itemsToRender); @@ -110,7 +109,7 @@ bool AtlasNode::initWithTexture(Texture2D* texture, unsigned int tileWidth, unsi _quadsToDraw = itemsToRender; // shader stuff - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture_uColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR)); _uniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color"); return true; @@ -142,7 +141,7 @@ void AtlasNode::draw(void) { CC_NODE_DRAW_SETUP(); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); GLfloat colors[4] = {_displayedColor.r / 255.0f, _displayedColor.g / 255.0f, _displayedColor.b / 255.0f, _displayedOpacity / 255.0f}; getShaderProgram()->setUniformLocationWith4fv(_uniformColor, colors, 1); @@ -220,10 +219,8 @@ void AtlasNode::setBlendFunc(const BlendFunc &blendFunc) void AtlasNode::updateBlendFunc() { - if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - } + if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha() ) + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } void AtlasNode::setTexture(Texture2D *texture) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index bcdb137f35..044d05436e 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -77,7 +77,6 @@ Node::Node(void) , _userData(NULL) , _userObject(NULL) , _shaderProgram(NULL) -, _GLServerState(ccGLServerState(0)) , _orderOfArrival(0) , _running(false) , _transformDirty(true) @@ -125,10 +124,10 @@ Node::~Node() Object* child; CCARRAY_FOREACH(_children, child) { - Node* pChild = static_cast(child); - if (pChild) + Node* node = static_cast(child); + if (node) { - pChild->_parent = NULL; + node->_parent = NULL; } } } @@ -456,16 +455,6 @@ void Node::setOrderOfArrival(int orderOfArrival) _orderOfArrival = orderOfArrival; } -ccGLServerState Node::getGLServerState() const -{ - return _GLServerState; -} - -void Node::setGLServerState(ccGLServerState glServerState) -{ - _GLServerState = glServerState; -} - void Node::setUserObject(Object *pUserObject) { CC_SAFE_RETAIN(pUserObject); diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 497100fb01..2a4e5fb3c3 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -515,19 +515,10 @@ public: virtual int getOrderOfArrival() const; - /** - * Sets the state of OpenGL server side. - * - * @param glServerState The state of OpenGL server side. - */ - virtual void setGLServerState(ccGLServerState serverState); - /** - * Returns the state of OpenGL server side. - * - * @return The state of OpenGL server side. - */ - virtual ccGLServerState getGLServerState() const; - + /** @deprecated No longer needed */ + CC_DEPRECATED_ATTRIBUTE void setGLServerState(int serverState) { /* ignore */ }; + /** @deprecated No longer needed */ + CC_DEPRECATED_ATTRIBUTE int getGLServerState() const { return 0; } /** * Sets whether the anchor point will be (0,0) when you position this node. @@ -823,7 +814,7 @@ public: * Since v2.0, each rendering node must set its shader program. * It should be set in initialize phase. * @code - * node->setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + * node->setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); * @endcode * * @param The shader program which fetchs from ShaderCache. @@ -1359,9 +1350,7 @@ protected: Object *_userObject; ///< A user assigned Object GLProgram *_shaderProgram; ///< OpenGL shader - - ccGLServerState _GLServerState; ///< OpenGL servier side state - + int _orderOfArrival; ///< used to preserve sequence while sorting children with the same zOrder Scheduler *_scheduler; ///< scheduler used to schedule timers and updates diff --git a/cocos2dx/ccTypes.cpp b/cocos2dx/ccTypes.cpp index 3a27c71bde..4b752b9310 100644 --- a/cocos2dx/ccTypes.cpp +++ b/cocos2dx/ccTypes.cpp @@ -43,6 +43,9 @@ Color4B::Color4B(const Color4F &color4F) a((GLubyte)(color4F.a * 255.0f)) {} -const BlendFunc BlendFunc::BLEND_FUNC_DISABLE = {GL_ONE, GL_ZERO}; +const BlendFunc BlendFunc::DISABLE = {GL_ONE, GL_ZERO}; +const BlendFunc BlendFunc::ALPHA_PREMULTIPLIED = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; +const BlendFunc BlendFunc::ALPHA_NON_PREMULTIPLIED = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; +const BlendFunc BlendFunc::ADDITIVE = {GL_SRC_ALPHA, GL_ONE}; NS_CC_END diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index f1ecce7120..cbbb86678e 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -227,12 +227,12 @@ String* String::createWithFormat(const char* format, ...) return pRet; } -String* String::createWithContentsOfFile(const char* pszFileName) +String* String::createWithContentsOfFile(const char* filename) { unsigned long size = 0; unsigned char* pData = 0; String* pRet = NULL; - pData = FileUtils::getInstance()->getFileData(pszFileName, "rb", &size); + pData = FileUtils::getInstance()->getFileData(filename, "rb", &size); pRet = String::createWithData(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 2840dd33bb..f8c085bd9d 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -115,7 +115,7 @@ public: * @return A String pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static String* createWithContentsOfFile(const char* pszFileName); + static String* createWithContentsOfFile(const char* filename); virtual void acceptVisitor(DataVisitor &visitor); virtual String* clone() const; diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index d109164fe1..859af0a34a 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "3.0-alpha0-pre"; + return "3.0-pre-alpha0"; } NS_CC_END diff --git a/cocos2dx/draw_nodes/CCDrawNode.cpp b/cocos2dx/draw_nodes/CCDrawNode.cpp index f9c92dc68e..dcc12a8723 100644 --- a/cocos2dx/draw_nodes/CCDrawNode.cpp +++ b/cocos2dx/draw_nodes/CCDrawNode.cpp @@ -103,8 +103,7 @@ DrawNode::DrawNode() , _buffer(NULL) , _dirty(false) { - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } DrawNode::~DrawNode() @@ -117,7 +116,7 @@ DrawNode::~DrawNode() #if CC_TEXTURE_ATLAS_USE_VAO glDeleteVertexArrays(1, &_vao); - ccGLBindVAO(0); + GL::bindVAO(0); _vao = 0; #endif @@ -154,35 +153,34 @@ void DrawNode::ensureCapacity(int count) bool DrawNode::init() { - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionLengthTexureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR)); ensureCapacity(512); #if CC_TEXTURE_ATLAS_USE_VAO glGenVertexArrays(1, &_vao); - ccGLBindVAO(_vao); + GL::bindVAO(_vao); #endif glGenBuffers(1, &_vbo); glBindBuffer(GL_ARRAY_BUFFER, _vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)* _bufferCapacity, _buffer, GL_STREAM_DRAW); - glEnableVertexAttribArray(kVertexAttrib_Position); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); - glEnableVertexAttribArray(kVertexAttrib_Color); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); - glEnableVertexAttribArray(kVertexAttrib_TexCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); glBindBuffer(GL_ARRAY_BUFFER, 0); #if CC_TEXTURE_ATLAS_USE_VAO - ccGLBindVAO(0); + GL::bindVAO(0); #endif CHECK_GL_ERROR_DEBUG(); @@ -209,19 +207,19 @@ void DrawNode::render() _dirty = false; } #if CC_TEXTURE_ATLAS_USE_VAO - ccGLBindVAO(_vao); + GL::bindVAO(_vao); #else - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); glBindBuffer(GL_ARRAY_BUFFER, _vbo); // vertex - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices)); // color - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors)); // texcood - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords)); #endif glDrawArrays(GL_TRIANGLES, 0, _bufferCount); @@ -234,7 +232,7 @@ void DrawNode::render() void DrawNode::draw() { CC_NODE_DRAW_SETUP(); - ccGLBlendFunc(_blendFunc.src, _blendFunc.dst); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); render(); } diff --git a/cocos2dx/draw_nodes/CCDrawingPrimitives.cpp b/cocos2dx/draw_nodes/CCDrawingPrimitives.cpp index 494fe2d86d..ad75b4a603 100644 --- a/cocos2dx/draw_nodes/CCDrawingPrimitives.cpp +++ b/cocos2dx/draw_nodes/CCDrawingPrimitives.cpp @@ -52,12 +52,14 @@ NS_CC_BEGIN #define M_PI 3.14159265358979323846 #endif -static bool s_bInitialized = false; -static GLProgram* s_pShader = NULL; -static int s_nColorLocation = -1; -static Color4F s_tColor(1.0f,1.0f,1.0f,1.0f); -static int s_nPointSizeLocation = -1; -static GLfloat s_fPointSize = 1.0f; +namespace DrawPrimitives { + +static bool s_initialized = false; +static GLProgram* s_shader = NULL; +static int s_colorLocation = -1; +static Color4F s_color(1.0f,1.0f,1.0f,1.0f); +static int s_pointSizeLocation = -1; +static GLfloat s_pointSize = 1.0f; #ifdef EMSCRIPTEN static GLuint s_bufferObject = 0; @@ -88,36 +90,36 @@ static void setGLBufferData(void *buf, GLuint bufSize) static void lazy_init( void ) { - if( ! s_bInitialized ) { + if( ! s_initialized ) { // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // - s_pShader = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); - s_pShader->retain(); + s_shader = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR); + s_shader->retain(); - s_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color"); + s_colorLocation = glGetUniformLocation( s_shader->getProgram(), "u_color"); CHECK_GL_ERROR_DEBUG(); - s_nPointSizeLocation = glGetUniformLocation( s_pShader->getProgram(), "u_pointSize"); + s_pointSizeLocation = glGetUniformLocation( s_shader->getProgram(), "u_pointSize"); CHECK_GL_ERROR_DEBUG(); - s_bInitialized = true; + s_initialized = true; } } // When switching from backround to foreground on android, we want the params to be initialized again -void ccDrawInit() +void init() { lazy_init(); } -void ccDrawFree() +void free() { - CC_SAFE_RELEASE_NULL(s_pShader); - s_bInitialized = false; + CC_SAFE_RELEASE_NULL(s_shader); + s_initialized = false; } -void ccDrawPoint( const Point& point ) +void drawPoint( const Point& point ) { lazy_init(); @@ -125,18 +127,18 @@ void ccDrawPoint( const Point& point ) p.x = point.x; p.y = point.y; - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); + s_shader->use(); + s_shader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); - s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); + s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); #ifdef EMSCRIPTEN setGLBufferData(&p, 8); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, &p); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, &p); #endif // EMSCRIPTEN glDrawArrays(GL_POINTS, 0, 1); @@ -144,15 +146,15 @@ void ccDrawPoint( const Point& point ) CC_INCREMENT_GL_DRAWS(1); } -void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) +void drawPoints( const Point *points, unsigned int numberOfPoints ) { lazy_init(); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); - s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); + s_shader->setUniformLocationWith1f(s_pointSizeLocation, s_pointSize); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed Vertex2F* newPoints = new Vertex2F[numberOfPoints]; @@ -162,9 +164,9 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) { #ifdef EMSCRIPTEN setGLBufferData((void*) points, numberOfPoints * sizeof(Point)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, points); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, points); #endif // EMSCRIPTEN } else @@ -178,9 +180,9 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) // Suspect Emscripten won't be emitting 64-bit code for a while yet, // but want to make sure this continues to work even if they do. setGLBufferData(newPoints, numberOfPoints * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoints); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoints); #endif // EMSCRIPTEN } @@ -192,7 +194,7 @@ void ccDrawPoints( const Point *points, unsigned int numberOfPoints ) } -void ccDrawLine( const Point& origin, const Point& destination ) +void drawLine( const Point& origin, const Point& destination ) { lazy_init(); @@ -201,31 +203,31 @@ void ccDrawLine( const Point& origin, const Point& destination ) Vertex2F(destination.x, destination.y) }; - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 16); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINES, 0, 2); CC_INCREMENT_GL_DRAWS(1); } -void ccDrawRect( Point origin, Point destination ) +void drawRect( Point origin, Point destination ) { - ccDrawLine(Point(origin.x, origin.y), Point(destination.x, origin.y)); - ccDrawLine(Point(destination.x, origin.y), Point(destination.x, destination.y)); - ccDrawLine(Point(destination.x, destination.y), Point(origin.x, destination.y)); - ccDrawLine(Point(origin.x, destination.y), Point(origin.x, origin.y)); + drawLine(Point(origin.x, origin.y), Point(destination.x, origin.y)); + drawLine(Point(destination.x, origin.y), Point(destination.x, destination.y)); + drawLine(Point(destination.x, destination.y), Point(origin.x, destination.y)); + drawLine(Point(origin.x, destination.y), Point(origin.x, origin.y)); } -void ccDrawSolidRect( Point origin, Point destination, Color4F color ) +void drawSolidRect( Point origin, Point destination, Color4F color ) { Point vertices[] = { origin, @@ -234,27 +236,27 @@ void ccDrawSolidRect( Point origin, Point destination, Color4F color ) Point(origin.x, destination.y) }; - ccDrawSolidPoly(vertices, 4, color ); + drawSolidPoly(vertices, 4, color ); } -void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon ) +void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon ) { lazy_init(); - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); // iPhone and 32-bit machines optimization if( sizeof(Point) == sizeof(Vertex2F) ) { #ifdef EMSCRIPTEN setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); #endif // EMSCRIPTEN if( closePolygon ) @@ -273,9 +275,9 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg } #ifdef EMSCRIPTEN setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli); #endif // EMSCRIPTEN if( closePolygon ) @@ -289,15 +291,15 @@ void ccDrawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolyg CC_INCREMENT_GL_DRAWS(1); } -void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ) +void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ) { lazy_init(); - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed Vertex2F* newPoli = new Vertex2F[numberOfPoints]; @@ -307,9 +309,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co { #ifdef EMSCRIPTEN setGLBufferData((void*) poli, numberOfPoints * sizeof(Point)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, poli); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, poli); #endif // EMSCRIPTEN } else @@ -321,9 +323,9 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co } #ifdef EMSCRIPTEN setGLBufferData(newPoli, numberOfPoints * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, newPoli); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, newPoli); #endif // EMSCRIPTEN } @@ -333,7 +335,7 @@ void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F co CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) +void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY) { lazy_init(); @@ -358,31 +360,31 @@ void ccDrawCircle( const Point& center, float radius, float angle, unsigned int vertices[(segments+1)*2] = center.x; vertices[(segments+1)*2+1] = center.y; - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments+additionalSegment); - free( vertices ); + ::free( vertices ); CC_INCREMENT_GL_DRAWS(1); } -void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) +void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) { - ccDrawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f); + drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f); } -void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) +void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY) { lazy_init(); @@ -403,32 +405,32 @@ void ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned vertices[(segments+1)*2] = center.x; vertices[(segments+1)*2+1] = center.y; - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, sizeof(GLfloat)*2*(segments+2)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_FAN, 0, (GLsizei) segments+1); - free( vertices ); + ::free( vertices ); CC_INCREMENT_GL_DRAWS(1); } -void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments) +void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments) { - ccDrawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f); + drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f); } -void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments) +void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments) { lazy_init(); @@ -444,17 +446,17 @@ void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& de vertices[segments].x = destination.x; vertices[segments].y = destination.y; - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); CC_SAFE_DELETE_ARRAY(vertices); @@ -462,12 +464,12 @@ void ccDrawQuadBezier(const Point& origin, const Point& control, const Point& de CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCatmullRom( PointArray *points, unsigned int segments ) +void drawCatmullRom( PointArray *points, unsigned int segments ) { - ccDrawCardinalSpline( points, 0.5f, segments ); + drawCardinalSpline( points, 0.5f, segments ); } -void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ) +void drawCardinalSpline( PointArray *config, float tension, unsigned int segments ) { lazy_init(); @@ -501,17 +503,17 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm vertices[i].y = newPos.y; } - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*)&s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); @@ -519,7 +521,7 @@ void ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segm CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments) +void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments) { lazy_init(); @@ -535,17 +537,17 @@ void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& vertices[segments].x = destination.x; vertices[segments].y = destination.y; - s_pShader->use(); - s_pShader->setUniformsForBuiltins(); - s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_shader->use(); + s_shader->setUniformsForBuiltins(); + s_shader->setUniformLocationWith4fv(s_colorLocation, (GLfloat*) &s_color.r, 1); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); #ifdef EMSCRIPTEN setGLBufferData(vertices, (segments + 1) * sizeof(Vertex2F)); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); #endif // EMSCRIPTEN glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); CC_SAFE_DELETE_ARRAY(vertices); @@ -553,28 +555,30 @@ void ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& CC_INCREMENT_GL_DRAWS(1); } -void ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) +void setDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) { - s_tColor.r = r; - s_tColor.g = g; - s_tColor.b = b; - s_tColor.a = a; + s_color.r = r; + s_color.g = g; + s_color.b = b; + s_color.a = a; } -void ccPointSize( GLfloat pointSize ) +void setPointSize( GLfloat pointSize ) { - s_fPointSize = pointSize * CC_CONTENT_SCALE_FACTOR(); + s_pointSize = pointSize * CC_CONTENT_SCALE_FACTOR(); //TODO :glPointSize( pointSize ); } -void ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) +void setDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) { - s_tColor.r = r/255.0f; - s_tColor.g = g/255.0f; - s_tColor.b = b/255.0f; - s_tColor.a = a/255.0f; + s_color.r = r/255.0f; + s_color.g = g/255.0f; + s_color.b = b/255.0f; + s_color.a = a/255.0f; } +} // DrawPrimitives namespace + NS_CC_END diff --git a/cocos2dx/draw_nodes/CCDrawingPrimitives.h b/cocos2dx/draw_nodes/CCDrawingPrimitives.h index 82e87cbf41..ba4f2c1955 100644 --- a/cocos2dx/draw_nodes/CCDrawingPrimitives.h +++ b/cocos2dx/draw_nodes/CCDrawingPrimitives.h @@ -47,18 +47,18 @@ THE SOFTWARE. /** @file Drawing OpenGL ES primitives. - - ccDrawPoint, ccDrawPoints - - ccDrawLine - - ccDrawRect, ccDrawSolidRect - - ccDrawPoly, ccDrawSolidPoly - - ccDrawCircle - - ccDrawQuadBezier - - ccDrawCubicBezier - - ccDrawCatmullRom - - ccDrawCardinalSpline + - drawPoint, drawPoints + - drawLine + - drawRect, drawSolidRect + - drawPoly, drawSolidPoly + - drawCircle + - drawQuadBezier + - drawCubicBezier + - drawCatmullRom + - drawCardinalSpline You can change the color, point size, width by calling: - - ccDrawColor4B(), ccDrawColor4F() + - drawColor4B(), drawColor4F() - ccPointSize() - glLineWidth() @@ -75,86 +75,90 @@ NS_CC_BEGIN class PointArray; -/** Initializes the drawing primitives */ -void CC_DLL ccDrawInit(); +namespace DrawPrimitives +{ + /** Initializes the drawing primitives */ + void init(); -/** Frees allocated resources by the drawing primitives */ -void CC_DLL ccDrawFree(); + /** Frees allocated resources by the drawing primitives */ + void free(); -/** draws a point given x and y coordinate measured in points */ -void CC_DLL ccDrawPoint( const Point& point ); + /** draws a point given x and y coordinate measured in points */ + void drawPoint( const Point& point ); -/** draws an array of points. - @since v0.7.2 - */ -void CC_DLL ccDrawPoints( const Point *points, unsigned int numberOfPoints ); + /** draws an array of points. + @since v0.7.2 + */ + void drawPoints( const Point *points, unsigned int numberOfPoints ); -/** draws a line given the origin and destination point measured in points */ -void CC_DLL ccDrawLine( const Point& origin, const Point& destination ); + /** draws a line given the origin and destination point measured in points */ + void drawLine( const Point& origin, const Point& destination ); -/** draws a rectangle given the origin and destination point measured in points. */ -void CC_DLL ccDrawRect( Point origin, Point destination ); + /** draws a rectangle given the origin and destination point measured in points. */ + void drawRect( Point origin, Point destination ); -/** draws a solid rectangle given the origin and destination point measured in points. - @since 1.1 - */ -void CC_DLL ccDrawSolidRect( Point origin, Point destination, Color4F color ); + /** draws a solid rectangle given the origin and destination point measured in points. + @since 1.1 + */ + void drawSolidRect( Point origin, Point destination, Color4F color ); -/** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points. -The polygon can be closed or open -*/ -void CC_DLL ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ); + /** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points. + The polygon can be closed or open + */ + void drawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ); -/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. - */ -void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ); + /** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color. + */ + void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ); -/** draws a circle given the center, radius and number of segments. */ -void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); -void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); + /** draws a circle given the center, radius and number of segments. */ + void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); + void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); -/** draws a solid circle given the center, radius and number of segments. */ -void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); -void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments); + /** draws a solid circle given the center, radius and number of segments. */ + void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); + void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments); -/** draws a quad bezier path - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v0.8 - */ -void CC_DLL ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments); + /** draws a quad bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v0.8 + */ + void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments); -/** draws a cubic bezier path - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v0.8 - */ -void CC_DLL ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments); + /** draws a cubic bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v0.8 + */ + void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments); -/** draws a Catmull Rom path. - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v2.0 - */ -void CC_DLL ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); + /** draws a Catmull Rom path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ + void drawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); -/** draws a Cardinal Spline path. - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v2.0 - */ -void CC_DLL ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ); + /** draws a Cardinal Spline path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ + void drawCardinalSpline( PointArray *config, float tension, unsigned int segments ); -/** set the drawing color with 4 unsigned bytes - @since v2.0 - */ -void CC_DLL ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); + /** set the drawing color with 4 unsigned bytes + @since v2.0 + */ + void setDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); -/** set the drawing color with 4 floats - @since v2.0 - */ -void CC_DLL ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); + /** set the drawing color with 4 floats + @since v2.0 + */ + void setDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); -/** set the point size in points. Default 1. - @since v2.0 - */ -void CC_DLL ccPointSize( GLfloat pointSize ); + /** set the point size in points. Default 1. + @since v2.0 + */ + void setPointSize( GLfloat pointSize ); + +}; // end of global group /// @} diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 0a58cdff44..656a4ea6f8 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -38,7 +38,7 @@ Grabber::Grabber(void) glGenFramebuffers(1, &_FBO); } -void Grabber::grab(Texture2D *pTexture) +void Grabber::grab(Texture2D *texture) { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); @@ -46,7 +46,7 @@ void Grabber::grab(Texture2D *pTexture) glBindFramebuffer(GL_FRAMEBUFFER, _FBO); // associate texture with FBO - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pTexture->getName(), 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->getName(), 0); // check if it worked (probably worth doing :) ) GLuint status = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -58,9 +58,9 @@ void Grabber::grab(Texture2D *pTexture) glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); } -void Grabber::beforeRender(Texture2D *pTexture) +void Grabber::beforeRender(Texture2D *texture) { - CC_UNUSED_PARAM(pTexture); + CC_UNUSED_PARAM(texture); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO); glBindFramebuffer(GL_FRAMEBUFFER, _FBO); @@ -80,9 +80,9 @@ void Grabber::beforeRender(Texture2D *pTexture) // glColorMask(true, true, true, false); // #631 } -void Grabber::afterRender(cocos2d::Texture2D *pTexture) +void Grabber::afterRender(cocos2d::Texture2D *texture) { - CC_UNUSED_PARAM(pTexture); + CC_UNUSED_PARAM(texture); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); // glColorMask(true, true, true, true); // #631 diff --git a/cocos2dx/effects/CCGrabber.h b/cocos2dx/effects/CCGrabber.h index 9f70b0725c..c75bb33ab3 100644 --- a/cocos2dx/effects/CCGrabber.h +++ b/cocos2dx/effects/CCGrabber.h @@ -45,9 +45,9 @@ public: Grabber(void); ~Grabber(void); - void grab(Texture2D *pTexture); - void beforeRender(Texture2D *pTexture); - void afterRender(Texture2D *pTexture); + void grab(Texture2D *texture); + void beforeRender(Texture2D *texture); + void afterRender(Texture2D *texture); protected: GLuint _FBO; diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 0093459dfe..870548d283 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -76,7 +76,7 @@ GridBase* GridBase::create(const Size& gridSize, Texture2D *texture, bool flippe return pGridBase; } -bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFlipped) +bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped) { bool bRet = true; @@ -84,7 +84,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli _reuseGrid = 0; _gridSize = gridSize; - _texture = pTexture; + _texture = texture; CC_SAFE_RETAIN(_texture); _isTextureFlipped = bFlipped; @@ -102,7 +102,7 @@ bool GridBase::initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFli bRet = false; } - _shaderProgram = ShaderCache::getInstance()->programForKey(kShader_PositionTexture); + _shaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE); calculateVertexPoints(); return bRet; @@ -117,7 +117,7 @@ bool GridBase::initWithSize(const Size& gridSize) unsigned long POTHigh = ccNextPOT((unsigned int)s.height); // we only use rgba8888 - Texture2DPixelFormat format = kTexture2DPixelFormat_RGBA8888; + Texture2D::PixelFormat format = Texture2D::PixelFormat::RGBA8888; void *data = calloc((int)(POTWide * POTHigh * 4), 1); if (! data) @@ -127,20 +127,20 @@ bool GridBase::initWithSize(const Size& gridSize) return false; } - Texture2D *pTexture = new Texture2D(); - pTexture->initWithData(data, format, POTWide, POTHigh, s); + Texture2D *texture = new Texture2D(); + texture->initWithData(data, format, POTWide, POTHigh, s); free(data); - if (! pTexture) + if (! texture) { CCLOG("cocos2d: Grid: error creating texture"); return false; } - initWithSize(gridSize, pTexture, false); + initWithSize(gridSize, texture, false); - pTexture->release(); + texture->release(); return true; } @@ -161,7 +161,7 @@ void GridBase::setActive(bool bActive) if (! bActive) { Director *pDirector = Director::getInstance(); - ccDirectorProjection proj = pDirector->getProjection(); + Director::Projection proj = pDirector->getProjection(); pDirector->setProjection(proj); } } @@ -192,8 +192,7 @@ void GridBase::set2DProjection() kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); - - ccSetProjectionMatrixDirty(); + GL::setProjectionMatrixDirty(); } void GridBase::beforeDraw(void) @@ -203,7 +202,7 @@ void GridBase::beforeDraw(void) _directorProjection = director->getProjection(); // 2d projection - // [director setProjection:kDirectorProjection2D]; + // [director setProjection:Director::Projection::_2D]; set2DProjection(); _grabber->beforeRender(_texture); } @@ -228,7 +227,7 @@ void GridBase::afterDraw(cocos2d::Node *target) kmGLTranslatef(-offset.x, -offset.y, 0); } - ccGLBindTexture2D(_texture->getName()); + GL::bindTexture2D(_texture->getName()); // restore projection for default FBO .fixed bug #543 #544 //TODO: Director::getInstance()->setProjection(Director::getInstance()->getProjection()); @@ -253,13 +252,13 @@ void GridBase::calculateVertexPoints(void) // implementation of Grid3D -Grid3D* Grid3D::create(const Size& gridSize, Texture2D *pTexture, bool bFlipped) +Grid3D* Grid3D::create(const Size& gridSize, Texture2D *texture, bool bFlipped) { Grid3D *pRet= new Grid3D(); if (pRet) { - if (pRet->initWithSize(gridSize, pTexture, bFlipped)) + if (pRet->initWithSize(gridSize, texture, bFlipped)) { pRet->autorelease(); } @@ -315,7 +314,7 @@ void Grid3D::blit(void) { int n = _gridSize.width * _gridSize.height; - ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins();; @@ -328,20 +327,20 @@ void Grid3D::blit(void) // position setGLBufferData(_vertices, numOfPoints * sizeof(Vertex3F), 0); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords setGLBufferData(_texCoordinates, numOfPoints * sizeof(Vertex2F), 1); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); #else // position - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN @@ -486,13 +485,13 @@ TiledGrid3D::~TiledGrid3D(void) CC_SAFE_FREE(_indices); } -TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *pTexture, bool bFlipped) +TiledGrid3D* TiledGrid3D::create(const Size& gridSize, Texture2D *texture, bool bFlipped) { TiledGrid3D *pRet= new TiledGrid3D(); if (pRet) { - if (pRet->initWithSize(gridSize, pTexture, bFlipped)) + if (pRet->initWithSize(gridSize, texture, bFlipped)) { pRet->autorelease(); } @@ -537,26 +536,26 @@ void TiledGrid3D::blit(void) // // Attributes // - ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); #ifdef EMSCRIPTEN int numQuads = _gridSize.width * _gridSize.height; // position setGLBufferData(_vertices, (numQuads*4*sizeof(Vertex3F)), 0); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0); // texCoords setGLBufferData(_texCoordinates, (numQuads*4*sizeof(Vertex2F)), 1); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLIndexData(_indices, n * 12, 0); glDrawElements(GL_TRIANGLES, (GLsizei) n*6, GL_UNSIGNED_SHORT, 0); #else // position - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, _vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _vertices); // texCoords - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoordinates); glDrawElements(GL_TRIANGLES, (GLsizei)n*6, GL_UNSIGNED_SHORT, _indices); #endif // EMSCRIPTEN diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index ed4b9387d1..732c324daa 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -59,7 +59,7 @@ public: virtual ~GridBase(void); - bool initWithSize(const Size& gridSize, Texture2D *pTexture, bool bFlipped); + bool initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped); bool initWithSize(const Size& gridSize); /** whether or not the grid is active */ @@ -99,7 +99,7 @@ protected: Grabber *_grabber; bool _isTextureFlipped; GLProgram* _shaderProgram; - ccDirectorProjection _directorProjection; + Director::Projection _directorProjection; }; /** @@ -112,7 +112,7 @@ class CC_DLL Grid3D : public GridBase { public: /** create one Grid */ - static Grid3D* create(const Size& gridSize, Texture2D *pTexture, bool bFlipped); + static Grid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped); /** create one Grid */ static Grid3D* create(const Size& gridSize); @@ -154,7 +154,7 @@ class CC_DLL TiledGrid3D : public GridBase { public: /** create one Grid */ - static TiledGrid3D* create(const Size& gridSize, Texture2D *pTexture, bool bFlipped); + static TiledGrid3D* create(const Size& gridSize, Texture2D *texture, bool bFlipped); /** create one Grid */ static TiledGrid3D* create(const Size& gridSize); diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index 708b97c862..2a1317de76 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -390,26 +390,26 @@ CC_DEPRECATED_ATTRIBUTE inline Rect CCRectMake(float x, float y, float width, fl } -CC_DEPRECATED_ATTRIBUTE const Point CCPointZero = Point::ZERO; +CC_DEPRECATED_ATTRIBUTE extern const Point CCPointZero; /* The "zero" size -- equivalent to Size(0, 0). */ -CC_DEPRECATED_ATTRIBUTE const Size CCSizeZero = Size::ZERO; +CC_DEPRECATED_ATTRIBUTE extern const Size CCSizeZero; /* The "zero" rectangle -- equivalent to Rect(0, 0, 0, 0). */ -CC_DEPRECATED_ATTRIBUTE const Rect CCRectZero = Rect::ZERO; +CC_DEPRECATED_ATTRIBUTE extern const Rect CCRectZero; -CC_DEPRECATED_ATTRIBUTE const Color3B ccWHITE = Color3B::WHITE; -CC_DEPRECATED_ATTRIBUTE const Color3B ccYELLOW = Color3B::YELLOW; -CC_DEPRECATED_ATTRIBUTE const Color3B ccGREEN = Color3B::GREEN; -CC_DEPRECATED_ATTRIBUTE const Color3B ccBLUE = Color3B::BLUE; -CC_DEPRECATED_ATTRIBUTE const Color3B ccRED = Color3B::RED; -CC_DEPRECATED_ATTRIBUTE const Color3B ccMAGENTA = Color3B::MAGENTA; -CC_DEPRECATED_ATTRIBUTE const Color3B ccBLACK = Color3B::BLACK; -CC_DEPRECATED_ATTRIBUTE const Color3B ccORANGE = Color3B::ORANGE; -CC_DEPRECATED_ATTRIBUTE const Color3B ccGRAY = Color3B::GRAY; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccWHITE; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccYELLOW; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGREEN; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLUE; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccRED; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccMAGENTA; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccBLACK; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccORANGE; +CC_DEPRECATED_ATTRIBUTE extern const Color3B ccGRAY; -CC_DEPRECATED_ATTRIBUTE const BlendFunc kBlendFuncDisable = BlendFunc::BLEND_FUNC_DISABLE; +CC_DEPRECATED_ATTRIBUTE extern const BlendFunc kCCBlendFuncDisable; CC_DEPRECATED_ATTRIBUTE static inline Color3B ccc3(GLubyte r, GLubyte g, GLubyte b) { @@ -471,9 +471,20 @@ CC_DEPRECATED_ATTRIBUTE static inline Tex2F tex2(const float u, const float v) return t; } -#define CCAffineTransformMake AffineTransformMake -#define CCPointApplyAffineTransform PointApplyAffineTransform -#define CCSizeApplyAffineTransform SizeApplyAffineTransform +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty) +{ + return AffineTransformMake(a, b, c, d, tx, ty); +} + +CC_DEPRECATED_ATTRIBUTE static inline Point CCPointApplyAffineTransform(const Point& point, const AffineTransform& t) +{ + return PointApplyAffineTransform(point, t); +} + +CC_DEPRECATED_ATTRIBUTE static inline Size CCSizeApplyAffineTransform(const Size& size, const AffineTransform& t) +{ + return SizeApplyAffineTransform(size, t); +} CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformMakeIdentity() { @@ -515,8 +526,10 @@ CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformInvert(co return AffineTransformInvert(t); } -#define CCAffineTransformIdentity AffineTransformIdentity - +CC_DEPRECATED_ATTRIBUTE static inline AffineTransform CCAffineTransformIdentity() +{ + return AffineTransformMakeIdentity(); +} // CC prefix compatibility CC_DEPRECATED_ATTRIBUTE typedef Object CCObject; @@ -622,6 +635,9 @@ CC_DEPRECATED_ATTRIBUTE typedef FlipX CCFlipX; CC_DEPRECATED_ATTRIBUTE typedef FlipY CCFlipY; CC_DEPRECATED_ATTRIBUTE typedef Place CCPlace; CC_DEPRECATED_ATTRIBUTE typedef CallFunc CCCallFunc; +CC_DEPRECATED_ATTRIBUTE typedef CallFuncN CCCallFuncN; +CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncND CCCallFuncND; +CC_DEPRECATED_ATTRIBUTE typedef __CCCallFuncO CCCallFuncO; CC_DEPRECATED_ATTRIBUTE typedef GridAction CCGridAction; CC_DEPRECATED_ATTRIBUTE typedef Grid3DAction CCGrid3DAction; CC_DEPRECATED_ATTRIBUTE typedef TiledGrid3DAction CCTiledGrid3DAction; @@ -760,6 +776,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Timer CCTimer; CC_DEPRECATED_ATTRIBUTE typedef Scheduler CCScheduler; CC_DEPRECATED_ATTRIBUTE typedef EGLView CCEGLView; +CC_DEPRECATED_ATTRIBUTE typedef Component CCComponent; CC_DEPRECATED_ATTRIBUTE typedef AffineTransform CCAffineTransform; CC_DEPRECATED_ATTRIBUTE typedef Point CCPoint; CC_DEPRECATED_ATTRIBUTE typedef Size CCSize; @@ -787,119 +804,175 @@ CC_DEPRECATED_ATTRIBUTE typedef FontShadow ccFontShadow; CC_DEPRECATED_ATTRIBUTE typedef FontStroke ccFontStroke; CC_DEPRECATED_ATTRIBUTE typedef FontDefinition ccFontDefinition; -CC_DEPRECATED_ATTRIBUTE typedef VerticalTextAlignment CCVerticalTextAlignment; -CC_DEPRECATED_ATTRIBUTE typedef TextAlignment CCTextAlignment; -CC_DEPRECATED_ATTRIBUTE typedef ProgressTimerType CCProgressTimerType; +CC_DEPRECATED_ATTRIBUTE typedef Label::VAlignment CCVerticalTextAlignment; +CC_DEPRECATED_ATTRIBUTE typedef Label::HAlignment CCTextAlignment; +CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type CCProgressTimerType; CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; -#define kCCVertexAttrib_Position kVertexAttrib_Position -#define kCCVertexAttrib_Color kVertexAttrib_Color -#define kCCVertexAttrib_TexCoords kVertexAttrib_TexCoords -#define kCCVertexAttrib_MAX kVertexAttrib_MAX +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Position; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_Color; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_TexCoords; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttrib_MAX; -#define kCCUniformPMatrix kUniformPMatrix -#define kCCUniformMVMatrix kUniformMVMatrix -#define kCCUniformMVPMatrix kUniformMVPMatrix -#define kCCUniformTime kUniformTime -#define kCCUniformSinTime kUniformSinTime -#define kCCUniformCosTime kUniformCosTime -#define kCCUniformRandom01 kUniformRandom01 -#define kCCUniformSampler kUniformSampler -#define kCCUniform_MAX kUniform_MAX +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformPMatrix; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVMatrix; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformMVPMatrix; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformTime; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSinTime; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformCosTime; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformRandom01; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniformSampler; +CC_DEPRECATED_ATTRIBUTE extern const int kCCUniform_MAX; - -#define kCCShader_PositionTextureColor kShader_PositionTextureColor -#define kCCShader_PositionTextureColorAlphaTest kShader_PositionTextureColorAlphaTest -#define kCCShader_PositionColor kShader_PositionColor -#define kCCShader_PositionTexture kShader_PositionTexture -#define kCCShader_PositionTexture_uColor kShader_PositionTexture_uColor -#define kCCShader_PositionTextureA8Color kShader_PositionTextureA8Color -#define kCCShader_Position_uColor kShader_Position_uColor -#define kCCShader_PositionLengthTexureColor kShader_PositionLengthTexureColor +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColor; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureColorAlphaTest; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionColor; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTexture_uColor; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionTextureA8Color; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_Position_uColor; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCShader_PositionLengthTexureColor; // uniform names -#define kCCUniformPMatrix_s kUniformPMatrix_s -#define kCCUniformMVMatrix_s kUniformMVMatrix_s -#define kCCUniformMVPMatrix_s kUniformMVPMatrix_s -#define kCCUniformTime_s kUniformTime_s -#define kCCUniformSinTime_s kUniformSinTime_s -#define kCCUniformCosTime_s kUniformCosTime_s -#define kCCUniformRandom01_s kUniformRandom01_s -#define kCCUniformSampler_s kUniformSampler_s -#define kCCUniformAlphaTestValue kUniformAlphaTestValue +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformPMatrix_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVMatrix_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformMVPMatrix_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformTime_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSinTime_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformCosTime_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformRandom01_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformSampler_s; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCUniformAlphaTestValue; // Attribute names -#define kCCAttributeNameColor kAttributeNameColor -#define kCCAttributeNamePosition kAttributeNamePosition -#define kCCAttributeNameTexCoord kAttributeNameTexCoord +CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameColor; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNamePosition; +CC_DEPRECATED_ATTRIBUTE extern const char* kCCAttributeNameTexCoord; -#define kCCVertexAttribFlag_None kVertexAttribFlag_None -#define kCCVertexAttribFlag_Position kVertexAttribFlag_Position -#define kCCVertexAttribFlag_Color kVertexAttribFlag_Color -#define kCCVertexAttribFlag_TexCoords kVertexAttribFlag_TexCoords -#define kCCVertexAttribFlag_PosColorTex kVertexAttribFlag_PosColorTex +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_None; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Position; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_Color; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_TexCoords; +CC_DEPRECATED_ATTRIBUTE extern const int kCCVertexAttribFlag_PosColorTex; -#define kCCProgressTimerTypeRadial kProgressTimerTypeRadial -#define kCCProgressTimerTypeBar kProgressTimerTypeBar +CC_DEPRECATED_ATTRIBUTE extern const ProgressTimer::Type kCCProgressTimerTypeRadial; +CC_DEPRECATED_ATTRIBUTE extern const ProgressTimer::Type kCCProgressTimerTypeBar; +CC_DEPRECATED_ATTRIBUTE typedef ProgressTimer::Type ProgressTimerType; -#define kCCDirectorProjection2D kDirectorProjection2D -#define kCCDirectorProjection3D kDirectorProjection3D -#define kCCDirectorProjectionCustom kDirectorProjectionCustom -#define kCCDirectorProjectionDefault kDirectorProjectionDefault +CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjection2D; +CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjection3D; +CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionCustom; +CC_DEPRECATED_ATTRIBUTE extern const Director::Projection kCCDirectorProjectionDefault; +CC_DEPRECATED_ATTRIBUTE typedef Director::Projection ccDirectorProjection; -#define kCCVerticalTextAlignmentTop kVerticalTextAlignmentTop -#define kCCVerticalTextAlignmentCenter kVerticalTextAlignmentCenter -#define kCCVerticalTextAlignmentBottom kVerticalTextAlignmentBottom +CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentTop; +CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentCenter; +CC_DEPRECATED_ATTRIBUTE extern const Label::VAlignment kCCVerticalTextAlignmentBottom; -#define kCCTextAlignmentLeft kTextAlignmentLeft -#define kCCTextAlignmentCenter kTextAlignmentCenter -#define kCCTextAlignmentRight kTextAlignmentRight +CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentLeft; +CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentCenter; +CC_DEPRECATED_ATTRIBUTE extern const Label::HAlignment kCCTextAlignmentRight; - -#define kCCTexture2DPixelFormat_RGBA8888 kTexture2DPixelFormat_RGBA8888 -#define kCCTexture2DPixelFormat_RGB888 kTexture2DPixelFormat_RGB888 -#define kCCTexture2DPixelFormat_RGB565 kTexture2DPixelFormat_RGB565 -#define kCCTexture2DPixelFormat_A8 kTexture2DPixelFormat_A8 -#define kCCTexture2DPixelFormat_I8 kTexture2DPixelFormat_I8 -#define kCCTexture2DPixelFormat_AI88 kTexture2DPixelFormat_AI88 -#define kCCTexture2DPixelFormat_RGBA4444 kTexture2DPixelFormat_RGBA4444 -#define kCCTexture2DPixelFormat_RGB5A1 kTexture2DPixelFormat_RGB5A1 -#define kCCTexture2DPixelFormat_PVRTC4 kTexture2DPixelFormat_PVRTC4 -#define kCCTexture2DPixelFormat_PVRTC2 kTexture2DPixelFormat_PVRTC2 -#define kCCTexture2DPixelFormat_Default kTexture2DPixelFormat_Default +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA8888; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB888; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB565; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_A8; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_I8; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_AI88; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGBA4444; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_RGB5A1; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC4; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_PVRTC2; +CC_DEPRECATED_ATTRIBUTE extern const Texture2D::PixelFormat kCCTexture2DPixelFormat_Default; +CC_DEPRECATED_ATTRIBUTE typedef Texture2D::PixelFormat CCTexture2DPixelFormat; #define kCCLabelAutomaticWidth kLabelAutomaticWidth -#define kCCParticleDurationInfinity kParticleDurationInfinity -#define kCCParticleStartSizeEqualToEndSize kParticleStartSizeEqualToEndSize -#define kCCParticleStartRadiusEqualToEndRadius kParticleStartRadiusEqualToEndRadius +CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDurationInfinity; +CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartSizeEqualToEndSize; +CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleStartRadiusEqualToEndRadius; -#define kCCParticleModeGravity kParticleModeGravity -#define kCCParticleModeRadius kParticleModeRadius -#define kCCPositionTypeFree kPositionTypeFree -#define kCCPositionTypeRelative kPositionTypeRelative -#define kCCPositionTypeGrouped kPositionTypeGrouped +CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::Mode kCCParticleModeGravity; +CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::Mode kCCParticleModeRadius; -#define kCCBlendFuncDisable kBlendFuncDisable +CC_DEPRECATED_ATTRIBUTE extern const int kCCParticleDefaultCapacity; -#define kCCMenuHandlerPriority kMenuHandlerPriority -#define kCCMenuStateWaiting kMenuStateWaiting -#define kCCMenuStateTrackingTouch kMenuStateTrackingTouch +CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeFree; +CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeRelative; +CC_DEPRECATED_ATTRIBUTE extern const ParticleSystem::PositionType kCCPositionTypeGrouped; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType; -#define kCCTouchesOneByOne kTouchesOneByOne -#define kCCTouchesAllAtOnce kTouchesAllAtOnce +CC_DEPRECATED_ATTRIBUTE extern const int kCCMenuHandlerPriority; +CC_DEPRECATED_ATTRIBUTE extern const Menu::State kCCMenuStateWaiting; +CC_DEPRECATED_ATTRIBUTE extern const Menu::State kCCMenuStateTrackingTouch; +CC_DEPRECATED_ATTRIBUTE typedef Menu::State tMenuState; -#define kCCImageFormatPNG kImageFormatPNG -#define kCCImageFormatJPEG kImageFormatJPEG +CC_DEPRECATED_ATTRIBUTE extern const Touch::DispatchMode kCCTouchesOneByOne; +CC_DEPRECATED_ATTRIBUTE extern const Touch::DispatchMode kCCTouchesAllAtOnce; +CC_DEPRECATED_ATTRIBUTE typedef Touch::DispatchMode ccTouchesMode; -#define kCCTransitionOrientationLeftOver kTransitionOrientationLeftOver -#define kCCTransitionOrientationRightOver kTransitionOrientationRightOver -#define kCCTransitionOrientationUpOver kTransitionOrientationUpOver -#define kCCTransitionOrientationDownOver kTransitionOrientationDownOver +CC_DEPRECATED_ATTRIBUTE extern const Image::Format kCCImageFormatPNG; +CC_DEPRECATED_ATTRIBUTE extern const Image::Format kCCImageFormatJPEG; +CC_DEPRECATED_ATTRIBUTE typedef Image::Format tImageFormat; -#define kCCPrioritySystem kPrioritySystem -#define kCCPriorityNonSystemMin kPriorityNonSystemMin +CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationLeftOver; +CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationRightOver; +CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationUpOver; +CC_DEPRECATED_ATTRIBUTE extern const TransitionScene::Orientation kCCTransitionOrientationDownOver; +CC_DEPRECATED_ATTRIBUTE typedef TransitionScene::Orientation tOrientation; + +CC_DEPRECATED_ATTRIBUTE extern const int kCCPrioritySystem; +CC_DEPRECATED_ATTRIBUTE extern const int kCCPriorityNonSystemMin; + +CC_DEPRECATED_ATTRIBUTE extern const int kCCActionTagInvalid; + + +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeTagInvalid; + +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnEnter; +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnExit; +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnEnterTransitionDidFinish; +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnExitTransitionDidStart; +CC_DEPRECATED_ATTRIBUTE extern const int kCCNodeOnCleanup; + + +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageEnglish; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageChinese; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageFrench; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageItalian; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageGerman; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageSpanish; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageRussian; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageKorean; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageJapanese; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageHungarian; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguagePortuguese; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageArabic; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguageNorwegian; +CC_DEPRECATED_ATTRIBUTE extern const LanguageType kLanguagePolish; + +CC_DEPRECATED_ATTRIBUTE typedef LanguageType ccLanguageType; + + +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetWindows; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetLinux; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetMacOS; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetAndroid; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetIphone; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetIpad; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetBlackBerry; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetNaCl; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetEmscripten; +CC_DEPRECATED_ATTRIBUTE extern const Application::Platform kTargetTizen; +CC_DEPRECATED_ATTRIBUTE typedef Application::Platform TargetPlatform; + +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionExactFit; +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionNoBorder; +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionShowAll; +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionFixedHeight; +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionFixedWidth; +CC_DEPRECATED_ATTRIBUTE extern const ResolutionPolicy kResolutionUnKnown; #define kCCTMXTileHorizontalFlag kTMXTileHorizontalFlag #define kCCTMXTileVerticalFlag kTMXTileVerticalFlag @@ -911,8 +984,42 @@ CC_DEPRECATED_ATTRIBUTE typedef void* CCZone; /** use log() instead */ CC_DEPRECATED_ATTRIBUTE void CC_DLL CCLog(const char * pszFormat, ...) CC_FORMAT_PRINTF(1, 2); -// end of data_structures group -/// @} +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawInit(); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawFree(); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoint( const Point& point ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoints( const Point *points, unsigned int numberOfPoints ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawLine( const Point& origin, const Point& destination ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawRect( Point origin, Point destination ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidRect( Point origin, Point destination, Color4F color ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawSolidCircle( const Point& center, float radius, float angle, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCatmullRom( PointArray *arrayOfControlPoints, unsigned int segments ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawCardinalSpline( PointArray *config, float tension, unsigned int segments ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); +CC_DEPRECATED_ATTRIBUTE void CC_DLL ccPointSize( GLfloat pointSize ); + + +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLInvalidateStateCache() { GL::invalidateStateCache(); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLUseProgram(GLuint program) { GL::useProgram(program); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteProgram(GLuint program){ GL::deleteProgram(program); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBlendFunc(GLenum sfactor, GLenum dfactor) { GL::blendFunc(sfactor, dfactor); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBlendResetToCache() { GL::blendResetToCache(); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccSetProjectionMatrixDirty() { GL::setProjectionMatrixDirty(); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnableVertexAttribs(unsigned int flags) { GL::enableVertexAttribs(flags); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2D(GLuint textureId) { GL::bindTexture2D(textureId); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) { GL::bindTexture2DN(textureUnit, textureId); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTexture(GLuint textureId) { GL::deleteTexture(textureId); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) { GL::deleteTextureN(textureUnit, textureId); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLBindVAO(GLuint vaoId) { GL::bindVAO(vaoId); } +CC_DEPRECATED_ATTRIBUTE inline void CC_DLL ccGLEnable( int flags ) { /* ignore */ }; +CC_DEPRECATED_ATTRIBUTE typedef int ccGLServerState; NS_CC_END diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index d9e7497e09..89d87582ab 100644 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -51,10 +51,10 @@ THE SOFTWARE. If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches. In order to use them, you have to use the following functions, instead of the the GL ones: - ccGLUseProgram() instead of glUseProgram() - - ccGLDeleteProgram() instead of glDeleteProgram() - - ccGLBlendFunc() instead of glBlendFunc() + - GL::deleteProgram() instead of glDeleteProgram() + - GL::blendFunc() instead of glBlendFunc() - If this functionality is disabled, then ccGLUseProgram(), ccGLDeleteProgram(), ccGLBlendFunc() will call the GL ones, without using the cache. + If this functionality is disabled, then ccGLUseProgram(), GL::deleteProgram(), GL::blendFunc() will call the GL ones, without using the cache. It is recommended to enable whenever possible to improve speed. If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on. diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index d1cb92c33b..dbea2d512a 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -97,7 +97,6 @@ default gl blend src function. Compatible with premultiplied alpha images. */ #define CC_NODE_DRAW_SETUP() \ do { \ - ccGLEnable(_GLServerState); \ CCASSERT(getShaderProgram(), "No shader program set for this node"); \ { \ getShaderProgram()->use(); \ diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 29b7a3b25d..bc8a163796 100644 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -42,9 +42,9 @@ struct Color3B Color3B(): r(0), g(0), b(0) {} Color3B(GLubyte _r, GLubyte _g, GLubyte _b) - :r(_r), - g(_g), - b(_b) + : r(_r) + , g(_g) + , b(_b) {} bool equals(const Color3B &other) @@ -77,13 +77,13 @@ struct Color4F; struct Color4B { Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a) - :r(_r), - g(_g), - b(_b), - a(_a) + : r(_r) + , g(_g) + , b(_b) + , a(_a) {} - Color4B(): r(0.f), g(0.f), b(0.f), a(0.f) {} + Color4B(): r(0), g(0), b(0), a(0) {} // This function should use Color4F, so implement it in .cpp file. explicit Color4B(const Color4F &color4F); @@ -101,24 +101,24 @@ struct Color4B struct Color4F { Color4F(float _r, float _g, float _b, float _a) - :r(_r), - g(_g), - b(_b), - a(_a) + : r(_r) + , g(_g) + , b(_b) + , a(_a) {} explicit Color4F(const Color3B &color3B) - :r(color3B.r) - ,g(color3B.g) - ,b(color3B.b) - ,a(1.f) + : r(color3B.r) + , g(color3B.g) + , b(color3B.b) + , a(1.f) {} explicit Color4F(const Color4B &color4B) - :r(color4B.r / 255.0f), - g(color4B.g / 255.0f), - b(color4B.b / 255.0f), - a(color4B.a / 255.0f) + : r(color4B.r / 255.0f) + , g(color4B.g / 255.0f) + , b(color4B.b / 255.0f) + , a(color4B.a / 255.0f) {} Color4F(): r(0.f), g(0.f), b(0.f), a(0.f) {} @@ -157,9 +157,9 @@ struct Vertex2F struct Vertex3F { Vertex3F(float _x, float _y, float _z) - :x(_x), - y(_y), - z(_z) + : x(_x) + , y(_y) + , z(_z) {} Vertex3F(): x(0.f), y(0.f), z(0.f) {} @@ -300,27 +300,38 @@ struct BlendFunc GLenum src; //! destination blend function GLenum dst; - - const static BlendFunc BLEND_FUNC_DISABLE; + + //! Blending disabled. Uses {GL_ONE, GL_ZERO} + const static BlendFunc DISABLE; + //! Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} + const static BlendFunc ALPHA_PREMULTIPLIED; + //! Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} + const static BlendFunc ALPHA_NON_PREMULTIPLIED; + //! Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE} + const static BlendFunc ADDITIVE; }; -// XXX: If any of these enums are edited and/or reordered, update Texture2D.m -//! Vertical text alignment type -typedef enum +class Label : public Object { - kVerticalTextAlignmentTop, - kVerticalTextAlignmentCenter, - kVerticalTextAlignmentBottom, -} VerticalTextAlignment; - -// XXX: If any of these enums are edited and/or reordered, update Texture2D.m -//! Horizontal text alignment type -typedef enum -{ - kTextAlignmentLeft, - kTextAlignmentCenter, - kTextAlignmentRight, -} TextAlignment; +public: + // XXX: If any of these enums are edited and/or reordered, update Texture2D.m + //! Vertical text alignment type + enum class VAlignment + { + TOP, + CENTER, + BOTTOM, + }; + + // XXX: If any of these enums are edited and/or reordered, update Texture2D.m + //! Horizontal text alignment type + enum class HAlignment + { + LEFT, + CENTER, + RIGHT, + }; +}; // types for animation in particle systems @@ -345,8 +356,6 @@ struct AnimationFrameData Size size; }; - - /** types used for defining fonts properties (i.e. font name, size, stroke or shadow) */ @@ -357,10 +366,12 @@ struct FontShadow public: // shadow is not enabled by default - FontShadow(): _shadowEnabled(false), - _shadowBlur(0), - _shadowOpacity(0){} - + FontShadow() + : _shadowEnabled(false) + , _shadowBlur(0) + , _shadowOpacity(0) + {} + // true if shadow enabled bool _shadowEnabled; // shadow x and y offset @@ -381,7 +392,7 @@ public: : _strokeEnabled(false) , _strokeColor(Color3B::BLACK) , _strokeSize(0) - {} + {} // true if stroke enabled bool _strokeEnabled; @@ -397,20 +408,22 @@ struct FontDefinition { public: - FontDefinition():_fontSize(0), - _alignment(kTextAlignmentCenter), - _vertAlignment(kVerticalTextAlignmentTop), - _fontFillColor(Color3B::WHITE) - { _dimensions = Size(0,0); } + FontDefinition() + : _fontSize(0) + , _alignment(Label::HAlignment::CENTER) + , _vertAlignment(Label::VAlignment::TOP) + , _fontFillColor(Color3B::WHITE) + , _dimensions(Size::ZERO) + {} // font name std::string _fontName; // font size int _fontSize; // horizontal alignment - TextAlignment _alignment; + Label::HAlignment _alignment; // vertical alignment - VerticalTextAlignment _vertAlignment; + Label::VAlignment _vertAlignment; // renering box Size _dimensions; // font color diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 94c9651861..6e3b7f68d1 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -430,23 +430,23 @@ LabelBMFont * LabelBMFont::create() return NULL; } -LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, TextAlignment alignment) +LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width, Label::HAlignment alignment) { return LabelBMFont::create(str, fntFile, width, alignment, Point::ZERO); } LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile, float width) { - return LabelBMFont::create(str, fntFile, width, kTextAlignmentLeft, Point::ZERO); + return LabelBMFont::create(str, fntFile, width, Label::HAlignment::LEFT, Point::ZERO); } LabelBMFont * LabelBMFont::create(const char *str, const char *fntFile) { - return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); + return LabelBMFont::create(str, fntFile, kLabelAutomaticWidth, Label::HAlignment::LEFT, Point::ZERO); } //LabelBMFont - Creation & Init -LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) +LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::HAlignment alignment/* = Label::HAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/) { LabelBMFont *pRet = new LabelBMFont(); if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset)) @@ -460,10 +460,10 @@ LabelBMFont *LabelBMFont::create(const char *str, const char *fntFile, float wid bool LabelBMFont::init() { - return initWithString(NULL, NULL, kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); + return initWithString(NULL, NULL, kLabelAutomaticWidth, Label::HAlignment::LEFT, Point::ZERO); } -bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, TextAlignment alignment/* = kTextAlignmentLeft*/, Point imageOffset/* = Point::ZERO*/) +bool LabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kLabelAutomaticWidth*/, Label::HAlignment alignment/* = Label::HAlignment::LEFT*/, Point imageOffset/* = Point::ZERO*/) { CCASSERT(!_configuration, "re-init is no longer supported"); CCASSERT( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for LabelBMFont"); @@ -530,7 +530,7 @@ bool LabelBMFont::initWithString(const char *theString, const char *fntFile, flo LabelBMFont::LabelBMFont() : _string(NULL) , _initialString(NULL) -, _alignment(kTextAlignmentCenter) +, _alignment(Label::HAlignment::CENTER) , _width(-1.0f) , _configuration(NULL) , _lineBreakWithoutSpaces(false) @@ -1094,7 +1094,7 @@ void LabelBMFont::updateLabel() } // Step 2: Make alignment - if (_alignment != kTextAlignmentLeft) + if (_alignment != Label::HAlignment::LEFT) { int i = 0; @@ -1125,10 +1125,10 @@ void LabelBMFont::updateLabel() float shift = 0; switch (_alignment) { - case kTextAlignmentCenter: + case Label::HAlignment::CENTER: shift = getContentSize().width/2.0f - lineWidth/2.0f; break; - case kTextAlignmentRight: + case Label::HAlignment::RIGHT: shift = getContentSize().width - lineWidth; break; default: @@ -1160,7 +1160,7 @@ void LabelBMFont::updateLabel() } // LabelBMFont - Alignment -void LabelBMFont::setAlignment(TextAlignment alignment) +void LabelBMFont::setAlignment(Label::HAlignment alignment) { this->_alignment = alignment; updateLabel(); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index b3d62d29a6..cd56971382 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -192,9 +192,9 @@ public: static void purgeCachedData(); /** creates a bitmap font atlas with an initial string and the FNT file */ - static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment, Point imageOffset); + static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::HAlignment alignment, Point imageOffset); - static LabelBMFont * create(const char *str, const char *fntFile, float width, TextAlignment alignment); + static LabelBMFont * create(const char *str, const char *fntFile, float width, Label::HAlignment alignment); static LabelBMFont * create(const char *str, const char *fntFile, float width); @@ -206,7 +206,7 @@ public: bool init(); /** init a bitmap font atlas with an initial string and the FNT file */ - bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, TextAlignment alignment = kTextAlignmentLeft, Point imageOffset = Point::ZERO); + bool initWithString(const char *str, const char *fntFile, float width = kLabelAutomaticWidth, Label::HAlignment alignment = Label::HAlignment::LEFT, Point imageOffset = Point::ZERO); /** updates the font chars based on the string to render */ void createFontChars(); @@ -218,7 +218,7 @@ public: virtual void setCString(const char *label); virtual void setAnchorPoint(const Point& var); virtual void updateLabel(); - virtual void setAlignment(TextAlignment alignment); + virtual void setAlignment(Label::HAlignment alignment); virtual void setWidth(float width); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setScale(float scale); @@ -265,7 +265,7 @@ protected: std::string _initialStringUTF8; // alignment of all lines - TextAlignment _alignment; + Label::HAlignment _alignment; // max width until a line break is added float _width; diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 97f309ea9c..ddafb2146e 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -31,17 +31,17 @@ THE SOFTWARE. NS_CC_BEGIN #if CC_USE_LA88_LABELS -#define SHADER_PROGRAM kShader_PositionTextureColor +#define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR #else -#define SHADER_PROGRAM kShader_PositionTextureA8Color +#define SHADER_PROGRAM GLProgram::SHADER_NAME_POSITION_TEXTUREA8Color #endif // //CCLabelTTF // LabelTTF::LabelTTF() -: _alignment(kTextAlignmentCenter) -, _vAlignment(kVerticalTextAlignmentTop) +: _alignment(Label::HAlignment::CENTER) +, _vAlignment(Label::VAlignment::TOP) , _fontName(NULL) , _fontSize(0.0) , _string("") @@ -73,18 +73,18 @@ LabelTTF * LabelTTF::create() LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize) { return LabelTTF::create(string, fontName, fontSize, - Size::ZERO, kTextAlignmentCenter, kVerticalTextAlignmentTop); + Size::ZERO, Label::HAlignment::CENTER, Label::VAlignment::TOP); } LabelTTF * LabelTTF::create(const char *string, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment hAlignment) + const Size& dimensions, Label::HAlignment hAlignment) { - return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, kVerticalTextAlignmentTop); + return LabelTTF::create(string, fontName, fontSize, dimensions, hAlignment, Label::VAlignment::TOP); } LabelTTF* LabelTTF::create(const char *string, const char *fontName, float fontSize, - const Size &dimensions, TextAlignment hAlignment, - VerticalTextAlignment vAlignment) + const Size &dimensions, Label::HAlignment hAlignment, + Label::VAlignment vAlignment) { LabelTTF *pRet = new LabelTTF(); if(pRet && pRet->initWithString(string, fontName, fontSize, dimensions, hAlignment, vAlignment)) @@ -114,20 +114,20 @@ bool LabelTTF::init() } bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment alignment) + const Size& dimensions, Label::HAlignment alignment) { - return this->initWithString(label, fontName, fontSize, dimensions, alignment, kVerticalTextAlignmentTop); + return this->initWithString(label, fontName, fontSize, dimensions, alignment, Label::VAlignment::TOP); } bool LabelTTF::initWithString(const char *label, const char *fontName, float fontSize) { return this->initWithString(label, fontName, fontSize, - Size::ZERO, kTextAlignmentLeft, kVerticalTextAlignmentTop); + Size::ZERO, Label::HAlignment::LEFT, Label::VAlignment::TOP); } bool LabelTTF::initWithString(const char *string, const char *fontName, float fontSize, - const cocos2d::Size &dimensions, TextAlignment hAlignment, - VerticalTextAlignment vAlignment) + const cocos2d::Size &dimensions, Label::HAlignment hAlignment, + Label::VAlignment vAlignment) { if (Sprite::init()) { @@ -193,12 +193,12 @@ const char* LabelTTF::description() const return String::createWithFormat("", _fontName->c_str(), _fontSize)->getCString(); } -TextAlignment LabelTTF::getHorizontalAlignment() const +Label::HAlignment LabelTTF::getHorizontalAlignment() const { return _alignment; } -void LabelTTF::setHorizontalAlignment(TextAlignment alignment) +void LabelTTF::setHorizontalAlignment(Label::HAlignment alignment) { if (alignment != _alignment) { @@ -212,12 +212,12 @@ void LabelTTF::setHorizontalAlignment(TextAlignment alignment) } } -VerticalTextAlignment LabelTTF::getVerticalAlignment() const +Label::VAlignment LabelTTF::getVerticalAlignment() const { return _vAlignment; } -void LabelTTF::setVerticalAlignment(VerticalTextAlignment verticalAlignment) +void LabelTTF::setVerticalAlignment(Label::VAlignment verticalAlignment) { if (verticalAlignment != _vAlignment) { diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index a4c223effb..468aa1a20d 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -48,9 +48,9 @@ NS_CC_BEGIN * Custom ttf file can be put in assets/ or external storage that the Application can access. * @code * LabelTTF *label1 = LabelTTF::create("alignment left", "A Damn Mess", fontSize, blockSize, - * kTextAlignmentLeft, kVerticalTextAlignmentCenter); + * Label::HAlignment::LEFT, Label::VAlignment::CENTER); * LabelTTF *label2 = LabelTTF::create("alignment right", "/mnt/sdcard/Scissor Cuts.ttf", fontSize, blockSize, - * kTextAlignmentLeft, kVerticalTextAlignmentCenter); + * Label::HAlignment::LEFT, Label::VAlignment::CENTER); * @endcode * */ @@ -70,14 +70,14 @@ public: @since v2.0.1 */ static LabelTTF * create(const char *string, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment hAlignment); + const Size& dimensions, Label::HAlignment hAlignment); /** creates a Label from a fontname, alignment, dimension in points and font size in points @since v2.0.1 */ static LabelTTF * create(const char *string, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment hAlignment, - VerticalTextAlignment vAlignment); + const Size& dimensions, Label::HAlignment hAlignment, + Label::VAlignment vAlignment); /** Create a lable with string and a font definition*/ @@ -88,12 +88,12 @@ public: /** initializes the LabelTTF with a font name, alignment, dimension and font size */ bool initWithString(const char *string, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment hAlignment); + const Size& dimensions, Label::HAlignment hAlignment); /** initializes the LabelTTF with a font name, alignment, dimension and font size */ bool initWithString(const char *string, const char *fontName, float fontSize, - const Size& dimensions, TextAlignment hAlignment, - VerticalTextAlignment vAlignment); + const Size& dimensions, Label::HAlignment hAlignment, + Label::VAlignment vAlignment); /** initializes the LabelTTF with a font name, alignment, dimension and font size */ bool initWithStringAndTextDefinition(const char *string, FontDefinition &textDefinition); @@ -136,11 +136,11 @@ public: virtual void setString(const char *label); virtual const char* getString(void) const; - TextAlignment getHorizontalAlignment() const; - void setHorizontalAlignment(TextAlignment alignment); + Label::HAlignment getHorizontalAlignment() const; + void setHorizontalAlignment(Label::HAlignment alignment); - VerticalTextAlignment getVerticalAlignment() const; - void setVerticalAlignment(VerticalTextAlignment verticalAlignment); + Label::VAlignment getVerticalAlignment() const; + void setVerticalAlignment(Label::VAlignment verticalAlignment); const Size& getDimensions() const; void setDimensions(const Size &dim); @@ -162,9 +162,9 @@ protected: /** Dimensions of the label in Points */ Size _dimensions; /** The alignment of the label */ - TextAlignment _alignment; + Label::HAlignment _alignment; /** The vertical alignment of the label */ - VerticalTextAlignment _vAlignment; + Label::VAlignment _vAlignment; /** Font name used in the label */ std::string * _fontName; /** Font size of the label */ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 6735b13e52..d3d218819c 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -48,7 +48,8 @@ Layer::Layer() , _keyboardEnabled(false) , _keypadEnabled(false) , _touchPriority(0) -, _touchMode(kTouchesAllAtOnce) +, _touchMode(Touch::DispatchMode::ALL_AT_ONCE) +, _swallowsTouches(true) { _ignoreAnchorPointForPosition = true; setAnchorPoint(Point(0.5f, 0.5f)); @@ -96,10 +97,10 @@ void Layer::registerWithTouchDispatcher() { TouchDispatcher* pDispatcher = Director::getInstance()->getTouchDispatcher(); - if( _touchMode == kTouchesAllAtOnce ) { + if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) { pDispatcher->addStandardDelegate(this, 0); } else { - pDispatcher->addTargetedDelegate(this, _touchPriority, true); + pDispatcher->addTargetedDelegate(this, _touchPriority, _swallowsTouches); } } @@ -155,7 +156,7 @@ void Layer::setTouchEnabled(bool enabled) } } -void Layer::setTouchMode(ccTouchesMode mode) +void Layer::setTouchMode(Touch::DispatchMode mode) { if(_touchMode != mode) { @@ -183,16 +184,38 @@ void Layer::setTouchPriority(int priority) } } +void Layer::setSwallowsTouches(bool swallowsTouches) +{ + if (_swallowsTouches != swallowsTouches) + { + _swallowsTouches = swallowsTouches; + + if( _touchEnabled) + { + setTouchEnabled(false); + setTouchEnabled(true); + } + } +} + + int Layer::getTouchPriority() const { return _touchPriority; } -int Layer::getTouchMode() const +Touch::DispatchMode Layer::getTouchMode() const { return _touchMode; } +bool Layer::isSwallowsTouches() const +{ + return _swallowsTouches; +} + + + /// isAccelerometerEnabled getter bool Layer::isAccelerometerEnabled() const { @@ -237,7 +260,7 @@ void Layer::didAccelerate(Acceleration* pAccelerationValue) { CC_UNUSED_PARAM(pAccelerationValue); - if(kScriptTypeNone == _scriptType) + if(kScriptTypeNone != _scriptType) { BasicScriptData data(this,(void*)pAccelerationValue); ScriptEvent event(kAccelerometerEvent,&data); @@ -622,8 +645,7 @@ void LayerRGBA::setCascadeColorEnabled(bool cascadeColorEnabled) LayerColor::LayerColor() { // default blend function - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } LayerColor::~LayerColor() @@ -691,8 +713,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) { // default blend function - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; _displayedColor.r = _realColor.r = color.r; _displayedColor.g = _realColor.g = color.g; @@ -708,7 +729,7 @@ bool LayerColor::initWithColor(const Color4B& color, GLfloat w, GLfloat h) updateColor(); setContentSize(Size(w, h)); - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_COLOR)); return true; } return false; @@ -762,23 +783,23 @@ void LayerColor::draw() { CC_NODE_DRAW_SETUP(); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_Color ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR ); // // Attributes // #ifdef EMSCRIPTEN setGLBufferData(_squareVertices, 4 * sizeof(Vertex2F), 0); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, _squareColors); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _squareVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors); #endif // EMSCRIPTEN - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index aa544079bd..9a9e63bc76 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -39,11 +39,6 @@ THE SOFTWARE. NS_CC_BEGIN -typedef enum { - kTouchesAllAtOnce, - kTouchesOneByOne, -} ccTouchesMode; - /** * @addtogroup layer * @{ @@ -62,7 +57,7 @@ All features from Node are valid, plus the following new features: */ class CC_DLL Layer : public Node, public TouchDelegate, public KeypadDelegate { -public: +public: /** creates a fullscreen black layer */ static Layer *create(void); Layer(); @@ -70,18 +65,18 @@ public: virtual bool init(); // default implements are used to call script callback if exist - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); - virtual void ccTouchMoved(Touch *pTouch, Event *pEvent); - virtual void ccTouchEnded(Touch *pTouch, Event *pEvent); - virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); + virtual void ccTouchMoved(Touch *touch, Event *event); + virtual void ccTouchEnded(Touch *touch, Event *event); + virtual void ccTouchCancelled(Touch *touch, Event *event); // default implements are used to call script callback if exist - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); - virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); + virtual void ccTouchesEnded(Set *touches, Event *event); + virtual void ccTouchesCancelled(Set *touches, Event *event); - virtual void didAccelerate(Acceleration* pAccelerationValue); + virtual void didAccelerate(Acceleration* accelerationValue); /** If isTouchEnabled, this method is called onEnter. Override it to change the way Layer receives touch events. @@ -103,13 +98,17 @@ public: virtual bool isTouchEnabled() const; virtual void setTouchEnabled(bool value); - virtual void setTouchMode(ccTouchesMode mode); - virtual int getTouchMode() const; + virtual void setTouchMode(Touch::DispatchMode mode); + virtual Touch::DispatchMode getTouchMode() const; /** priority of the touch events. Default is 0 */ virtual void setTouchPriority(int priority); virtual int getTouchPriority() const; + /** swallowsTouches of the touch events. Default is true */ + virtual void setSwallowsTouches(bool swallowsTouches); + virtual bool isSwallowsTouches() const; + /** whether or not it will receive Accelerometer events You can enable / disable accelerometer events with this property. @since v0.8.1 @@ -148,7 +147,8 @@ protected: private: int _touchPriority; - ccTouchesMode _touchMode; + Touch::DispatchMode _touchMode; + bool _swallowsTouches; int executeScriptTouchHandler(int eventType, Touch* touch); int executeScriptTouchesHandler(int eventType, Set* touches); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 54b25e1144..8143dcd28c 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -206,7 +206,7 @@ TransitionSceneOriented::~TransitionSceneOriented() { } -TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, tOrientation orientation) +TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, Orientation orientation) { TransitionSceneOriented * pScene = new TransitionSceneOriented(); pScene->initWithDuration(t,scene,orientation); @@ -214,7 +214,7 @@ TransitionSceneOriented * TransitionSceneOriented::create(float t, Scene *scene, return pScene; } -bool TransitionSceneOriented::initWithDuration(float t, Scene *scene, tOrientation orientation) +bool TransitionSceneOriented::initWithDuration(float t, Scene *scene, Orientation orientation) { if ( TransitionScene::initWithDuration(t, scene) ) { @@ -740,7 +740,7 @@ void TransitionFlipX::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation == kTransitionOrientationRightOver ) + if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; @@ -776,7 +776,7 @@ void TransitionFlipX::onEnter() _outScene->runAction(outA); } -TransitionFlipX* TransitionFlipX::create(float t, Scene* s, tOrientation o) +TransitionFlipX* TransitionFlipX::create(float t, Scene* s, Orientation o) { TransitionFlipX* pScene = new TransitionFlipX(); pScene->initWithDuration(t, s, o); @@ -787,7 +787,7 @@ TransitionFlipX* TransitionFlipX::create(float t, Scene* s, tOrientation o) TransitionFlipX* TransitionFlipX::create(float t, Scene* s) { - return TransitionFlipX::create(t, s, kTransitionOrientationRightOver); + return TransitionFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // @@ -810,7 +810,7 @@ void TransitionFlipY::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation == kTransitionOrientationUpOver ) + if( _orientation == TransitionScene::Orientation::UP_OVER ) { inDeltaZ = 90; inAngleZ = 270; @@ -846,7 +846,7 @@ void TransitionFlipY::onEnter() } -TransitionFlipY* TransitionFlipY::create(float t, Scene* s, tOrientation o) +TransitionFlipY* TransitionFlipY::create(float t, Scene* s, Orientation o) { TransitionFlipY* pScene = new TransitionFlipY(); pScene->initWithDuration(t, s, o); @@ -857,7 +857,7 @@ TransitionFlipY* TransitionFlipY::create(float t, Scene* s, tOrientation o) TransitionFlipY* TransitionFlipY::create(float t, Scene* s) { - return TransitionFlipY::create(t, s, kTransitionOrientationUpOver); + return TransitionFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } // @@ -881,7 +881,7 @@ void TransitionFlipAngular::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation == kTransitionOrientationRightOver ) + if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; @@ -916,7 +916,7 @@ void TransitionFlipAngular::onEnter() _outScene->runAction(outA); } -TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, tOrientation o) +TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, Orientation o) { TransitionFlipAngular* pScene = new TransitionFlipAngular(); pScene->initWithDuration(t, s, o); @@ -927,7 +927,7 @@ TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s, tOrienta TransitionFlipAngular* TransitionFlipAngular::create(float t, Scene* s) { - return TransitionFlipAngular::create(t, s, kTransitionOrientationRightOver); + return TransitionFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // @@ -950,7 +950,7 @@ void TransitionZoomFlipX::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation == kTransitionOrientationRightOver ) { + if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; @@ -994,7 +994,7 @@ void TransitionZoomFlipX::onEnter() _outScene->runAction(outA); } -TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, tOrientation o) +TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, Orientation o) { TransitionZoomFlipX* pScene = new TransitionZoomFlipX(); pScene->initWithDuration(t, s, o); @@ -1005,7 +1005,7 @@ TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s, tOrientation TransitionZoomFlipX* TransitionZoomFlipX::create(float t, Scene* s) { - return TransitionZoomFlipX::create(t, s, kTransitionOrientationRightOver); + return TransitionZoomFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // @@ -1029,7 +1029,7 @@ void TransitionZoomFlipY::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation== kTransitionOrientationUpOver ) { + if( _orientation== TransitionScene::Orientation::UP_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; @@ -1073,7 +1073,7 @@ void TransitionZoomFlipY::onEnter() _outScene->runAction(outA); } -TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, tOrientation o) +TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, Orientation o) { TransitionZoomFlipY* pScene = new TransitionZoomFlipY(); pScene->initWithDuration(t, s, o); @@ -1084,7 +1084,7 @@ TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s, tOrientation TransitionZoomFlipY* TransitionZoomFlipY::create(float t, Scene* s) { - return TransitionZoomFlipY::create(t, s, kTransitionOrientationUpOver); + return TransitionZoomFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } // @@ -1108,7 +1108,7 @@ void TransitionZoomFlipAngular::onEnter() float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; - if( _orientation == kTransitionOrientationRightOver ) { + if( _orientation == TransitionScene::Orientation::RIGHT_OVER ) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; @@ -1154,7 +1154,7 @@ void TransitionZoomFlipAngular::onEnter() _outScene->runAction(outA); } -TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, tOrientation o) +TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, Orientation o) { TransitionZoomFlipAngular* pScene = new TransitionZoomFlipAngular(); pScene->initWithDuration(t, s, o); @@ -1165,7 +1165,7 @@ TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s, TransitionZoomFlipAngular* TransitionZoomFlipAngular::create(float t, Scene* s) { - return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver); + return TransitionZoomFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } // diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index cdc318c8d7..59f29e15c2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -56,31 +56,25 @@ public: virtual ActionInterval * easeActionWithAction(ActionInterval * action) = 0; }; -/** Orientation Type used by some transitions -*/ -typedef enum { - /// An horizontal orientation where the Left is nearer - kTransitionOrientationLeftOver = 0, - /// An horizontal orientation where the Right is nearer - kTransitionOrientationRightOver = 1, - /// A vertical orientation where the Up is nearer - kTransitionOrientationUpOver = 0, - /// A vertical orientation where the Bottom is nearer - kTransitionOrientationDownOver = 1, - - // Deprecated - // kOrientationLeftOver = kTransitionOrientationLeftOver, - // kOrientationRightOver = kTransitionOrientationRightOver, - // kOrientationUpOver = kTransitionOrientationUpOver, - // kOrientationDownOver = kTransitionOrientationDownOver, -} tOrientation; - /** @brief Base class for Transition scenes */ class CC_DLL TransitionScene : public Scene { - public: + /** Orientation Type used by some transitions + */ + enum class Orientation + { + /// An horizontal orientation where the Left is nearer + LEFT_OVER = 0, + /// An horizontal orientation where the Right is nearer + RIGHT_OVER = 1, + /// A vertical orientation where the Up is nearer + UP_OVER = 0, + /// A vertical orientation where the Bottom is nearer + DOWN_OVER = 1, + }; + /** creates a base transition with duration and incoming scene */ static TransitionScene * create(float t, Scene *scene); @@ -125,16 +119,16 @@ class CC_DLL TransitionSceneOriented : public TransitionScene { public: /** creates a base transition with duration and incoming scene */ - static TransitionSceneOriented * create(float t,Scene* scene, tOrientation orientation); + static TransitionSceneOriented * create(float t,Scene* scene, Orientation orientation); TransitionSceneOriented(); virtual ~TransitionSceneOriented(); /** initializes a transition with duration and incoming scene */ - bool initWithDuration(float t,Scene* scene,tOrientation orientation); + bool initWithDuration(float t,Scene* scene,Orientation orientation); protected: - tOrientation _orientation; + Orientation _orientation; }; /** @brief TransitionRotoZoom: @@ -345,7 +339,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionFlipX : public TransitionSceneOriented { public: - static TransitionFlipX* create(float t, Scene* s, tOrientation o); + static TransitionFlipX* create(float t, Scene* s, Orientation o); static TransitionFlipX* create(float t, Scene* s); TransitionFlipX(); @@ -364,7 +358,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionFlipY : public TransitionSceneOriented { public: - static TransitionFlipY* create(float t, Scene* s, tOrientation o); + static TransitionFlipY* create(float t, Scene* s, Orientation o); static TransitionFlipY* create(float t, Scene* s); TransitionFlipY(); @@ -383,7 +377,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionFlipAngular : public TransitionSceneOriented { public: - static TransitionFlipAngular* create(float t, Scene* s, tOrientation o); + static TransitionFlipAngular* create(float t, Scene* s, Orientation o); static TransitionFlipAngular* create(float t, Scene* s); TransitionFlipAngular(); @@ -402,7 +396,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionZoomFlipX : public TransitionSceneOriented { public: - static TransitionZoomFlipX* create(float t, Scene* s, tOrientation o); + static TransitionZoomFlipX* create(float t, Scene* s, Orientation o); static TransitionZoomFlipX* create(float t, Scene* s); TransitionZoomFlipX(); @@ -421,7 +415,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionZoomFlipY : public TransitionSceneOriented { public: - static TransitionZoomFlipY* create(float t, Scene* s, tOrientation o); + static TransitionZoomFlipY* create(float t, Scene* s, Orientation o); static TransitionZoomFlipY* create(float t, Scene* s); TransitionZoomFlipY(); @@ -440,7 +434,7 @@ The front face is the outgoing scene and the back face is the incoming scene. class CC_DLL TransitionZoomFlipAngular : public TransitionSceneOriented { public: - static TransitionZoomFlipAngular* create(float t, Scene* s, tOrientation o); + static TransitionZoomFlipAngular* create(float t, Scene* s, Orientation o); static TransitionZoomFlipAngular* create(float t, Scene* s); TransitionZoomFlipAngular(); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index 05e1cde65c..a2c5772848 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -140,7 +140,7 @@ ProgressTimer* TransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(R // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType(kProgressTimerTypeRadial); + pNode->setType(ProgressTimer::Type::RADIAL); // Return the radial type that we want to use pNode->setReverseDirection(false); @@ -184,7 +184,7 @@ ProgressTimer* TransitionProgressRadialCW::progressTimerNodeWithRenderTexture(Re // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType( kProgressTimerTypeRadial ); + pNode->setType( ProgressTimer::Type::RADIAL ); // Return the radial type that we want to use pNode->setReverseDirection(true); @@ -216,7 +216,7 @@ ProgressTimer* TransitionProgressHorizontal::progressTimerNodeWithRenderTexture( // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType( kProgressTimerTypeBar); + pNode->setType( ProgressTimer::Type::BAR); pNode->setMidpoint(Point(1, 0)); pNode->setBarChangeRate(Point(1,0)); @@ -249,7 +249,7 @@ ProgressTimer* TransitionProgressVertical::progressTimerNodeWithRenderTexture(Re // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType(kProgressTimerTypeBar); + pNode->setType(ProgressTimer::Type::BAR); pNode->setMidpoint(Point(0, 0)); pNode->setBarChangeRate(Point(0,1)); @@ -295,7 +295,7 @@ ProgressTimer* TransitionProgressInOut::progressTimerNodeWithRenderTexture(Rende // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType( kProgressTimerTypeBar); + pNode->setType( ProgressTimer::Type::BAR); pNode->setMidpoint(Point(0.5f, 0.5f)); pNode->setBarChangeRate(Point(1, 1)); @@ -329,7 +329,7 @@ ProgressTimer* TransitionProgressOutIn::progressTimerNodeWithRenderTexture(Rende // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); - pNode->setType( kProgressTimerTypeBar ); + pNode->setType( ProgressTimer::Type::BAR ); pNode->setMidpoint(Point(0.5f, 0.5f)); pNode->setBarChangeRate(Point(1, 1)); diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 01f98ca415..0979e0c8b3 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -121,8 +121,8 @@ bool Menu::initWithArray(Array* pArrayOfItems) { if (Layer::init()) { - setTouchPriority(kMenuHandlerPriority); - setTouchMode(kTouchesOneByOne); + setTouchPriority(Menu::HANDLER_PRIORITY); + setTouchMode(Touch::DispatchMode::ONE_BY_ONE); setTouchEnabled(true); _enabled = true; @@ -149,7 +149,7 @@ bool Menu::initWithArray(Array* pArrayOfItems) // [self alignItemsVertically]; _selectedItem = NULL; - _state = kMenuStateWaiting; + _state = Menu::State::WAITING; // enable cascade color and opacity on menus setCascadeColorEnabled(true); @@ -181,7 +181,7 @@ void Menu::addChild(Node * child, int zOrder, int tag) void Menu::onExit() { - if (_state == kMenuStateTrackingTouch) + if (_state == Menu::State::TRACKING_TOUCH) { if (_selectedItem) { @@ -189,7 +189,7 @@ void Menu::onExit() _selectedItem = NULL; } - _state = kMenuStateWaiting; + _state = Menu::State::WAITING; } Layer::onExit(); @@ -225,7 +225,7 @@ void Menu::registerWithTouchDispatcher() bool Menu::ccTouchBegan(Touch* touch, Event* event) { CC_UNUSED_PARAM(event); - if (_state != kMenuStateWaiting || ! _visible || !_enabled) + if (_state != Menu::State::WAITING || ! _visible || !_enabled) { return false; } @@ -241,7 +241,7 @@ bool Menu::ccTouchBegan(Touch* touch, Event* event) _selectedItem = this->itemForTouch(touch); if (_selectedItem) { - _state = kMenuStateTrackingTouch; + _state = Menu::State::TRACKING_TOUCH; _selectedItem->selected(); return true; } @@ -252,31 +252,31 @@ void Menu::ccTouchEnded(Touch *touch, Event* event) { CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event); - CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchEnded] -- invalid state"); + CCASSERT(_state == Menu::State::TRACKING_TOUCH, "[Menu ccTouchEnded] -- invalid state"); if (_selectedItem) { _selectedItem->unselected(); _selectedItem->activate(); } - _state = kMenuStateWaiting; + _state = Menu::State::WAITING; } void Menu::ccTouchCancelled(Touch *touch, Event* event) { CC_UNUSED_PARAM(touch); CC_UNUSED_PARAM(event); - CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchCancelled] -- invalid state"); + CCASSERT(_state == Menu::State::TRACKING_TOUCH, "[Menu ccTouchCancelled] -- invalid state"); if (_selectedItem) { _selectedItem->unselected(); } - _state = kMenuStateWaiting; + _state = Menu::State::WAITING; } void Menu::ccTouchMoved(Touch* touch, Event* event) { CC_UNUSED_PARAM(event); - CCASSERT(_state == kMenuStateTrackingTouch, "[Menu ccTouchMoved] -- invalid state"); + CCASSERT(_state == Menu::State::TRACKING_TOUCH, "[Menu ccTouchMoved] -- invalid state"); MenuItem *currentItem = this->itemForTouch(touch); if (currentItem != _selectedItem) { @@ -306,10 +306,10 @@ void Menu::alignItemsVerticallyWithPadding(float padding) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { - height += pChild->getContentSize().height * pChild->getScaleY() + padding; + height += child->getContentSize().height * child->getScaleY() + padding; } } } @@ -320,11 +320,11 @@ void Menu::alignItemsVerticallyWithPadding(float padding) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { - pChild->setPosition(Point(0, y - pChild->getContentSize().height * pChild->getScaleY() / 2.0f)); - y -= pChild->getContentSize().height * pChild->getScaleY() + padding; + child->setPosition(Point(0, y - child->getContentSize().height * child->getScaleY() / 2.0f)); + y -= child->getContentSize().height * child->getScaleY() + padding; } } } @@ -344,10 +344,10 @@ void Menu::alignItemsHorizontallyWithPadding(float padding) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { - width += pChild->getContentSize().width * pChild->getScaleX() + padding; + width += child->getContentSize().width * child->getScaleX() + padding; } } } @@ -358,11 +358,11 @@ void Menu::alignItemsHorizontallyWithPadding(float padding) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { - pChild->setPosition(Point(x + pChild->getContentSize().width * pChild->getScaleX() / 2.0f, 0)); - x += pChild->getContentSize().width * pChild->getScaleX() + padding; + child->setPosition(Point(x + child->getContentSize().width * child->getScaleX() / 2.0f, 0)); + x += child->getContentSize().width * child->getScaleX() + padding; } } } @@ -405,8 +405,8 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { CCASSERT(row < rows.size(), ""); @@ -414,7 +414,7 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray) // can not have zero columns on a row CCASSERT(rowColumns, ""); - float tmp = pChild->getContentSize().height; + float tmp = child->getContentSize().height; rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); ++columnsOccupied; @@ -447,8 +447,8 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { if (rowColumns == 0) { @@ -457,11 +457,11 @@ void Menu::alignItemsInColumnsWithArray(Array* rowsArray) x = w; } - float tmp = pChild->getContentSize().height; + float tmp = child->getContentSize().height; rowHeight = (unsigned int)((rowHeight >= tmp || isnan(tmp)) ? rowHeight : tmp); - pChild->setPosition(Point(x - winSize.width / 2, - y - pChild->getContentSize().height / 2)); + child->setPosition(Point(x - winSize.width / 2, + y - child->getContentSize().height / 2)); x += w; ++columnsOccupied; @@ -520,8 +520,8 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { // check if too many menu items for the amount of rows/columns CCASSERT(column < columns.size(), ""); @@ -531,10 +531,10 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray) CCASSERT(columnRows, ""); // columnWidth = fmaxf(columnWidth, [item contentSize].width); - float tmp = pChild->getContentSize().width; + float tmp = child->getContentSize().width; columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); - columnHeight += (int)(pChild->getContentSize().height + 5); + columnHeight += (int)(child->getContentSize().height + 5); ++rowsOccupied; if (rowsOccupied >= columnRows) @@ -568,8 +568,8 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Node* pChild = dynamic_cast(pObject); - if (pChild) + Node* child = dynamic_cast(pObject); + if (child) { if (columnRows == 0) { @@ -578,13 +578,13 @@ void Menu::alignItemsInRowsWithArray(Array* columnArray) } // columnWidth = fmaxf(columnWidth, [item contentSize].width); - float tmp = pChild->getContentSize().width; + float tmp = child->getContentSize().width; columnWidth = (unsigned int)((columnWidth >= tmp || isnan(tmp)) ? columnWidth : tmp); - pChild->setPosition(Point(x + columnWidths[column] / 2, + child->setPosition(Point(x + columnWidths[column] / 2, y - winSize.height / 2)); - y -= pChild->getContentSize().height + 10; + y -= child->getContentSize().height + 10; ++rowsOccupied; if (rowsOccupied >= columnRows) @@ -609,16 +609,16 @@ MenuItem* Menu::itemForTouch(Touch *touch) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - MenuItem* pChild = dynamic_cast(pObject); - if (pChild && pChild->isVisible() && pChild->isEnabled()) + MenuItem* child = dynamic_cast(pObject); + if (child && child->isVisible() && child->isEnabled()) { - Point local = pChild->convertToNodeSpace(touchLocation); - Rect r = pChild->rect(); + Point local = child->convertToNodeSpace(touchLocation); + Rect r = child->rect(); r.origin = Point::ZERO; if (r.containsPoint(local)) { - return pChild; + return child; } } } diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 2199495ad6..e9b971a440 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -36,16 +36,8 @@ NS_CC_BEGIN * @addtogroup menu * @{ */ -typedef enum -{ - kMenuStateWaiting, - kMenuStateTrackingTouch -} tMenuState; -enum { - //* priority used by the menu for the event handler - kMenuHandlerPriority = -128, -}; + /** @brief A Menu * @@ -56,6 +48,17 @@ enum { class CC_DLL Menu : public LayerRGBA { public: + enum + { + HANDLER_PRIORITY = -128, + }; + + enum class State + { + WAITING, + TRACKING_TOUCH, + }; + /** creates an empty Menu */ static Menu* create(); @@ -133,7 +136,7 @@ protected: bool _enabled; MenuItem* itemForTouch(Touch * touch); - tMenuState _state; + State _state; MenuItem *_selectedItem; }; diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 2bfbf933c5..37747938e9 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -33,6 +33,13 @@ THE SOFTWARE. #include #include +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (push) +#pragma warning (disable: 4996) +#endif + NS_CC_BEGIN static unsigned int _globalFontSize = kItemSize; @@ -986,3 +993,9 @@ MenuItem* MenuItemToggle::getSelectedItem() } NS_CC_END + +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) +#pragma GCC diagnostic warning "-Wdeprecated-declarations" +#elif _MSC_VER >= 1400 //vs 2005 or higher +#pragma warning (pop) +#endif diff --git a/cocos2dx/misc_nodes/CCClippingNode.cpp b/cocos2dx/misc_nodes/CCClippingNode.cpp index d26ab5fe11..be9cee588a 100644 --- a/cocos2dx/misc_nodes/CCClippingNode.cpp +++ b/cocos2dx/misc_nodes/CCClippingNode.cpp @@ -151,7 +151,7 @@ void ClippingNode::drawFullScreenQuadClearStencil() kmGLPushMatrix(); kmGLLoadIdentity(); - ccDrawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Point(-1,-1), Point(1,1), Color4F(1, 1, 1, 1)); kmGLMatrixMode(KM_GL_PROJECTION); kmGLPopMatrix(); @@ -308,8 +308,8 @@ void ClippingNode::visit() #else // since glAlphaTest do not exists in OES, use a shader that writes // pixel only if greater than an alpha threshold - GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); + GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // set our alphaThreshold program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); // we need to recursively apply this shader to all the nodes in the stencil node diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 40159988f1..1e65cbd587 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -49,9 +49,8 @@ MotionStreak::MotionStreak() , _vertices(NULL) , _colorPointer(NULL) , _texCoords(NULL) +, _blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; } MotionStreak::~MotionStreak() @@ -123,11 +122,10 @@ bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Co _colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4); // Set blend mode - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; // shader program - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); setTexture(texture); setColor(color); @@ -331,25 +329,25 @@ void MotionStreak::draw() CC_NODE_DRAW_SETUP(); - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); - ccGLBindTexture2D( _texture->getName() ); + GL::bindTexture2D( _texture->getName() ); #ifdef EMSCRIPTEN // Size calculations from ::initWithFade setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _vertices); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index c1b099e4b5..dbc09d05c4 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -45,7 +45,7 @@ const char kProgressTextureCoords = 0x4b; ProgressTimer::ProgressTimer() -:_type(kProgressTimerTypeRadial) +:_type(Type::RADIAL) ,_percentage(0.0f) ,_sprite(NULL) ,_vertexDataCount(0) @@ -78,13 +78,13 @@ bool ProgressTimer::initWithSprite(Sprite* sp) _vertexDataCount = 0; setAnchorPoint(Point(0.5f,0.5f)); - _type = kProgressTimerTypeRadial; + _type = Type::RADIAL; _reverseDirection = false; setMidpoint(Point(0.5f, 0.5f)); setBarChangeRate(Point(1,1)); setSprite(sp); // shader program - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } @@ -121,7 +121,7 @@ void ProgressTimer::setSprite(Sprite *pSprite) } } -void ProgressTimer::setType(ProgressTimerType type) +void ProgressTimer::setType(Type type) { if (type != _type) { @@ -225,10 +225,10 @@ void ProgressTimer::updateProgress(void) { switch (_type) { - case kProgressTimerTypeRadial: + case Type::RADIAL: updateRadial(); break; - case kProgressTimerTypeBar: + case Type::BAR: updateBar(); break; default: @@ -504,34 +504,34 @@ void ProgressTimer::draw(void) CC_NODE_DRAW_SETUP(); - ccGLBlendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst ); + GL::blendFunc( _sprite->getBlendFunc().src, _sprite->getBlendFunc().dst ); - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); - ccGLBindTexture2D( _sprite->getTexture()->getName() ); + GL::bindTexture2D( _sprite->getTexture()->getName() ); #ifdef EMSCRIPTEN setGLBufferData((void*) _vertexData, (_vertexDataCount * sizeof(V2F_C4B_T2F)), 0); int offset = 0; - glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Vertex2F); - glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); offset += sizeof(Color4B); - glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid*)offset); #else - glVertexAttribPointer( kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices); - glVertexAttribPointer( kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); - glVertexAttribPointer( kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]) , &_vertexData[0].vertices); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(_vertexData[0]), &_vertexData[0].texCoords); + glVertexAttribPointer( GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(_vertexData[0]), &_vertexData[0].colors); #endif // EMSCRIPTEN - if(_type == kProgressTimerTypeRadial) + if(_type == Type::RADIAL) { glDrawArrays(GL_TRIANGLE_FAN, 0, _vertexDataCount); } - else if (_type == kProgressTimerTypeBar) + else if (_type == Type::BAR) { if (!_reverseDirection) { diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index 849cb54a07..f8fea4ca68 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -37,16 +37,6 @@ NS_CC_BEGIN * @{ */ -/** Types of progress - @since v0.99.1 - */ -typedef enum { - /// Radial Counter-Clockwise - kProgressTimerTypeRadial, - /// Bar - kProgressTimerTypeBar, -} ProgressTimerType; - /** @brief ProgressTimer is a subclass of Node. It renders the inner sprite according to the percentage. @@ -59,6 +49,17 @@ class CC_DLL ProgressTimer : public NodeRGBA #endif // EMSCRIPTEN { public: + /** Types of progress + @since v0.99.1 + */ + enum class Type + { + /// Radial Counter-Clockwise + RADIAL, + /// Bar + BAR, + }; + /** Creates a progress timer with the sprite as the shape the timer goes through */ static ProgressTimer* create(Sprite* sp); @@ -69,7 +70,7 @@ public: bool initWithSprite(Sprite* sp); /** Change the percentage to change progress. */ - inline ProgressTimerType getType() const { return _type; } + inline Type getType() const { return _type; } /** Percentages are from 0 to 100 */ inline float getPercentage() const {return _percentage; } @@ -79,7 +80,7 @@ public: void setPercentage(float fPercentage); void setSprite(Sprite *pSprite); - void setType(ProgressTimerType type); + void setType(Type type); void setReverseProgress(bool reverse); inline bool isReverseDirection() { return _reverseDirection; }; @@ -126,7 +127,7 @@ protected: void updateColor(void); Point boundaryTexCoord(char index); - ProgressTimerType _type; + Type _type; Point _midpoint; Point _barChangeRate; float _percentage; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index edeab9643e..5f321b9c75 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -51,7 +51,7 @@ RenderTexture::RenderTexture() , _texture(0) , _textureCopy(0) , _UITextureImage(NULL) -, _pixelFormat(kTexture2DPixelFormat_RGBA8888) +, _pixelFormat(Texture2D::PixelFormat::RGBA8888) , _clearFlags(0) , _clearColor(Color4F(0,0,0,0)) , _clearDepth(0.0f) @@ -102,11 +102,11 @@ void RenderTexture::listenToBackground(cocos2d::Object *obj) if (_UITextureImage) { const Size& s = _texture->getContentSizeInPixels(); - VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); + VolatileTexture::addDataTexture(_texture, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s); if ( _textureCopy ) { - VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); + VolatileTexture::addDataTexture(_textureCopy, _UITextureImage->getData(), Texture2D::PixelFormat::RGBA8888, s); } } else @@ -140,7 +140,7 @@ void RenderTexture::listenToForeground(cocos2d::Object *obj) #endif } -RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat) +RenderTexture * RenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat) { RenderTexture *pRet = new RenderTexture(); @@ -153,7 +153,7 @@ RenderTexture * RenderTexture::create(int w, int h, Texture2DPixelFormat eFormat return NULL; } -RenderTexture * RenderTexture::create(int w ,int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +RenderTexture * RenderTexture::create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat) { RenderTexture *pRet = new RenderTexture(); @@ -170,7 +170,7 @@ RenderTexture * RenderTexture::create(int w, int h) { RenderTexture *pRet = new RenderTexture(); - if(pRet && pRet->initWithWidthAndHeight(w, h, kTexture2DPixelFormat_RGBA8888, 0)) + if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGBA8888, 0)) { pRet->autorelease(); return pRet; @@ -179,14 +179,14 @@ RenderTexture * RenderTexture::create(int w, int h) return NULL; } -bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat) +bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat) { return initWithWidthAndHeight(w, h, eFormat, 0); } -bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat) { - CCASSERT(eFormat != kTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture"); + CCASSERT(eFormat != Texture2D::PixelFormat::A8, "only RGB and RGBA formats are valid for a render texture"); bool bRet = false; void *data = NULL; @@ -221,7 +221,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF _texture = new Texture2D(); if (_texture) { - _texture->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); + _texture->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); } else { @@ -235,7 +235,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF _textureCopy = new Texture2D(); if (_textureCopy) { - _textureCopy->initWithData(data, (Texture2DPixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); + _textureCopy->initWithData(data, (Texture2D::PixelFormat)_pixelFormat, powW, powH, Size((float)w, (float)h)); } else { @@ -276,8 +276,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eF _texture->release(); _sprite->setScaleY(-1); - BlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; - _sprite->setBlendFunc(tBlendFunc); + _sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); glBindRenderbuffer(GL_RENDERBUFFER, oldRBO); glBindFramebuffer(GL_FRAMEBUFFER, _oldFBO); @@ -531,11 +530,11 @@ void RenderTexture::draw() Object *pElement; CCARRAY_FOREACH(_children, pElement) { - Node *pChild = static_cast(pElement); + Node *child = static_cast(pElement); - if (pChild != _sprite) + if (child != _sprite) { - pChild->visit(); + child->visit(); } } @@ -545,40 +544,40 @@ void RenderTexture::draw() bool RenderTexture::saveToFile(const char *szFilePath) { - bool bRet = false; + bool ret = false; - Image *pImage = newImage(true); - if (pImage) + Image *image = newImage(true); + if (image) { - bRet = pImage->saveToFile(szFilePath, kImageFormatJPEG); + ret = image->saveToFile(szFilePath); } - CC_SAFE_DELETE(pImage); - return bRet; + CC_SAFE_DELETE(image); + return ret; } -bool RenderTexture::saveToFile(const char *fileName, tImageFormat format) +bool RenderTexture::saveToFile(const char *fileName, Image::Format format) { bool bRet = false; - CCASSERT(format == kImageFormatJPEG || format == kImageFormatPNG, + CCASSERT(format == Image::Format::JPG || format == Image::Format::PNG, "the image can only be saved as JPG or PNG format"); - Image *pImage = newImage(true); - if (pImage) + Image *image = newImage(true); + if (image) { std::string fullpath = FileUtils::getInstance()->getWritablePath() + fileName; - bRet = pImage->saveToFile(fullpath.c_str(), true); + bRet = image->saveToFile(fullpath.c_str(), true); } - CC_SAFE_DELETE(pImage); + CC_SAFE_DELETE(image); return bRet; } /* get buffer as Image */ -Image* RenderTexture::newImage(bool flipImage) +Image* RenderTexture::newImage(bool fliimage) { - CCASSERT(_pixelFormat == kTexture2DPixelFormat_RGBA8888, "only RGBA8888 can be saved as image"); + CCASSERT(_pixelFormat == Texture2D::PixelFormat::RGBA8888, "only RGBA8888 can be saved as image"); if (NULL == _texture) { @@ -595,7 +594,7 @@ Image* RenderTexture::newImage(bool flipImage) GLubyte *pBuffer = NULL; GLubyte *pTempData = NULL; - Image *pImage = new Image(); + Image *image = new Image(); do { @@ -613,7 +612,7 @@ Image* RenderTexture::newImage(bool flipImage) glReadPixels(0,0,nSavedBufferWidth, nSavedBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, pTempData); this->end(); - if ( flipImage ) // -- flip is only required when saving image to file + if ( fliimage ) // -- flip is only required when saving image to file { // to get the actual texture data // #640 the image read from rendertexture is dirty @@ -624,11 +623,11 @@ Image* RenderTexture::newImage(bool flipImage) nSavedBufferWidth * 4); } - pImage->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, Image::kFmtRawData, nSavedBufferWidth, nSavedBufferHeight, 8); + image->initWithImageData(pBuffer, nSavedBufferWidth * nSavedBufferHeight * 4, Image::Format::RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8); } else { - pImage->initWithImageData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, Image::kFmtRawData, nSavedBufferWidth, nSavedBufferHeight, 8); + image->initWithImageData(pTempData, nSavedBufferWidth * nSavedBufferHeight * 4, Image::Format::RAW_DATA, nSavedBufferWidth, nSavedBufferHeight, 8); } } while (0); @@ -636,7 +635,7 @@ Image* RenderTexture::newImage(bool flipImage) CC_SAFE_DELETE_ARRAY(pBuffer); CC_SAFE_DELETE_ARRAY(pTempData); - return pImage; + return image; } NS_CC_END diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 4fe49434e5..c65143baf8 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -28,6 +28,7 @@ THE SOFTWARE. #include "base_nodes/CCNode.h" #include "sprite_nodes/CCSprite.h" #include "kazmath/mat4.h" +#include "platform/CCImage.h" NS_CC_BEGIN @@ -36,11 +37,6 @@ NS_CC_BEGIN * @{ */ -typedef enum eImageFormat -{ - kImageFormatJPEG = 0, - kImageFormatPNG = 1, -} tImageFormat; /** @brief RenderTexture is a generic rendering target. To render things into it, simply construct a render target, call begin on it, call visit on any cocos @@ -55,10 +51,10 @@ class CC_DLL RenderTexture : public Node { public: /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ - static RenderTexture * create(int w ,int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + static RenderTexture * create(int w ,int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ - static RenderTexture * create(int w, int h, Texture2DPixelFormat eFormat); + static RenderTexture * create(int w, int h, Texture2D::PixelFormat eFormat); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */ static RenderTexture * create(int w, int h); @@ -67,10 +63,10 @@ public: virtual ~RenderTexture(); /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ - bool initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat); + bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat); /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ - bool initWithWidthAndHeight(int w, int h, Texture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + bool initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat eFormat, GLuint uDepthStencilFormat); /** starts grabbing */ void begin(); @@ -104,7 +100,10 @@ public: /* creates a new Image from with the texture's data. Caller is responsible for releasing it by calling delete. */ + Image* newImage(bool flipImage = true); + + CC_DEPRECATED_ATTRIBUTE Image* newCCImage(bool flipImage = true) { return newImage(flipImage); }; /** saves the texture into a file using JPEG format. The file will be saved in the Documents folder. Returns YES if the operation is successful. @@ -114,7 +113,7 @@ public: /** saves the texture into a file. The format could be JPG or PNG. The file will be saved in the Documents folder. Returns YES if the operation is successful. */ - bool saveToFile(const char *name, tImageFormat format); + bool saveToFile(const char *name, Image::Format format); /** Listen "come to background" message, and save render texture. It only has effect on Android. @@ -140,7 +139,7 @@ public: /** Value for clear Stencil. Valid only when autoDraw is true */ inline int getClearStencil() const { return _clearStencil; }; - inline void setClearStencil(float clearStencil) { _clearStencil = clearStencil; }; + inline void setClearStencil(int clearStencil) { _clearStencil = clearStencil; }; /** When enabled, it will render its children into the texture automatically. Disabled by default for compatiblity reasons. Will be enabled in the future. @@ -172,7 +171,7 @@ protected: Texture2D* _texture; Texture2D* _textureCopy; // a copy of _texture Image* _UITextureImage; - GLenum _pixelFormat; + Texture2D::PixelFormat _pixelFormat; // code for "auto" update GLbitfield _clearFlags; diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 15890dec8c..deb3a8f401 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -99,10 +99,9 @@ bool ParticleBatchNode::initWithTexture(Texture2D *tex, unsigned int capacity) _children = new Array(); _children->initWithCapacity(capacity); - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } @@ -165,22 +164,22 @@ void ParticleBatchNode::addChild(Node * child, int zOrder) Node::addChild(child, zOrder); } -void ParticleBatchNode::addChild(Node * child, int zOrder, int tag) +void ParticleBatchNode::addChild(Node * aChild, int zOrder, int tag) { - CCASSERT( child != NULL, "Argument must be non-NULL"); - CCASSERT( dynamic_cast(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); - ParticleSystem* pChild = (ParticleSystem*)child; - CCASSERT( pChild->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id"); + CCASSERT( aChild != NULL, "Argument must be non-NULL"); + CCASSERT( dynamic_cast(aChild) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); + ParticleSystem* child = static_cast(aChild); + CCASSERT( child->getTexture()->getName() == _textureAtlas->getTexture()->getName(), "CCParticleSystem is not using the same texture id"); // If this is the 1st children, then copy blending function if( _children->count() == 0 ) { - setBlendFunc(pChild->getBlendFunc()); + setBlendFunc(child->getBlendFunc()); } - CCASSERT( _blendFunc.src == pChild->getBlendFunc().src && _blendFunc.dst == pChild->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function"); + CCASSERT( _blendFunc.src == child->getBlendFunc().src && _blendFunc.dst == child->getBlendFunc().dst, "Can't add a PaticleSystem that uses a different blending function"); //no lazy sorting, so don't call super addChild, call helper instead - unsigned int pos = addChildHelper(pChild,zOrder,tag); + unsigned int pos = addChildHelper(child,zOrder,tag); //get new atlasIndex int atlasIndex = 0; @@ -196,10 +195,10 @@ void ParticleBatchNode::addChild(Node * child, int zOrder, int tag) atlasIndex = 0; } - insertChild(pChild, atlasIndex); + insertChild(child, atlasIndex); // update quad info - pChild->setBatchNode(this); + child->setBatchNode(this); } // don't use lazy sorting, reordering the particle systems quads afterwards would be too complex @@ -236,13 +235,13 @@ unsigned int ParticleBatchNode::addChildHelper(ParticleSystem* child, int z, int } // Reorder will be done in this function, no "lazy" reorder to particles -void ParticleBatchNode::reorderChild(Node * child, int zOrder) +void ParticleBatchNode::reorderChild(Node * aChild, int zOrder) { - CCASSERT( child != NULL, "Child must be non-NULL"); - CCASSERT( dynamic_cast(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); - CCASSERT( _children->containsObject(child), "Child doesn't belong to batch" ); + CCASSERT( aChild != NULL, "Child must be non-NULL"); + CCASSERT( dynamic_cast(aChild) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); + CCASSERT( _children->containsObject(aChild), "Child doesn't belong to batch" ); - ParticleSystem* pChild = (ParticleSystem*)(child); + ParticleSystem* child = static_cast(aChild); if( zOrder == child->getZOrder() ) { @@ -254,19 +253,19 @@ void ParticleBatchNode::reorderChild(Node * child, int zOrder) { unsigned int newIndex = 0, oldIndex = 0; - getCurrentIndex(&oldIndex, &newIndex, pChild, zOrder); + getCurrentIndex(&oldIndex, &newIndex, child, zOrder); if( oldIndex != newIndex ) { // reorder _children->array - pChild->retain(); + child->retain(); _children->removeObjectAtIndex(oldIndex); - _children->insertObject(pChild, newIndex); - pChild->release(); + _children->insertObject(child, newIndex); + child->release(); // save old altasIndex - int oldAtlasIndex = pChild->getAtlasIndex(); + int oldAtlasIndex = child->getAtlasIndex(); // update atlas index updateAllAtlasIndexes(); @@ -276,21 +275,21 @@ void ParticleBatchNode::reorderChild(Node * child, int zOrder) for( unsigned int i=0;i < _children->count();i++) { ParticleSystem* pNode = (ParticleSystem*)_children->objectAtIndex(i); - if( pNode == pChild ) + if( pNode == child ) { - newAtlasIndex = pChild->getAtlasIndex(); + newAtlasIndex = child->getAtlasIndex(); break; } } // reorder textureAtlas quads - _textureAtlas->moveQuadsFromIndex(oldAtlasIndex, pChild->getTotalParticles(), newAtlasIndex); + _textureAtlas->moveQuadsFromIndex(oldAtlasIndex, child->getTotalParticles(), newAtlasIndex); - pChild->updateWithNoTime(); + child->updateWithNoTime(); } } - pChild->_setZOrder(zOrder); + child->_setZOrder(zOrder); } void ParticleBatchNode::getCurrentIndex(unsigned int* oldIndex, unsigned int* newIndex, Node* child, int z) @@ -360,28 +359,26 @@ unsigned int ParticleBatchNode::searchNewPositionInChildrenForZ(int z) } // override removeChild: -void ParticleBatchNode::removeChild(Node* child, bool cleanup) +void ParticleBatchNode::removeChild(Node* aChild, bool cleanup) { // explicit nil handling - if (child == NULL) - { + if (aChild == NULL) return; - } - CCASSERT( dynamic_cast(child) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); - CCASSERT(_children->containsObject(child), "CCParticleBatchNode doesn't contain the sprite. Can't remove it"); + CCASSERT( dynamic_cast(aChild) != NULL, "CCParticleBatchNode only supports QuadParticleSystems as children"); + CCASSERT(_children->containsObject(aChild), "CCParticleBatchNode doesn't contain the sprite. Can't remove it"); - ParticleSystem* pChild = (ParticleSystem*)child; - Node::removeChild(pChild, cleanup); + ParticleSystem* child = static_cast(aChild); + Node::removeChild(child, cleanup); // remove child helper - _textureAtlas->removeQuadsAtIndex(pChild->getAtlasIndex(), pChild->getTotalParticles()); + _textureAtlas->removeQuadsAtIndex(child->getAtlasIndex(), child->getTotalParticles()); // after memmove of data, empty the quads at the end of array - _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getTotalQuads(), pChild->getTotalParticles()); + _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getTotalQuads(), child->getTotalParticles()); // particle could be reused for self rendering - pChild->setBatchNode(NULL); + child->setBatchNode(NULL); updateAllAtlasIndexes(); } @@ -411,7 +408,7 @@ void ParticleBatchNode::draw(void) CC_NODE_DRAW_SETUP(); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); _textureAtlas->drawQuads(); @@ -443,26 +440,26 @@ void ParticleBatchNode::disableParticle(unsigned int particleIndex) // ParticleBatchNode - add / remove / reorder helper methods // add child helper -void ParticleBatchNode::insertChild(ParticleSystem* pSystem, int index) +void ParticleBatchNode::insertChild(ParticleSystem* system, int index) { - pSystem->setAtlasIndex(index); + system->setAtlasIndex(index); - if(_textureAtlas->getTotalQuads() + pSystem->getTotalParticles() > _textureAtlas->getCapacity()) + if(_textureAtlas->getTotalQuads() + system->getTotalParticles() > _textureAtlas->getCapacity()) { - increaseAtlasCapacityTo(_textureAtlas->getTotalQuads() + pSystem->getTotalParticles()); + increaseAtlasCapacityTo(_textureAtlas->getTotalQuads() + system->getTotalParticles()); // after a realloc empty quads of textureAtlas can be filled with gibberish (realloc doesn't perform calloc), insert empty quads to prevent it - _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getCapacity() - pSystem->getTotalParticles(), pSystem->getTotalParticles()); + _textureAtlas->fillWithEmptyQuadsFromIndex(_textureAtlas->getCapacity() - system->getTotalParticles(), system->getTotalParticles()); } // make room for quads, not necessary for last child - if (pSystem->getAtlasIndex() + pSystem->getTotalParticles() != _textureAtlas->getTotalQuads()) + if (system->getAtlasIndex() + system->getTotalParticles() != _textureAtlas->getTotalQuads()) { - _textureAtlas->moveQuadsFromIndex(index, index+pSystem->getTotalParticles()); + _textureAtlas->moveQuadsFromIndex(index, index+system->getTotalParticles()); } // increase totalParticles here for new particles, update method of particle-system will fill the quads - _textureAtlas->increaseTotalQuadsWith(pSystem->getTotalParticles()); + _textureAtlas->increaseTotalQuadsWith(system->getTotalParticles()); updateAllAtlasIndexes(); } @@ -485,10 +482,8 @@ void ParticleBatchNode::updateAllAtlasIndexes() void ParticleBatchNode::updateBlendFunc(void) { - if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha()) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - } + if( ! _textureAtlas->getTexture()->hasPremultipliedAlpha()) + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } void ParticleBatchNode::setTexture(Texture2D* texture) @@ -498,8 +493,7 @@ void ParticleBatchNode::setTexture(Texture2D* texture) // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it if( texture && ! texture->hasPremultipliedAlpha() && ( _blendFunc.src == CC_BLEND_SRC && _blendFunc.dst == CC_BLEND_DST ) ) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } } diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index f0eff12919..01484e56b6 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -83,7 +83,7 @@ public: bool initWithFile(const char* fileImage, unsigned int capacity); /** Inserts a child into the ParticleBatchNode */ - void insertChild(ParticleSystem* pSystem, int index); + void insertChild(ParticleSystem* system, int index); void removeChildAtIndex(unsigned int index, bool doCleanup); void removeAllChildrenWithCleanup(bool doCleanup); diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index 56332ec05c..d117f7748d 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -36,26 +36,26 @@ NS_CC_BEGIN static Texture2D* getDefaultTexture() { - Texture2D* pTexture = NULL; + Texture2D* texture = NULL; Image* pImage = NULL; do { bool bRet = false; const char* key = "__firePngData"; - pTexture = TextureCache::getInstance()->textureForKey(key); - CC_BREAK_IF(pTexture != NULL); + texture = TextureCache::getInstance()->textureForKey(key); + CC_BREAK_IF(texture != NULL); pImage = new Image(); CC_BREAK_IF(NULL == pImage); - bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::kFmtPng); + bRet = pImage->initWithImageData((void*)__firePngData, sizeof(__firePngData), Image::Format::PNG); CC_BREAK_IF(!bRet); - pTexture = TextureCache::getInstance()->addUIImage(pImage, key); + texture = TextureCache::getInstance()->addUIImage(pImage, key); } while (0); CC_SAFE_RELEASE(pImage); - return pTexture; + return texture; } ParticleFire* ParticleFire::create() @@ -91,10 +91,10 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - this->_emitterMode = kParticleModeGravity; + this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity this->modeA.gravity = Point(0,0); @@ -124,7 +124,7 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 54.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per frame _emissionRate = _totalParticles/_life; @@ -147,10 +147,10 @@ bool ParticleFire::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -196,10 +196,10 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration= kParticleDurationInfinity; + _duration= DURATION_INFINITY; // Gravity Mode - this->_emitterMode = kParticleModeGravity; + this->_emitterMode = Mode::GRAVITY; // Gravity Mode: gravity this->modeA.gravity = Point(0,-90); @@ -248,12 +248,12 @@ bool ParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 8.0f; _startSizeVar = 2.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive this->setBlendAdditive(false); @@ -300,10 +300,10 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles) this->setBlendAdditive(true); // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -333,7 +333,7 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 30.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per seconds _emissionRate = _totalParticles/_life; @@ -356,10 +356,10 @@ bool ParticleSun::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } return true; @@ -404,10 +404,10 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -440,7 +440,7 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 37.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; @@ -463,10 +463,10 @@ bool ParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -513,10 +513,10 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -549,7 +549,7 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 30.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; @@ -572,10 +572,10 @@ bool ParticleFlower::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -621,10 +621,10 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(-200,200)); @@ -657,7 +657,7 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 60.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; @@ -680,10 +680,10 @@ bool ParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -730,10 +730,10 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -766,7 +766,7 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 20.0f; _startSizeVar = 0.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_life; @@ -789,10 +789,10 @@ bool ParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -841,7 +841,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) // duration _duration = 0.1f; - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -874,7 +874,7 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 15.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = _totalParticles/_duration; @@ -897,10 +897,10 @@ bool ParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.5f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -947,10 +947,10 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // Emitter mode: Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -979,7 +979,7 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 60.0f; _startSizeVar = 10.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per frame _emissionRate = _totalParticles/_life; @@ -1002,10 +1002,10 @@ bool ParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -1052,10 +1052,10 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; // set gravity mode. - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,-1)); @@ -1088,7 +1088,7 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 10.0f; _startSizeVar = 5.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = 10; @@ -1111,10 +1111,10 @@ bool ParticleSnow::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive @@ -1160,9 +1160,9 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles) if( ParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // duration - _duration = kParticleDurationInfinity; + _duration = DURATION_INFINITY; - setEmitterMode(kParticleModeGravity); + setEmitterMode(Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(10,-10)); @@ -1196,7 +1196,7 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels _startSize = 4.0f; _startSizeVar = 2.0f; - _endSize = kParticleStartSizeEqualToEndSize; + _endSize = START_SIZE_EQUAL_TO_END_SIZE; // emits per second _emissionRate = 20; @@ -1219,10 +1219,10 @@ bool ParticleRain::initWithTotalParticles(unsigned int numberOfParticles) _endColorVar.b = 0.0f; _endColorVar.a = 0.0f; - Texture2D* pTexture = getDefaultTexture(); - if (pTexture != NULL) + Texture2D* texture = getDefaultTexture(); + if (texture != NULL) { - setTexture(pTexture); + setTexture(texture); } // additive diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 836a6c6977..90aa34e547 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -42,6 +42,9 @@ THE SOFTWARE. // #include "CCParticleSystem.h" + +#include + #include "CCParticleBatchNode.h" #include "ccTypes.h" #include "textures/CCTextureCache.h" @@ -55,8 +58,6 @@ THE SOFTWARE. // opengl #include "CCGL.h" -#include - using namespace std; @@ -111,9 +112,10 @@ ParticleSystem::ParticleSystem() , _texture(NULL) , _opacityModifyRGB(false) , _isBlendAdditive(false) -, _positionType(kPositionTypeFree) +, _positionType(PositionType::FREE) , _isAutoRemoveOnFinish(false) -, _emitterMode(kParticleModeGravity) +, _emitterMode(Mode::GRAVITY) +, _blendFunc(BlendFunc::ALPHA_PREMULTIPLIED) { modeA.gravity = Point::ZERO; modeA.speed = 0; @@ -129,8 +131,6 @@ ParticleSystem::ParticleSystem() modeB.endRadiusVar = 0; modeB.rotatePerSecond = 0; modeB.rotatePerSecondVar = 0; - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; } // implementation ParticleSystem @@ -256,10 +256,10 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn _endSpin= dictionary->valueForKey("rotationEnd")->floatValue(); _endSpinVar= dictionary->valueForKey("rotationEndVariance")->floatValue(); - _emitterMode = dictionary->valueForKey("emitterType")->intValue(); + _emitterMode = (Mode) dictionary->valueForKey("emitterType")->intValue(); // Mode A: Gravity + tangential accel + radial accel - if( _emitterMode == kParticleModeGravity ) + if (_emitterMode == Mode::GRAVITY) { // gravity modeA.gravity.x = dictionary->valueForKey("gravityx")->floatValue(); @@ -282,7 +282,7 @@ bool ParticleSystem::initWithDictionary(Dictionary *dictionary, const char *dirn } // or Mode B: radius movement - else if( _emitterMode == kParticleModeRadius ) + else if (_emitterMode == Mode::RADIUS) { modeB.startRadius = dictionary->valueForKey("maxRadius")->floatValue(); modeB.startRadiusVar = dictionary->valueForKey("maxRadiusVariance")->floatValue(); @@ -414,14 +414,13 @@ bool ParticleSystem::initWithTotalParticles(unsigned int numberOfParticles) _isActive = true; // default blend function - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; // default movement type; - _positionType = kPositionTypeFree; + _positionType = PositionType::FREE; // by default be in mode A: - _emitterMode = kParticleModeGravity; + _emitterMode = Mode::GRAVITY; // default: modulate // XXX: not used @@ -501,7 +500,7 @@ void ParticleSystem::initParticle(tParticle* particle) particle->size = startS; - if( _endSize == kParticleStartSizeEqualToEndSize ) + if (_endSize == START_SIZE_EQUAL_TO_END_SIZE) { particle->deltaSize = 0; } @@ -519,11 +518,11 @@ void ParticleSystem::initParticle(tParticle* particle) particle->deltaRotation = (endA - startA) / particle->timeToLive; // position - if( _positionType == kPositionTypeFree ) + if (_positionType == PositionType::FREE) { particle->startPos = this->convertToWorldSpace(Point::ZERO); } - else if ( _positionType == kPositionTypeRelative ) + else if (_positionType == PositionType::RELATIVE) { particle->startPos = _position; } @@ -532,7 +531,7 @@ void ParticleSystem::initParticle(tParticle* particle) float a = CC_DEGREES_TO_RADIANS( _angle + _angleVar * CCRANDOM_MINUS1_1() ); // Mode Gravity: A - if (_emitterMode == kParticleModeGravity) + if (_emitterMode == Mode::GRAVITY) { Point v(cosf( a ), sinf( a )); float s = modeA.speed + modeA.speedVar * CCRANDOM_MINUS1_1(); @@ -561,7 +560,7 @@ void ParticleSystem::initParticle(tParticle* particle) particle->modeB.radius = startRadius; - if(modeB.endRadius == kParticleStartRadiusEqualToEndRadius) + if (modeB.endRadius == START_RADIUS_EQUAL_TO_END_RADIUS) { particle->modeB.deltaRadius = 0; } @@ -627,11 +626,11 @@ void ParticleSystem::update(float dt) _particleIdx = 0; Point currentPosition = Point::ZERO; - if (_positionType == kPositionTypeFree) + if (_positionType == PositionType::FREE) { currentPosition = this->convertToWorldSpace(Point::ZERO); } - else if (_positionType == kPositionTypeRelative) + else if (_positionType == PositionType::RELATIVE) { currentPosition = _position; } @@ -648,7 +647,7 @@ void ParticleSystem::update(float dt) if (p->timeToLive > 0) { // Mode A: gravity, direction, tangential accel & radial accel - if (_emitterMode == kParticleModeGravity) + if (_emitterMode == Mode::GRAVITY) { Point tmp, radial, tangential; @@ -705,7 +704,7 @@ void ParticleSystem::update(float dt) Point newPos; - if (_positionType == kPositionTypeFree || _positionType == kPositionTypeRelative) + if (_positionType == PositionType::FREE || _positionType == PositionType::RELATIVE) { Point diff = currentPosition - p->startPos; newPos = p->pos - diff; @@ -814,8 +813,7 @@ void ParticleSystem::updateBlendFunc() } else { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } } } @@ -831,21 +829,14 @@ void ParticleSystem::setBlendAdditive(bool additive) { if( additive ) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE; + _blendFunc = BlendFunc::ADDITIVE; } else { if( _texture && ! _texture->hasPremultipliedAlpha() ) - { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - } + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; else - { - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; - } + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; } } @@ -857,170 +848,170 @@ bool ParticleSystem::isBlendAdditive() const // ParticleSystem - Properties of Gravity Mode void ParticleSystem::setTangentialAccel(float t) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT( _emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.tangentialAccel = t; } float ParticleSystem::getTangentialAccel() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT( _emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.tangentialAccel; } void ParticleSystem::setTangentialAccelVar(float t) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.tangentialAccelVar = t; } float ParticleSystem::getTangentialAccelVar() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.tangentialAccelVar; } void ParticleSystem::setRadialAccel(float t) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.radialAccel = t; } float ParticleSystem::getRadialAccel() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.radialAccel; } void ParticleSystem::setRadialAccelVar(float t) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.radialAccelVar = t; } float ParticleSystem::getRadialAccelVar() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.radialAccelVar; } void ParticleSystem::setRotationIsDir(bool t) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.rotationIsDir = t; } bool ParticleSystem::getRotationIsDir() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.rotationIsDir; } void ParticleSystem::setGravity(const Point& g) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.gravity = g; } const Point& ParticleSystem::getGravity() { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.gravity; } void ParticleSystem::setSpeed(float speed) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.speed = speed; } float ParticleSystem::getSpeed() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.speed; } void ParticleSystem::setSpeedVar(float speedVar) { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); modeA.speedVar = speedVar; } float ParticleSystem::getSpeedVar() const { - CCASSERT( _emitterMode == kParticleModeGravity, "Particle Mode should be Gravity"); + CCASSERT(_emitterMode == Mode::GRAVITY, "Particle Mode should be Gravity"); return modeA.speedVar; } // ParticleSystem - Properties of Radius Mode void ParticleSystem::setStartRadius(float startRadius) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.startRadius = startRadius; } float ParticleSystem::getStartRadius() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.startRadius; } void ParticleSystem::setStartRadiusVar(float startRadiusVar) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.startRadiusVar = startRadiusVar; } float ParticleSystem::getStartRadiusVar() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.startRadiusVar; } void ParticleSystem::setEndRadius(float endRadius) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.endRadius = endRadius; } float ParticleSystem::getEndRadius() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.endRadius; } void ParticleSystem::setEndRadiusVar(float endRadiusVar) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.endRadiusVar = endRadiusVar; } float ParticleSystem::getEndRadiusVar() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.endRadiusVar; } void ParticleSystem::setRotatePerSecond(float degrees) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.rotatePerSecond = degrees; } float ParticleSystem::getRotatePerSecond() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.rotatePerSecond; } void ParticleSystem::setRotatePerSecondVar(float degrees) { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); modeB.rotatePerSecondVar = degrees; } float ParticleSystem::getRotatePerSecondVar() const { - CCASSERT( _emitterMode == kParticleModeRadius, "Particle Mode should be Radius"); + CCASSERT(_emitterMode == Mode::RADIUS, "Particle Mode should be Radius"); return modeB.rotatePerSecondVar; } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index be34da3f6e..aa3810dec0 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -40,45 +40,6 @@ NS_CC_BEGIN class ParticleBatchNode; -//* @enum -enum { - /** The Particle emitter lives forever */ - kParticleDurationInfinity = -1, - - /** The starting size of the particle is equal to the ending size */ - kParticleStartSizeEqualToEndSize = -1, - - /** The starting radius of the particle is equal to the ending radius */ - kParticleStartRadiusEqualToEndRadius = -1 -}; - -//* @enum -enum { - /** Gravity mode (A mode) */ - kParticleModeGravity, - - /** Radius mode (B mode) */ - kParticleModeRadius, -}; - - -/** @typedef tPositionType -possible types of particle positions -*/ -typedef enum { - /** Living particles are attached to the world and are unaffected by emitter repositioning. */ - kPositionTypeFree, - - /** Living particles are attached to the world but will follow the emitter repositioning. - Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite. - */ - kPositionTypeRelative, - - /** Living particles are attached to the emitter and are translated along with it. */ - kPositionTypeGrouped, -}tPositionType; - - /** Structure that contains the values of each particle */ @@ -166,6 +127,41 @@ emitter.startSpin = 0; class CC_DLL ParticleSystem : public Node, public TextureProtocol { public: + enum class Mode + { + GRAVITY, + RADIUS, + }; + + /** @typedef PositionType + possible types of particle positions + */ + enum class PositionType + { + /** Living particles are attached to the world and are unaffected by emitter repositioning. */ + FREE, + + /** Living particles are attached to the world but will follow the emitter repositioning. + Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite. + */ + RELATIVE, + + /** Living particles are attached to the emitter and are translated along with it. */ + GROUPED, + }; + + //* @enum + enum { + /** The Particle emitter lives forever */ + DURATION_INFINITY = -1, + + /** The starting size of the particle is equal to the ending size */ + START_SIZE_EQUAL_TO_END_SIZE = -1, + + /** The starting radius of the particle is equal to the ending radius */ + START_RADIUS_EQUAL_TO_END_RADIUS = -1, + }; + /** creates an initializes a ParticleSystem from a plist file. This plist files can be created manually or with Particle Designer: http://particledesigner.71squared.com/ @@ -304,8 +300,8 @@ public: - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kParticleModeRadius: uses radius movement + rotation */ - inline int getEmitterMode() const { return _emitterMode; }; - inline void setEmitterMode(int mode) { _emitterMode = mode; }; + inline Mode getEmitterMode() const { return _emitterMode; }; + inline void setEmitterMode(Mode mode) { _emitterMode = mode; }; /** start size in pixels of each particle */ inline float getStartSize() const { return _startSize; }; @@ -371,8 +367,8 @@ public: /** particles movement type: Free or Grouped @since v0.8 */ - inline tPositionType getPositionType() const { return _positionType; }; - inline void setPositionType(tPositionType type) { _positionType = type; }; + inline PositionType getPositionType() const { return _positionType; }; + inline void setPositionType(PositionType type) { _positionType = type; }; // Overrides virtual void update(float dt) override; @@ -491,7 +487,7 @@ protected: - kParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kParticleModeRadius: uses radius movement + rotation */ - int _emitterMode; + Mode _emitterMode; /** start size in pixels of each particle */ float _startSize; @@ -531,7 +527,7 @@ protected: /** particles movement type: Free or Grouped @since v0.8 */ - tPositionType _positionType; + PositionType _positionType; }; // end of particle_nodes group diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index bb796f4f2a..3adcd4b58c 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -63,7 +63,7 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles) setupVBO(); #endif - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); #if CC_ENABLE_CACHE_TEXTURE_DATA // Need to listen the event only when not use batchnode, because it will use VBO @@ -97,7 +97,7 @@ ParticleSystemQuad::~ParticleSystemQuad() glDeleteBuffers(2, &_buffersVBO[0]); #if CC_TEXTURE_ATLAS_USE_VAO glDeleteVertexArrays(1, &_VAOname); - ccGLBindVAO(0); + GL::bindVAO(0); #endif } @@ -350,8 +350,8 @@ void ParticleSystemQuad::draw() CC_NODE_DRAW_SETUP(); - ccGLBindTexture2D( _texture->getName() ); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::bindTexture2D( _texture->getName() ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad"); @@ -359,7 +359,7 @@ void ParticleSystemQuad::draw() // // Using VBO and VAO // - ccGLBindVAO(_VAOname); + GL::bindVAO(_VAOname); #if CC_REBIND_INDICES_BUFFER glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); @@ -378,15 +378,15 @@ void ParticleSystemQuad::draw() #define kQuadSize sizeof(_quads[0].bl) - ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); // vertices - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); @@ -474,10 +474,10 @@ void ParticleSystemQuad::setupVBOandVAO() // clean VAO glDeleteBuffers(2, &_buffersVBO[0]); glDeleteVertexArrays(1, &_VAOname); - ccGLBindVAO(0); + GL::bindVAO(0); glGenVertexArrays(1, &_VAOname); - ccGLBindVAO(_VAOname); + GL::bindVAO(_VAOname); #define kQuadSize sizeof(_quads[0].bl) @@ -487,22 +487,22 @@ void ParticleSystemQuad::setupVBOandVAO() glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _totalParticles, _quads, GL_DYNAMIC_DRAW); // vertices - glEnableVertexAttribArray(kVertexAttrib_Position); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors - glEnableVertexAttribArray(kVertexAttrib_Color); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(kVertexAttrib_TexCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _totalParticles * 6, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. - ccGLBindVAO(0); + GL::bindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -598,7 +598,7 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode) glDeleteBuffers(2, &_buffersVBO[0]); #if CC_TEXTURE_ATLAS_USE_VAO glDeleteVertexArrays(1, &_VAOname); - ccGLBindVAO(0); + GL::bindVAO(0); #endif } } diff --git a/cocos2dx/platform/CCApplicationProtocol.h b/cocos2dx/platform/CCApplicationProtocol.h index 317fbb5c15..b567072279 100644 --- a/cocos2dx/platform/CCApplicationProtocol.h +++ b/cocos2dx/platform/CCApplicationProtocol.h @@ -3,20 +3,6 @@ NS_CC_BEGIN -enum TargetPlatform -{ - kTargetWindows, - kTargetLinux, - kTargetMacOS, - kTargetAndroid, - kTargetIphone, - kTargetIpad, - kTargetBlackBerry, - kTargetNaCl, - kTargetEmscripten, - kTargetTizen -}; - /** * @addtogroup platform * @{ @@ -26,6 +12,23 @@ class CC_DLL ApplicationProtocol { public: + // Since WINDOWS and ANDROID are defined as macros, we could not just use these keywords in enumeration(Platform). + // Therefore, 'OS_' prefix is added to avoid conflicts with the definitions of system macros. + enum class Platform + { + OS_WINDOWS, + OS_LINUX, + OS_MAC, + OS_ANDROID, + OS_IPHONE, + OS_IPAD, + OS_BLACKBERRY, + OS_NACL, + OS_EMSCRIPTEN, + OS_TIZEN + }; + + virtual ~ApplicationProtocol() {} /** @@ -57,12 +60,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage() = 0; + virtual LanguageType getCurrentLanguage() = 0; /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform() = 0; + virtual Platform getTargetPlatform() = 0; }; // end of platform group diff --git a/cocos2dx/platform/CCCommon.h b/cocos2dx/platform/CCCommon.h index ff98158a14..b83b83efb2 100644 --- a/cocos2dx/platform/CCCommon.h +++ b/cocos2dx/platform/CCCommon.h @@ -55,25 +55,25 @@ void CC_DLL MessageBox(const char * pszMsg, const char * pszTitle); /** @brief Enum the language type supported now */ -typedef enum LanguageType +enum class LanguageType { - kLanguageEnglish = 0, - kLanguageChinese, - kLanguageFrench, - kLanguageItalian, - kLanguageGerman, - kLanguageSpanish, - kLanguageRussian, - kLanguageKorean, - kLanguageJapanese, - kLanguageHungarian, - kLanguagePortuguese, - kLanguageArabic, - kLanguageNorwegian, - kLanguagePolish -} ccLanguageType; + ENGLISH = 0, + CHINESE, + FRENCH, + ITALIAN, + GERMAN, + SPANISH, + RUSSIAN, + KOREAN, + JAPANESE, + HUNGARIAN, + PORTUGUESE, + ARABIC, + NORWEGIAN, + POLISH +}; -// end of platform group +// END of platform group /// @} NS_CC_END diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index fbd0049419..17448f9871 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -46,7 +46,7 @@ EGLViewProtocol::EGLViewProtocol() : _delegate(NULL) , _scaleX(1.0f) , _scaleY(1.0f) -, _resolutionPolicy(kResolutionUnKnown) +, _resolutionPolicy(ResolutionPolicy::UNKNOWN) { } @@ -57,7 +57,7 @@ EGLViewProtocol::~EGLViewProtocol() void EGLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy) { - CCASSERT(resolutionPolicy != kResolutionUnKnown, "should set resolutionPolicy"); + CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy"); if (width == 0.0f || height == 0.0f) { @@ -69,22 +69,22 @@ void EGLViewProtocol::setDesignResolutionSize(float width, float height, Resolut _scaleX = (float)_screenSize.width / _designResolutionSize.width; _scaleY = (float)_screenSize.height / _designResolutionSize.height; - if (resolutionPolicy == kResolutionNoBorder) + if (resolutionPolicy == ResolutionPolicy::NO_BORDER) { _scaleX = _scaleY = MAX(_scaleX, _scaleY); } - if (resolutionPolicy == kResolutionShowAll) + if (resolutionPolicy == ResolutionPolicy::SHOW_ALL) { _scaleX = _scaleY = MIN(_scaleX, _scaleY); } - if ( resolutionPolicy == kResolutionFixedHeight) { + if ( resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) { _scaleX = _scaleY; _designResolutionSize.width = ceilf(_screenSize.width/_scaleX); } - if ( resolutionPolicy == kResolutionFixedWidth) { + if ( resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) { _scaleY = _scaleX; _designResolutionSize.height = ceilf(_screenSize.height/_scaleY); } @@ -120,7 +120,7 @@ void EGLViewProtocol::setFrameSize(float width, float height) Size EGLViewProtocol::getVisibleSize() const { - if (_resolutionPolicy == kResolutionNoBorder) + if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) { return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY); } @@ -132,7 +132,7 @@ Size EGLViewProtocol::getVisibleSize() const Point EGLViewProtocol::getVisibleOrigin() const { - if (_resolutionPolicy == kResolutionNoBorder) + if (_resolutionPolicy == ResolutionPolicy::NO_BORDER) { return Point((_designResolutionSize.width - _screenSize.width/_scaleX)/2, (_designResolutionSize.height - _screenSize.height/_scaleY)/2); diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index c5aad7f507..5cfb959032 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -3,29 +3,29 @@ #include "ccTypes.h" -enum ResolutionPolicy +enum class ResolutionPolicy { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. // Distortion can occur, and the application may appear stretched or compressed. - kResolutionExactFit, + EXACT_FIT, // The entire application fills the specified area, without distortion but possibly with some cropping, // while maintaining the original aspect ratio of the application. - kResolutionNoBorder, + NO_BORDER, // The entire application is visible in the specified area without distortion while maintaining the original // aspect ratio of the application. Borders can appear on two sides of the application. - kResolutionShowAll, + SHOW_ALL, // The application takes the height of the design resolution size and modifies the width of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios - kResolutionFixedHeight, + FIXED_HEIGHT, // The application takes the width of the design resolution size and modifies the height of the internal // canvas so that it fits the aspect ratio of the device // no distortion will occur however you must make sure your application works on different // aspect ratios - kResolutionFixedWidth, + FIXED_WIDTH, - kResolutionUnKnown, + UNKNOWN, }; NS_CC_BEGIN @@ -84,9 +84,9 @@ public: * @param width Design resolution width. * @param height Design resolution height. * @param resolutionPolicy The resolution policy desired, you may choose: - * [1] kResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched. - * [2] kResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut. - * [3] kResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown. + * [1] EXACT_FIT Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched. + * [2] NO_BORDER Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut. + * [3] SHOW_ALL Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown. */ virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); diff --git a/cocos2dx/platform/CCFileUtils.cpp b/cocos2dx/platform/CCFileUtils.cpp index 5f0e25007d..7b14c6dafe 100644 --- a/cocos2dx/platform/CCFileUtils.cpp +++ b/cocos2dx/platform/CCFileUtils.cpp @@ -498,15 +498,15 @@ void FileUtils::purgeCachedEntries() _fullPathCache.clear(); } -unsigned char* FileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtils::getFileData(const char* filename, const char* pszMode, unsigned long * pSize) { unsigned char * pBuffer = NULL; - CCASSERT(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters."); + CCASSERT(filename != NULL && pSize != NULL && pszMode != NULL, "Invalid parameters."); *pSize = 0; do { // read the file from hardware - std::string fullPath = fullPathForFilename(pszFileName); + std::string fullPath = fullPathForFilename(filename); FILE *fp = fopen(fullPath.c_str(), pszMode); CC_BREAK_IF(!fp); @@ -521,14 +521,14 @@ unsigned char* FileUtils::getFileData(const char* pszFileName, const char* pszMo if (! pBuffer) { std::string msg = "Get data from file("; - msg.append(pszFileName).append(") failed!"); + msg.append(filename).append(") failed!"); CCLOG("%s", msg.c_str()); } return pBuffer; } -unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize) +unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long * pSize) { unsigned char * pBuffer = NULL; unzFile pFile = NULL; @@ -536,13 +536,13 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c do { - CC_BREAK_IF(!pszZipFilePath || !pszFileName); + CC_BREAK_IF(!pszZipFilePath || !filename); CC_BREAK_IF(strlen(pszZipFilePath) == 0); pFile = unzOpen(pszZipFilePath); CC_BREAK_IF(!pFile); - int nRet = unzLocateFile(pFile, pszFileName, 1); + int nRet = unzLocateFile(pFile, filename, 1); CC_BREAK_IF(UNZ_OK != nRet); char szFilePathA[260]; @@ -569,13 +569,13 @@ unsigned char* FileUtils::getFileDataFromZip(const char* pszZipFilePath, const c return pBuffer; } -std::string FileUtils::getNewFilename(const char* pszFileName) +std::string FileUtils::getNewFilename(const char* filename) { const char* pszNewFileName = NULL; // in Lookup Filename dictionary ? - String* fileNameFound = _filenameLookupDict ? (String*)_filenameLookupDict->objectForKey(pszFileName) : NULL; + String* fileNameFound = _filenameLookupDict ? (String*)_filenameLookupDict->objectForKey(filename) : NULL; if( NULL == fileNameFound || fileNameFound->length() == 0) { - pszNewFileName = pszFileName; + pszNewFileName = filename; } else { pszNewFileName = fileNameFound->getCString(); @@ -607,19 +607,19 @@ std::string FileUtils::getPathForFilename(const std::string& filename, const std } -std::string FileUtils::fullPathForFilename(const char* pszFileName) +std::string FileUtils::fullPathForFilename(const char* filename) { - CCASSERT(pszFileName != NULL, "CCFileUtils: Invalid path"); + CCASSERT(filename != NULL, "CCFileUtils: Invalid path"); - std::string strFileName = pszFileName; - if (isAbsolutePath(pszFileName)) + std::string strFileName = filename; + if (isAbsolutePath(filename)) { - //CCLOG("Return absolute path( %s ) directly.", pszFileName); - return pszFileName; + //CCLOG("Return absolute path( %s ) directly.", filename); + return filename; } // Already Cached ? - std::map::iterator cacheIter = _fullPathCache.find(pszFileName); + std::map::iterator cacheIter = _fullPathCache.find(filename); if (cacheIter != _fullPathCache.end()) { //CCLOG("Return full path from cache: %s", cacheIter->second.c_str()); @@ -627,7 +627,7 @@ std::string FileUtils::fullPathForFilename(const char* pszFileName) } // Get the new file name. - std::string newFilename = getNewFilename(pszFileName); + std::string newFilename = getNewFilename(filename); string fullpath = ""; @@ -643,25 +643,25 @@ std::string FileUtils::fullPathForFilename(const char* pszFileName) if (fullpath.length() > 0) { // Using the filename passed in as key. - _fullPathCache.insert(std::pair(pszFileName, fullpath)); + _fullPathCache.insert(std::pair(filename, fullpath)); // CCLOG("Returning path: %s", fullpath.c_str()); return fullpath; } } } -// CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", pszFileName); +// CCLOG("cocos2d: fullPathForFilename: No file found at %s. Possible missing file.", filename); // The file wasn't found, return the file name passed in. - return pszFileName; + return filename; } -const char* FileUtils::fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile) +const char* FileUtils::fullPathFromRelativeFile(const char *filename, const char *pszRelativeFile) { std::string relativeFile = pszRelativeFile; String *pRet = String::create(""); pRet->_string = relativeFile.substr(0, relativeFile.rfind('/')+1); - pRet->_string += getNewFilename(pszFilename); + pRet->_string += getNewFilename(filename); return pRet->getCString(); } diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index a5681b6902..ec01aba5ab 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -90,23 +90,23 @@ public: /** * Gets resource file data * - * @param[in] pszFileName The resource file name which contains the path. + * @param[in] filename The resource file name which contains the path. * @param[in] pszMode The read mode of the file. * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); + virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); /** * Gets resource file data from a zip file. * - * @param[in] pszFileName The resource file name which contains the relative path of the zip file. + * @param[in] filename The resource file name which contains the relative path of the zip file. * @param[out] pSize If the file read operation succeeds, it will be the data size, otherwise 0. * @return Upon success, a pointer to the data is returned, otherwise NULL. * @warning Recall: you are responsible for calling delete[] on any Non-NULL pointer returned. */ - virtual unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); + virtual unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* filename, unsigned long * pSize); /** Returns the fullpath for a given filename. @@ -147,14 +147,14 @@ public: internal_dir/gamescene/uilayer/resources-iphonehd/sprite.pvr.gz (if not found, search next) internal_dir/gamescene/uilayer/sprite.pvr.gz (if not found, return "gamescene/uilayer/sprite.png") - If the new file can't be found on the file system, it will return the parameter pszFileName directly. + If the new file can't be found on the file system, it will return the parameter filename directly. This method was added to simplify multiplatform support. Whether you are using cocos2d-js or any cross-compilation toolchain like StellaSDK or Apportable, you might need to load different resources for a given file in the different platforms. @since v2.1 */ - virtual std::string fullPathForFilename(const char* pszFileName); + virtual std::string fullPathForFilename(const char* filename); /** * Loads the filenameLookup dictionary from the contents of a filename. @@ -199,14 +199,14 @@ public: /** * Gets full path from a file name and the path of the reletive file. - * @param pszFilename The file name. + * @param filename The file name. * @param pszRelativeFile The path of the relative file. * @return The full path. - * e.g. pszFilename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist + * e.g. filename: hello.png, pszRelativeFile: /User/path1/path2/hello.plist * Return: /User/path1/path2/hello.pvr (If there a a key(hello.png)-value(hello.pvr) in FilenameLookup dictionary. ) * */ - virtual const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); + virtual const char* fullPathFromRelativeFile(const char *filename, const char *pszRelativeFile); /** * Sets the array that contains the search order of the resources. @@ -318,11 +318,11 @@ protected: /** * Gets the new filename from the filename lookup dictionary. - * @param pszFileName The original filename. + * @param filename The original filename. * @return The new filename after searching in the filename lookup dictionary. * If the original filename wasn't in the dictionary, it will return the original filename. */ - virtual std::string getNewFilename(const char* pszFileName); + virtual std::string getNewFilename(const char* filename); /** * Gets full path for filename, resolution directory and search path. diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index dd2895a511..8c09f89269 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -50,15 +50,22 @@ public: Image(); virtual ~Image(); - typedef enum + /** Supported formats for Image */ + enum class Format { - kFmtJpg = 0, - kFmtPng, - kFmtTiff, - kFmtWebp, - kFmtRawData, - kFmtUnKnown - }EImageFormat; + //! JPEG + JPG, + //! PNG + PNG, + //! TIFF + TIFF, + //! WebP + WEBP, + //! Raw Data + RAW_DATA, + //! Unknown format + UNKOWN + }; typedef enum { @@ -79,7 +86,7 @@ public: @param imageType the type of image, currently only supporting two types. @return true if loaded correctly. */ - bool initWithImageFile(const char * strPath, EImageFormat imageType = kFmtPng); + bool initWithImageFile(const char * strPath, Format imageType = Format::PNG); /** @brief Load image from stream buffer. @@ -92,7 +99,7 @@ public: */ bool initWithImageData(void * pData, int nDataLen, - EImageFormat eFmt = kFmtUnKnown, + Format eFmt = Format::UNKOWN, int nWidth = 0, int nHeight = 0, int nBitsPerComponent = 8); @@ -165,13 +172,13 @@ public: // protected: - bool _initWithJpgData(void *pData, int nDatalen); - bool _initWithPngData(void *pData, int nDatalen); - bool _initWithTiffData(void *pData, int nDataLen); - bool _initWithWebpData(void *pData, int nDataLen); + bool initWithJpgData(void *pData, int nDatalen); + bool initWithPngData(void *pData, int nDatalen); + bool initWithTiffData(void *pData, int nDataLen); + bool initWithWebpData(void *pData, int nDataLen); - bool _saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true); - bool _saveImageToJPG(const char *pszFilePath); + bool saveImageToPNG(const char *pszFilePath, bool bIsToRGB = true); + bool saveImageToJPG(const char *pszFilePath); unsigned short _width; unsigned short _height; @@ -194,7 +201,7 @@ private: @param imageType the type of image, currently only supporting two types. @return true if loaded correctly. */ - bool initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType = kFmtPng); + bool initWithImageFileThreadSafe(const char *fullpath, Format imageType = Format::PNG); }; // end of platform group diff --git a/cocos2dx/platform/CCImageCommonWebp.cpp b/cocos2dx/platform/CCImageCommonWebp.cpp index aef2bfc47e..45f181d194 100644 --- a/cocos2dx/platform/CCImageCommonWebp.cpp +++ b/cocos2dx/platform/CCImageCommonWebp.cpp @@ -38,7 +38,7 @@ NS_CC_BEGIN -bool Image::_initWithWebpData(void *pData, int nDataLen) +bool Image::initWithWebpData(void *pData, int nDataLen) { bool bRet = false; do diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index b68ff02c40..bdd3d40121 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -91,16 +91,17 @@ Image::~Image() CC_SAFE_DELETE_ARRAY(_data); } -bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) +bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/) { bool bRet = false; + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath); #ifdef EMSCRIPTEN // Emscripten includes a re-implementation of SDL that uses HTML5 canvas // operations underneath. Consequently, loading images via IMG_Load (an SDL // API) will be a lot faster than running libpng et al as compiled with // Emscripten. - SDL_Surface *iSurf = IMG_Load(strPath); + SDL_Surface *iSurf = IMG_Load(fullPath.c_str()); int size = 4 * (iSurf->w * iSurf->h); bRet = initWithRawData((void*)iSurf->pixels, size, iSurf->w, iSurf->h, 8, true); @@ -116,7 +117,6 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm SDL_FreeSurface(iSurf); #else unsigned long nSize = 0; - std::string fullPath = FileUtils::getInstance()->fullPathForFilename(strPath); unsigned char* pBuffer = FileUtils::getInstance()->getFileData(fullPath.c_str(), "rb", &nSize); if (pBuffer != NULL && nSize > 0) { @@ -128,7 +128,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm return bRet; } -bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) +bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType) { bool bRet = false; unsigned long nSize = 0; @@ -148,7 +148,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image bool Image::initWithImageData(void * pData, int nDataLen, - EImageFormat eFmt/* = eSrcFmtPng*/, + Format eFmt/* = eSrcFmtPng*/, int nWidth/* = 0*/, int nHeight/* = 0*/, int nBitsPerComponent/* = 8*/) @@ -158,27 +158,27 @@ bool Image::initWithImageData(void * pData, { CC_BREAK_IF(! pData || nDataLen <= 0); - if (kFmtPng == eFmt) + if (Format::PNG == eFmt) { - bRet = _initWithPngData(pData, nDataLen); + bRet = initWithPngData(pData, nDataLen); break; } - else if (kFmtJpg == eFmt) + else if (Format::JPG == eFmt) { - bRet = _initWithJpgData(pData, nDataLen); + bRet = initWithJpgData(pData, nDataLen); break; } - else if (kFmtTiff == eFmt) + else if (Format::TIFF == eFmt) { - bRet = _initWithTiffData(pData, nDataLen); + bRet = initWithTiffData(pData, nDataLen); break; } - else if (kFmtWebp == eFmt) + else if (Format::WEBP == eFmt) { - bRet = _initWithWebpData(pData, nDataLen); + bRet = initWithWebpData(pData, nDataLen); break; } - else if (kFmtRawData == eFmt) + else if (Format::RAW_DATA == eFmt) { bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); break; @@ -198,7 +198,7 @@ bool Image::initWithImageData(void * pData, && pHead[6] == 0x1A && pHead[7] == 0x0A) { - bRet = _initWithPngData(pData, nDataLen); + bRet = initWithPngData(pData, nDataLen); break; } } @@ -211,7 +211,7 @@ bool Image::initWithImageData(void * pData, || (pHead[0] == 0x4d && pHead[1] == 0x4d) ) { - bRet = _initWithTiffData(pData, nDataLen); + bRet = initWithTiffData(pData, nDataLen); break; } } @@ -223,7 +223,7 @@ bool Image::initWithImageData(void * pData, if ( pHead[0] == 0xff && pHead[1] == 0xd8) { - bRet = _initWithJpgData(pData, nDataLen); + bRet = initWithJpgData(pData, nDataLen); break; } } @@ -281,7 +281,7 @@ my_error_exit (j_common_ptr cinfo) longjmp(myerr->setjmp_buffer, 1); } -bool Image::_initWithJpgData(void * data, int nSize) +bool Image::initWithJpgData(void * data, int nSize) { /* these are standard libjpeg structures for reading(decompression) */ struct jpeg_decompress_struct cinfo; @@ -378,7 +378,7 @@ bool Image::_initWithJpgData(void * data, int nSize) return bRet; } -bool Image::_initWithPngData(void * pData, int nDatalen) +bool Image::initWithPngData(void * pData, int nDatalen) { // length of bytes to check if it is a valid png file #define PNGSIGSIZE 8 @@ -611,7 +611,7 @@ static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size) CC_UNUSED_PARAM(size); } -bool Image::_initWithTiffData(void* pData, int nDataLen) +bool Image::initWithTiffData(void* pData, int nDataLen) { bool bRet = false; do @@ -726,11 +726,11 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB) if (std::string::npos != strLowerCasePath.find(".png")) { - CC_BREAK_IF(!_saveImageToPNG(pszFilePath, bIsToRGB)); + CC_BREAK_IF(!saveImageToPNG(pszFilePath, bIsToRGB)); } else if (std::string::npos != strLowerCasePath.find(".jpg")) { - CC_BREAK_IF(!_saveImageToJPG(pszFilePath)); + CC_BREAK_IF(!saveImageToJPG(pszFilePath)); } else { @@ -743,7 +743,7 @@ bool Image::saveToFile(const char *pszFilePath, bool bIsToRGB) return bRet; } -bool Image::_saveImageToPNG(const char * pszFilePath, bool bIsToRGB) +bool Image::saveImageToPNG(const char * pszFilePath, bool bIsToRGB) { bool bRet = false; do @@ -883,7 +883,7 @@ bool Image::_saveImageToPNG(const char * pszFilePath, bool bIsToRGB) } while (0); return bRet; } -bool Image::_saveImageToJPG(const char * pszFilePath) +bool Image::saveImageToJPG(const char * pszFilePath) { bool bRet = false; do diff --git a/cocos2dx/platform/android/CCApplication.cpp b/cocos2dx/platform/android/CCApplication.cpp index 215af4c8f8..abb5f54044 100644 --- a/cocos2dx/platform/android/CCApplication.cpp +++ b/cocos2dx/platform/android/CCApplication.cpp @@ -67,74 +67,74 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { std::string languageName = getCurrentLanguageJNI(); const char* pLanguageName = languageName.c_str(); - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; if (0 == strcmp("zh", pLanguageName)) { - ret = kLanguageChinese; + ret = LanguageType::CHINESE; } else if (0 == strcmp("en", pLanguageName)) { - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH; } else if (0 == strcmp("fr", pLanguageName)) { - ret = kLanguageFrench; + ret = LanguageType::FRENCH; } else if (0 == strcmp("it", pLanguageName)) { - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; } else if (0 == strcmp("de", pLanguageName)) { - ret = kLanguageGerman; + ret = LanguageType::GERMAN; } else if (0 == strcmp("es", pLanguageName)) { - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; } else if (0 == strcmp("ru", pLanguageName)) { - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; } else if (0 == strcmp("ko", pLanguageName)) { - ret = kLanguageKorean; + ret = LanguageType::KOREAN; } else if (0 == strcmp("ja", pLanguageName)) { - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; } else if (0 == strcmp("hu", pLanguageName)) { - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; } else if (0 == strcmp("pt", pLanguageName)) { - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; } else if (0 == strcmp("ar", pLanguageName)) { - ret = kLanguageArabic; + ret = LanguageType::ARABIC; } - else if (0 == strcmp("nb", pLanguageName)) + else if (0 == strcmp("nb", pLanguageName)) { - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; } else if (0 == strcmp("pl", pLanguageName)) { - ret = kLanguagePolish; + ret = LanguageType::POLISH; } return ret; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetAndroid; + return Platform::OS_ANDROID; } NS_CC_END diff --git a/cocos2dx/platform/android/CCApplication.h b/cocos2dx/platform/android/CCApplication.h index a2a431e220..d3225516f2 100644 --- a/cocos2dx/platform/android/CCApplication.h +++ b/cocos2dx/platform/android/CCApplication.h @@ -38,12 +38,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); protected: static Application * sm_pSharedApplication; diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp index 6b0683bd6c..56cda63c06 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.cpp +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.cpp @@ -59,7 +59,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsAndroid(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsAndroid"); + } } return s_sharedFileUtils; } @@ -132,35 +137,35 @@ bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) } -unsigned char* FileUtilsAndroid::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileData(const char* filename, const char* pszMode, unsigned long * pSize) { - return doGetFileData(pszFileName, pszMode, pSize, false); + return doGetFileData(filename, pszMode, pSize, false); } -unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* pszFileName, const char* pszMode, unsigned long * pSize) +unsigned char* FileUtilsAndroid::getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize) { - return doGetFileData(pszFileName, pszMode, pSize, true); + return doGetFileData(filename, pszMode, pSize, true); } -unsigned char* FileUtilsAndroid::doGetFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize, bool forAsync) +unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync) { unsigned char * pData = 0; - if ((! pszFileName) || (! pszMode) || 0 == strlen(pszFileName)) + if ((! filename) || (! pszMode) || 0 == strlen(filename)) { return 0; } - string fullPath = fullPathForFilename(pszFileName); + string fullPath = fullPathForFilename(filename); if (fullPath[0] != '/') { - string fullPath(pszFileName); + string fullPath(filename); // fullPathForFilename is not thread safe. if (! forAsync) { - fullPath = fullPathForFilename(pszFileName); + fullPath = fullPathForFilename(filename); } const char* relativepath = fullPath.c_str(); @@ -200,7 +205,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* pszFileName, const ch do { // read rrom other path than user set it - //CCLOG("GETTING FILE ABSOLUTE DATA: %s", pszFileName); + //CCLOG("GETTING FILE ABSOLUTE DATA: %s", filename); FILE *fp = fopen(fullPath.c_str(), pszMode); CC_BREAK_IF(!fp); @@ -222,7 +227,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* pszFileName, const ch if (! pData) { std::string msg = "Get data from file("; - msg.append(pszFileName).append(") failed!"); + msg.append(filename).append(") failed!"); CCLOG(msg.c_str()); } diff --git a/cocos2dx/platform/android/CCFileUtilsAndroid.h b/cocos2dx/platform/android/CCFileUtilsAndroid.h index 7c2ff207d3..e137ffe9ac 100644 --- a/cocos2dx/platform/android/CCFileUtilsAndroid.h +++ b/cocos2dx/platform/android/CCFileUtilsAndroid.h @@ -54,7 +54,7 @@ public: /* override funtions */ bool init(); - virtual unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); + virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize); virtual std::string getWritablePath(); virtual bool isFileExist(const std::string& strFilePath); virtual bool isAbsolutePath(const std::string& strPath); @@ -62,10 +62,10 @@ public: /** This function is android specific. It is used for TextureCache::addImageAsync(). Don't use it in your codes. */ - unsigned char* getFileDataForAsync(const char* pszFileName, const char* pszMode, unsigned long * pSize); + unsigned char* getFileDataForAsync(const char* filename, const char* pszMode, unsigned long * pSize); private: - unsigned char* doGetFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize, bool forAsync); + unsigned char* doGetFileData(const char* filename, const char* pszMode, unsigned long * pSize, bool forAsync); }; // end of platform group diff --git a/cocos2dx/platform/emscripten/CCApplication.cpp b/cocos2dx/platform/emscripten/CCApplication.cpp index 2c3b98b54d..cf78ff625b 100644 --- a/cocos2dx/platform/emscripten/CCApplication.cpp +++ b/cocos2dx/platform/emscripten/CCApplication.cpp @@ -85,9 +85,9 @@ const std::string& Application::getResourceRootPath(void) return _resourceRootPath; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetEmscripten; + return Platform::OS_EMSCRIPTEN; } ////////////////////////////////////////////////////////////////////////// @@ -105,9 +105,9 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { - return kLanguageEnglish; + return LanguageType::ENGLISH; } NS_CC_END; diff --git a/cocos2dx/platform/emscripten/CCApplication.h b/cocos2dx/platform/emscripten/CCApplication.h index 396b6046ae..634238606f 100644 --- a/cocos2dx/platform/emscripten/CCApplication.h +++ b/cocos2dx/platform/emscripten/CCApplication.h @@ -38,12 +38,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); /** diff --git a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp index 6e1094ff7d..f21ff121fa 100644 --- a/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp +++ b/cocos2dx/platform/emscripten/CCFileUtilsEmscripten.cpp @@ -14,7 +14,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsEmscripten(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsEmscripten"); + } } return s_sharedFileUtils; } @@ -24,7 +29,7 @@ FileUtilsEmscripten::FileUtilsEmscripten() bool FileUtilsEmscripten::init() { - _defaultResRootPath = "app/native/Resources/"; + _defaultResRootPath = "/"; return FileUtils::init(); } diff --git a/cocos2dx/platform/ios/CCApplication.h b/cocos2dx/platform/ios/CCApplication.h index 8a7451dff2..297ddbd8c3 100644 --- a/cocos2dx/platform/ios/CCApplication.h +++ b/cocos2dx/platform/ios/CCApplication.h @@ -49,7 +49,7 @@ public: */ static Application* getInstance(); - /** @deprecated Use getInstance() instead */ + /** @deprecated Use getInstance() instead */ CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /** @@ -62,12 +62,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); protected: static Application * sm_pSharedApplication; diff --git a/cocos2dx/platform/ios/CCApplication.mm b/cocos2dx/platform/ios/CCApplication.mm index 1f118009ed..8c8d543c2e 100644 --- a/cocos2dx/platform/ios/CCApplication.mm +++ b/cocos2dx/platform/ios/CCApplication.mm @@ -75,7 +75,7 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { // get the current language and country config NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -86,63 +86,63 @@ ccLanguageType Application::getCurrentLanguage() NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; if ([languageCode isEqualToString:@"zh"]) { - ret = kLanguageChinese; + ret = LanguageType::CHINESE; } else if ([languageCode isEqualToString:@"en"]) { - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH; } else if ([languageCode isEqualToString:@"fr"]){ - ret = kLanguageFrench; + ret = LanguageType::FRENCH; } else if ([languageCode isEqualToString:@"it"]){ - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; } else if ([languageCode isEqualToString:@"de"]){ - ret = kLanguageGerman; + ret = LanguageType::GERMAN; } else if ([languageCode isEqualToString:@"es"]){ - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; } else if ([languageCode isEqualToString:@"ru"]){ - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; } else if ([languageCode isEqualToString:@"ko"]){ - ret = kLanguageKorean; + ret = LanguageType::KOREAN; } else if ([languageCode isEqualToString:@"ja"]){ - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; } else if ([languageCode isEqualToString:@"hu"]){ - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; } else if ([languageCode isEqualToString:@"pt"]){ - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; } else if ([languageCode isEqualToString:@"ar"]){ - ret = kLanguageArabic; + ret = LanguageType::ARABIC; } else if ([languageCode isEqualToString:@"nb"]){ - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; } else if ([languageCode isEqualToString:@"pl"]){ - ret = kLanguagePolish; + ret = LanguageType::POLISH; } return ret; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // idiom for iOS <= 3.2, otherwise: [UIDevice userInterfaceIdiom] is faster. { - return kTargetIpad; + return Platform::OS_IPAD; } else { - return kTargetIphone; + return Platform::OS_IPHONE; } } diff --git a/cocos2dx/platform/ios/CCEGLView.mm b/cocos2dx/platform/ios/CCEGLView.mm index e9e0eec5ad..c302bdf149 100644 --- a/cocos2dx/platform/ios/CCEGLView.mm +++ b/cocos2dx/platform/ios/CCEGLView.mm @@ -48,7 +48,7 @@ bool EGLView::isOpenGLReady() bool EGLView::setContentScaleFactor(float contentScaleFactor) { - assert(_resolutionPolicy == kResolutionUnKnown); // cannot enable retina mode + assert(_resolutionPolicy == ResolutionPolicy::UNKNOWN); // cannot enable retina mode _scaleX = _scaleY = contentScaleFactor; [[CCEAGLView sharedEGLView] setNeedsLayout]; diff --git a/cocos2dx/platform/ios/CCFileUtilsIOS.mm b/cocos2dx/platform/ios/CCFileUtilsIOS.mm index 5eb9e0e772..519353c367 100644 --- a/cocos2dx/platform/ios/CCFileUtilsIOS.mm +++ b/cocos2dx/platform/ios/CCFileUtilsIOS.mm @@ -213,7 +213,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsIOS(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsIOS"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 857c8160a0..3a81c61c7c 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -416,7 +416,7 @@ Image::~Image() CC_SAFE_DELETE_ARRAY(_data); } -bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) +bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/) { bool bRet = false; unsigned long nSize = 0; @@ -433,7 +433,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm return bRet; } -bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) +bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType) { /* * FileUtils::fullPathFromRelativePath() is not thread-safe. @@ -451,7 +451,7 @@ bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat image bool Image::initWithImageData(void * pData, int nDataLen, - EImageFormat eFmt, + Format eFmt, int nWidth, int nHeight, int nBitsPerComponent) @@ -465,13 +465,13 @@ bool Image::initWithImageData(void * pData, do { CC_BREAK_IF(! pData || nDataLen <= 0); - if (eFmt == kFmtRawData) + if (eFmt == Format::RAW_DATA) { bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); } - else if (eFmt == kFmtWebp) + else if (eFmt == Format::WEBP) { - bRet = _initWithWebpData(pData, nDataLen); + bRet = initWithWebpData(pData, nDataLen); } else // init with png or jpg file data { @@ -515,25 +515,25 @@ bool Image::initWithRawData(void *pData, int nDatalen, int nWidth, int nHeight, return bRet; } -bool Image::_initWithJpgData(void *pData, int nDatalen) +bool Image::initWithJpgData(void *pData, int nDatalen) { assert(0); return false; } -bool Image::_initWithPngData(void *pData, int nDatalen) +bool Image::initWithPngData(void *pData, int nDatalen) { assert(0); return false; } -bool Image::_saveImageToPNG(const char *pszFilePath, bool bIsToRGB) +bool Image::saveImageToPNG(const char *pszFilePath, bool bIsToRGB) { assert(0); return false; } -bool Image::_saveImageToJPG(const char *pszFilePath) +bool Image::saveImageToJPG(const char *pszFilePath) { assert(0); return false; diff --git a/cocos2dx/platform/linux/CCApplication.cpp b/cocos2dx/platform/linux/CCApplication.cpp index 8b3f6f6f32..93232a7643 100644 --- a/cocos2dx/platform/linux/CCApplication.cpp +++ b/cocos2dx/platform/linux/CCApplication.cpp @@ -84,9 +84,9 @@ const std::string& Application::getResourceRootPath(void) return _resourceRootPath; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetLinux; + return Platform::OS_LINUX; } ////////////////////////////////////////////////////////////////////////// @@ -104,75 +104,75 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { char *pLanguageName = getenv("LANG"); - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; if (!pLanguageName) { - return kLanguageEnglish; + return LanguageType::ENGLISH; } strtok(pLanguageName, "_"); if (!pLanguageName) { - return kLanguageEnglish; + return LanguageType::ENGLISH; } if (0 == strcmp("zh", pLanguageName)) { - ret = kLanguageChinese; + ret = LanguageType::CHINESE; } else if (0 == strcmp("en", pLanguageName)) { - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH; } else if (0 == strcmp("fr", pLanguageName)) { - ret = kLanguageFrench; + ret = LanguageType::FRENCH; } else if (0 == strcmp("it", pLanguageName)) { - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; } else if (0 == strcmp("de", pLanguageName)) { - ret = kLanguageGerman; + ret = LanguageType::GERMAN; } else if (0 == strcmp("es", pLanguageName)) { - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; } else if (0 == strcmp("ru", pLanguageName)) { - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; } else if (0 == strcmp("ko", pLanguageName)) { - ret = kLanguageKorean; + ret = LanguageType::KOREAN; } else if (0 == strcmp("ja", pLanguageName)) { - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; } else if (0 == strcmp("hu", pLanguageName)) { - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; } else if (0 == strcmp("pt", pLanguageName)) { - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; } else if (0 == strcmp("ar", pLanguageName)) { - ret = kLanguageArabic; + ret = LanguageType::ARABIC; } else if (0 == strcmp("nb", pLanguageName)) { - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; } else if (0 == strcmp("pl", pLanguageName)) { - ret = kLanguagePolish; + ret = LanguageType::POLISH; } return ret; diff --git a/cocos2dx/platform/linux/CCApplication.h b/cocos2dx/platform/linux/CCApplication.h index 2d5c92c750..1320a50ce8 100644 --- a/cocos2dx/platform/linux/CCApplication.h +++ b/cocos2dx/platform/linux/CCApplication.h @@ -42,7 +42,7 @@ public: CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /* override functions */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** * Sets the Resource root path. @@ -59,7 +59,7 @@ public: /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); protected: long _animationInterval; //micro second std::string _resourceRootPath; diff --git a/cocos2dx/platform/linux/CCFileUtilsLinux.cpp b/cocos2dx/platform/linux/CCFileUtilsLinux.cpp index d8d19a25ea..90ff1e0e04 100644 --- a/cocos2dx/platform/linux/CCFileUtilsLinux.cpp +++ b/cocos2dx/platform/linux/CCFileUtilsLinux.cpp @@ -23,7 +23,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsLinux(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsLinux"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/mac/CCApplication.h b/cocos2dx/platform/mac/CCApplication.h index ad31dcb097..ada3d28c0f 100644 --- a/cocos2dx/platform/mac/CCApplication.h +++ b/cocos2dx/platform/mac/CCApplication.h @@ -65,12 +65,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); /** * Sets the Resource root path. diff --git a/cocos2dx/platform/mac/CCApplication.mm b/cocos2dx/platform/mac/CCApplication.mm index 226665d3dd..62047a3d4f 100644 --- a/cocos2dx/platform/mac/CCApplication.mm +++ b/cocos2dx/platform/mac/CCApplication.mm @@ -60,9 +60,9 @@ void Application::setAnimationInterval(double interval) [[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ]; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetMacOS; + return Platform::OS_MAC; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -81,7 +81,7 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { // get the current language and country config NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -92,52 +92,52 @@ ccLanguageType Application::getCurrentLanguage() NSDictionary* temp = [NSLocale componentsFromLocaleIdentifier:currentLanguage]; NSString * languageCode = [temp objectForKey:NSLocaleLanguageCode]; - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; if ([languageCode isEqualToString:@"zh"]) { - ret = kLanguageChinese; + ret = LanguageType::CHINESE; } else if ([languageCode isEqualToString:@"en"]) { - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH;; } else if ([languageCode isEqualToString:@"fr"]){ - ret = kLanguageFrench; + ret = LanguageType::FRENCH; } else if ([languageCode isEqualToString:@"it"]){ - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; } else if ([languageCode isEqualToString:@"de"]){ - ret = kLanguageGerman; + ret = LanguageType::GERMAN; } else if ([languageCode isEqualToString:@"es"]){ - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; } else if ([languageCode isEqualToString:@"ru"]){ - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; } else if ([languageCode isEqualToString:@"ko"]){ - ret = kLanguageKorean; + ret = LanguageType::KOREAN; } else if ([languageCode isEqualToString:@"ja"]){ - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; } else if ([languageCode isEqualToString:@"hu"]){ - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; } else if ([languageCode isEqualToString:@"pt"]) { - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; } else if ([languageCode isEqualToString:@"ar"]) { - ret = kLanguageArabic; + ret = LanguageType::ARABIC; } else if ([languageCode isEqualToString:@"nb"]){ - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; } else if ([languageCode isEqualToString:@"pl"]){ - ret = kLanguagePolish; + ret = LanguageType::POLISH; } return ret; } diff --git a/cocos2dx/platform/mac/CCFileUtilsMac.mm b/cocos2dx/platform/mac/CCFileUtilsMac.mm index 03766ee554..426a42149c 100644 --- a/cocos2dx/platform/mac/CCFileUtilsMac.mm +++ b/cocos2dx/platform/mac/CCFileUtilsMac.mm @@ -210,7 +210,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsMac(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsMac"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/mac/CCImage.mm b/cocos2dx/platform/mac/CCImage.mm index 83913abd7b..424d400232 100644 --- a/cocos2dx/platform/mac/CCImage.mm +++ b/cocos2dx/platform/mac/CCImage.mm @@ -68,7 +68,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT bool hasAlpha; CGImageAlphaInfo info; CGSize imageSize; - Texture2DPixelFormat pixelFormat; + Texture2D::PixelFormat pixelFormat; info = CGImageGetAlphaInfo(image); hasAlpha = ((info == kCGImageAlphaPremultipliedLast) || (info == kCGImageAlphaPremultipliedFirst) || (info == kCGImageAlphaLast) || (info == kCGImageAlphaFirst) ? YES : NO); @@ -80,17 +80,17 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT { if(hasAlpha || bpp >= 8) { - pixelFormat = kTexture2DPixelFormat_Default; + pixelFormat = Texture2D::PixelFormat::DEFAULT; } else { - pixelFormat = kTexture2DPixelFormat_RGB565; + pixelFormat = Texture2D::PixelFormat::RGB565; } } else { // NOTE: No colorspace means a mask image - pixelFormat = kTexture2DPixelFormat_A8; + pixelFormat = Texture2D::PixelFormat::A8; } imageSize.width = CGImageGetWidth(image); @@ -100,9 +100,9 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT switch(pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: - case kTexture2DPixelFormat_RGBA4444: - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGBA8888: + case Texture2D::PixelFormat::RGBA4444: + case Texture2D::PixelFormat::RGB5A1: colorSpace = CGColorSpaceCreateDeviceRGB(); data = new unsigned char[POTHigh * POTWide * 4]; info = hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNoneSkipLast; @@ -110,14 +110,14 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT CGColorSpaceRelease(colorSpace); break; - case kTexture2DPixelFormat_RGB565: + case Texture2D::PixelFormat::RGB565: colorSpace = CGColorSpaceCreateDeviceRGB(); data = new unsigned char[POTHigh * POTWide * 4]; info = kCGImageAlphaNoneSkipLast; context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, 4 * POTWide, colorSpace, info | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); break; - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::A8: data = new unsigned char[POTHigh * POTWide]; info = kCGImageAlphaOnly; context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info); @@ -138,7 +138,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT // Repack the pixel data into the right format - if(pixelFormat == kTexture2DPixelFormat_RGB565) + if(pixelFormat == Texture2D::PixelFormat::RGB565) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" tempData = new unsigned char[POTHigh * POTWide * 2]; @@ -153,7 +153,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT data = tempData; } - else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) + else if (pixelFormat == Texture2D::PixelFormat::RGBA4444) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" tempData = new unsigned char[POTHigh * POTWide * 2]; @@ -172,7 +172,7 @@ static bool _initPremultipliedATextureWithImage(CGImageRef image, NSUInteger POT data = tempData; } - else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) + else if (pixelFormat == Texture2D::PixelFormat::RGB5A1) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" tempData = new unsigned char[POTHigh * POTWide * 2]; @@ -542,7 +542,7 @@ Image::~Image() CC_SAFE_DELETE_ARRAY(_data); } -bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) +bool Image::initWithImageFile(const char * strPath, Format eImgFmt/* = eFmtPng*/) { std::string strTemp = FileUtils::getInstance()->fullPathForFilename(strPath); if (_enabledScale) @@ -585,7 +585,7 @@ bool Image::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFm return ret; } -bool Image::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) +bool Image::initWithImageFileThreadSafe(const char *fullpath, Format imageType) { /* * FileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). @@ -612,7 +612,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) unsigned int* inPixel32 = NULL; unsigned short* outPixel16 = NULL; bool hasAlpha; - Texture2DPixelFormat pixelFormat; + Texture2D::PixelFormat pixelFormat; hasAlpha = this->hasAlpha(); @@ -627,21 +627,21 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) { if (bpp >= 8) { - pixelFormat = kTexture2DPixelFormat_RGB888; + pixelFormat = Texture2D::PixelFormat::RGB888; } else { CCLOG("cocos2d: Texture2D: Using RGB565 texture since image has no alpha"); - pixelFormat = kTexture2DPixelFormat_RGB565; + pixelFormat = Texture2D::PixelFormat::RGB565; } } switch(pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: - case kTexture2DPixelFormat_RGBA4444: - case kTexture2DPixelFormat_RGB5A1: - case kTexture2DPixelFormat_RGB565: - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::RGBA8888: + case Texture2D::PixelFormat::RGBA4444: + case Texture2D::PixelFormat::RGB5A1: + case Texture2D::PixelFormat::RGB565: + case Texture2D::PixelFormat::A8: tempData = (unsigned char*)(this->getData()); CCASSERT(tempData != NULL, "NULL image data."); @@ -666,7 +666,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) } break; - case kTexture2DPixelFormat_RGB888: + case Texture2D::PixelFormat::RGB888: tempData = (unsigned char*)(this->getData()); CCASSERT(tempData != NULL, "NULL image data."); if(this->getWidth() == (short)POTWide && this->getHeight() == (short)POTHigh) @@ -695,7 +695,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) // Repack the pixel data into the right format - if(pixelFormat == kTexture2DPixelFormat_RGB565) { + if(pixelFormat == Texture2D::PixelFormat::RGB565) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGGBBBBB" tempData = new unsigned char[POTHigh * POTWide * 2]; inPixel32 = (unsigned int*)data; @@ -713,7 +713,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) delete [] data; data = tempData; } - else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) { + else if (pixelFormat == Texture2D::PixelFormat::RGBA4444) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" tempData = new unsigned char[POTHigh * POTWide * 2]; inPixel32 = (unsigned int*)data; @@ -732,7 +732,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) delete [] data; data = tempData; } - else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) { + else if (pixelFormat == Texture2D::PixelFormat::RGB5A1) { //Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" tempData = new unsigned char[POTHigh * POTWide * 2]; inPixel32 = (unsigned int*)data; @@ -751,10 +751,10 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) delete []data; data = tempData; } - else if (pixelFormat == kTexture2DPixelFormat_A8) + else if (pixelFormat == Texture2D::PixelFormat::A8) { // fix me, how to convert to A8 - pixelFormat = kTexture2DPixelFormat_RGBA8888; + pixelFormat = Texture2D::PixelFormat::RGBA8888; // //The code can not work, how to convert to A8? @@ -786,7 +786,7 @@ bool Image::potImageData(unsigned int POTWide, unsigned int POTHigh) //bool Image::initWithImageData(void * pData, int nDataLen, EImageFormat eFmt/* = eSrcFmtPng*/) bool Image::initWithImageData(void * pData, int nDataLen, - EImageFormat eFmt, + Format eFmt, int nWidth, int nHeight, int nBitsPerComponent) @@ -797,13 +797,13 @@ bool Image::initWithImageData(void * pData, { CC_BREAK_IF(! pData || nDataLen <= 0); - if (eFmt == kFmtRawData) + if (eFmt == Format::RAW_DATA) { bRet = initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false); } - else if (eFmt == Image::kFmtWebp) + else if (eFmt == Image::Format::WEBP) { - bRet = _initWithWebpData(pData, nDataLen); + bRet = initWithWebpData(pData, nDataLen); } else { @@ -813,7 +813,7 @@ bool Image::initWithImageData(void * pData, _height = (short)info.height; _width = (short)info.width; _bitsPerComponent = info.bitsPerComponent; - if (eFmt == kFmtJpg) + if (eFmt == Format::JPG) { _hasAlpha = true; _preMulti = false; diff --git a/cocos2dx/platform/nacl/CCApplication.cpp b/cocos2dx/platform/nacl/CCApplication.cpp index 918d37240a..4b335dac8d 100644 --- a/cocos2dx/platform/nacl/CCApplication.cpp +++ b/cocos2dx/platform/nacl/CCApplication.cpp @@ -90,9 +90,9 @@ void Application::setAnimationInterval(double interval) _animationInterval = interval * 1000.0f; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetNaCl; + return Platform::OS_NACL; } Application* Application::getInstance() @@ -107,9 +107,9 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; return ret; } diff --git a/cocos2dx/platform/nacl/CCApplication.h b/cocos2dx/platform/nacl/CCApplication.h index 5be4d12325..5b970623cb 100644 --- a/cocos2dx/platform/nacl/CCApplication.h +++ b/cocos2dx/platform/nacl/CCApplication.h @@ -58,12 +58,12 @@ public: CC_DEPRECATED_ATTRIBUTE static Application* sharedApplication(); /* override functions */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); static bool isRunning() { return s_running; } protected: diff --git a/cocos2dx/platform/nacl/CCFileUtilsNaCl.cpp b/cocos2dx/platform/nacl/CCFileUtilsNaCl.cpp index a9d0a9e773..631d94dca2 100644 --- a/cocos2dx/platform/nacl/CCFileUtilsNaCl.cpp +++ b/cocos2dx/platform/nacl/CCFileUtilsNaCl.cpp @@ -35,7 +35,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsNaCl(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsNacl"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/tizen/CCApplication.cpp b/cocos2dx/platform/tizen/CCApplication.cpp index 211be5391c..d8d535d374 100644 --- a/cocos2dx/platform/tizen/CCApplication.cpp +++ b/cocos2dx/platform/tizen/CCApplication.cpp @@ -84,12 +84,12 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { result r = E_SUCCESS; int index = 0; Tizen::Base::String localelanguageCode, languageCode; - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; r = SettingInfo::GetValue(L"http://tizen.org/setting/locale.language", localelanguageCode); TryLog(!IsFailed(r), "[%s] Cannot get the current language setting", GetErrorMessage(r)); @@ -98,66 +98,66 @@ ccLanguageType Application::getCurrentLanguage() if (0 == languageCode.CompareTo(L"zho")) { - ret = kLanguageChinese; + ret = LanguageType::CHINESE; } else if (0 == languageCode.CompareTo(L"eng")) { - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH; } else if (0 == languageCode.CompareTo(L"fre")) { - ret = kLanguageFrench; + ret = LanguageType::FRENCH; } else if (0 == languageCode.CompareTo(L"ita")) { - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; } else if (0 == languageCode.CompareTo(L"deu")) { - ret = kLanguageGerman; + ret = LanguageType::GERMAN; } else if (0 == languageCode.CompareTo(L"spa")) { - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; } else if (0 == languageCode.CompareTo(L"rus")) { - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; } else if (0 == languageCode.CompareTo(L"kor")) { - ret = kLanguageKorean; + ret = LanguageType::KOREAN; } else if (0 == languageCode.CompareTo(L"jpn")) { - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; } else if (0 == languageCode.CompareTo(L"hun")) { - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; } else if (0 == languageCode.CompareTo(L"por")) { - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; } else if (0 == languageCode.CompareTo(L"ara")) { - ret = kLanguageArabic; + ret = LanguageType::ARABIC; } else if (0 == languageCode.CompareTo(L"nor")) { - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; } else if (0 == languageCode.CompareTo(L"pol")) { - ret = kLanguagePolish; + ret = LanguageType::POLISH; } return ret; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetTizen; + return Platform::OS_TIZEN; } NS_CC_END diff --git a/cocos2dx/platform/tizen/CCApplication.h b/cocos2dx/platform/tizen/CCApplication.h index 2614a90481..53f8dc5cc9 100644 --- a/cocos2dx/platform/tizen/CCApplication.h +++ b/cocos2dx/platform/tizen/CCApplication.h @@ -66,12 +66,12 @@ public: @brief Get current language config @return Current language config */ - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); protected: static Application * sm_pSharedApplication; diff --git a/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp b/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp index b01f273bd7..dad418107f 100644 --- a/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp +++ b/cocos2dx/platform/tizen/CCFileUtilsTizen.cpp @@ -45,7 +45,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsTizen(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsTizen"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/win32/CCApplication.cpp b/cocos2dx/platform/win32/CCApplication.cpp index 04cd15c75d..742ae62275 100644 --- a/cocos2dx/platform/win32/CCApplication.cpp +++ b/cocos2dx/platform/win32/CCApplication.cpp @@ -112,9 +112,9 @@ Application* Application::sharedApplication() return Application::getInstance(); } -ccLanguageType Application::getCurrentLanguage() +LanguageType Application::getCurrentLanguage() { - ccLanguageType ret = kLanguageEnglish; + LanguageType ret = LanguageType::ENGLISH; LCID localeID = GetUserDefaultLCID(); unsigned short primaryLanguageID = localeID & 0xFF; @@ -122,55 +122,55 @@ ccLanguageType Application::getCurrentLanguage() switch (primaryLanguageID) { case LANG_CHINESE: - ret = kLanguageChinese; + ret = LanguageType::CHINESE; break; case LANG_ENGLISH: - ret = kLanguageEnglish; + ret = LanguageType::ENGLISH; break; case LANG_FRENCH: - ret = kLanguageFrench; + ret = LanguageType::FRENCH; break; case LANG_ITALIAN: - ret = kLanguageItalian; + ret = LanguageType::ITALIAN; break; case LANG_GERMAN: - ret = kLanguageGerman; + ret = LanguageType::GERMAN; break; case LANG_SPANISH: - ret = kLanguageSpanish; + ret = LanguageType::SPANISH; break; case LANG_RUSSIAN: - ret = kLanguageRussian; + ret = LanguageType::RUSSIAN; break; case LANG_KOREAN: - ret = kLanguageKorean; + ret = LanguageType::KOREAN; break; case LANG_JAPANESE: - ret = kLanguageJapanese; + ret = LanguageType::JAPANESE; break; case LANG_HUNGARIAN: - ret = kLanguageHungarian; + ret = LanguageType::HUNGARIAN; break; case LANG_PORTUGUESE: - ret = kLanguagePortuguese; + ret = LanguageType::PORTUGUESE; break; case LANG_ARABIC: - ret = kLanguageArabic; + ret = LanguageType::ARABIC; break; case LANG_NORWEGIAN: - ret = kLanguageNorwegian; + ret = LanguageType::NORWEGIAN; break; case LANG_POLISH: - ret = kLanguagePolish; + ret = LanguageType::POLISH; break; } return ret; } -TargetPlatform Application::getTargetPlatform() +Application::Platform Application::getTargetPlatform() { - return kTargetWindows; + return Platform::OS_WINDOWS; } void Application::setResourceRootPath(const std::string& rootResDir) diff --git a/cocos2dx/platform/win32/CCApplication.h b/cocos2dx/platform/win32/CCApplication.h index bd86206482..d8e56fc0da 100644 --- a/cocos2dx/platform/win32/CCApplication.h +++ b/cocos2dx/platform/win32/CCApplication.h @@ -32,12 +32,12 @@ public: /* override functions */ virtual void setAnimationInterval(double interval); - virtual ccLanguageType getCurrentLanguage(); + virtual LanguageType getCurrentLanguage(); /** @brief Get target platform */ - virtual TargetPlatform getTargetPlatform(); + virtual Platform getTargetPlatform(); /** * Sets the Resource root path. diff --git a/cocos2dx/platform/win32/CCFileUtilsWin32.cpp b/cocos2dx/platform/win32/CCFileUtilsWin32.cpp index 9c34e2a107..460e2400df 100644 --- a/cocos2dx/platform/win32/CCFileUtilsWin32.cpp +++ b/cocos2dx/platform/win32/CCFileUtilsWin32.cpp @@ -48,7 +48,12 @@ FileUtils* FileUtils::getInstance() if (s_sharedFileUtils == NULL) { s_sharedFileUtils = new FileUtilsWin32(); - s_sharedFileUtils->init(); + if(!s_sharedFileUtils->init()) + { + delete s_sharedFileUtils; + s_sharedFileUtils = NULL; + CCLOG("ERROR: Could not init CCFileUtilsWin32"); + } } return s_sharedFileUtils; } diff --git a/cocos2dx/platform/win32/CCStdC.h b/cocos2dx/platform/win32/CCStdC.h index 7ad586ecdb..0092baf798 100644 --- a/cocos2dx/platform/win32/CCStdC.h +++ b/cocos2dx/platform/win32/CCStdC.h @@ -103,5 +103,9 @@ NS_CC_END #undef MessageBox #endif +#ifdef RELATIVE +#undef RELATIVE +#endif + #endif // __CC_STD_C_H__ diff --git a/cocos2dx/proj.emscripten/cocos2dx.mk b/cocos2dx/proj.emscripten/cocos2dx.mk index 348d635dfd..b6893beeea 100644 --- a/cocos2dx/proj.emscripten/cocos2dx.mk +++ b/cocos2dx/proj.emscripten/cocos2dx.mk @@ -97,9 +97,12 @@ STATICLIBS = \ SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(RPATH_REL)/$(LIB_DIR) LIBS = -lrt -lz +HTMLTPL_DIR = $(COCOS_ROOT)/tools/emscripten-template +HTMLTPL_FILE = index.html + clean: rm -rf $(OBJ_DIR) - rm -f $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR)/index.html core + rm -rf $(TARGET).js $(TARGET).data $(TARGET).data.js $(BIN_DIR) core .PHONY: all clean @@ -108,7 +111,7 @@ clean: ifdef EXECUTABLE TARGET := $(BIN_DIR)/$(EXECUTABLE) -all: $(TARGET).js $(TARGET).data $(BIN_DIR)/index.html +all: $(TARGET).js $(TARGET).data $(BIN_DIR)/$(HTMLTPL_FILE) run: $(TARGET) cd $(dir $^) && ./$(notdir $^) diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index b077cf08b0..d1d6b249a3 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -136,7 +136,8 @@ SOURCES = ../actions/CCAction.cpp \ ../CCScheduler.cpp \ ../ccFPSImages.c \ ../ccTypes.cpp \ -../cocos2d.cpp +../cocos2d.cpp \ +../CCDeprecated.cpp COCOS_ROOT = ../.. diff --git a/cocos2dx/proj.nacl/Makefile b/cocos2dx/proj.nacl/Makefile index f5a37dda8c..6e8db938f4 100644 --- a/cocos2dx/proj.nacl/Makefile +++ b/cocos2dx/proj.nacl/Makefile @@ -130,7 +130,8 @@ SOURCES = ../actions/CCAction.cpp \ ../CCScheduler.cpp \ ../ccFPSImages.c \ ../ccTypes.cpp \ -../cocos2d.cpp +../cocos2d.cpp \ +../CCDeprecated.cpp include cocos2dx.mk diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj index 4770871db4..5f45a4e614 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj +++ b/cocos2dx/proj.win32/cocos2d.vcxproj @@ -142,6 +142,7 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters index 43c5bbfbca..4564d7b152 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters @@ -481,6 +481,7 @@ keyboard_dispatcher + diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index a4ebbe8ead..36a680b809 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -45,6 +45,31 @@ typedef struct _hashUniformEntry UT_hash_handle hh; // hash entry } tHashUniformEntry; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor"; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest"; +const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"; +const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"; +const char* GLProgram::SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor"; +const char* GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR = "ShaderPositionLengthTextureColor"; + +// uniform names +const char* GLProgram::UNIFORM_NAME_P_MATRIX = "CC_PMatrix"; +const char* GLProgram::UNIFORM_NAME_MV_MATRIX = "CC_MVMatrix"; +const char* GLProgram::UNIFORM_NAME_MVP_MATRIX = "CC_MVPMatrix"; +const char* GLProgram::UNIFORM_NAME_TIME = "CC_Time"; +const char* GLProgram::UNIFORM_NAME_SIN_TIME = "CC_SinTime"; +const char* GLProgram::UNIFORM_NAME_COS_TIME = "CC_CosTime"; +const char* GLProgram::UNIFORM_NAME_RANDOM01 = "CC_Random01"; +const char* GLProgram::UNIFORM_NAME_SAMPLER = "CC_Texture0"; +const char* GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value"; + +// Attribute names +const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color"; +const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position"; +const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord"; + GLProgram::GLProgram() : _program(0) , _vertShader(0) @@ -65,7 +90,7 @@ GLProgram::~GLProgram() if (_program) { - ccGLDeleteProgram(_program); + GL::deleteProgram(_program); } tHashUniformEntry *current_element, *tmp; @@ -197,28 +222,28 @@ void GLProgram::addAttribute(const char* attributeName, GLuint index) void GLProgram::updateUniforms() { - _uniforms[kUniformPMatrix] = glGetUniformLocation(_program, kUniformPMatrix_s); - _uniforms[kUniformMVMatrix] = glGetUniformLocation(_program, kUniformMVMatrix_s); - _uniforms[kUniformMVPMatrix] = glGetUniformLocation(_program, kUniformMVPMatrix_s); + _uniforms[UNIFORM_P_MATRIX] = glGetUniformLocation(_program, UNIFORM_NAME_P_MATRIX); + _uniforms[UNIFORM_MV_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MV_MATRIX); + _uniforms[UNIFORM_MVP_MATRIX] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_MVP_MATRIX); - _uniforms[kUniformTime] = glGetUniformLocation(_program, kUniformTime_s); - _uniforms[kUniformSinTime] = glGetUniformLocation(_program, kUniformSinTime_s); - _uniforms[kUniformCosTime] = glGetUniformLocation(_program, kUniformCosTime_s); + _uniforms[GLProgram::UNIFORM_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_TIME); + _uniforms[GLProgram::UNIFORM_SIN_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_SIN_TIME); + _uniforms[GLProgram::UNIFORM_COS_TIME] = glGetUniformLocation(_program, GLProgram::UNIFORM_NAME_COS_TIME); _usesTime = ( - _uniforms[kUniformTime] != -1 || - _uniforms[kUniformSinTime] != -1 || - _uniforms[kUniformCosTime] != -1 + _uniforms[GLProgram::UNIFORM_TIME] != -1 || + _uniforms[GLProgram::UNIFORM_SIN_TIME] != -1 || + _uniforms[GLProgram::UNIFORM_COS_TIME] != -1 ); - _uniforms[kUniformRandom01] = glGetUniformLocation(_program, kUniformRandom01_s); + _uniforms[UNIFORM_RANDOM01] = glGetUniformLocation(_program, UNIFORM_NAME_RANDOM01); - _uniforms[kUniformSampler] = glGetUniformLocation(_program, kUniformSampler_s); + _uniforms[UNIFORM_SAMPLER] = glGetUniformLocation(_program, UNIFORM_NAME_SAMPLER); this->use(); // Since sample most probably won't change, set it to 0 now. - this->setUniformLocationWith1i(_uniforms[kUniformSampler], 0); + this->setUniformLocationWith1i(_uniforms[GLProgram::UNIFORM_SAMPLER], 0); } bool GLProgram::link() @@ -247,7 +272,7 @@ bool GLProgram::link() if (status == GL_FALSE) { CCLOG("cocos2d: ERROR: Failed to link program: %i", _program); - ccGLDeleteProgram(_program); + GL::deleteProgram(_program); _program = 0; } #endif @@ -257,7 +282,7 @@ bool GLProgram::link() void GLProgram::use() { - ccGLUseProgram(_program); + GL::useProgram(_program); } const char* GLProgram::logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const @@ -509,9 +534,9 @@ void GLProgram::setUniformsForBuiltins() kmMat4Multiply(&matrixMVP, &matrixP, &matrixMV); - setUniformLocationWithMatrix4fv(_uniforms[kUniformPMatrix], matrixP.mat, 1); - setUniformLocationWithMatrix4fv(_uniforms[kUniformMVMatrix], matrixMV.mat, 1); - setUniformLocationWithMatrix4fv(_uniforms[kUniformMVPMatrix], matrixMVP.mat, 1); + setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_P_MATRIX], matrixP.mat, 1); + setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MV_MATRIX], matrixMV.mat, 1); + setUniformLocationWithMatrix4fv(_uniforms[UNIFORM_MVP_MATRIX], matrixMVP.mat, 1); if(_usesTime) { @@ -521,14 +546,14 @@ void GLProgram::setUniformsForBuiltins() // Getting Mach time per frame per shader using time could be extremely expensive. float time = director->getTotalFrames() * director->getAnimationInterval(); - setUniformLocationWith4f(_uniforms[kUniformTime], time/10.0, time, time*2, time*4); - setUniformLocationWith4f(_uniforms[kUniformSinTime], time/8.0, time/4.0, time/2.0, sinf(time)); - setUniformLocationWith4f(_uniforms[kUniformCosTime], time/8.0, time/4.0, time/2.0, cosf(time)); + setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_TIME], time/10.0, time, time*2, time*4); + setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_SIN_TIME], time/8.0, time/4.0, time/2.0, sinf(time)); + setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_COS_TIME], time/8.0, time/4.0, time/2.0, cosf(time)); } - if (_uniforms[kUniformRandom01] != -1) + if (_uniforms[GLProgram::UNIFORM_RANDOM01] != -1) { - setUniformLocationWith4f(_uniforms[kUniformRandom01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); + setUniformLocationWith4f(_uniforms[GLProgram::UNIFORM_RANDOM01], CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1()); } } @@ -539,7 +564,7 @@ void GLProgram::reset() // it is already deallocated by android - //ccGLDeleteProgram(_program); + //GL::deleteProgram(_program); _program = 0; diff --git a/cocos2dx/shaders/CCGLProgram.h b/cocos2dx/shaders/CCGLProgram.h index 2de2e78788..a5bb3b292b 100644 --- a/cocos2dx/shaders/CCGLProgram.h +++ b/cocos2dx/shaders/CCGLProgram.h @@ -40,52 +40,6 @@ NS_CC_BEGIN * @{ */ -enum { - kVertexAttrib_Position, - kVertexAttrib_Color, - kVertexAttrib_TexCoords, - - kVertexAttrib_MAX, -}; - -enum { - kUniformPMatrix, - kUniformMVMatrix, - kUniformMVPMatrix, - kUniformTime, - kUniformSinTime, - kUniformCosTime, - kUniformRandom01, - kUniformSampler, - - kUniform_MAX, -}; - -#define kShader_PositionTextureColor "ShaderPositionTextureColor" -#define kShader_PositionTextureColorAlphaTest "ShaderPositionTextureColorAlphaTest" -#define kShader_PositionColor "ShaderPositionColor" -#define kShader_PositionTexture "ShaderPositionTexture" -#define kShader_PositionTexture_uColor "ShaderPositionTexture_uColor" -#define kShader_PositionTextureA8Color "ShaderPositionTextureA8Color" -#define kShader_Position_uColor "ShaderPosition_uColor" -#define kShader_PositionLengthTexureColor "ShaderPositionLengthTextureColor" - -// uniform names -#define kUniformPMatrix_s "CC_PMatrix" -#define kUniformMVMatrix_s "CC_MVMatrix" -#define kUniformMVPMatrix_s "CC_MVPMatrix" -#define kUniformTime_s "CC_Time" -#define kUniformSinTime_s "CC_SinTime" -#define kUniformCosTime_s "CC_CosTime" -#define kUniformRandom01_s "CC_Random01" -#define kUniformSampler_s "CC_Texture0" -#define kUniformAlphaTestValue "CC_alpha_value" - -// Attribute names -#define kAttributeNameColor "a_color" -#define kAttributeNamePosition "a_position" -#define kAttributeNameTexCoord "a_texCoord" - struct _hashUniformEntry; typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params); @@ -100,6 +54,54 @@ typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, class CC_DLL GLProgram : public Object { public: + enum + { + VERTEX_ATTRIB_POSITION, + VERTEX_ATTRIB_COLOR, + VERTEX_ATTRIB_TEX_COORDS, + + VERTEX_ATTRIB_MAX, + }; + + enum + { + UNIFORM_P_MATRIX, + UNIFORM_MV_MATRIX, + UNIFORM_MVP_MATRIX, + UNIFORM_TIME, + UNIFORM_SIN_TIME, + UNIFORM_COS_TIME, + UNIFORM_RANDOM01, + UNIFORM_SAMPLER, + + UNIFORM_MAX, + }; + + static const char* SHADER_NAME_POSITION_TEXTURE_COLOR; + static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST; + static const char* SHADER_NAME_POSITION_COLOR; + static const char* SHADER_NAME_POSITION_TEXTURE; + static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR; + static const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR; + static const char* SHADER_NAME_POSITION_U_COLOR; + static const char* SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR; + + // uniform names + static const char* UNIFORM_NAME_P_MATRIX; + static const char* UNIFORM_NAME_MV_MATRIX; + static const char* UNIFORM_NAME_MVP_MATRIX; + static const char* UNIFORM_NAME_TIME; + static const char* UNIFORM_NAME_SIN_TIME; + static const char* UNIFORM_NAME_COS_TIME; + static const char* UNIFORM_NAME_RANDOM01; + static const char* UNIFORM_NAME_SAMPLER; + static const char* UNIFORM_NAME_ALPHA_TEST_VALUE; + + // Attribute names + static const char* ATTRIBUTE_NAME_COLOR; + static const char* ATTRIBUTE_NAME_POSITION; + static const char* ATTRIBUTE_NAME_TEX_COORD; + GLProgram(); virtual ~GLProgram(); /** Initializes the GLProgram with a vertex and fragment with bytes array */ @@ -116,9 +118,9 @@ public: - kUniformPMatrix - kUniformMVMatrix - kUniformMVPMatrix - - kUniformSampler + - GLProgram::UNIFORM_SAMPLER - And it will bind "kUniformSampler" to 0 + And it will bind "GLProgram::UNIFORM_SAMPLER" to 0 */ void updateUniforms(); @@ -198,7 +200,7 @@ private: GLuint _program; GLuint _vertShader; GLuint _fragShader; - GLint _uniforms[kUniform_MAX]; + GLint _uniforms[UNIFORM_MAX]; struct _hashUniformEntry* _hashForUniforms; bool _usesTime; }; diff --git a/cocos2dx/shaders/CCShaderCache.cpp b/cocos2dx/shaders/CCShaderCache.cpp index 1fe685885e..2377cb02f0 100644 --- a/cocos2dx/shaders/CCShaderCache.cpp +++ b/cocos2dx/shaders/CCShaderCache.cpp @@ -100,14 +100,14 @@ void ShaderCache::loadDefaultShaders() GLProgram *p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColor); - _programs->setObject(p, kShader_PositionTextureColor); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); p->release(); // Position Texture Color alpha test p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); - _programs->setObject(p, kShader_PositionTextureColorAlphaTest); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->release(); // @@ -116,7 +116,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionColor); - _programs->setObject(p, kShader_PositionColor); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_COLOR); p->release(); // @@ -125,7 +125,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture); - _programs->setObject(p, kShader_PositionTexture); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE); p->release(); // @@ -134,7 +134,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTexture_uColor); - _programs->setObject(p ,kShader_PositionTexture_uColor); + _programs->setObject(p ,GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); p->release(); // @@ -143,7 +143,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionTextureA8Color); - _programs->setObject(p, kShader_PositionTextureA8Color); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); p->release(); // @@ -152,7 +152,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_Position_uColor); - _programs->setObject(p, kShader_Position_uColor); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_U_COLOR); p->release(); // @@ -161,7 +161,7 @@ void ShaderCache::loadDefaultShaders() p = new GLProgram(); loadDefaultShader(p, kShaderType_PositionLengthTexureColor); - _programs->setObject(p, kShader_PositionLengthTexureColor); + _programs->setObject(p, GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); p->release(); } @@ -170,54 +170,54 @@ void ShaderCache::reloadDefaultShaders() // reset all programs and reload them // Position Texture Color shader - GLProgram *p = programForKey(kShader_PositionTextureColor); + GLProgram *p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColor); // Position Texture Color alpha test - p = programForKey(kShader_PositionTextureColorAlphaTest); + p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureColorAlphaTest); // // Position, Color shader // - p = programForKey(kShader_PositionColor); + p = programForKey(GLProgram::SHADER_NAME_POSITION_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionColor); // // Position Texture shader // - p = programForKey(kShader_PositionTexture); + p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE); p->reset(); loadDefaultShader(p, kShaderType_PositionTexture); // // Position, Texture attribs, 1 Color as uniform shader // - p = programForKey(kShader_PositionTexture_uColor); + p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTexture_uColor); // // Position Texture A8 Color shader // - p = programForKey(kShader_PositionTextureA8Color); + p = programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionTextureA8Color); // // Position and 1 color passed as a uniform (to simulate glColor4ub ) // - p = programForKey(kShader_Position_uColor); + p = programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR); p->reset(); loadDefaultShader(p, kShaderType_Position_uColor); // // Position, Legth(TexCoords, Color (used by Draw Node basically ) // - p = programForKey(kShader_PositionLengthTexureColor); + p = programForKey(GLProgram::SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR); p->reset(); loadDefaultShader(p, kShaderType_PositionLengthTexureColor); } @@ -228,60 +228,60 @@ void ShaderCache::loadDefaultShader(GLProgram *p, int type) case kShaderType_PositionTextureColor: p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColor_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTextureColorAlphaTest: p->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionColor: p->initWithVertexShaderByteArray(ccPositionColor_vert ,ccPositionColor_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; case kShaderType_PositionTexture: p->initWithVertexShaderByteArray(ccPositionTexture_vert ,ccPositionTexture_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTexture_uColor: p->initWithVertexShaderByteArray(ccPositionTexture_uColor_vert, ccPositionTexture_uColor_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_PositionTextureA8Color: p->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, ccPositionTextureA8Color_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); break; case kShaderType_Position_uColor: p->initWithVertexShaderByteArray(ccPosition_uColor_vert, ccPosition_uColor_frag); - p->addAttribute("aVertex", kVertexAttrib_Position); + p->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); break; case kShaderType_PositionLengthTexureColor: p->initWithVertexShaderByteArray(ccPositionColorLengthTexture_vert, ccPositionColorLengthTexture_frag); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); - p->addAttribute(kAttributeNameColor, kVertexAttrib_Color); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); break; default: diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index 601bc69d0b..0e8054bd40 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -57,7 +57,9 @@ static GLuint s_uVAO = 0; // GL State Cache functions -void ccGLInvalidateStateCache( void ) +namespace GL { + +void invalidateStateCache( void ) { kmGLFreeAll(); @@ -83,7 +85,7 @@ void ccGLInvalidateStateCache( void ) #endif // CC_ENABLE_GL_STATE_CACHE } -void ccGLDeleteProgram( GLuint program ) +void deleteProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE if(program == s_uCurrentShaderProgram) @@ -95,7 +97,7 @@ void ccGLDeleteProgram( GLuint program ) glDeleteProgram( program ); } -void ccGLUseProgram( GLuint program ) +void useProgram( GLuint program ) { #if CC_ENABLE_GL_STATE_CACHE if( program != s_uCurrentShaderProgram ) { @@ -120,7 +122,7 @@ static void SetBlending(GLenum sfactor, GLenum dfactor) } } -void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) +void blendFunc(GLenum sfactor, GLenum dfactor) { #if CC_ENABLE_GL_STATE_CACHE if (sfactor != s_eBlendingSource || dfactor != s_eBlendingDest) @@ -134,7 +136,7 @@ void ccGLBlendFunc(GLenum sfactor, GLenum dfactor) #endif // CC_ENABLE_GL_STATE_CACHE } -void ccGLBlendResetToCache(void) +void blendResetToCache(void) { glBlendEquation(GL_FUNC_ADD); #if CC_ENABLE_GL_STATE_CACHE @@ -144,12 +146,12 @@ void ccGLBlendResetToCache(void) #endif // CC_ENABLE_GL_STATE_CACHE } -void ccGLBindTexture2D(GLuint textureId) +void bindTexture2D(GLuint textureId) { - ccGLBindTexture2DN(0, textureId); + GL::bindTexture2DN(0, textureId); } -void ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) +void bindTexture2DN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE CCASSERT(textureUnit < kMaxActiveTexture, "textureUnit is too big"); @@ -166,12 +168,12 @@ void ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId) } -void ccGLDeleteTexture(GLuint textureId) +void deleteTexture(GLuint textureId) { - ccGLDeleteTextureN(0, textureId); + deleteTextureN(0, textureId); } -void ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) +void deleteTextureN(GLuint textureUnit, GLuint textureId) { #if CC_ENABLE_GL_STATE_CACHE if (s_uCurrentBoundTexture[textureUnit] == textureId) @@ -183,7 +185,7 @@ void ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId) glDeleteTextures(1, &textureId); } -void ccGLBindVAO(GLuint vaoId) +void bindVAO(GLuint vaoId) { #if CC_TEXTURE_ATLAS_USE_VAO @@ -200,69 +202,44 @@ void ccGLBindVAO(GLuint vaoId) #endif } -void ccGLEnable(ccGLServerState flags) -{ -#if CC_ENABLE_GL_STATE_CACHE - -// int enabled = 0; -// -// /* GL_BLEND */ -// if( (enabled = (flags & CC_GL_BLEND)) != (s_eGLServerState & CC_GL_BLEND) ) { -// if( enabled ) { -// glEnable( GL_BLEND ); -// s_eGLServerState |= CC_GL_BLEND; -// } else { -// glDisable( GL_BLEND ); -// s_eGLServerState &= ~CC_GL_BLEND; -// } -// } - -#else -// if( flags & CC_GL_BLEND ) -// glEnable( GL_BLEND ); -// else -// glDisable( GL_BLEND ); -#endif -} - //#pragma mark - GL Vertex Attrib functions -void ccGLEnableVertexAttribs( unsigned int flags ) +void enableVertexAttribs( unsigned int flags ) { - ccGLBindVAO(0); + bindVAO(0); /* Position */ - bool enablePosition = flags & kVertexAttribFlag_Position; + bool enablePosition = flags & VERTEX_ATTRIB_FLAG_POSITION; if( enablePosition != s_bVertexAttribPosition ) { if( enablePosition ) - glEnableVertexAttribArray( kVertexAttrib_Position ); + glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); else - glDisableVertexAttribArray( kVertexAttrib_Position ); + glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_POSITION ); s_bVertexAttribPosition = enablePosition; } /* Color */ - bool enableColor = (flags & kVertexAttribFlag_Color) != 0 ? true : false; + bool enableColor = (flags & VERTEX_ATTRIB_FLAG_COLOR) != 0 ? true : false; if( enableColor != s_bVertexAttribColor ) { if( enableColor ) - glEnableVertexAttribArray( kVertexAttrib_Color ); + glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); else - glDisableVertexAttribArray( kVertexAttrib_Color ); + glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_COLOR ); s_bVertexAttribColor = enableColor; } /* Tex Coords */ - bool enableTexCoords = (flags & kVertexAttribFlag_TexCoords) != 0 ? true : false; + bool enableTexCoords = (flags & VERTEX_ATTRIB_FLAG_TEX_COORDS) != 0 ? true : false; if( enableTexCoords != s_bVertexAttribTexCoords ) { if( enableTexCoords ) - glEnableVertexAttribArray( kVertexAttrib_TexCoords ); + glEnableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); else - glDisableVertexAttribArray( kVertexAttrib_TexCoords ); + glDisableVertexAttribArray( GLProgram::VERTEX_ATTRIB_TEX_COORDS ); s_bVertexAttribTexCoords = enableTexCoords; } @@ -270,9 +247,11 @@ void ccGLEnableVertexAttribs( unsigned int flags ) //#pragma mark - GL Uniforms functions -void ccSetProjectionMatrixDirty( void ) +void setProjectionMatrixDirty( void ) { s_uCurrentProjectionMatrix = -1; } +} // Namespace GL + NS_CC_END diff --git a/cocos2dx/shaders/ccGLStateCache.h b/cocos2dx/shaders/ccGLStateCache.h index cd78582ffc..3ea973918a 100644 --- a/cocos2dx/shaders/ccGLStateCache.h +++ b/cocos2dx/shaders/ccGLStateCache.h @@ -39,31 +39,19 @@ NS_CC_BEGIN class GLProgram; +namespace GL { + /** vertex attrib flags */ enum { - kVertexAttribFlag_None = 0, + VERTEX_ATTRIB_FLAT_NONE = 0, - kVertexAttribFlag_Position = 1 << 0, - kVertexAttribFlag_Color = 1 << 1, - kVertexAttribFlag_TexCoords = 1 << 2, + VERTEX_ATTRIB_FLAG_POSITION = 1 << 0, + VERTEX_ATTRIB_FLAG_COLOR = 1 << 1, + VERTEX_ATTRIB_FLAG_TEX_COORDS = 1 << 2, - kVertexAttribFlag_PosColorTex = ( kVertexAttribFlag_Position | kVertexAttribFlag_Color | kVertexAttribFlag_TexCoords ), + VERTEX_ATTRIB_FLAG_POS_COLOR_TEX = (VERTEX_ATTRIB_FLAG_POSITION | VERTEX_ATTRIB_FLAG_COLOR | VERTEX_ATTRIB_FLAG_TEX_COORDS), }; -/** GL server side states */ -typedef enum { -// CC_GL_SCISSOR_TEST = 1 << 0, -// CC_GL_STENCIL_TEST = 1 << 1, -// CC_GL_DEPTH_TEST = 1 << 2, -// CC_GL_BLEND = 1 << 3, -// CC_GL_DITHER = 1 << 4, - -// CC_GL_ALL = ( CC_GL_SCISSOR_TEST | CC_GL_STENCIL_TEST | CC_GL_DEPTH_TEST | CC_GL_BLEND | CC_GL_DITHER ), -// CC_GL_ALL = ( CC_GL_BLEND ), - CC_GL_ALL = 0, - -} ccGLServerState; - /** @file ccGLStateCache.h */ @@ -71,90 +59,85 @@ typedef enum { If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache. @since v2.0.0 */ -void CC_DLL ccGLInvalidateStateCache(void); +void CC_DLL invalidateStateCache(void); /** Uses the GL program in case program is different than the current one. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly. @since v2.0.0 */ -void CC_DLL ccGLUseProgram(GLuint program); +void CC_DLL useProgram(GLuint program); /** Deletes the GL program. If it is the one that is being used, it invalidates it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glDeleteProgram() directly. @since v2.0.0 */ -void CC_DLL ccGLDeleteProgram(GLuint program); +void CC_DLL deleteProgram(GLuint program); /** Uses a blending function in case it not already used. If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly. @since v2.0.0 */ -void CC_DLL ccGLBlendFunc(GLenum sfactor, GLenum dfactor); +void CC_DLL blendFunc(GLenum sfactor, GLenum dfactor); /** Resets the blending mode back to the cached state in case you used glBlendFuncSeparate() or glBlendEquation(). If CC_ENABLE_GL_STATE_CACHE is disabled, it will just set the default blending mode using GL_FUNC_ADD. @since v2.0.0 */ -void CC_DLL ccGLBlendResetToCache(void); +void CC_DLL blendResetToCache(void); /** sets the projection matrix as dirty @since v2.0.0 */ -void CC_DLL ccSetProjectionMatrixDirty(void); +void CC_DLL setProjectionMatrixDirty(void); /** Will enable the vertex attribs that are passed as flags. Possible flags: - * kVertexAttribFlag_Position - * kVertexAttribFlag_Color - * kVertexAttribFlag_TexCoords + * VERTEX_ATTRIB_FLAG_POSITION + * VERTEX_ATTRIB_FLAG_COLOR + * VERTEX_ATTRIB_FLAG_TEX_COORDS These flags can be ORed. The flags that are not present, will be disabled. @since v2.0.0 */ -void CC_DLL ccGLEnableVertexAttribs(unsigned int flags); +void CC_DLL enableVertexAttribs(unsigned int flags); /** If the texture is not already bound to texture unit 0, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.0.0 */ -void CC_DLL ccGLBindTexture2D(GLuint textureId); +void CC_DLL bindTexture2D(GLuint textureId); /** If the texture is not already bound to a given unit, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly. @since v2.1.0 */ -void CC_DLL ccGLBindTexture2DN(GLuint textureUnit, GLuint textureId); +void CC_DLL bindTexture2DN(GLuint textureUnit, GLuint textureId); /** It will delete a given texture. If the texture was bound, it will invalidate the cached. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. @since v2.0.0 */ -void CC_DLL ccGLDeleteTexture(GLuint textureId); +void CC_DLL deleteTexture(GLuint textureId); /** It will delete a given texture. If the texture was bound, it will invalidate the cached for the given texture unit. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glDeleteTextures() directly. @since v2.1.0 */ -void CC_DLL ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId); +void CC_DLL deleteTextureN(GLuint textureUnit, GLuint textureId); /** If the vertex array is not already bound, it binds it. If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindVertexArray() directly. @since v2.0.0 */ -void CC_DLL ccGLBindVAO(GLuint vaoId); - -/** It will enable / disable the server side GL states. - If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly. - @since v2.0.0 - */ -void CC_DLL ccGLEnable( ccGLServerState flags ); +void CC_DLL bindVAO(GLuint vaoId); // end of shaders group /// @} +} // Namespace GL NS_CC_END diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 89cbbe8671..50dda491af 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -174,12 +174,12 @@ void Animation::addSpriteFrame(SpriteFrame *pFrame) _totalDelayUnits++; } -void Animation::addSpriteFrameWithFileName(const char *pszFileName) +void Animation::addSpriteFrameWithFileName(const char *filename) { - Texture2D *pTexture = TextureCache::getInstance()->addImage(pszFileName); + Texture2D *texture = TextureCache::getInstance()->addImage(filename); Rect rect = Rect::ZERO; - rect.size = pTexture->getContentSize(); - SpriteFrame *pFrame = SpriteFrame::createWithTexture(pTexture, rect); + rect.size = texture->getContentSize(); + SpriteFrame *pFrame = SpriteFrame::createWithTexture(texture, rect); addSpriteFrame(pFrame); } diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index c4840f8f06..054480734e 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -157,7 +157,7 @@ public: The frame will be added with one "delay unit". Added to facilitate the migration from v0.8 to v0.9. */ - void addSpriteFrameWithFileName(const char *pszFileName); + void addSpriteFrameWithFileName(const char *filename); /** Adds a frame with a texture and a rect. Internally it will create a SpriteFrame and it will add it. The frame will be added with one "delay unit". diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index df593fcfa1..7ba285e3d0 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -56,73 +56,73 @@ NS_CC_BEGIN #define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__)) #endif -Sprite* Sprite::createWithTexture(Texture2D *pTexture) +Sprite* Sprite::createWithTexture(Texture2D *texture) { - Sprite *pobSprite = new Sprite(); - if (pobSprite && pobSprite->initWithTexture(pTexture)) + Sprite *sprite = new Sprite(); + if (sprite && sprite->initWithTexture(texture)) { - pobSprite->autorelease(); - return pobSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pobSprite); + CC_SAFE_DELETE(sprite); return NULL; } -Sprite* Sprite::createWithTexture(Texture2D *pTexture, const Rect& rect) +Sprite* Sprite::createWithTexture(Texture2D *texture, const Rect& rect) { - Sprite *pobSprite = new Sprite(); - if (pobSprite && pobSprite->initWithTexture(pTexture, rect)) + Sprite *sprite = new Sprite(); + if (sprite && sprite->initWithTexture(texture, rect)) { - pobSprite->autorelease(); - return pobSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pobSprite); + CC_SAFE_DELETE(sprite); return NULL; } -Sprite* Sprite::create(const char *pszFileName) +Sprite* Sprite::create(const char *filename) { - Sprite *pobSprite = new Sprite(); - if (pobSprite && pobSprite->initWithFile(pszFileName)) + Sprite *sprite = new Sprite(); + if (sprite && sprite->initWithFile(filename)) { - pobSprite->autorelease(); - return pobSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pobSprite); + CC_SAFE_DELETE(sprite); return NULL; } -Sprite* Sprite::create(const char *pszFileName, const Rect& rect) +Sprite* Sprite::create(const char *filename, const Rect& rect) { - Sprite *pobSprite = new Sprite(); - if (pobSprite && pobSprite->initWithFile(pszFileName, rect)) + Sprite *sprite = new Sprite(); + if (sprite && sprite->initWithFile(filename, rect)) { - pobSprite->autorelease(); - return pobSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pobSprite); + CC_SAFE_DELETE(sprite); return NULL; } Sprite* Sprite::createWithSpriteFrame(SpriteFrame *pSpriteFrame) { - Sprite *pobSprite = new Sprite(); - if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame)) + Sprite *sprite = new Sprite(); + if (pSpriteFrame && sprite && sprite->initWithSpriteFrame(pSpriteFrame)) { - pobSprite->autorelease(); - return pobSprite; + sprite->autorelease(); + return sprite; } - CC_SAFE_DELETE(pobSprite); + CC_SAFE_DELETE(sprite); return NULL; } -Sprite* Sprite::createWithSpriteFrameName(const char *pszSpriteFrameName) +Sprite* Sprite::createWithSpriteFrameName(const char *spriteFrameName) { - SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pszSpriteFrameName); + SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); #if COCOS2D_DEBUG > 0 char msg[256] = {0}; - sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName); + sprintf(msg, "Invalid spriteFrameName: %s", spriteFrameName); CCASSERT(pFrame != NULL, msg); #endif @@ -147,7 +147,7 @@ bool Sprite::init(void) } // designated initializer -bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated) +bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect, bool rotated) { if (NodeRGBA::init()) { @@ -158,8 +158,7 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated _opacityModifyRGB = true; - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _flipX = _flipY = false; @@ -182,10 +181,10 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated _quad.tr.colors = tmpColor; // shader program - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); // update texture (calls updateBlendFunc) - setTexture(pTexture); + setTexture(texture); setTextureRect(rect, rotated, rect.size); // by default use "Self Render". @@ -200,31 +199,31 @@ bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated } } -bool Sprite::initWithTexture(Texture2D *pTexture, const Rect& rect) +bool Sprite::initWithTexture(Texture2D *texture, const Rect& rect) { - return initWithTexture(pTexture, rect, false); + return initWithTexture(texture, rect, false); } -bool Sprite::initWithTexture(Texture2D *pTexture) +bool Sprite::initWithTexture(Texture2D *texture) { - CCASSERT(pTexture != NULL, "Invalid texture for sprite"); + CCASSERT(texture != NULL, "Invalid texture for sprite"); Rect rect = Rect::ZERO; - rect.size = pTexture->getContentSize(); + rect.size = texture->getContentSize(); - return initWithTexture(pTexture, rect); + return initWithTexture(texture, rect); } -bool Sprite::initWithFile(const char *pszFilename) +bool Sprite::initWithFile(const char *filename) { - CCASSERT(pszFilename != NULL, "Invalid filename for sprite"); + CCASSERT(filename != NULL, "Invalid filename for sprite"); - Texture2D *pTexture = TextureCache::getInstance()->addImage(pszFilename); - if (pTexture) + Texture2D *texture = TextureCache::getInstance()->addImage(filename); + if (texture) { Rect rect = Rect::ZERO; - rect.size = pTexture->getContentSize(); - return initWithTexture(pTexture, rect); + rect.size = texture->getContentSize(); + return initWithTexture(texture, rect); } // don't release here. @@ -233,14 +232,14 @@ bool Sprite::initWithFile(const char *pszFilename) return false; } -bool Sprite::initWithFile(const char *pszFilename, const Rect& rect) +bool Sprite::initWithFile(const char *filename, const Rect& rect) { - CCASSERT(pszFilename != NULL, ""); + CCASSERT(filename != NULL, ""); - Texture2D *pTexture = TextureCache::getInstance()->addImage(pszFilename); - if (pTexture) + Texture2D *texture = TextureCache::getInstance()->addImage(filename); + if (texture) { - return initWithTexture(pTexture, rect); + return initWithTexture(texture, rect); } // don't release here. @@ -259,11 +258,11 @@ bool Sprite::initWithSpriteFrame(SpriteFrame *pSpriteFrame) return bRet; } -bool Sprite::initWithSpriteFrameName(const char *pszSpriteFrameName) +bool Sprite::initWithSpriteFrameName(const char *spriteFrameName) { - CCASSERT(pszSpriteFrameName != NULL, ""); + CCASSERT(spriteFrameName != NULL, ""); - SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(pszSpriteFrameName); + SpriteFrame *pFrame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName); return initWithSpriteFrame(pFrame); } @@ -284,9 +283,9 @@ Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey) CCASSERT(pImage != NULL); // XXX: possible bug. See issue #349. New API should be added - Texture2D *pTexture = TextureCache::getInstance()->addCGImage(pImage, pszKey); + Texture2D *texture = TextureCache::getInstance()->addCGImage(pImage, pszKey); - const Size& size = pTexture->getContentSize(); + const Size& size = texture->getContentSize(); Rect rect = Rect(0 ,0, size.width, size.height); return initWithTexture(texture, rect); @@ -382,14 +381,14 @@ void Sprite::setTextureCoords(Rect rect) { #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL left = (2*rect.origin.x+1)/(2*atlasWidth); - right = left+(rect.size.height*2-2)/(2*atlasWidth); - top = (2*rect.origin.y+1)/(2*atlasHeight); - bottom = top+(rect.size.width*2-2)/(2*atlasHeight); + right = left+(rect.size.height*2-2)/(2*atlasWidth); + top = (2*rect.origin.y+1)/(2*atlasHeight); + bottom = top+(rect.size.width*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; - right = (rect.origin.x+rect.size.height) / atlasWidth; - top = rect.origin.y/atlasHeight; - bottom = (rect.origin.y+rect.size.width) / atlasHeight; + right = (rect.origin.x+rect.size.height) / atlasWidth; + top = rect.origin.y/atlasHeight; + bottom = (rect.origin.y+rect.size.width) / atlasHeight; #endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if (_flipX) @@ -551,10 +550,10 @@ void Sprite::draw(void) CC_NODE_DRAW_SETUP(); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); - ccGLBindTexture2D( _texture->getName() ); - ccGLEnableVertexAttribs( kVertexAttribFlag_PosColorTex ); + GL::bindTexture2D( _texture->getName() ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); #define kQuadSize sizeof(_quad.bl) #ifdef EMSCRIPTEN @@ -566,15 +565,15 @@ void Sprite::draw(void) // vertex int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -609,27 +608,27 @@ void Sprite::draw(void) // Node overrides -void Sprite::addChild(Node* pChild) +void Sprite::addChild(Node* child) { - Node::addChild(pChild); + Node::addChild(child); } -void Sprite::addChild(Node *pChild, int zOrder) +void Sprite::addChild(Node *child, int zOrder) { - Node::addChild(pChild, zOrder); + Node::addChild(child, zOrder); } -void Sprite::addChild(Node *pChild, int zOrder, int tag) +void Sprite::addChild(Node *child, int zOrder, int tag) { - CCASSERT(pChild != NULL, "Argument must be non-NULL"); + CCASSERT(child != NULL, "Argument must be non-NULL"); if (_batchNode) { - Sprite* pChildSprite = dynamic_cast(pChild); - CCASSERT( pChildSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); - CCASSERT(pChildSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); + Sprite* childSprite = dynamic_cast(child); + CCASSERT( childSprite, "CCSprite only supports Sprites as children when using SpriteBatchNode"); + CCASSERT(childSprite->getTexture()->getName() == _textureAtlas->getTexture()->getName(), ""); //put it in descendants array of batch node - _batchNode->appendChild(pChildSprite); + _batchNode->appendChild(childSprite); if (!_reorderChildDirty) { @@ -637,16 +636,16 @@ void Sprite::addChild(Node *pChild, int zOrder, int tag) } } //CCNode already sets isReorderChildDirty_ so this needs to be after batchNode check - Node::addChild(pChild, zOrder, tag); + Node::addChild(child, zOrder, tag); _hasChildren = true; } -void Sprite::reorderChild(Node *pChild, int zOrder) +void Sprite::reorderChild(Node *child, int zOrder) { - CCASSERT(pChild != NULL, ""); - CCASSERT(_children->containsObject(pChild), ""); + CCASSERT(child != NULL, ""); + CCASSERT(_children->containsObject(child), ""); - if (zOrder == pChild->getZOrder()) + if (zOrder == child->getZOrder()) { return; } @@ -657,17 +656,17 @@ void Sprite::reorderChild(Node *pChild, int zOrder) _batchNode->reorderBatch(true); } - Node::reorderChild(pChild, zOrder); + Node::reorderChild(child, zOrder); } -void Sprite::removeChild(Node *pChild, bool bCleanup) +void Sprite::removeChild(Node *child, bool bCleanup) { if (_batchNode) { - _batchNode->removeSpriteFromAtlas((Sprite*)(pChild)); + _batchNode->removeSpriteFromAtlas((Sprite*)(child)); } - Node::removeChild(pChild, bCleanup); + Node::removeChild(child, bCleanup); } @@ -678,10 +677,10 @@ void Sprite::removeAllChildrenWithCleanup(bool bCleanup) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Sprite* pChild = dynamic_cast(pObject); - if (pChild) + Sprite* child = dynamic_cast(pObject); + if (child) { - _batchNode->removeSpriteFromAtlas(pChild); + _batchNode->removeSpriteFromAtlas(child); } } } @@ -754,10 +753,10 @@ void Sprite::setDirtyRecursively(bool bValue) Object* pObject = NULL; CCARRAY_FOREACH(_children, pObject) { - Sprite* pChild = dynamic_cast(pObject); - if (pChild) + Sprite* child = dynamic_cast(pObject); + if (child) { - pChild->setDirtyRecursively(true); + child->setDirtyRecursively(true); } } } @@ -1017,9 +1016,9 @@ SpriteBatchNode* Sprite::getBatchNode(void) return _batchNode; } -void Sprite::setBatchNode(SpriteBatchNode *pobSpriteBatchNode) +void Sprite::setBatchNode(SpriteBatchNode *spriteBatchNode) { - _batchNode = pobSpriteBatchNode; // weak reference + _batchNode = spriteBatchNode; // weak reference // self render if( ! _batchNode ) { @@ -1054,14 +1053,12 @@ void Sprite::updateBlendFunc(void) // it is possible to have an untextured sprite if (! _texture || ! _texture->hasPremultipliedAlpha()) { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; setOpacityModifyRGB(false); } else { - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setOpacityModifyRGB(true); } } @@ -1102,7 +1099,7 @@ void Sprite::setTexture(Texture2D *texture) if (NULL == texture) { Image* image = new Image(); - bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::kFmtRawData, 2, 2, 8); + bool isOK = image->initWithImageData(cc_2x2_white_image, sizeof(cc_2x2_white_image), Image::Format::RAW_DATA, 2, 2, 8); CCASSERT(isOK, "The 2x2 empty texture was created unsuccessfully."); texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 313abd4b2e..bcead0dc23 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -101,40 +101,40 @@ public: * After creation, the rect of sprite will be the size of the image, * and the offset will be (0,0). * - * @param pszFileName The string which indicates a path to image file, e.g., "scene1/monster.png". + * @param filename The string which indicates a path to image file, e.g., "scene1/monster.png". * @return A valid sprite object that is marked as autoreleased. */ - static Sprite* create(const char *pszFileName); + static Sprite* create(const char *filename); /** * Creates a sprite with an image filename and a rect. * - * @param pszFileName The string wich indicates a path to image file, e.g., "scene1/monster.png" - * @param rect Only the contents inside rect of pszFileName's texture will be applied for this sprite. + * @param filename The string wich indicates a path to image file, e.g., "scene1/monster.png" + * @param rect Only the contents inside rect of filename's texture will be applied for this sprite. * @return A valid sprite object that is marked as autoreleased. */ - static Sprite* create(const char *pszFileName, const Rect& rect); + static Sprite* create(const char *filename, const Rect& rect); /** * Creates a sprite with an exsiting texture contained in a Texture2D object * After creation, the rect will be the size of the texture, and the offset will be (0,0). * - * @param pTexture A pointer to a Texture2D object. + * @param texture A pointer to a Texture2D object. * @return A valid sprite object that is marked as autoreleased. */ - static Sprite* createWithTexture(Texture2D *pTexture); + static Sprite* createWithTexture(Texture2D *texture); /** * Creates a sprite with a texture and a rect. * * After creation, the offset will be (0,0). * - * @param pTexture A pointer to an existing Texture2D object. + * @param texture A pointer to an existing Texture2D object. * You can use a Texture2D object for many sprites. * @param rect Only the contents inside the rect of this texture will be applied for this sprite. * @return A valid sprite object that is marked as autoreleased. */ - static Sprite* createWithTexture(Texture2D *pTexture, const Rect& rect); + static Sprite* createWithTexture(Texture2D *texture, const Rect& rect); /** * Creates a sprite with an sprite frame. @@ -147,13 +147,13 @@ public: /** * Creates a sprite with an sprite frame name. * - * A SpriteFrame will be fetched from the SpriteFrameCache by pszSpriteFrameName param. + * A SpriteFrame will be fetched from the SpriteFrameCache by spriteFrameName param. * If the SpriteFrame doesn't exist it will raise an exception. * - * @param pszSpriteFrameName A null terminated string which indicates the sprite frame name. + * @param spriteFrameName A null terminated string which indicates the sprite frame name. * @return A valid sprite object that is marked as autoreleased. */ - static Sprite* createWithSpriteFrameName(const char *pszSpriteFrameName); + static Sprite* createWithSpriteFrameName(const char *spriteFrameName); /// @} end of creators group @@ -181,23 +181,23 @@ public: * * After initialization, the rect used will be the size of the texture, and the offset will be (0,0). * - * @param pTexture A pointer to an existing Texture2D object. + * @param texture A pointer to an existing Texture2D object. * You can use a Texture2D object for many sprites. * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithTexture(Texture2D *pTexture); + virtual bool initWithTexture(Texture2D *texture); /** * Initializes a sprite with a texture and a rect. * * After initialization, the offset will be (0,0). * - * @param pTexture A pointer to an exisiting Texture2D object. + * @param texture A pointer to an exisiting Texture2D object. * You can use a Texture2D object for many sprites. * @param rect Only the contents inside rect of this texture will be applied for this sprite. * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithTexture(Texture2D *pTexture, const Rect& rect); + virtual bool initWithTexture(Texture2D *texture, const Rect& rect); /** * Initializes a sprite with a texture and a rect in points, optionally rotated. @@ -205,12 +205,12 @@ public: * After initialization, the offset will be (0,0). * @note This is the designated initializer. * - * @param pTexture A Texture2D object whose texture will be applied to this sprite. + * @param texture A Texture2D object whose texture will be applied to this sprite. * @param rect A rectangle assigned the contents of texture. * @param rotated Whether or not the texture rectangle is rotated. * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithTexture(Texture2D *pTexture, const Rect& rect, bool rotated); + virtual bool initWithTexture(Texture2D *texture, const Rect& rect, bool rotated); /** * Initializes a sprite with an SpriteFrame. The texture and rect in SpriteFrame will be applied on this sprite @@ -226,35 +226,35 @@ public: * A SpriteFrame will be fetched from the SpriteFrameCache by name. * If the SpriteFrame doesn't exist it will raise an exception. * - * @param pszSpriteFrameName A key string that can fected a volid SpriteFrame from SpriteFrameCache + * @param spriteFrameName A key string that can fected a volid SpriteFrame from SpriteFrameCache * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithSpriteFrameName(const char *pszSpriteFrameName); + virtual bool initWithSpriteFrameName(const char *spriteFrameName); /** * Initializes a sprite with an image filename. * - * This method will find pszFilename from local file system, load its content to Texture2D, + * This method will find filename from local file system, load its content to Texture2D, * then use Texture2D to create a sprite. * After initialization, the rect used will be the size of the image. The offset will be (0,0). * - * @param pszFilename The path to an image file in local file system + * @param filename The path to an image file in local file system * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithFile(const char *pszFilename); + virtual bool initWithFile(const char *filename); /** * Initializes a sprite with an image filename, and a rect. * - * This method will find pszFilename from local file system, load its content to Texture2D, + * This method will find filename from local file system, load its content to Texture2D, * then use Texture2D to create a sprite. * After initialization, the offset will be (0,0). * - * @param pszFilename The path to an image file in local file system. + * @param filename The path to an image file in local file system. * @param rect The rectangle assigned the content area from texture. * @return true if the sprite is initialized properly, false otherwise. */ - virtual bool initWithFile(const char *pszFilename, const Rect& rect); + virtual bool initWithFile(const char *filename, const Rect& rect); /// @} end of initializers @@ -283,7 +283,7 @@ public: * layer->addChild(batch); * @endcode */ - virtual void setBatchNode(SpriteBatchNode *pobSpriteBatchNode); + virtual void setBatchNode(SpriteBatchNode *spriteBatchNode); /// @} end of BatchNode methods @@ -464,12 +464,12 @@ public: virtual void setRotationY(float fRotationY) override; virtual void setSkewX(float sx) override; virtual void setSkewY(float sy) override; - virtual void removeChild(Node* pChild, bool bCleanup) override; + virtual void removeChild(Node* child, bool bCleanup) override; virtual void removeAllChildrenWithCleanup(bool bCleanup) override; - virtual void reorderChild(Node *pChild, int zOrder) override; - virtual void addChild(Node *pChild) override; - virtual void addChild(Node *pChild, int zOrder) override; - virtual void addChild(Node *pChild, int zOrder, int tag) override; + virtual void reorderChild(Node *child, int zOrder) override; + virtual void addChild(Node *child) override; + virtual void addChild(Node *child, int zOrder) override; + virtual void addChild(Node *child, int zOrder, int tag) override; virtual void sortAllChildren() override; virtual void setScale(float fScale) override; virtual void setVertexZ(float fVertexZ) override; diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index e3c9744a1e..073d2718b3 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -74,8 +74,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity) { CCASSERT(capacity>=0, "Capacity must be >= 0"); - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _textureAtlas = new TextureAtlas(); if (0 == capacity) @@ -94,7 +93,7 @@ bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity) _descendants = new Array(); _descendants->initWithCapacity(capacity); - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return true; } @@ -110,8 +109,8 @@ bool SpriteBatchNode::init() */ bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity) { - Texture2D *pTexture2D = TextureCache::getInstance()->addImage(fileImage); - return initWithTexture(pTexture2D, capacity); + Texture2D *texture2D = TextureCache::getInstance()->addImage(fileImage); + return initWithTexture(texture2D, capacity); } SpriteBatchNode::SpriteBatchNode() @@ -166,7 +165,6 @@ void SpriteBatchNode::visit(void) setOrderOfArrival(0); CC_PROFILER_STOP_CATEGORY(kProfilerCategoryBatchSprite, "CCSpriteBatchNode - visit"); - } void SpriteBatchNode::addChild(Node *child, int zOrder, int tag) @@ -281,8 +279,8 @@ void SpriteBatchNode::sortAllChildren() // and at the same time reorder descendants and the quads to the right index CCARRAY_FOREACH(_children, pObj) { - Sprite* pChild = static_cast(pObj); - updateAtlasIndex(pChild, &index); + Sprite* child = static_cast(pObj); + updateAtlasIndex(child, &index); } } @@ -293,10 +291,10 @@ void SpriteBatchNode::sortAllChildren() void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex) { unsigned int count = 0; - Array* pArray = sprite->getChildren(); - if (pArray != NULL) + Array* array = sprite->getChildren(); + if (array != NULL) { - count = pArray->count(); + count = array->count(); } int oldIndex = 0; @@ -315,7 +313,7 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex) { bool needNewIndex=true; - if (static_cast(pArray->data->arr[0])->getZOrder() >= 0) + if (static_cast(array->data->arr[0])->getZOrder() >= 0) { //all children are in front of the parent oldIndex = sprite->getAtlasIndex(); @@ -331,7 +329,7 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex) } Object* pObj = NULL; - CCARRAY_FOREACH(pArray,pObj) + CCARRAY_FOREACH(array,pObj) { Sprite* child = static_cast(pObj); if (needNewIndex && child->getZOrder() >= 0) @@ -400,7 +398,7 @@ void SpriteBatchNode::draw(void) arrayMakeObjectsPerformSelector(_children, updateTransform, Sprite*); - ccGLBlendFunc( _blendFunc.src, _blendFunc.dst ); + GL::blendFunc( _blendFunc.src, _blendFunc.dst ); _textureAtlas->drawQuads(); @@ -428,17 +426,17 @@ void SpriteBatchNode::increaseAtlasCapacity(void) unsigned int SpriteBatchNode::rebuildIndexInOrder(Sprite *pobParent, unsigned int uIndex) { - Array *pChildren = pobParent->getChildren(); + Array *children = pobParent->getChildren(); - if (pChildren && pChildren->count() > 0) + if (children && children->count() > 0) { Object* pObject = NULL; - CCARRAY_FOREACH(pChildren, pObject) + CCARRAY_FOREACH(children, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild && (pChild->getZOrder() < 0)) + Sprite* child = static_cast(pObject); + if (child && (child->getZOrder() < 0)) { - uIndex = rebuildIndexInOrder(pChild, uIndex); + uIndex = rebuildIndexInOrder(child, uIndex); } } } @@ -450,15 +448,15 @@ unsigned int SpriteBatchNode::rebuildIndexInOrder(Sprite *pobParent, unsigned in uIndex++; } - if (pChildren && pChildren->count() > 0) + if (children && children->count() > 0) { Object* pObject = NULL; - CCARRAY_FOREACH(pChildren, pObject) + CCARRAY_FOREACH(children, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild && (pChild->getZOrder() >= 0)) + Sprite* child = static_cast(pObject); + if (child && (child->getZOrder() >= 0)) { - uIndex = rebuildIndexInOrder(pChild, uIndex); + uIndex = rebuildIndexInOrder(child, uIndex); } } } @@ -468,39 +466,39 @@ unsigned int SpriteBatchNode::rebuildIndexInOrder(Sprite *pobParent, unsigned in unsigned int SpriteBatchNode::highestAtlasIndexInChild(Sprite *pSprite) { - Array *pChildren = pSprite->getChildren(); + Array *children = pSprite->getChildren(); - if (! pChildren || pChildren->count() == 0) + if (! children || children->count() == 0) { return pSprite->getAtlasIndex(); } else { - return highestAtlasIndexInChild((Sprite*)(pChildren->lastObject())); + return highestAtlasIndexInChild((Sprite*)(children->lastObject())); } } unsigned int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *pSprite) { - Array *pChildren = pSprite->getChildren(); + Array *children = pSprite->getChildren(); - if (! pChildren || pChildren->count() == 0) + if (! children || children->count() == 0) { return pSprite->getAtlasIndex(); } else { - return lowestAtlasIndexInChild((Sprite*)(pChildren->objectAtIndex(0))); + return lowestAtlasIndexInChild((Sprite*)(children->objectAtIndex(0))); } } -unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *pobSprite, int nZ) +unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ) { - Array *pBrothers = pobSprite->getParent()->getChildren(); - unsigned int uChildIndex = pBrothers->indexOfObject(pobSprite); + Array *pBrothers = sprite->getParent()->getChildren(); + unsigned int uChildIndex = pBrothers->indexOfObject(sprite); // ignore parent Z if parent is spriteSheet - bool bIgnoreParent = (SpriteBatchNode*)(pobSprite->getParent()) == this; + bool bIgnoreParent = (SpriteBatchNode*)(sprite->getParent()) == this; Sprite *pPrevious = NULL; if (uChildIndex > 0 && uChildIndex < UINT_MAX) @@ -524,7 +522,7 @@ unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *pobSprite, int nZ) // first child of an Sprite ? if (uChildIndex == 0) { - Sprite *p = (Sprite*)(pobSprite->getParent()); + Sprite *p = (Sprite*)(sprite->getParent()); // less than parent and brothers if (nZ < 0) @@ -545,7 +543,7 @@ unsigned int SpriteBatchNode::atlasIndexForChild(Sprite *pobSprite, int nZ) } // else (previous < 0 and sprite >= 0 ) - Sprite *p = (Sprite*)(pobSprite->getParent()); + Sprite *p = (Sprite*)(sprite->getParent()); return p->getAtlasIndex() + 1; } @@ -577,19 +575,19 @@ void SpriteBatchNode::insertChild(Sprite *pSprite, unsigned int uIndex) // update indices unsigned int i = uIndex+1; - Sprite* pChild = nullptr; + Sprite* child = nullptr; for(; inum; i++){ - pChild = static_cast(descendantsData->arr[i]); - pChild->setAtlasIndex(pChild->getAtlasIndex() + 1); + child = static_cast(descendantsData->arr[i]); + child->setAtlasIndex(child->getAtlasIndex() + 1); } // add children recursively Object* pObj = nullptr; CCARRAY_FOREACH(pSprite->getChildren(), pObj) { - pChild = static_cast(pObj); - unsigned int idx = atlasIndexForChild(pChild, pChild->getZOrder()); - insertChild(pChild, idx); + child = static_cast(pObj); + unsigned int idx = atlasIndexForChild(child, child->getZOrder()); + insertChild(child, idx); } } @@ -625,15 +623,15 @@ void SpriteBatchNode::appendChild(Sprite* sprite) } } -void SpriteBatchNode::removeSpriteFromAtlas(Sprite *pobSprite) +void SpriteBatchNode::removeSpriteFromAtlas(Sprite *sprite) { // remove from TextureAtlas - _textureAtlas->removeQuadAtIndex(pobSprite->getAtlasIndex()); + _textureAtlas->removeQuadAtIndex(sprite->getAtlasIndex()); // Cleanup sprite. It might be reused (issue #569) - pobSprite->setBatchNode(NULL); + sprite->setBatchNode(NULL); - unsigned int uIndex = _descendants->indexOfObject(pobSprite); + unsigned int uIndex = _descendants->indexOfObject(sprite); if (uIndex != UINT_MAX) { _descendants->removeObjectAtIndex(uIndex); @@ -649,16 +647,16 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *pobSprite) } // remove children recursively - Array *pChildren = pobSprite->getChildren(); - if (pChildren && pChildren->count() > 0) + Array *children = sprite->getChildren(); + if (children && children->count() > 0) { Object* pObject = NULL; - CCARRAY_FOREACH(pChildren, pObject) + CCARRAY_FOREACH(children, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild) + Sprite* child = static_cast(pObject); + if (child) { - removeSpriteFromAtlas(pChild); + removeSpriteFromAtlas(child); } } } @@ -667,10 +665,7 @@ void SpriteBatchNode::removeSpriteFromAtlas(Sprite *pobSprite) void SpriteBatchNode::updateBlendFunc(void) { if (! _textureAtlas->getTexture()->hasPremultipliedAlpha()) - { - _blendFunc.src = GL_SRC_ALPHA; - _blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - } + _blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED; } // CocosNodeTexture protocol @@ -761,8 +756,8 @@ SpriteBatchNode * SpriteBatchNode::addSpriteWithoutQuad(Sprite*child, int z, int Object* pObject = NULL; CCARRAY_FOREACH(_descendants, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild && (pChild->getAtlasIndex() >= z)) + Sprite* child = static_cast(pObject); + if (child && (child->getAtlasIndex() >= z)) { ++i; } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index a3d4bf0236..202df05c70 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -264,11 +264,11 @@ void SpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) CCLOG("cocos2d: SpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); } - Texture2D *pTexture = TextureCache::getInstance()->addImage(texturePath.c_str()); + Texture2D *texture = TextureCache::getInstance()->addImage(texturePath.c_str()); - if (pTexture) + if (texture) { - addSpriteFramesWithDictionary(dict, pTexture); + addSpriteFramesWithDictionary(dict, texture); _loadedFileNames->insert(pszPlist); } else diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index db2a46296f..ba4ca83b01 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -193,13 +193,13 @@ void tgaFlipImage( tImageTGA *psInfo ) } // this is the function to call when we want to load an image -tImageTGA * tgaLoad(const char *pszFilename) +tImageTGA * tgaLoad(const char *filename) { int mode,total; tImageTGA *info = NULL; unsigned long nSize = 0; - unsigned char* pBuffer = FileUtils::getInstance()->getFileData(pszFilename, "rb", &nSize); + unsigned char* pBuffer = FileUtils::getInstance()->getFileData(filename, "rb", &nSize); do { diff --git a/cocos2dx/support/image_support/TGAlib.h b/cocos2dx/support/image_support/TGAlib.h index 141b6a2fff..28a19324b1 100644 --- a/cocos2dx/support/image_support/TGAlib.h +++ b/cocos2dx/support/image_support/TGAlib.h @@ -59,7 +59,7 @@ bool tgaLoadHeader(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psIn bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *psInfo); /// this is the function to call when we want to load an image -tImageTGA * tgaLoad(const char *pszFilename); +tImageTGA * tgaLoad(const char *filename); // /converts RGB to grayscale void tgaRGBtogreyscale(tImageTGA *psInfo); diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.cpp b/cocos2dx/text_input_node/CCTextFieldTTF.cpp index 59cba466d7..f6a719a936 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.cpp +++ b/cocos2dx/text_input_node/CCTextFieldTTF.cpp @@ -70,7 +70,7 @@ TextFieldTTF::~TextFieldTTF() // static constructor ////////////////////////////////////////////////////////////////////////// -TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) +TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment alignment, const char *fontName, float fontSize) { TextFieldTTF *pRet = new TextFieldTTF(); if(pRet && pRet->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize)) @@ -106,7 +106,7 @@ TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const char *placeholder, c // initialize ////////////////////////////////////////////////////////////////////////// -bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize) +bool TextFieldTTF::initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment alignment, const char *fontName, float fontSize) { if (placeholder) { diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index fc7893d620..3b4b2fbee9 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -103,11 +103,11 @@ public: //char * description(); /** creates a TextFieldTTF from a fontname, alignment, dimension and font size */ - static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); + static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment alignment, const char *fontName, float fontSize); /** creates a LabelTTF from a fontname and font size */ static TextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); /** initializes the TextFieldTTF with a font name, alignment, dimension and font size */ - bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, TextAlignment alignment, const char *fontName, float fontSize); + bool initWithPlaceHolder(const char *placeholder, const Size& dimensions, Label::HAlignment alignment, const char *fontName, float fontSize); /** initializes the TextFieldTTF with a font name and font size */ bool initWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 2ed6ad2813..05c388c9ee 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -55,7 +55,7 @@ NS_CC_BEGIN // If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit) // Default is: RGBA8888 (32-bit textures) -static Texture2DPixelFormat g_defaultAlphaPixelFormat = kTexture2DPixelFormat_Default; +static Texture2D::PixelFormat g_defaultAlphaPixelFormat = Texture2D::PixelFormat::DEFAULT; // By default PVR images are treated as if they don't have the alpha channel premultiplied static bool PVRHaveAlphaPremultiplied_ = false; @@ -64,7 +64,7 @@ Texture2D::Texture2D() : _PVRHaveAlphaPremultiplied(true) , _pixelsWide(0) , _pixelsHigh(0) -, _pixelFormat(kTexture2DPixelFormat_Default) +, _pixelFormat(Texture2D::PixelFormat::DEFAULT) , _name(0) , _maxS(0.0) , _maxT(0.0) @@ -85,11 +85,11 @@ Texture2D::~Texture2D() if(_name) { - ccGLDeleteTexture(_name); + GL::deleteTexture(_name); } } -Texture2DPixelFormat Texture2D::getPixelFormat() const +Texture2D::PixelFormat Texture2D::getPixelFormat() const { return _pixelFormat; } @@ -172,11 +172,11 @@ bool Texture2D::hasPremultipliedAlpha() const return _hasPremultipliedAlpha; } -bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize) +bool Texture2D::initWithData(const void *data, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize) { unsigned int bitsPerPixel; //Hack: bitsPerPixelForFormat returns wrong number for RGB_888 textures. See function. - if(pixelFormat == kTexture2DPixelFormat_RGB888) + if(pixelFormat == Texture2D::PixelFormat::RGB888) { bitsPerPixel = 24; } @@ -206,7 +206,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, glGenTextures(1, &_name); - ccGLBindTexture2D(_name); + GL::bindTexture2D(_name); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); @@ -217,28 +217,28 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, switch(pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: + case Texture2D::PixelFormat::RGBA8888: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); break; - case kTexture2DPixelFormat_RGB888: + case Texture2D::PixelFormat::RGB888: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_BYTE, data); break; - case kTexture2DPixelFormat_RGBA4444: + case Texture2D::PixelFormat::RGBA4444: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data); break; - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGB5A1: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data); break; - case kTexture2DPixelFormat_RGB565: + case Texture2D::PixelFormat::RGB565: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); break; - case kTexture2DPixelFormat_AI88: + case Texture2D::PixelFormat::AI88: glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data); break; - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data); break; - case kTexture2DPixelFormat_I8: + case Texture2D::PixelFormat::I8: glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, (GLsizei)pixelsWide, (GLsizei)pixelsHigh, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); break; default: @@ -256,7 +256,7 @@ bool Texture2D::initWithData(const void *data, Texture2DPixelFormat pixelFormat, _hasPremultipliedAlpha = false; _hasMipmaps = false; - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTexture)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE)); return true; } @@ -301,7 +301,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi unsigned short* outPixel16 = NULL; bool hasAlpha = image->hasAlpha(); Size imageSize = Size((float)(image->getWidth()), (float)(image->getHeight())); - Texture2DPixelFormat pixelFormat; + Texture2D::PixelFormat pixelFormat; size_t bpp = image->getBitsPerComponent(); // compute pixel format @@ -313,11 +313,11 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi { if (bpp >= 8) { - pixelFormat = kTexture2DPixelFormat_RGB888; + pixelFormat = Texture2D::PixelFormat::RGB888; } else { - pixelFormat = kTexture2DPixelFormat_RGB565; + pixelFormat = Texture2D::PixelFormat::RGB565; } } @@ -325,7 +325,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi // Repack the pixel data into the right format unsigned int length = width * height; - if (pixelFormat == kTexture2DPixelFormat_RGB565) + if (pixelFormat == Texture2D::PixelFormat::RGB565) { if (hasAlpha) { @@ -360,7 +360,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi } } } - else if (pixelFormat == kTexture2DPixelFormat_RGBA4444) + else if (pixelFormat == Texture2D::PixelFormat::RGBA4444) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRGGGGBBBBAAAA" @@ -377,7 +377,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi ((((*inPixel32 >> 24) & 0xFF) >> 4) << 0); // A } } - else if (pixelFormat == kTexture2DPixelFormat_RGB5A1) + else if (pixelFormat == Texture2D::PixelFormat::RGB5A1) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRGGGGGBBBBBA" inPixel32 = (unsigned int*)image->getData(); @@ -393,7 +393,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi ((((*inPixel32 >> 24) & 0xFF) >> 7) << 0); // A } } - else if (pixelFormat == kTexture2DPixelFormat_A8) + else if (pixelFormat == Texture2D::PixelFormat::A8) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "AAAAAAAA" inPixel32 = (unsigned int*)image->getData(); @@ -406,7 +406,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi } } - if (hasAlpha && pixelFormat == kTexture2DPixelFormat_RGB888) + if (hasAlpha && pixelFormat == Texture2D::PixelFormat::RGB888) { // Convert "RRRRRRRRRGGGGGGGGBBBBBBBBAAAAAAAA" to "RRRRRRRRGGGGGGGGBBBBBBBB" inPixel32 = (unsigned int*)image->getData(); @@ -433,7 +433,7 @@ bool Texture2D::initPremultipliedATextureWithImage(Image *image, unsigned int wi } // implementation Texture2D (Text) -bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, TextAlignment hAlignment/* = kTextAlignmentCenter */, VerticalTextAlignment vAlignment/* = kVerticalTextAlignmentTop */) +bool Texture2D::initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions/* = Size(0, 0)*/, Label::HAlignment hAlignment/* = Label::HAlignment::CENTER */, Label::VAlignment vAlignment/* = Label::VAlignment::TOP */) { FontDefinition tempDef; @@ -461,20 +461,20 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin bool bRet = false; Image::ETextAlign eAlign; - if (kVerticalTextAlignmentTop == textDefinition._vertAlignment) + if (Label::VAlignment::TOP == textDefinition._vertAlignment) { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignTop - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignTop + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignTopLeft : Image::kAlignTopRight; } - else if (kVerticalTextAlignmentCenter == textDefinition._vertAlignment) + else if (Label::VAlignment::CENTER == textDefinition._vertAlignment) { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignCenter - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignCenter + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignLeft : Image::kAlignRight; } - else if (kVerticalTextAlignmentBottom == textDefinition._vertAlignment) + else if (Label::VAlignment::BOTTOM == textDefinition._vertAlignment) { - eAlign = (kTextAlignmentCenter == textDefinition._alignment) ? Image::kAlignBottom - : (kTextAlignmentLeft == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; + eAlign = (Label::HAlignment::CENTER == textDefinition._alignment) ? Image::kAlignBottom + : (Label::HAlignment::LEFT == textDefinition._alignment) ? Image::kAlignBottomLeft : Image::kAlignBottomRight; } else { @@ -591,22 +591,22 @@ void Texture2D::drawAtPoint(const Point& point) point.x, height + point.y, width + point.x, height + point.y }; - ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins(); - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -625,21 +625,21 @@ void Texture2D::drawInRect(const Rect& rect) rect.origin.x, rect.origin.y + rect.size.height, /*0.0f,*/ rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, /*0.0f*/ }; - ccGLEnableVertexAttribs( kVertexAttribFlag_Position | kVertexAttribFlag_TexCoords ); + GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS ); _shaderProgram->use(); _shaderProgram->setUniformsForBuiltins(); - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); #ifdef EMSCRIPTEN setGLBufferData(vertices, 8 * sizeof(GLfloat), 0); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0); setGLBufferData(coordinates, 8 * sizeof(GLfloat), 1); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0); #else - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coordinates); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, coordinates); #endif // EMSCRIPTEN glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } @@ -662,7 +662,7 @@ bool Texture2D::initWithPVRFile(const char* file) _pixelsWide = pvr->getWidth(); _pixelsHigh = pvr->getHeight(); _contentSize = Size((float)_pixelsWide, (float)_pixelsHigh); - _hasPremultipliedAlpha = PVRHaveAlphaPremultiplied_; + _hasPremultipliedAlpha = (pvr->isForcePremultipliedAlpha()) ? pvr->hasPremultipliedAlpha() : _PVRHaveAlphaPremultiplied; _pixelFormat = pvr->getFormat(); _hasMipmaps = pvr->getNumberOfMipmaps() > 1; @@ -718,7 +718,7 @@ void Texture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) void Texture2D::generateMipmap() { CCASSERT( _pixelsWide == ccNextPOT(_pixelsWide) && _pixelsHigh == ccNextPOT(_pixelsHigh), "Mipmap texture only works in POT textures"); - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); glGenerateMipmap(GL_TEXTURE_2D); _hasMipmaps = true; } @@ -734,7 +734,7 @@ void Texture2D::setTexParameters(const ccTexParams &texParams) (_pixelsHigh == ccNextPOT(_pixelsHigh) || texParams.wrapT == GL_CLAMP_TO_EDGE), "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams.minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams.magFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texParams.wrapS ); @@ -747,7 +747,7 @@ void Texture2D::setTexParameters(const ccTexParams &texParams) void Texture2D::setAliasTexParameters() { - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); if( ! _hasMipmaps ) { @@ -767,7 +767,7 @@ void Texture2D::setAliasTexParameters() void Texture2D::setAntiAliasTexParameters() { - ccGLBindTexture2D( _name ); + GL::bindTexture2D( _name ); if( ! _hasMipmaps ) { @@ -789,34 +789,34 @@ const char* Texture2D::getStringForFormat() const { switch (_pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: + case Texture2D::PixelFormat::RGBA8888: return "RGBA8888"; - case kTexture2DPixelFormat_RGB888: + case Texture2D::PixelFormat::RGB888: return "RGB888"; - case kTexture2DPixelFormat_RGB565: + case Texture2D::PixelFormat::RGB565: return "RGB565"; - case kTexture2DPixelFormat_RGBA4444: + case Texture2D::PixelFormat::RGBA4444: return "RGBA4444"; - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGB5A1: return "RGB5A1"; - case kTexture2DPixelFormat_AI88: + case Texture2D::PixelFormat::AI88: return "AI88"; - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::A8: return "A8"; - case kTexture2DPixelFormat_I8: + case Texture2D::PixelFormat::I8: return "I8"; - case kTexture2DPixelFormat_PVRTC4: + case Texture2D::PixelFormat::PRVTC4: return "PVRTC4"; - case kTexture2DPixelFormat_PVRTC2: + case Texture2D::PixelFormat::PRVTC2: return "PVRTC2"; default: @@ -833,50 +833,50 @@ const char* Texture2D::getStringForFormat() const // // implementation Texture2D (PixelFormat) -void Texture2D::setDefaultAlphaPixelFormat(Texture2DPixelFormat format) +void Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat format) { g_defaultAlphaPixelFormat = format; } -Texture2DPixelFormat Texture2D::getDefaultAlphaPixelFormat() +Texture2D::PixelFormat Texture2D::getDefaultAlphaPixelFormat() { return g_defaultAlphaPixelFormat; } -unsigned int Texture2D::getBitsPerPixelForFormat(Texture2DPixelFormat format) const +unsigned int Texture2D::getBitsPerPixelForFormat(Texture2D::PixelFormat format) const { unsigned int ret=0; switch (format) { - case kTexture2DPixelFormat_RGBA8888: + case Texture2D::PixelFormat::RGBA8888: ret = 32; break; - case kTexture2DPixelFormat_RGB888: + case Texture2D::PixelFormat::RGB888: // It is 32 and not 24, since its internal representation uses 32 bits. ret = 32; break; - case kTexture2DPixelFormat_RGB565: + case Texture2D::PixelFormat::RGB565: ret = 16; break; - case kTexture2DPixelFormat_RGBA4444: + case Texture2D::PixelFormat::RGBA4444: ret = 16; break; - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGB5A1: ret = 16; break; - case kTexture2DPixelFormat_AI88: + case Texture2D::PixelFormat::AI88: ret = 16; break; - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::A8: ret = 8; break; - case kTexture2DPixelFormat_I8: + case Texture2D::PixelFormat::I8: ret = 8; break; - case kTexture2DPixelFormat_PVRTC4: + case Texture2D::PixelFormat::PRVTC4: ret = 4; break; - case kTexture2DPixelFormat_PVRTC2: + case Texture2D::PixelFormat::PRVTC2: ret = 2; break; default: diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 85e90b0776..0a5a234678 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -45,37 +45,6 @@ class Image; //CONSTANTS: -/** @typedef Texture2DPixelFormat -Possible texture pixel formats -*/ -typedef enum { - - //! 32-bit texture: RGBA8888 - kTexture2DPixelFormat_RGBA8888, - //! 24-bit texture: RGBA888 - kTexture2DPixelFormat_RGB888, - //! 16-bit texture without Alpha channel - kTexture2DPixelFormat_RGB565, - //! 8-bit textures used as masks - kTexture2DPixelFormat_A8, - //! 8-bit intensity texture - kTexture2DPixelFormat_I8, - //! 16-bit textures used as masks - kTexture2DPixelFormat_AI88, - //! 16-bit textures: RGBA4444 - kTexture2DPixelFormat_RGBA4444, - //! 16-bit textures: RGB5A1 - kTexture2DPixelFormat_RGB5A1, - //! 4-bit PVRTC-compressed texture: PVRTC4 - kTexture2DPixelFormat_PVRTC4, - //! 2-bit PVRTC-compressed texture: PVRTC2 - kTexture2DPixelFormat_PVRTC2, - - - //! Default texture format: RGBA8888 - kTexture2DPixelFormat_Default = kTexture2DPixelFormat_RGBA8888 -} Texture2DPixelFormat; - class GLProgram; /** @@ -102,14 +71,45 @@ class CC_DLL Texture2D : public Object #endif // EMSCRIPTEN { public: + /** @typedef Texture2D::PixelFormat + Possible texture pixel formats + */ + enum class PixelFormat + { + + //! 32-bit texture: RGBA8888 + RGBA8888, + //! 24-bit texture: RGBA888 + RGB888, + //! 16-bit texture without Alpha channel + RGB565, + //! 8-bit textures used as masks + A8, + //! 8-bit intensity texture + I8, + //! 16-bit textures used as masks + AI88, + //! 16-bit textures: RGBA4444 + RGBA4444, + //! 16-bit textures: RGB5A1 + RGB5A1, + //! 4-bit PVRTC-compressed texture: PVRTC4 + PRVTC4, + //! 2-bit PVRTC-compressed texture: PVRTC2 + PRVTC2, + + //! Default texture format: RGBA8888 + DEFAULT = RGBA8888 + }; + /** sets the default pixel format for UIImagescontains alpha channel. If the UIImage contains alpha channel, then the options are: - - generate 32-bit textures: kTexture2DPixelFormat_RGBA8888 (default one) - - generate 24-bit textures: kTexture2DPixelFormat_RGB888 - - generate 16-bit textures: kTexture2DPixelFormat_RGBA4444 - - generate 16-bit textures: kTexture2DPixelFormat_RGB5A1 - - generate 16-bit textures: kTexture2DPixelFormat_RGB565 - - generate 8-bit textures: kTexture2DPixelFormat_A8 (only use it if you use just 1 color) + - generate 32-bit textures: Texture2D::PixelFormat::RGBA8888 (default one) + - generate 24-bit textures: Texture2D::PixelFormat::RGB888 + - generate 16-bit textures: Texture2D::PixelFormat::RGBA4444 + - generate 16-bit textures: Texture2D::PixelFormat::RGB5A1 + - generate 16-bit textures: Texture2D::PixelFormat::RGB565 + - generate 8-bit textures: Texture2D::PixelFormat::A8 (only use it if you use just 1 color) How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) @@ -119,13 +119,13 @@ public: @since v0.8 */ - static void setDefaultAlphaPixelFormat(Texture2DPixelFormat format); + static void setDefaultAlphaPixelFormat(Texture2D::PixelFormat format); /** returns the alpha pixel format @since v0.8 */ - static Texture2DPixelFormat getDefaultAlphaPixelFormat(); - CC_DEPRECATED_ATTRIBUTE static Texture2DPixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); }; + static Texture2D::PixelFormat getDefaultAlphaPixelFormat(); + CC_DEPRECATED_ATTRIBUTE static Texture2D::PixelFormat defaultAlphaPixelFormat() { return Texture2D::getDefaultAlphaPixelFormat(); }; /** treats (or not) PVR files as if they have alpha premultiplied. Since it is impossible to know at runtime if the PVR images have the alpha channel premultiplied, it is @@ -148,7 +148,7 @@ public: void* keepData(void *data, unsigned int length); /** Initializes with a texture2d with data */ - bool initWithData(const void* data, Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize); + bool initWithData(const void* data, Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const Size& contentSize); /** Drawing extensions to make it easy to draw basic quads using a Texture2D object. @@ -168,7 +168,7 @@ public: bool initWithImage(Image * uiImage); /** Initializes a texture from a string with dimensions, alignment, font name and font size */ - bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), TextAlignment hAlignment = kTextAlignmentCenter, VerticalTextAlignment vAlignment = kVerticalTextAlignmentTop); + bool initWithString(const char *text, const char *fontName, float fontSize, const Size& dimensions = Size(0, 0), Label::HAlignment hAlignment = Label::HAlignment::CENTER, Label::VAlignment vAlignment = Label::VAlignment::TOP); /** Initializes a texture from a string using a text definition*/ bool initWithString(const char *text, const FontDefinition& textDefinition); @@ -186,6 +186,7 @@ public: @since v0.8 */ void setTexParameters(const ccTexParams& texParams); + CC_DEPRECATED_ATTRIBUTE void setTexParameters(const ccTexParams* texParams) { return setTexParameters(*texParams); }; /** sets antialias texture parameters: - GL_TEXTURE_MIN_FILTER = GL_LINEAR @@ -229,8 +230,8 @@ public: /** Helper functions that returns bits per pixels for a given format. @since v2.0 */ - unsigned int getBitsPerPixelForFormat(Texture2DPixelFormat format) const; - CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2DPixelFormat format) const { return getBitsPerPixelForFormat(format); }; + unsigned int getBitsPerPixelForFormat(Texture2D::PixelFormat format) const; + CC_DEPRECATED_ATTRIBUTE unsigned int bitsPerPixelForFormat(Texture2D::PixelFormat format) const { return getBitsPerPixelForFormat(format); }; /** content size */ const Size& getContentSizeInPixels(); @@ -239,7 +240,7 @@ public: bool hasMipmaps() const; /** Gets the pixel format of the texture */ - Texture2DPixelFormat getPixelFormat() const; + Texture2D::PixelFormat getPixelFormat() const; /** Gets the width of the texture in pixels */ unsigned int getPixelsWide() const; @@ -273,7 +274,7 @@ private: protected: /** pixel format of the texture */ - Texture2DPixelFormat _pixelFormat; + Texture2D::PixelFormat _pixelFormat; /** width in pixels */ unsigned int _pixelsWide; diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 417604370b..c7add0a1b2 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -62,7 +62,7 @@ TextureAtlas::~TextureAtlas() #if CC_TEXTURE_ATLAS_USE_VAO glDeleteVertexArrays(1, &_VAOname); - ccGLBindVAO(0); + GL::bindVAO(0); #endif CC_SAFE_RELEASE(_texture); @@ -121,13 +121,13 @@ TextureAtlas * TextureAtlas::create(const char* file, int capacity) TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity) { - TextureAtlas * pTextureAtlas = new TextureAtlas(); - if (pTextureAtlas && pTextureAtlas->initWithTexture(texture, capacity)) + TextureAtlas * textureAtlas = new TextureAtlas(); + if (textureAtlas && textureAtlas->initWithTexture(texture, capacity)) { - pTextureAtlas->autorelease(); - return pTextureAtlas; + textureAtlas->autorelease(); + return textureAtlas; } - CC_SAFE_DELETE(pTextureAtlas); + CC_SAFE_DELETE(textureAtlas); return NULL; } @@ -252,7 +252,7 @@ void TextureAtlas::setupIndices() void TextureAtlas::setupVBOandVAO() { glGenVertexArrays(1, &_VAOname); - ccGLBindVAO(_VAOname); + GL::bindVAO(_VAOname); #define kQuadSize sizeof(_quads[0].bl) @@ -262,22 +262,22 @@ void TextureAtlas::setupVBOandVAO() glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); // vertices - glEnableVertexAttribArray(kVertexAttrib_Position); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices)); // colors - glEnableVertexAttribArray(kVertexAttrib_Color); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors)); // tex coords - glEnableVertexAttribArray(kVertexAttrib_TexCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); + glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(_indices[0]) * _capacity * 6, _indices, GL_STATIC_DRAW); // Must unbind the VAO before changing the element buffer. - ccGLBindVAO(0); + GL::bindVAO(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -295,7 +295,7 @@ void TextureAtlas::setupVBO() void TextureAtlas::mapBuffers() { // Avoid changing the element buffer for whatever VAO might be bound. - ccGLBindVAO(0); + GL::bindVAO(0); glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, _quads, GL_DYNAMIC_DRAW); @@ -601,7 +601,7 @@ void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) if(!numberOfQuads) return; - ccGLBindTexture2D(_texture->getName()); + GL::bindTexture2D(_texture->getName()); #if CC_TEXTURE_ATLAS_USE_VAO @@ -630,7 +630,7 @@ void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) _dirty = false; } - ccGLBindVAO(_VAOname); + GL::bindVAO(_VAOname); #if CC_REBIND_INDICES_BUFFER glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); @@ -664,16 +664,16 @@ void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start) _dirty = false; } - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); // vertices - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices)); // colors - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors)); // tex coords - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]); diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8313506d2e..be124de3dc 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -207,8 +207,8 @@ void TextureCache::loadImage() const char *filename = pAsyncStruct->filename.c_str(); // compute image type - Image::EImageFormat imageType = computeImageFormatType(pAsyncStruct->filename); - if (imageType == Image::kFmtUnKnown) + Image::Format imageType = computeImageFormatType(pAsyncStruct->filename); + if (imageType == Image::Format::UNKOWN) { CCLOG("unsupported format %s",filename); delete pAsyncStruct; @@ -246,25 +246,25 @@ void TextureCache::loadImage() } } -Image::EImageFormat TextureCache::computeImageFormatType(string& filename) +Image::Format TextureCache::computeImageFormatType(string& filename) { - Image::EImageFormat ret = Image::kFmtUnKnown; + Image::Format ret = Image::Format::UNKOWN; if ((std::string::npos != filename.find(".jpg")) || (std::string::npos != filename.find(".jpeg"))) { - ret = Image::kFmtJpg; + ret = Image::Format::JPG; } else if ((std::string::npos != filename.find(".png")) || (std::string::npos != filename.find(".PNG"))) { - ret = Image::kFmtPng; + ret = Image::Format::PNG; } else if ((std::string::npos != filename.find(".tiff")) || (std::string::npos != filename.find(".TIFF"))) { - ret = Image::kFmtTiff; + ret = Image::Format::TIFF; } else if ((std::string::npos != filename.find(".webp")) || (std::string::npos != filename.find(".WEBP"))) { - ret = Image::kFmtWebp; + ret = Image::Format::WEBP; } return ret; @@ -365,22 +365,22 @@ Texture2D * TextureCache::addImage(const char * path) } else { - Image::EImageFormat eImageFormat = Image::kFmtUnKnown; + Image::Format eImageFormat = Image::Format::UNKOWN; if (std::string::npos != lowerCase.find(".png")) { - eImageFormat = Image::kFmtPng; + eImageFormat = Image::Format::PNG; } else if (std::string::npos != lowerCase.find(".jpg") || std::string::npos != lowerCase.find(".jpeg")) { - eImageFormat = Image::kFmtJpg; + eImageFormat = Image::Format::JPG; } else if (std::string::npos != lowerCase.find(".tif") || std::string::npos != lowerCase.find(".tiff")) { - eImageFormat = Image::kFmtTiff; + eImageFormat = Image::Format::TIFF; } else if (std::string::npos != lowerCase.find(".webp")) { - eImageFormat = Image::kFmtWebp; + eImageFormat = Image::Format::WEBP; } pImage = new Image(); @@ -433,7 +433,7 @@ Texture2D * TextureCache::addPVRImage(const char* path) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name - VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::kFmtRawData); + VolatileTexture::addImageTexture(texture, fullpath.c_str(), Image::Format::RAW_DATA); #endif _textures->setObject(texture, key.c_str()); texture->autorelease(); @@ -641,9 +641,9 @@ VolatileTexture::VolatileTexture(Texture2D *t) : _texture(t) , _cashedImageType(kInvalid) , _textureData(NULL) -, _pixelFormat(kTexture2DPixelFormat_RGBA8888) +, _pixelFormat(Texture2D::PixelFormat::RGBA8888) , _fileName("") -, _fmtImage(Image::kFmtPng) +, _fmtImage(Image::Format::PNG) , _text("") , _uiImage(NULL) { @@ -660,7 +660,7 @@ VolatileTexture::~VolatileTexture() CC_SAFE_RELEASE(_uiImage); } -void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format) +void VolatileTexture::addImageTexture(Texture2D *tt, const char* imageFileName, Image::Format format) { if (_isReloading) { @@ -705,7 +705,7 @@ VolatileTexture* VolatileTexture::findVolotileTexture(Texture2D *tt) return vt; } -void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize) +void VolatileTexture::addDataTexture(Texture2D *tt, void* data, Texture2D::PixelFormat pixelFormat, const Size& contentSize) { if (_isReloading) { @@ -785,7 +785,7 @@ void VolatileTexture::reloadAllTextures() if (std::string::npos != lowerCase.find(".pvr")) { - Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat(); + Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); vt->_texture->initWithPVRFile(vt->_fileName.c_str()); @@ -799,7 +799,7 @@ void VolatileTexture::reloadAllTextures() if (pImage && pImage->initWithImageData((void*)pBuffer, nSize, vt->_fmtImage)) { - Texture2DPixelFormat oldPixelFormat = Texture2D::defaultAlphaPixelFormat(); + Texture2D::PixelFormat oldPixelFormat = Texture2D::getDefaultAlphaPixelFormat(); Texture2D::setDefaultAlphaPixelFormat(vt->_pixelFormat); vt->_texture->initWithImage(pImage); Texture2D::setDefaultAlphaPixelFormat(oldPixelFormat); diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 594017734d..82d199609f 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -161,7 +161,7 @@ public: private: void addImageAsyncCallBack(float dt); void loadImage(); - Image::EImageFormat computeImageFormatType(std::string& filename); + Image::Format computeImageFormatType(std::string& filename); public: struct AsyncStruct @@ -179,7 +179,7 @@ protected: { AsyncStruct *asyncStruct; Image *image; - Image::EImageFormat imageType; + Image::Format imageType; } ImageInfo; std::thread* _loadingThread; @@ -218,9 +218,9 @@ public: VolatileTexture(Texture2D *t); ~VolatileTexture(); - static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::EImageFormat format); + static void addImageTexture(Texture2D *tt, const char* imageFileName, Image::Format format); static void addStringTexture(Texture2D *tt, const char* text, const FontDefinition& fontDefinition); - static void addDataTexture(Texture2D *tt, void* data, Texture2DPixelFormat pixelFormat, const Size& contentSize); + static void addDataTexture(Texture2D *tt, void* data, Texture2D::PixelFormat pixelFormat, const Size& contentSize); static void addImage(Texture2D *tt, Image *image); static void setTexParameters(Texture2D *t, const ccTexParams &texParams); @@ -245,10 +245,10 @@ protected: void *_textureData; Size _textureSize; - Texture2DPixelFormat _pixelFormat; + Texture2D::PixelFormat _pixelFormat; std::string _fileName; - Image::EImageFormat _fmtImage; + Image::Format _fmtImage; ccTexParams _texParams; std::string _text; diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 00aa5c0ef8..d06c0f8a35 100644 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -46,35 +46,35 @@ NS_CC_BEGIN static const ccPVRTexturePixelFormatInfo PVRTableFormats[] = { // 0: BGRA_8888 - {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true, kTexture2DPixelFormat_RGBA8888}, + {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PixelFormat::RGBA8888}, // 1: RGBA_8888 - {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, kTexture2DPixelFormat_RGBA8888}, + {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, true, Texture2D::PixelFormat::RGBA8888}, // 2: RGBA_4444 - {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, kTexture2DPixelFormat_RGBA4444}, + {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, true, Texture2D::PixelFormat::RGBA4444}, // 3: RGBA_5551 - {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, kTexture2DPixelFormat_RGB5A1}, + {GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, true, Texture2D::PixelFormat::RGB5A1}, // 4: RGB_565 - {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, kTexture2DPixelFormat_RGB565}, + {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, false, Texture2D::PixelFormat::RGB565}, // 5: RGB_888 - {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, kTexture2DPixelFormat_RGB888}, + {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, false, Texture2D::PixelFormat::RGB888}, // 6: A_8 - {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, kTexture2DPixelFormat_A8}, + {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PixelFormat::A8}, // 7: L_8 - {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, kTexture2DPixelFormat_I8}, + {GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, false, Texture2D::PixelFormat::I8}, // 8: LA_88 - {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, kTexture2DPixelFormat_AI88}, + {GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, true, Texture2D::PixelFormat::AI88}, // Not all platforms include GLES/gl2ext.h so these PVRTC enums are not always // available. #ifdef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG // 9: PVRTC 2BPP RGB - {GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false, kTexture2DPixelFormat_PVRTC2}, + {GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, false, Texture2D::PixelFormat::PRVTC2}, // 10: PVRTC 2BPP RGBA - {GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, kTexture2DPixelFormat_PVRTC2}, + {GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 2, true, true, Texture2D::PixelFormat::PRVTC2}, // 11: PVRTC 4BPP RGB - {GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, kTexture2DPixelFormat_PVRTC4}, + {GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, false, Texture2D::PixelFormat::PRVTC4}, // 12: PVRTC 4BPP RGBA - {GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, kTexture2DPixelFormat_PVRTC4}, + {GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 0xFFFFFFFF, 0xFFFFFFFF, 4, true, true, Texture2D::PixelFormat::PRVTC4}, #endif }; @@ -235,7 +235,7 @@ TexturePVR::TexturePVR() , _hasPremultipliedAlpha(false) , _forcePremultipliedAlpha(false) , _retainName(false) -, _format(kTexture2DPixelFormat_Default) +, _format(Texture2D::PixelFormat::DEFAULT) , _pixelFormatInfo(NULL) { } @@ -246,7 +246,7 @@ TexturePVR::~TexturePVR() if (_name != 0 && ! _retainName) { - ccGLDeleteTexture(_name); + GL::deleteTexture(_name); } } @@ -540,14 +540,14 @@ bool TexturePVR::createGLTexture() { if (_name != 0) { - ccGLDeleteTexture(_name); + GL::deleteTexture(_name); } // From PVR sources: "PVR files are never row aligned." glPixelStorei(GL_UNPACK_ALIGNMENT,1); glGenTextures(1, &_name); - ccGLBindTexture2D(_name); + GL::bindTexture2D(_name); // Default: Anti alias. if (_numberOfMipmaps == 1) @@ -667,21 +667,21 @@ bool TexturePVR::initWithContentsOfFile(const char* path) TexturePVR * TexturePVR::create(const char* path) { - TexturePVR * pTexture = new TexturePVR(); - if (pTexture) + TexturePVR * texture = new TexturePVR(); + if (texture) { - if (pTexture->initWithContentsOfFile(path)) + if (texture->initWithContentsOfFile(path)) { - pTexture->autorelease(); + texture->autorelease(); } else { - delete pTexture; - pTexture = NULL; + delete texture; + texture = NULL; } } - return pTexture; + return texture; } NS_CC_END diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index d98a4fe5b9..36a4add479 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -53,7 +53,7 @@ typedef struct _ccPVRTexturePixelFormatInfo { uint32_t bpp; bool compressed; bool alpha; - Texture2DPixelFormat ccPixelFormat; + Texture2D::PixelFormat ccPixelFormat; } ccPVRTexturePixelFormatInfo; /** @@ -115,7 +115,7 @@ public: inline bool isForcePremultipliedAlpha() const { return _forcePremultipliedAlpha; } /** how many mipmaps the texture has. 1 means one level (level 0 */ inline unsigned int getNumberOfMipmaps() const { return _numberOfMipmaps; } - inline Texture2DPixelFormat getFormat() const { return _format; } + inline Texture2D::PixelFormat getFormat() const { return _format; } inline bool isRetainName() const { return _retainName; } inline void setRetainName(bool retainName) { _retainName = retainName; } @@ -136,7 +136,7 @@ protected: // cocos2d integration bool _retainName; - Texture2DPixelFormat _format; + Texture2D::PixelFormat _format; const ccPVRTexturePixelFormatInfo *_pixelFormatInfo; }; diff --git a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h index 00ed30e664..7a752d4b2d 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tilemap_parallax_nodes/CCParallaxNode.h @@ -56,6 +56,9 @@ public: ParallaxNode(); virtual ~ParallaxNode(); + // prevents compiler warning: "Included function hides overloaded virtual functions" + using Node::addChild; + void addChild(Node * child, int z, const Point& parallaxRatio, const Point& positionOffset); /** Sets an array of layers for the Parallax node */ diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp index b2f6a03f5c..4929e12d70 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.cpp @@ -186,7 +186,7 @@ void TMXLayer::setupTiles() } // TMXLayer - Properties -String* TMXLayer::getPropertyNamed(const char *propertyName) const +String* TMXLayer::getProperty(const char *propertyName) const { return static_cast(_properties->objectForKey(propertyName)); } @@ -195,22 +195,22 @@ void TMXLayer::parseInternalProperties() { // if cc_vertex=automatic, then tiles will be rendered using vertexz - String *vertexz = getPropertyNamed("cc_vertexz"); + String *vertexz = getProperty("cc_vertexz"); if (vertexz) { // If "automatic" is on, then parse the "cc_alpha_func" too if (vertexz->_string == "automatic") { _useAutomaticVertexZ = true; - String *alphaFuncVal = getPropertyNamed("cc_alpha_func"); + String *alphaFuncVal = getProperty("cc_alpha_func"); float alphaFuncValue = 0.0f; if (alphaFuncVal != NULL) { alphaFuncValue = alphaFuncVal->floatValue(); } - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST)); - GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kUniformAlphaTestValue); + GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison @@ -390,13 +390,13 @@ Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos) Object* pObject = nullptr; CCARRAY_FOREACH(_children, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild) + Sprite* child = static_cast(pObject); + if (child) { - unsigned int ai = pChild->getAtlasIndex(); + unsigned int ai = child->getAtlasIndex(); if ( ai >= indexForZ ) { - pChild->setAtlasIndex(ai+1); + child->setAtlasIndex(ai+1); } } } @@ -596,13 +596,13 @@ void TMXLayer::removeTileAt(const Point& pos) Object* pObject = nullptr; CCARRAY_FOREACH(_children, pObject) { - Sprite* pChild = static_cast(pObject); - if (pChild) + Sprite* child = static_cast(pObject); + if (child) { - unsigned int ai = pChild->getAtlasIndex(); + unsigned int ai = child->getAtlasIndex(); if ( ai >= atlasIndex ) { - pChild->setAtlasIndex(ai-1); + child->setAtlasIndex(ai-1); } } } diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h index be459ac8a7..e672fe4472 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXLayer.h @@ -130,8 +130,8 @@ public: CC_DEPRECATED_ATTRIBUTE Point positionAt(const Point& tileCoordinate) { return getPositionAt(tileCoordinate); }; /** return the value for the specific property name */ - String* getPropertyNamed(const char *propertyName) const; - CC_DEPRECATED_ATTRIBUTE String* propertyNamed(const char *propertyName) const { return getPropertyNamed(propertyName); }; + String* getProperty(const char *propertyName) const; + CC_DEPRECATED_ATTRIBUTE String* propertyNamed(const char *propertyName) const { return getProperty(propertyName); }; /** Creates the tiles */ void setupTiles(); diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp index aecfa72320..12fce07617 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.cpp @@ -47,7 +47,7 @@ TMXObjectGroup::~TMXObjectGroup() CC_SAFE_RELEASE(_properties); } -Dictionary* TMXObjectGroup::getObjectNamed(const char *objectName) const +Dictionary* TMXObjectGroup::getObject(const char *objectName) const { if (_objects && _objects->count() > 0) { @@ -66,9 +66,9 @@ Dictionary* TMXObjectGroup::getObjectNamed(const char *objectName) const return NULL; } -String* TMXObjectGroup::getPropertyNamed(const char* propertyName) const -{ - return static_cast(_properties->objectForKey(propertyName)); +String* TMXObjectGroup::getProperty(const char* propertyName) const +{ + return static_cast(_properties->objectForKey(propertyName)); } NS_CC_END diff --git a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h index b758c177aa..73404c3533 100644 --- a/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h +++ b/cocos2dx/tilemap_parallax_nodes/CCTMXObjectGroup.h @@ -52,16 +52,16 @@ public: inline void setGroupName(const char *groupName){ _groupName = groupName; } /** return the value for the specific property name */ - String* getPropertyNamed(const char* propertyName) const; + String* getProperty(const char* propertyName) const; - CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char* propertyName) const { return getPropertyNamed(propertyName); }; + CC_DEPRECATED_ATTRIBUTE String *propertyNamed(const char* propertyName) const { return getProperty(propertyName); }; /** return the dictionary for the specific object name. It will return the 1st object found on the array for the given name. */ - Dictionary* getObjectNamed(const char *objectName) const; + Dictionary* getObject(const char *objectName) const; - CC_DEPRECATED_ATTRIBUTE Dictionary* objectNamed(const char *objectName) const { return getObjectNamed(objectName); }; + CC_DEPRECATED_ATTRIBUTE Dictionary* objectNamed(const char *objectName) const { return getObject(objectName); }; /** Gets the offset position of child objects */ inline const Point& getPositionOffset() const { return _positionOffset; }; diff --git a/cocos2dx/touch_dispatcher/CCTouch.h b/cocos2dx/touch_dispatcher/CCTouch.h index b6e8fcfd73..1750122124 100644 --- a/cocos2dx/touch_dispatcher/CCTouch.h +++ b/cocos2dx/touch_dispatcher/CCTouch.h @@ -38,6 +38,14 @@ NS_CC_BEGIN class CC_DLL Touch : public Object { public: + /** how the touches are dispathced */ + enum class DispatchMode { + /** All at once */ + ALL_AT_ONCE, + /** one by one */ + ONE_BY_ONE, + }; + Touch() : _id(0), _startPointCaptured(false) diff --git a/create-android-project.bat b/create-android-project.bat deleted file mode 100644 index a935eb3f15..0000000000 --- a/create-android-project.bat +++ /dev/null @@ -1,52 +0,0 @@ -@echo off -:: This script is used to create an android project. -:: You should modify _ANDROIDTOOLS _CYGBIN _NDKROOT to work under your environment. -:: Don't change it until you know what you do. - -setlocal - -:: Check if it was run under cocos2d-x root -if not exist "%cd%\create-android-project.bat" echo Error!!! You should run it under cocos2dx root & pause & exit 2 - -if not exist "%~dpn0.sh" echo Script "%~dpn0.sh" not found & pause & exit 3 - -:: modify it to work under your environment -set _CYGBIN=e:\cygwin\bin -if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & pause & exit 4 - -:: modify it to work under your environment -set _ANDROIDTOOLS=e:\android\android-sdk\tools -if not exist "%_ANDROIDTOOLS%" echo Couldn't find android sdk tools at "%_ANDROIDTOOLS%" & pause & exit 5 - -:: modify it to work under your environment -set _NDKROOT=e:\android\android-ndk-r8 -if not exist "%_NDKROOT%" echo Couldn't find ndk at "%_NDKROOT%" & pause & exit 6 - -:: create android project -set /P _PACKAGEPATH=Please enter your package path. For example: org.cocos2dx.example: -set /P _PROJECTNAME=Please enter your project name: -if exist "%CD%\%_PROJECTNAME%" echo "%_PROJECTNAME%" exists, please use another name & pause & exit 7 -echo "Now cocos2d-x suppurts Android 2.1-update1, 2.2, 2.3 & 3.0" -echo "Other versions have not tested." -call "%_ANDROIDTOOLS%\android.bat" list targets -set /P _TARGETID=Please input target id: -set _PROJECTDIR=%CD%\%_PROJECTNAME% - -echo Create android project -mkdir %_PROJECTDIR% -echo Create Android project inside proj.android -call "%_ANDROIDTOOLS%\android.bat" create project -n %_PROJECTNAME% -t %_TARGETID% -k %_PACKAGEPATH% -a %_PROJECTNAME% -p %_PROJECTDIR%\proj.android -call "%_ANDROIDTOOLS%\android.bat" update project -l ../../cocos2dx/platform/android/java -p %_PROJECTDIR%\proj.android -:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT% -for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn0.sh"') do set _CYGSCRIPT=%%A - -:: Resolve current dir to cygwin path -for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%cd%"') do set _CURRENTDIR=%%A - -:: Resolve ndk dir to cygwin path -for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%_NDKROOT%"') do set _NDKROOT=%%A - -:: Throw away temporary env vars and invoke script, passing any args that were passed to us -endlocal & %_CYGBIN%\bash --login "%_CYGSCRIPT%" %_CURRENTDIR% %_PROJECTNAME% %_NDKROOT% %_PACKAGEPATH% "windows" - -pause diff --git a/create-android-project.sh b/create-android-project.sh deleted file mode 100755 index d3ca9b52eb..0000000000 --- a/create-android-project.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash -# parameters passed to script -# This script should be called by create-android-project.bat -# or should be runned in linux shell. It can not be runned under cygwin. -# Don't modify the script until you know what you do. -PARAMS=$@ - -# you can set the environment here and uncomment them if you haven't set them in .bashrc -#export NDK_ROOT= -#export ANDROID_SDK_ROOT= -#export COCOS2DX_ROOT= - -# set environment paramters -if [ "x${NDK_ROOT}" == "x" ] ; then - NDK_ROOT="/opt/android-ndk" -fi - -if [ "x${ANDROID_SDK_ROOT}" == "x" ] ; then - ANDROID_SDK_ROOT="/opt/android-sdk-update-manager" -fi -ANDROID_CMD="${ANDROID_SDK_ROOT}/tools/android" - -if [ "x${COCOS2DX_ROOT}" == "x" ] ; then - COCOS2DX_ROOT="${HOME}/cocos2d-x" - if [ ! -d $COCOS2DX_ROOT ] ; then - COCOS2DX_ROOT=`pwd` - fi -fi - -if [ ! -d ${NDK_ROOT} -o ! -d ${ANDROID_SDK_ROOT} -o ! -x ${ANDROID_CMD} ] ; then - echo "Please set the environment at first" -fi - -USE_BOX2D=false -USE_CHIPMUNK=false -USE_LUA=false - -print_usage(){ - echo "usage:" - echo "$0 [-b|--box2d] [-c|--chipmunk] [-l|--lua]" -} - -check_param(){ - for param in ${PARAMS[@]} - do - case $param in - -b | --box2d) - echo using box2d - USE_BOX2D=true - ;; - -c | --chipmunk) - echo using chipmunk - USE_CHIPMUNK=true - ;; - -l | --lua) - echo using lua - USE_LUA=true - ;; - -linux) - // skip it - ;; - *) - print_usage - exit 1 - esac - done - - if [ $USE_BOX2D == "true" -a $USE_CHIPMUNK == "true" ] ; then - echo '[WARN] Using box2d and chipmunk together!' - fi -} - -# check if it was called by .bat file -if [ $# -ge 5 -a "x$5" == "xwindows" ] ; then - # should be called by .bat file - length=`expr $# - 5` - PARAMS=${@:6:$length} - check_param - ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT COCOS2DX_ROOT=$COCOS2DX_ROOT sh $COCOS2DX_ROOT/template/android/copy_files.sh $1 $2 $3 $4 $USE_BOX2D $USE_CHIPMUNK $USE_LUA - exit -fi - -# the bash file should not be called by cygwin -KERNEL_NAME=`uname -s | grep "CYGWIN*"` -if [ "x$KERNEL_NAME" != "x" ] ; then - echo "[ERROR] Don't run in cygwin. You should run .bat file" - exit -fi - -# ok, it was run under linux - -create_android_project(){ - DEFAULT_PACKAGE_PATH='org.cocos2dx.demo' - DEFAULT_TARGET_ID='1' - DEFAULT_PROJECT_NAME="Hello" - - echo -n "Input package path [${DEFAULT_PACKAGE_PATH}]:" - read PACKAGE_PATH - if [ "x${PACKAGE_PATH}" == "x" ] ; then - PACKAGE_PATH=${DEFAULT_PACKAGE_PATH} - fi - - ${ANDROID_CMD} list targets - echo -n "Input target id [${DEFAULT_TARGET_ID}]:" - read TARGET_ID - if [ "x${TARGET_ID}" == "x" ] ; then - TARGET_ID=${DEFAULT_TARGET_ID} - fi - - echo -n "Input your project name [${DEFAULT_PROJECT_NAME}]:" - read PROJECT_NAME - if [ "x${PROJECT_NAME}" == "x" ] ; then - PROJECT_NAME=${DEFAULT_PROJECT_NAME} - fi - PROJECT_DIR=`pwd`/${PROJECT_NAME} - - # check if PROJECT_DIR is exist - if [ -d $PROJECT_DIR ] ; then - echo "$PROJECT_DIR already exist, please use another name" - exit - fi - - # Make project directory - mkdir $PROJECT_DIR - # Create Android project inside proj.android - $ANDROID_CMD create project -n $PROJECT_NAME -t $TARGET_ID -k $PACKAGE_PATH -a $PROJECT_NAME -p $PROJECT_DIR/proj.android - $ANDROID_CMD update project -l ${COCOS2DX_ROOT}/cocos2dx/platform/android/java -p $PROJECT_DIR/proj.android -} - -check_param -create_android_project - -if [ $0 = "linux" ]; then - # invoked by create-linux-android-project.sh - ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT COCOS2DX_ROOT=$COCOS2DX_ROOT sh $COCOS2DX_ROOT/template/linux/mycopy_files.sh $COCOS2DX_ROOT $PROJECT_NAME $NDK_ROOT $PACKAGE_PATH $USE_BOX2D $USE_CHIPMUNK $USE_LUA -else - # invoke template/android/copy_files.sh - ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT COCOS2DX_ROOT=$COCOS2DX_ROOT sh $COCOS2DX_ROOT/template/android/copy_files.sh $COCOS2DX_ROOT $PROJECT_DIR $PACKAGE_PATH $USE_BOX2D $USE_CHIPMUNK $USE_LUA -fi - diff --git a/create-multi-platform-projects.py b/create-multi-platform-projects.py new file mode 100755 index 0000000000..fa3c2123b4 --- /dev/null +++ b/create-multi-platform-projects.py @@ -0,0 +1,9 @@ +#! /usr/bin/evn python +# filename = create-multi-platform-projects.py + +import os +from tools.project_creator import create_project + +if __name__ == '__main__': + os.chdir(os.getcwd()+'/tools/project_creator/') + create_project.createPlatformProjects() diff --git a/extensions/AssetsManager/AssetsManager.h b/extensions/AssetsManager/AssetsManager.h index 6523e73473..46f50ebe71 100644 --- a/extensions/AssetsManager/AssetsManager.h +++ b/extensions/AssetsManager/AssetsManager.h @@ -213,6 +213,10 @@ public: virtual void onSuccess() {}; }; +// Deprecated declaration +CC_DEPRECATED_ATTRIBUTE typedef AssetsManager CCAssetsManager; +CC_DEPRECATED_ATTRIBUTE typedef AssetsManagerDelegateProtocol CCAssetsManagerDelegateProtocol; + NS_CC_EXT_END; #endif /* defined(__AssetsManager__) */ diff --git a/extensions/CCArmature/CCArmature.cpp b/extensions/CCArmature/CCArmature.cpp index 3b29271fef..2efa6661ae 100644 --- a/extensions/CCArmature/CCArmature.cpp +++ b/extensions/CCArmature/CCArmature.cpp @@ -122,10 +122,7 @@ bool Armature::init(const char *name) _topBoneList = new Array(); _topBoneList->init(); - - _blendFunc.src = CC_BLEND_SRC; - _blendFunc.dst = CC_BLEND_DST; - + _blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; _name = name == NULL ? "" : name; @@ -191,7 +188,7 @@ bool Armature::init(const char *name) } - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); unscheduleUpdate(); scheduleUpdate(); @@ -427,7 +424,7 @@ void Armature::draw() if (_parentBone == NULL) { CC_NODE_DRAW_SETUP(); - ccGLBlendFunc(_blendFunc.src, _blendFunc.dst); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); } Object *object = NULL; @@ -483,7 +480,7 @@ void Armature::draw() node->visit(); CC_NODE_DRAW_SETUP(); - ccGLBlendFunc(_blendFunc.src, _blendFunc.dst); + GL::blendFunc(_blendFunc.src, _blendFunc.dst); } } diff --git a/extensions/CCArmature/CCArmature.h b/extensions/CCArmature/CCArmature.h index 0f3c2f4e41..f076a4fa04 100644 --- a/extensions/CCArmature/CCArmature.h +++ b/extensions/CCArmature/CCArmature.h @@ -28,9 +28,45 @@ THE SOFTWARE. #include "utils/CCArmatureDefine.h" #include "CCBone.h" #include "display/CCBatchNode.h" +#include "display/CCShaderNode.h" #include "animation/CCArmatureAnimation.h" +#include "physics/CCPhysicsWorld.h" +#include "utils/CCSpriteFrameCacheHelper.h" +#include "utils/CCArmatureDataManager.h" namespace cocos2d { namespace extension { namespace armature { + +CC_DEPRECATED_ATTRIBUTE typedef ProcessBase CCProcessBase; +CC_DEPRECATED_ATTRIBUTE typedef BaseData CCBaseData; +CC_DEPRECATED_ATTRIBUTE typedef DisplayData CCDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef SpriteDisplayData CCSpriteDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef ArmatureDisplayData CCArmatureDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef ParticleDisplayData CCParticleDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef ShaderDisplayData CCShaderDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef BoneData CCBoneData; +CC_DEPRECATED_ATTRIBUTE typedef FrameData CCFrameData; +CC_DEPRECATED_ATTRIBUTE typedef MovementBoneData CCMovementBoneData; +CC_DEPRECATED_ATTRIBUTE typedef MovementData CCMovementData; +CC_DEPRECATED_ATTRIBUTE typedef AnimationData CCAnimationData; +CC_DEPRECATED_ATTRIBUTE typedef ContourData CCContourData; +CC_DEPRECATED_ATTRIBUTE typedef TextureData CCTextureData; +CC_DEPRECATED_ATTRIBUTE typedef ShaderNode CCShaderNode; +CC_DEPRECATED_ATTRIBUTE typedef DecorativeDisplay CCDecorativeDisplay; +CC_DEPRECATED_ATTRIBUTE typedef DisplayData CCDisplayData; +CC_DEPRECATED_ATTRIBUTE typedef DisplayFactory CCDisplayFactory; +CC_DEPRECATED_ATTRIBUTE typedef BatchNode CCBatchNode; +CC_DEPRECATED_ATTRIBUTE typedef DecorativeDisplay CCDecorativeDisplay; +CC_DEPRECATED_ATTRIBUTE typedef DisplayManager CCDisplayManager; +CC_DEPRECATED_ATTRIBUTE typedef ColliderBody CCColliderBody; +CC_DEPRECATED_ATTRIBUTE typedef ColliderDetector CCColliderDetector; +CC_DEPRECATED_ATTRIBUTE typedef PhysicsWorld CCPhysicsWorld; +CC_DEPRECATED_ATTRIBUTE typedef SpriteFrameCacheHelper CCSpriteFrameCacheHelper; +CC_DEPRECATED_ATTRIBUTE typedef TweenFunction CCTweenFunction; +CC_DEPRECATED_ATTRIBUTE typedef ArmatureData CCArmatureData; +CC_DEPRECATED_ATTRIBUTE typedef Bone CCBone; +CC_DEPRECATED_ATTRIBUTE typedef ArmatureAnimation CCArmatureAnimation; +CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature; +CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager; class Armature : public NodeRGBA, public BlendProtocol { diff --git a/extensions/CCArmature/animation/CCTween.cpp b/extensions/CCArmature/animation/CCTween.cpp index f1fa777154..0aafdd29d8 100644 --- a/extensions/CCArmature/animation/CCTween.cpp +++ b/extensions/CCArmature/animation/CCTween.cpp @@ -94,11 +94,11 @@ bool Tween::init(Bone *bone) } -void Tween::play(MovementBoneData *_movementBoneData, int _durationTo, int _durationTween, int _loop, int _tweenEasing) +void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing) { - ProcessBase::play(NULL, _durationTo, _durationTween, _loop, _tweenEasing); + ProcessBase::play(NULL, durationTo, durationTween, loop, tweenEasing); - _loopType = (AnimationType)_loop; + _loopType = (AnimationType)loop; _currentKeyFrame = NULL; _isTweenKeyFrame = false; @@ -107,14 +107,14 @@ void Tween::play(MovementBoneData *_movementBoneData, int _durationTo, int _dura betweenDuration = 0; _toIndex = 0; - setMovementBoneData(_movementBoneData); + setMovementBoneData(movementBoneData); if (_movementBoneData->frameList.count() == 1) { _loopType = SINGLE_FRAME; FrameData *_nextKeyFrame = _movementBoneData->getFrameData(0); - if(_durationTo == 0) + if(durationTo == 0) { setBetween(_nextKeyFrame, _nextKeyFrame); } @@ -130,7 +130,7 @@ void Tween::play(MovementBoneData *_movementBoneData, int _durationTo, int _dura } else if (_movementBoneData->frameList.count() > 1) { - if (_loop) + if (loop) { _loopType = ANIMATION_TO_LOOP_BACK; _rawDuration = _movementBoneData->duration; @@ -141,9 +141,9 @@ void Tween::play(MovementBoneData *_movementBoneData, int _durationTo, int _dura _rawDuration = _movementBoneData->duration - 1; } - _durationTween = _durationTween * _movementBoneData->scale; + _durationTween = durationTween * _movementBoneData->scale; - if (_loop && _movementBoneData->delay != 0) + if (loop && _movementBoneData->delay != 0) { setBetween(_tweenData, tweenNodeTo(updateFrameData(1 - _movementBoneData->delay), _between)); @@ -333,6 +333,7 @@ void Tween::arriveKeyFrame(FrameData *keyFrameData) FrameData *Tween::tweenNodeTo(float percent, FrameData *node) { + node = node == NULL ? _tweenData : node; node->x = _from->x + percent * _between->x; diff --git a/extensions/CCArmature/display/CCBatchNode.cpp b/extensions/CCArmature/display/CCBatchNode.cpp index c54d5eb3db..09d10dc41c 100644 --- a/extensions/CCArmature/display/CCBatchNode.cpp +++ b/extensions/CCArmature/display/CCBatchNode.cpp @@ -48,7 +48,7 @@ BatchNode::BatchNode() bool BatchNode::init() { bool ret = Node::init(); - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); return ret; } diff --git a/extensions/CCArmature/display/CCShaderNode.cpp b/extensions/CCArmature/display/CCShaderNode.cpp index d9f582dd25..b45f649d23 100644 --- a/extensions/CCArmature/display/CCShaderNode.cpp +++ b/extensions/CCArmature/display/CCShaderNode.cpp @@ -72,7 +72,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) GLProgram *shader = new GLProgram(); shader->initWithVertexShaderFilename(vert, frag); - shader->addAttribute("aVertex", kVertexAttrib_Position); + shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); shader->link(); shader->updateUniforms(); @@ -123,9 +123,9 @@ void ShaderNode::draw() // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version glUniform1f(_uniformTime, _time); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLES, 0, 6); diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp index a352930c88..63c607be18 100644 --- a/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp +++ b/extensions/CCArmature/external_tool/CCTexture2DMutable.cpp @@ -40,7 +40,7 @@ void* Texture2DMutable::keepData(void* data, unsigned int lenght) return newData; } -bool Texture2DMutable::initWithImageFile(const char *imageFile, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize) +bool Texture2DMutable::initWithImageFile(const char *imageFile, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize) { image_ = new cocos2d::Image(); image_->initWithImageFile(imageFile); @@ -57,22 +57,22 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile) bool hasAlpha = image_->hasAlpha(); Size imageSize = Size((float)(image_->getWidth()), (float)(image_->getHeight())); size_t bpp = image_->getBitsPerComponent(); - cocos2d::Texture2DPixelFormat pixelFormat; + cocos2d::Texture2D::PixelFormat pixelFormat; // compute pixel format if(hasAlpha) { - pixelFormat = kTexture2DPixelFormat_Default; + pixelFormat = Texture2D::PixelFormat::DEFAULT; } else { if (bpp >= 8) { - pixelFormat = kTexture2DPixelFormat_RGB888; + pixelFormat = Texture2D::PixelFormat::RGB888; } else { - pixelFormat = kTexture2DPixelFormat_RGB565; + pixelFormat = Texture2D::PixelFormat::RGB565; } } @@ -80,18 +80,18 @@ bool Texture2DMutable::initWithImageFile(const char *imageFile) return initWithData(image_->getData(), pixelFormat, imageSize.width, imageSize.height, imageSize); } -bool Texture2DMutable::initWithData(const void* data, Texture2DPixelFormat pixelFormat, unsigned int width, unsigned int height, const Size& size) +bool Texture2DMutable::initWithData(const void* data, Texture2D::PixelFormat pixelFormat, unsigned int width, unsigned int height, const Size& size) { if(!Texture2D::initWithData(data, pixelFormat, width, height, size)) { return false; } switch (pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: bytesPerPixel_ = 4; break; - case kTexture2DPixelFormat_A8: bytesPerPixel_ = 1; break; - case kTexture2DPixelFormat_RGBA4444: - case kTexture2DPixelFormat_RGB565: - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGBA8888: bytesPerPixel_ = 4; break; + case Texture2D::PixelFormat::A8: bytesPerPixel_ = 1; break; + case Texture2D::PixelFormat::RGBA4444: + case Texture2D::PixelFormat::RGB565: + case Texture2D::PixelFormat::RGB5A1: bytesPerPixel_ = 2; break; default:break; @@ -120,35 +120,35 @@ Color4B Texture2DMutable::pixelAt(const Point& pt) //! unsigned int x = pt.x, y = pt.y unsigned int x = pt.x, y = _pixelsHigh - pt.y; - if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){ + if(_pixelFormat == Texture2D::PixelFormat::RGBA8888){ unsigned int *pixel = (unsigned int *)data_; pixel = pixel + (y * _pixelsWide) + x; c.r = *pixel & 0xff; c.g = (*pixel >> 8) & 0xff; c.b = (*pixel >> 16) & 0xff; c.a = (*pixel >> 24) & 0xff; - } else if(_pixelFormat == kTexture2DPixelFormat_RGBA4444){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGBA4444){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; c.a = ((*pixel & 0xf) << 4) | (*pixel & 0xf); c.b = (((*pixel >> 4) & 0xf) << 4) | ((*pixel >> 4) & 0xf); c.g = (((*pixel >> 8) & 0xf) << 4) | ((*pixel >> 8) & 0xf); c.r = (((*pixel >> 12) & 0xf) << 4) | ((*pixel >> 12) & 0xf); - } else if(_pixelFormat == kTexture2DPixelFormat_RGB5A1){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGB5A1){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; c.r = ((*pixel >> 11) & 0x1f)<<3; c.g = ((*pixel >> 6) & 0x1f)<<3; c.b = ((*pixel >> 1) & 0x1f)<<3; c.a = (*pixel & 0x1)*255; - } else if(_pixelFormat == kTexture2DPixelFormat_RGB565){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGB565){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; c.b = (*pixel & 0x1f)<<3; c.g = ((*pixel >> 5) & 0x3f)<<2; c.r = ((*pixel >> 11) & 0x1f)<<3; c.a = 255; - } else if(_pixelFormat == kTexture2DPixelFormat_A8){ + } else if(_pixelFormat == Texture2D::PixelFormat::A8){ GLubyte *pixel = (GLubyte *)data_; c.a = pixel[(y * _pixelsWide) + x]; // Default white @@ -174,22 +174,22 @@ bool Texture2DMutable::setPixelAt(const Point& pt, Color4B c) // Shifted bit placement based on little-endian, let's make this more // portable =/ - if(_pixelFormat == kTexture2DPixelFormat_RGBA8888){ + if(_pixelFormat == Texture2D::PixelFormat::RGBA8888){ unsigned int *pixel = (unsigned int *)data_; pixel[(y * _pixelsWide) + x] = (c.a << 24) | (c.b << 16) | (c.g << 8) | c.r; - } else if(_pixelFormat == kTexture2DPixelFormat_RGBA4444){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGBA4444){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; *pixel = ((c.r >> 4) << 12) | ((c.g >> 4) << 8) | ((c.b >> 4) << 4) | (c.a >> 4); - } else if(_pixelFormat == kTexture2DPixelFormat_RGB5A1){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGB5A1){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; *pixel = ((c.r >> 3) << 11) | ((c.g >> 3) << 6) | ((c.b >> 3) << 1) | (c.a > 0); - } else if(_pixelFormat == kTexture2DPixelFormat_RGB565){ + } else if(_pixelFormat == Texture2D::PixelFormat::RGB565){ GLushort *pixel = (GLushort *)data_; pixel = pixel + (y * _pixelsWide) + x; *pixel = ((c.r >> 3) << 11) | ((c.g >> 2) << 5) | (c.b >> 3); - } else if(_pixelFormat == kTexture2DPixelFormat_A8){ + } else if(_pixelFormat == Texture2D::PixelFormat::A8){ GLubyte *pixel = (GLubyte *)data_; pixel[(y * _pixelsWide) + x] = c.a; } else { @@ -264,19 +264,19 @@ void Texture2DMutable::apply() switch(_pixelFormat) { - case kTexture2DPixelFormat_RGBA8888: + case Texture2D::PixelFormat::RGBA8888: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_BYTE, data_); break; - case kTexture2DPixelFormat_RGBA4444: + case Texture2D::PixelFormat::RGBA4444: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data_); break; - case kTexture2DPixelFormat_RGB5A1: + case Texture2D::PixelFormat::RGB5A1: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _pixelsWide, _pixelsHigh, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data_); break; - case kTexture2DPixelFormat_RGB565: + case Texture2D::PixelFormat::RGB565: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _pixelsWide, _pixelsHigh, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data_); break; - case kTexture2DPixelFormat_A8: + case Texture2D::PixelFormat::A8: glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _pixelsWide, _pixelsHigh, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data_); break; default: diff --git a/extensions/CCArmature/external_tool/CCTexture2DMutable.h b/extensions/CCArmature/external_tool/CCTexture2DMutable.h index bde9ab1fa0..dfcbd6cd6d 100644 --- a/extensions/CCArmature/external_tool/CCTexture2DMutable.h +++ b/extensions/CCArmature/external_tool/CCTexture2DMutable.h @@ -40,12 +40,12 @@ public: void releaseData(void *data); void* keepData(void *data, unsigned int length); - bool initWithImageFile(const char *imageFile, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); + bool initWithImageFile(const char *imageFile, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); bool initWithImageFile(const char *imageFilex); /** Intializes with a texture2d with data */ - bool initWithData(const void* data, cocos2d::Texture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); + bool initWithData(const void* data, cocos2d::Texture2D::PixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const cocos2d::Size& contentSize); cocos2d::Color4B pixelAt(const cocos2d::Point& pt); diff --git a/extensions/CCArmature/external_tool/GLES-Render.cpp b/extensions/CCArmature/external_tool/GLES-Render.cpp index 6677d182ad..3ccbee1040 100644 --- a/extensions/CCArmature/external_tool/GLES-Render.cpp +++ b/extensions/CCArmature/external_tool/GLES-Render.cpp @@ -42,7 +42,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio ) void GLESDebugDraw::initShader( void ) { - mShaderProgram = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); + mShaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR); mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); } @@ -61,7 +61,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_LINE_LOOP, 0, vertexCount); CC_INCREMENT_GL_DRAWS(1); @@ -84,7 +84,7 @@ void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); @@ -118,7 +118,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col } mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINE_LOOP, 0, vertexCount); @@ -149,7 +149,7 @@ void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const } mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); @@ -178,7 +178,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo p1.x * mRatio, p1.y * mRatio, p2.x * mRatio, p2.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINES, 0, 2); @@ -211,7 +211,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo p.x * mRatio, p.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_POINTS, 0, 1); // glPointSize(1.0f); @@ -242,7 +242,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color) aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINE_LOOP, 0, 8); CC_INCREMENT_GL_DRAWS(1); diff --git a/extensions/CCArmature/external_tool/sigslot.h b/extensions/CCArmature/external_tool/sigslot.h index 3513a6f857..ee6ea813b9 100644 --- a/extensions/CCArmature/external_tool/sigslot.h +++ b/extensions/CCArmature/external_tool/sigslot.h @@ -301,6 +301,8 @@ namespace sigslot { class _connection_base0 { public: + virtual ~_connection_base0() { } + virtual has_slots* getdest() const = 0; virtual void emit() = 0; virtual _connection_base0* clone() = 0; @@ -386,6 +388,8 @@ namespace sigslot { class _connection_base7 { public: + virtual ~_connection_base7() { } + virtual has_slots* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type) = 0; @@ -400,6 +404,8 @@ namespace sigslot { class _connection_base8 { public: + virtual ~_connection_base8() { } + virtual has_slots* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type) = 0; @@ -413,6 +419,8 @@ namespace sigslot { class _signal_base : public mt_policy { public: + virtual ~_signal_base() { } + virtual void slot_disconnect(has_slots* pslot) = 0; virtual void slot_duplicate(const has_slots* poldslot, has_slots* pnewslot) = 0; }; diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 135ef99368..24476de243 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -617,7 +617,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann CCBSelectorResolver* targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { - selCallFunc = targetAsCCBSelectorResolver->onResolveCCBCallFuncSelector(target, selectorName.c_str ()); + selCallFunc = targetAsCCBSelectorResolver->onResolveCCBCCCallFuncSelector(target, selectorName.c_str ()); } if(selCallFunc == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); diff --git a/extensions/CCBReader/CCBSelectorResolver.h b/extensions/CCBReader/CCBSelectorResolver.h index be4d88dbf5..2eb6ae06d8 100644 --- a/extensions/CCBReader/CCBSelectorResolver.h +++ b/extensions/CCBReader/CCBSelectorResolver.h @@ -23,9 +23,9 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: virtual ~CCBSelectorResolver() {}; - virtual SEL_MenuHandler onResolveCCBMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0; - virtual SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; }; - virtual SEL_CCControlHandler onResolveCCBControlSelector(Object * pTarget, const char* pSelectorName) = 0; + virtual SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char* pSelectorName) = 0; + virtual SEL_CallFuncN onResolveCCBCCCallFuncSelector(Object * pTarget, const char* pSelectorName) { return NULL; }; + virtual SEL_CCControlHandler onResolveCCBCCControlSelector(Object * pTarget, const char* pSelectorName) = 0; }; diff --git a/extensions/CCBReader/CCLabelTTFLoader.cpp b/extensions/CCBReader/CCLabelTTFLoader.cpp index a42e15f6c0..182315148d 100644 --- a/extensions/CCBReader/CCLabelTTFLoader.cpp +++ b/extensions/CCBReader/CCLabelTTFLoader.cpp @@ -64,9 +64,9 @@ void LabelTTFLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParent, co void LabelTTFLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { - ((LabelTTF *)pNode)->setHorizontalAlignment(TextAlignment(pIntegerLabeled)); + ((LabelTTF *)pNode)->setHorizontalAlignment(Label::HAlignment(pIntegerLabeled)); } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { - ((LabelTTF *)pNode)->setVerticalAlignment(VerticalTextAlignment(pIntegerLabeled)); + ((LabelTTF *)pNode)->setVerticalAlignment(Label::VAlignment(pIntegerLabeled)); } else { NodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index a574b25c39..1090787909 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -754,12 +754,12 @@ BlockData * NodeLoader::parsePropTypeBlock(Node * pNode, Node * pParent, CCBRead CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { - selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBMenuItemSelector(target, selectorName.c_str()); + selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); } if(selMenuHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { - selMenuHandler = ccbSelectorResolver->onResolveCCBMenuItemSelector(target, selectorName.c_str()); + selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName.c_str()); } } @@ -816,12 +816,12 @@ BlockControlData * NodeLoader::parsePropTypeBlockControl(Node * pNode, Node * pP CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { - selControlHandler = targetAsCCBSelectorResolver->onResolveCCBControlSelector(target, selectorName.c_str()); + selControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); } if(selControlHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { - selControlHandler = ccbSelectorResolver->onResolveCCBControlSelector(target, selectorName.c_str()); + selControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName.c_str()); } } diff --git a/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 794201ec62..515df267ff 100644 --- a/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -81,7 +81,7 @@ void NodeLoaderLibrary::purge(bool pReleaseNodeLoaders) { static NodeLoaderLibrary * sSharedNodeLoaderLibrary = NULL; -NodeLoaderLibrary * NodeLoaderLibrary::sharedNodeLoaderLibrary() { +NodeLoaderLibrary * NodeLoaderLibrary::getInstance() { if(sSharedNodeLoaderLibrary == NULL) { sSharedNodeLoaderLibrary = new NodeLoaderLibrary(); @@ -90,7 +90,7 @@ NodeLoaderLibrary * NodeLoaderLibrary::sharedNodeLoaderLibrary() { return sSharedNodeLoaderLibrary; } -void NodeLoaderLibrary::purgeSharedNodeLoaderLibrary() { +void NodeLoaderLibrary::destroyInstance() { CC_SAFE_DELETE(sSharedNodeLoaderLibrary); } diff --git a/extensions/CCBReader/CCNodeLoaderLibrary.h b/extensions/CCBReader/CCNodeLoaderLibrary.h index 914cf99f33..9abd64b660 100644 --- a/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -12,29 +12,39 @@ typedef std::map NodeLoaderMap; typedef std::pair NodeLoaderMapEntry; class NodeLoaderLibrary : public Object { - private: - NodeLoaderMap mNodeLoaders; +private: + NodeLoaderMap mNodeLoaders; - public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoaderLibrary, library); +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoaderLibrary, library); - NodeLoaderLibrary(); - virtual ~NodeLoaderLibrary(); + NodeLoaderLibrary(); + virtual ~NodeLoaderLibrary(); - void registerDefaultNodeLoaders(); - void registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader); - //void registerNodeLoader(String * pClassName, NodeLoader * pNodeLoader); - void unregisterNodeLoader(const char * pClassName); - //void unregisterNodeLoader(String * pClassName); - NodeLoader * getNodeLoader(const char * pClassName); - //CCNodeLoader * getNodeLoader(String * pClassName); - void purge(bool pDelete); + void registerDefaultNodeLoaders(); + void registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader); + //void registerNodeLoader(String * pClassName, NodeLoader * pNodeLoader); + void unregisterNodeLoader(const char * pClassName); + //void unregisterNodeLoader(String * pClassName); + NodeLoader * getNodeLoader(const char * pClassName); + //CCNodeLoader * getNodeLoader(String * pClassName); + void purge(bool pDelete); - public: - static NodeLoaderLibrary * sharedNodeLoaderLibrary(); - static void purgeSharedNodeLoaderLibrary(); + CC_DEPRECATED_ATTRIBUTE void registerDefaultCCNodeLoaders() { registerDefaultNodeLoaders(); } + CC_DEPRECATED_ATTRIBUTE void registerCCNodeLoader(const char * pClassName, NodeLoader * pNodeLoader) { registerNodeLoader(pClassName, pNodeLoader); }; + CC_DEPRECATED_ATTRIBUTE void unregisterCCNodeLoader(const char * pClassName) { unregisterNodeLoader(pClassName); }; + CC_DEPRECATED_ATTRIBUTE NodeLoader * getCCNodeLoader(const char * pClassName) { return getNodeLoader(pClassName); }; + +public: + static NodeLoaderLibrary * getInstance(); + static void destroyInstance(); - static NodeLoaderLibrary * newDefaultNodeLoaderLibrary(); + static NodeLoaderLibrary * newDefaultNodeLoaderLibrary(); + + CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * sharedNodeLoaderLibrary() { return NodeLoaderLibrary::getInstance(); }; + CC_DEPRECATED_ATTRIBUTE static void purgeSharedNodeLoaderLibrary() { NodeLoaderLibrary::destroyInstance(); }; + + CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * newDefaultCCNodeLoaderLibrary() { return NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); }; }; NS_CC_EXT_END diff --git a/extensions/CCBReader/CCParticleSystemQuadLoader.cpp b/extensions/CCBReader/CCParticleSystemQuadLoader.cpp index 74ed82c506..e0b17e3232 100644 --- a/extensions/CCBReader/CCParticleSystemQuadLoader.cpp +++ b/extensions/CCBReader/CCParticleSystemQuadLoader.cpp @@ -29,7 +29,7 @@ NS_CC_EXT_BEGIN void ParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) { - ((ParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); + ((ParticleSystemQuad *)pNode)->setEmitterMode((ParticleSystem::Mode)pIntegerLabeled); } else { NodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } diff --git a/extensions/CCDeprecated-ext.h b/extensions/CCDeprecated-ext.h new file mode 100644 index 0000000000..8c93828447 --- /dev/null +++ b/extensions/CCDeprecated-ext.h @@ -0,0 +1,182 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +/** Add deprecated global functions and variables here + */ + +#ifndef COCOS2D_CCDEPRECATED_EXT_H__ +#define COCOS2D_CCDEPRECATED_EXT_H__ + +NS_CC_EXT_BEGIN + +CC_DEPRECATED_ATTRIBUTE typedef TableView CCTableView; +CC_DEPRECATED_ATTRIBUTE typedef TableViewCell CCTableViewCell; +CC_DEPRECATED_ATTRIBUTE typedef TableViewDelegate CCTableViewDelegate; +CC_DEPRECATED_ATTRIBUTE typedef TableViewDataSource CCTableViewDataSource; +CC_DEPRECATED_ATTRIBUTE typedef TableView CCTableView; +CC_DEPRECATED_ATTRIBUTE typedef ScrollView CCScrollView; +CC_DEPRECATED_ATTRIBUTE typedef ScrollViewDelegate CCScrollViewDelegate; +CC_DEPRECATED_ATTRIBUTE typedef ScrollView CCScrollView; +CC_DEPRECATED_ATTRIBUTE typedef SortableObject CCSortableObject; +CC_DEPRECATED_ATTRIBUTE typedef ArrayForObjectSorting CCArrayForObjectSorting; +CC_DEPRECATED_ATTRIBUTE typedef TableViewCell CCTableViewCell; +CC_DEPRECATED_ATTRIBUTE typedef EditBox CCEditBox; +CC_DEPRECATED_ATTRIBUTE typedef EditBoxDelegate CCEditBoxDelegate; + +CC_DEPRECATED_ATTRIBUTE typedef Color3bObject CCColor3bObject; +CC_DEPRECATED_ATTRIBUTE typedef ControlUtils CCControlUtils; +CC_DEPRECATED_ATTRIBUTE typedef Scale9Sprite CCScale9Sprite; +CC_DEPRECATED_ATTRIBUTE typedef ControlSwitchSprite CCControlSwitchSprite; +CC_DEPRECATED_ATTRIBUTE typedef ControlHuePicker CCControlHuePicker; +CC_DEPRECATED_ATTRIBUTE typedef Invocation CCInvocation; +CC_DEPRECATED_ATTRIBUTE typedef ControlSaturationBrightnessPicker CCControlSaturationBrightnessPicker; +CC_DEPRECATED_ATTRIBUTE typedef ControlStepper CCControlStepper; +CC_DEPRECATED_ATTRIBUTE typedef ControlPotentiometer CCControlPotentiometer; +CC_DEPRECATED_ATTRIBUTE typedef ControlSwitchSprite CCControlSwitchSprite; +CC_DEPRECATED_ATTRIBUTE typedef ControlSwitch CCControlSwitch; +CC_DEPRECATED_ATTRIBUTE typedef ControlButton CCControlButton; +CC_DEPRECATED_ATTRIBUTE typedef ControlSlider CCControlSlider; +CC_DEPRECATED_ATTRIBUTE typedef Control CCControl; +CC_DEPRECATED_ATTRIBUTE typedef ControlLoader CCControlLoader; +CC_DEPRECATED_ATTRIBUTE typedef ControlColourPicker CCControlColourPicker; + +CC_DEPRECATED_ATTRIBUTE typedef LabelBMFontLoader CCLabelBMFontLoader; +CC_DEPRECATED_ATTRIBUTE typedef ScrollViewLoader CCScrollViewLoader; +CC_DEPRECATED_ATTRIBUTE typedef SpriteLoader CCSpriteLoader; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoader CCNodeLoader; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderLibrary CCNodeLoaderLibrary; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderListener CCNodeLoaderListener; +CC_DEPRECATED_ATTRIBUTE typedef LayerLoader CCLayerLoader; +CC_DEPRECATED_ATTRIBUTE typedef MenuLoader CCMenuLoader; +CC_DEPRECATED_ATTRIBUTE typedef Color3BWapper CCColor3BWapper; +CC_DEPRECATED_ATTRIBUTE typedef ParticleSystemQuadLoader CCParticleSystemQuadLoader; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemImageLoader CCMenuItemImageLoader; +CC_DEPRECATED_ATTRIBUTE typedef ControlButtonLoader CCControlButtonLoader; +CC_DEPRECATED_ATTRIBUTE typedef LayerGradientLoader CCLayerGradientLoader; +CC_DEPRECATED_ATTRIBUTE typedef Scale9SpriteLoader CCScale9SpriteLoader; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderLibrary CCNodeLoaderLibrary; +CC_DEPRECATED_ATTRIBUTE typedef MenuItemLoader CCMenuItemLoader; +CC_DEPRECATED_ATTRIBUTE typedef LayerColorLoader CCLayerColorLoader; +CC_DEPRECATED_ATTRIBUTE typedef LabelTTFLoader CCLabelTTFLoader; + + +#if CC_ENABLE_BOX2D_INTEGRATION || CC_ENABLE_CHIPMUNK_INTEGRATION +CC_DEPRECATED_ATTRIBUTE typedef PhysicsSprite CCPhysicsSprite; +CC_DEPRECATED_ATTRIBUTE typedef PhysicsDebugNode CCPhysicsDebugNode; +#endif + +CC_DEPRECATED_ATTRIBUTE typedef ComController CCComController; +CC_DEPRECATED_ATTRIBUTE typedef ComAttribute CCComAttribute; +CC_DEPRECATED_ATTRIBUTE typedef InputDelegate CCInputDelegate; +CC_DEPRECATED_ATTRIBUTE typedef ComAudio CCComAudio; + +CC_DEPRECATED_ATTRIBUTE typedef HttpClient CCHttpClient; +CC_DEPRECATED_ATTRIBUTE typedef HttpResponse CCHttpResponse; +CC_DEPRECATED_ATTRIBUTE typedef HttpRequest CCHttpRequest; +CC_DEPRECATED_ATTRIBUTE typedef Skin CCSkin; + +CC_DEPRECATED_ATTRIBUTE typedef AtlasFormat CCAtlasFormat; +CC_DEPRECATED_ATTRIBUTE typedef AtlasFilter CCAtlasFilter; +CC_DEPRECATED_ATTRIBUTE typedef AtlasWrap CCAtlasWrap; +CC_DEPRECATED_ATTRIBUTE typedef AtlasPage CCAtlasPage; +CC_DEPRECATED_ATTRIBUTE typedef AtlasRegion CCAtlasRegion; +CC_DEPRECATED_ATTRIBUTE typedef Atlas CCAtlas; +CC_DEPRECATED_ATTRIBUTE typedef AnimationStateData CCAnimationStateData; +CC_DEPRECATED_ATTRIBUTE typedef SlotData CCSlotData; +CC_DEPRECATED_ATTRIBUTE typedef AttachmentLoader CCAttachmentLoader; +CC_DEPRECATED_ATTRIBUTE typedef AnimationState CCAnimationState; +CC_DEPRECATED_ATTRIBUTE typedef SkeletonJson CCSkeletonJson; +CC_DEPRECATED_ATTRIBUTE typedef Timeline CCTimeline; +CC_DEPRECATED_ATTRIBUTE typedef CurveTimeline CCCurveTimeline; +CC_DEPRECATED_ATTRIBUTE typedef RotateTimeline CCRotateTimeline; +CC_DEPRECATED_ATTRIBUTE typedef TranslateTimeline CCTranslateTimeline; +CC_DEPRECATED_ATTRIBUTE typedef ScaleTimeline CCScaleTimeline; +CC_DEPRECATED_ATTRIBUTE typedef ColorTimeline CCColorTimeline; +CC_DEPRECATED_ATTRIBUTE typedef AttachmentTimeline CCAttachmentTimeline; +CC_DEPRECATED_ATTRIBUTE typedef AtlasAttachmentLoader CCAtlasAttachmentLoader; +CC_DEPRECATED_ATTRIBUTE typedef VertexIndex CCVertexIndex; +CC_DEPRECATED_ATTRIBUTE typedef RegionAttachment CCRegionAttachment; +CC_DEPRECATED_ATTRIBUTE typedef ScrollViewDirection CCScrollViewDirection; +CC_DEPRECATED_ATTRIBUTE typedef TableViewVerticalFillOrder CCTableViewVerticalFillOrder; +CC_DEPRECATED_ATTRIBUTE typedef ControlStepperPart CCControlStepperPart; +CC_DEPRECATED_ATTRIBUTE typedef ControlEvent CCControlEvent; +CC_DEPRECATED_ATTRIBUTE typedef ControlState CCControlState; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMap CCNodeLoaderMap; +CC_DEPRECATED_ATTRIBUTE typedef NodeLoaderMapEntry CCNodeLoaderMapEntry; +CC_DEPRECATED_ATTRIBUTE typedef EventRegistry CCEventRegistry; +CC_DEPRECATED_ATTRIBUTE typedef AttachmentType CCAttachmentType; + +#define kCCTableViewFillTopDown kTableViewFillTopDown +#define kCCTableViewFillBottomUp kTableViewFillBottomUp +#define kCCScrollViewDirectionNone kScrollViewDirectionNone +#define kCCScrollViewDirectionHorizontal kScrollViewDirectionHorizontal +#define kCCScrollViewDirectionVertical kScrollViewDirectionVertical +#define kCCScrollViewDirectionBoth kScrollViewDirectionBoth +#define kCCKeyboardReturnTypeDefault kKeyboardReturnTypeDefault +#define kCCKeyboardReturnTypeDone kKeyboardReturnTypeDone +#define kCCKeyboardReturnTypeSend kKeyboardReturnTypeSend +#define kCCKeyboardReturnTypeSearch kKeyboardReturnTypeSearch +#define kCCKeyboardReturnTypeGo kKeyboardReturnTypeGo + +#define kCCEditBoxInputModeAny kEditBoxInputModeAny +#define kCCEditBoxInputModeEmailAddr kEditBoxInputModeEmailAddr +#define kCCEditBoxInputModeNumeric kEditBoxInputModeNumeric +#define kCCEditBoxInputModePhoneNumber kEditBoxInputModePhoneNumber +#define kCCEditBoxInputModeUrl kEditBoxInputModeUrl +#define kCCEditBoxInputModeDecimal kEditBoxInputModeDecimal +#define kCCEditBoxInputModeSingleLine kEditBoxInputModeSingleLine + +#define kCCControlStepperPartMinus kControlStepperPartMinus +#define kCCControlStepperPartPlus kControlStepperPartPlus +#define kCCControlStepperPartNone kControlStepperPartNone + +#define CCControlEventTouchDown ControlEventTouchDown +#define CCControlEventTouchDragInside ControlEventTouchDragInside +#define CCControlEventTouchDragOutside ControlEventTouchDragOutside +#define CCControlEventTouchDragEnter ControlEventTouchDragEnter +#define CCControlEventTouchDragExit ControlEventTouchDragExit +#define CCControlEventTouchUpInside ControlEventTouchUpInside +#define CCControlEventTouchUpOutside ControlEventTouchUpOutside +#define CCControlEventTouchCancel ControlEventTouchCancel +#define CCControlEventValueChanged ControlEventValueChanged + +#define CCControlStateNormal ControlStateNormal +#define CCControlStateHighlighted ControlStateHighlighted +#define CCControlStateDisabled ControlStateDisabled +#define CCControlStateSelected ControlStateSelected + +#define kCCCreateFile kCreateFile +#define kCCNetwork kNetwork +#define kCCNoNewVersion kNoNewVersion +#define kCCUncompress kUncompress + +#define kCCHttpGet kHttpGet +#define kCCHttpPut kHttpPut +#define kCCHttpPost kHttpPost +#define kCCHttpDelete kHttpDelete +#define kCCHttpUnkown kHttpUnkown + +NS_CC_EXT_END + +#endif // COCOS2D_CCDEPRECATED_EXT_H__ diff --git a/extensions/Components/CCInputDelegate.cpp b/extensions/Components/CCInputDelegate.cpp index 440074b7f9..5e621d587a 100644 --- a/extensions/Components/CCInputDelegate.cpp +++ b/extensions/Components/CCInputDelegate.cpp @@ -31,7 +31,7 @@ InputDelegate::InputDelegate(void) , _accelerometerEnabled(false) , _keypadEnabled(false) , _touchPriority(0) -, _touchMode(kTouchesAllAtOnce) +, _touchMode(Touch::DispatchMode::ALL_AT_ONCE) { } @@ -94,7 +94,7 @@ void InputDelegate::didAccelerate(Acceleration* pAccelerationValue) CC_UNUSED_PARAM(pAccelerationValue); } -bool InputDelegate::isTouchEnabled() +bool InputDelegate::isTouchEnabled() const { return _touchEnabled; } @@ -106,7 +106,7 @@ void InputDelegate::setTouchEnabled(bool enabled) _touchEnabled = enabled; if (enabled) { - if( _touchMode == kTouchesAllAtOnce ) + if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) { Director::getInstance()->getTouchDispatcher()->addStandardDelegate(this, 0); } @@ -122,7 +122,7 @@ void InputDelegate::setTouchEnabled(bool enabled) } } -void InputDelegate::setTouchMode(ccTouchesMode mode) +void InputDelegate::setTouchMode(Touch::DispatchMode mode) { if(_touchMode != mode) { @@ -150,17 +150,17 @@ void InputDelegate::setTouchPriority(int priority) } } -int InputDelegate::getTouchPriority() +int InputDelegate::getTouchPriority() const { return _touchPriority; } -int InputDelegate::getTouchMode() +Touch::DispatchMode InputDelegate::getTouchMode() const { return _touchMode; } -bool InputDelegate::isAccelerometerEnabled() +bool InputDelegate::isAccelerometerEnabled() const { return _accelerometerEnabled; } @@ -183,7 +183,7 @@ void InputDelegate::setAccelerometerEnabled(bool enabled) } } -bool InputDelegate::isKeypadEnabled() +bool InputDelegate::isKeypadEnabled() const { return _keypadEnabled; } diff --git a/extensions/Components/CCInputDelegate.h b/extensions/Components/CCInputDelegate.h index 301c7cf284..bc8f798557 100644 --- a/extensions/Components/CCInputDelegate.h +++ b/extensions/Components/CCInputDelegate.h @@ -37,33 +37,33 @@ protected: virtual ~InputDelegate(void); public: - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); - virtual void ccTouchMoved(Touch *pTouch, Event *pEvent); - virtual void ccTouchEnded(Touch *pTouch, Event *pEvent); - virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent); - - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); - virtual void ccTouchesCancelled(Set *pTouches, Event *pEvent); - - virtual void didAccelerate(Acceleration* pAccelerationValue); -public: - virtual bool isTouchEnabled(); + virtual bool isTouchEnabled() const; virtual void setTouchEnabled(bool value); - virtual bool isAccelerometerEnabled(); + virtual bool isAccelerometerEnabled() const; virtual void setAccelerometerEnabled(bool value); - virtual bool isKeypadEnabled(); + virtual bool isKeypadEnabled() const; virtual void setKeypadEnabled(bool value); - virtual void setTouchMode(ccTouchesMode mode); - virtual int getTouchMode(); + virtual void setTouchMode(Touch::DispatchMode mode); + virtual Touch::DispatchMode getTouchMode() const; virtual void setTouchPriority(int priority); - virtual int getTouchPriority(); - + virtual int getTouchPriority() const; + + virtual void didAccelerate(Acceleration* accelerationValue); + + // Overrides + virtual bool ccTouchBegan(Touch *touch, Event *event) override; + virtual void ccTouchMoved(Touch *touch, Event *event) override; + virtual void ccTouchEnded(Touch *touch, Event *event) override; + virtual void ccTouchCancelled(Touch *touch, Event *event) override; + virtual void ccTouchesBegan(Set *touches, Event *event) override; + virtual void ccTouchesMoved(Set *touches, Event *event) override; + virtual void ccTouchesEnded(Set *touches, Event *event) override; + virtual void ccTouchesCancelled(Set *touches, Event *event) override; + protected: bool _touchEnabled; bool _accelerometerEnabled; @@ -71,7 +71,7 @@ protected: private: int _touchPriority; - ccTouchesMode _touchMode; + Touch::DispatchMode _touchMode; }; NS_CC_EXT_END diff --git a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp index 00dd0bc634..2679618f88 100644 --- a/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp +++ b/extensions/GUI/CCControlExtension/CCControlPotentiometer.cpp @@ -59,7 +59,7 @@ ControlPotentiometer* ControlPotentiometer::create(const char* backgroundFile, c // Prepare progress for potentiometer ProgressTimer *progressTimer = ProgressTimer::create(Sprite::create(progressFile)); - //progressTimer.type = kProgressTimerTypeRadialCW; + //progressTimer.type = ProgressTimer::RADIALCW; if (pRet->initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite)) { pRet->autorelease(); diff --git a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp index 7f1d258a75..6ea3789b62 100644 --- a/extensions/GUI/CCControlExtension/CCControlSwitch.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSwitch.cpp @@ -124,9 +124,9 @@ bool ControlSwitchSprite::initWithMaskSprite( CHECK_GL_ERROR_DEBUG(); - getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color); - getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); CHECK_GL_ERROR_DEBUG(); getShaderProgram()->link(); @@ -157,14 +157,14 @@ void ControlSwitchSprite::draw() { CC_NODE_DRAW_SETUP(); - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); - ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); + GL::blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); getShaderProgram()->setUniformsForBuiltins(); - ccGLBindTexture2DN(0, getTexture()->getName()); + GL::bindTexture2DN(0, getTexture()->getName()); glUniform1i(_textureLocation, 0); - ccGLBindTexture2DN(1, _maskTexture->getName()); + GL::bindTexture2DN(1, _maskTexture->getName()); glUniform1i(_maskLocation, 1); #define kQuadSize sizeof(_quad.bl) @@ -177,19 +177,19 @@ void ControlSwitchSprite::draw() // vertex int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - ccGLBindTexture2DN(0, 0); + GL::bindTexture2DN(0, 0); } void ControlSwitchSprite::needsLayout() diff --git a/extensions/cocos-ext.h b/extensions/cocos-ext.h index 13e1c33e97..716f269065 100644 --- a/extensions/cocos-ext.h +++ b/extensions/cocos-ext.h @@ -39,17 +39,21 @@ #include "network/HttpRequest.h" #include "network/HttpResponse.h" #include "network/HttpClient.h" +#include "network/WebSocket.h" +#include "network/SocketIO.h" // Physics integration #if CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION #include "physics_nodes/CCPhysicsDebugNode.h" #include "physics_nodes/CCPhysicsSprite.h" #endif - + #include "spine/spine-cocos2dx.h" #include "Components/CCComAttribute.h" #include "Components/CCComAudio.h" #include "Components/CCComController.h" +#include "CCDeprecated-ext.h" + #endif /* __COCOS2D_EXT_H__ */ diff --git a/extensions/network/WebSocket.cpp b/extensions/network/WebSocket.cpp index b979776da6..b55d2b34cc 100644 --- a/extensions/network/WebSocket.cpp +++ b/extensions/network/WebSocket.cpp @@ -28,12 +28,15 @@ ****************************************************************************/ #include "WebSocket.h" + #include #include #include #include #include +#include "libwebsockets.h" + NS_CC_EXT_BEGIN class WsMessage @@ -444,7 +447,7 @@ void WebSocket::onSubThreadEnded() int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, - enum libwebsocket_callback_reasons reason, + int reason, void *user, void *in, size_t len) { //CCLOG("socket callback for %d reason", reason); diff --git a/extensions/network/WebSocket.h b/extensions/network/WebSocket.h index 1dc262077b..d27afe7736 100644 --- a/extensions/network/WebSocket.h +++ b/extensions/network/WebSocket.h @@ -32,9 +32,12 @@ #include "ExtensionMacros.h" #include "cocos2d.h" -#include "libwebsockets.h" #include +struct libwebsocket; +struct libwebsocket_context; +struct libwebsocket_protocols; + NS_CC_EXT_BEGIN class WsThreadHelper; @@ -132,7 +135,7 @@ private: friend class WebSocketCallbackWrapper; int onSocketCallback(struct libwebsocket_context *ctx, struct libwebsocket *wsi, - enum libwebsocket_callback_reasons reason, + int reason, void *user, void *in, size_t len); private: diff --git a/extensions/spine/CCSkeleton.cpp b/extensions/spine/CCSkeleton.cpp index 31b6fea4a1..ef64a5d189 100644 --- a/extensions/spine/CCSkeleton.cpp +++ b/extensions/spine/CCSkeleton.cpp @@ -56,11 +56,10 @@ void CCSkeleton::initialize () { debugBones = false; timeScale = 1; - blendFunc.src = GL_ONE; - blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + blendFunc = BlendFunc::ALPHA_PREMULTIPLIED; setOpacityModifyRGB(true); - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); scheduleUpdate(); } @@ -120,7 +119,7 @@ void CCSkeleton::update (float deltaTime) { void CCSkeleton::draw () { CC_NODE_DRAW_SETUP(); - ccGLBlendFunc(blendFunc.src, blendFunc.dst); + GL::blendFunc(blendFunc.src, blendFunc.dst); Color3B color = getColor(); skeleton->r = color.r / (float)255; skeleton->g = color.g / (float)255; @@ -162,7 +161,7 @@ void CCSkeleton::draw () { if (debugSlots) { // Slots. - ccDrawColor4B(0, 0, 255, 255); + DrawPrimitives::setDrawColor4B(0, 0, 255, 255); glLineWidth(1); Point points[4]; V3F_C4B_T2F_Quad quad; @@ -175,26 +174,26 @@ void CCSkeleton::draw () { points[1] = Point(quad.br.vertices.x, quad.br.vertices.y); points[2] = Point(quad.tr.vertices.x, quad.tr.vertices.y); points[3] = Point(quad.tl.vertices.x, quad.tl.vertices.y); - ccDrawPoly(points, 4, true); + DrawPrimitives::drawPoly(points, 4, true); } } if (debugBones) { // Bone lengths. glLineWidth(2); - ccDrawColor4B(255, 0, 0, 255); + DrawPrimitives::setDrawColor4B(255, 0, 0, 255); for (int i = 0, n = skeleton->boneCount; i < n; i++) { Bone *bone = skeleton->bones[i]; float x = bone->data->length * bone->m00 + bone->worldX; float y = bone->data->length * bone->m10 + bone->worldY; - ccDrawLine(Point(bone->worldX, bone->worldY), Point(x, y)); + DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y)); } // Bone origins. - ccPointSize(4); - ccDrawColor4B(0, 0, 255, 255); // Root bone is blue. + DrawPrimitives::setPointSize(4); + DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue. for (int i = 0, n = skeleton->boneCount; i < n; i++) { Bone *bone = skeleton->bones[i]; - ccDrawPoint(Point(bone->worldX, bone->worldY)); - if (i == 0) ccDrawColor4B(0, 255, 0, 255); + DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY)); + if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255); } } } diff --git a/install-templates-xcode.sh b/install-templates-xcode.sh deleted file mode 100755 index 135825d035..0000000000 --- a/install-templates-xcode.sh +++ /dev/null @@ -1,251 +0,0 @@ -#!/bin/bash - -echo 'cocos2d-x template installer' - -COCOS2D_VER='2.1rc0-x-2.1.4' -BASE_TEMPLATE_DIR="/Library/Application Support/Developer/Shared/Xcode" -BASE_TEMPLATE_USER_DIR="$HOME/Library/Application Support/Developer/Shared/Xcode" - -force= -user_dir= - -usage(){ -cat << EOF -usage: $0 [options] - -Install / update templates for ${COCOS2D_VER} - -OPTIONS: - -f force overwrite if directories exist - -h this help - -u install in user's Library directory instead of global directory -EOF -} - -while getopts "fhu" OPTION; do - case "$OPTION" in - f) - force=1 - ;; - h) - usage - exit 0 - ;; - u) - user_dir=1 - ;; - esac -done - -# Make sure only root can run our script -if [[ ! $user_dir && "$(id -u)" != "0" ]]; then - echo "" - echo "Error: This script must be run as root in order to copy templates to ${BASE_TEMPLATE_DIR}" 1>&2 - echo "" - echo "Try running it with 'sudo', or with '-u' to install it only you:" 1>&2 - echo " sudo $0" 1>&2 - echo "or:" 1>&2 - echo " $0 -u" 1>&2 -exit 1 -fi - -# Make sure root and user_dir is not executed at the same time -if [[ $user_dir && "$(id -u)" == "0" ]]; then - echo "" - echo "Error: Do not run this script as root with the '-u' option." 1>&2 - echo "" - echo "Either use the '-u' option or run it as root, but not both options at the same time." 1>&2 - echo "" - echo "RECOMMENDED WAY:" 1>&2 - echo " $0 -u -f" 1>&2 - echo "" -exit 1 -fi - -copy_files(){ - # SRC_DIR="${SCRIPT_DIR}/${1}" - rsync -r --exclude=.svn "$1" "$2" -} - -check_dst_dir(){ - if [[ -d $DST_DIR ]]; then - if [[ $force ]]; then - echo "removing old libraries: ${DST_DIR}" - rm -rf "${DST_DIR}" - else - echo "templates already installed. To force a re-install use the '-f' parameter" - exit 1 - fi - fi - - echo ...creating destination directory: $DST_DIR - mkdir -p "$DST_DIR" -} - -# copy_base_mac_files(){ -# echo ...copying cocos2dx files -# copy_files cocos2dx "$LIBS_DIR" - -# echo ...copying CocosDenshion files -# copy_files CocosDenshion "$LIBS_DIR" -# } - -copy_base_files(){ - echo ...copying cocos2dx files - copy_files cocos2dx "$LIBS_DIR" - - - echo ...copying CocosDenshion files - copy_files CocosDenshion "$LIBS_DIR" -} - -copy_cocos2d_files(){ - echo ...copying cocos2d files - copy_files cocos2dx "$LIBS_DIR" - copy_files licenses/LICENSE_cocos2d-x.txt "$LIBS_DIR" -} - -copy_cocosdenshion_files(){ - echo ...copying CocosDenshion files - copy_files CocosDenshion "$LIBS_DIR" - # copy_files licenses/LICENSE_CocosDenshion.txt "$LIBS_DIR" -} - -copy_extensions_files(){ - echo ...copying extension files - copy_files extensions "$LIBS_DIR" -} - -# copy_cocosdenshionextras_files(){ -# echo ...copying CocosDenshionExtras files -# copy_files CocosDenshion/CocosDenshionExtras "$LIBS_DIR" -# } - -# copy_fontlabel_files(){ -# echo ...copying FontLabel files -# copy_files external/FontLabel "$LIBS_DIR" -# copy_files licenses/LICENSE_FontLabel.txt "$LIBS_DIR" -# } - -# copy_cocoslive_files(){ -# echo ...copying cocoslive files -# copy_files cocoslive "$LIBS_DIR" - -# echo ...copying TouchJSON files -# copy_files external/TouchJSON "$LIBS_DIR" -# copy_files licenses/LICENSE_TouchJSON.txt "$LIBS_DIR" -# } - -print_template_banner(){ - echo '' - echo '' - echo '' - echo "$1" - echo '----------------------------------------------------' - echo '' -} - -# Xcode4 templates -copy_xcode4_project_templates(){ - TEMPLATE_DIR="$HOME/Library/Developer/Xcode/Templates/cocos2d-x/" - - print_template_banner "Installing Xcode 4 cocos2d-x iOS template" - - DST_DIR="$TEMPLATE_DIR" - check_dst_dir - - LIBS_DIR="$DST_DIR""lib_cocos2dx.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - copy_cocos2d_files - - LIBS_DIR="$DST_DIR""lib_cocosdenshion.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - copy_cocosdenshion_files - - echo ...copying websockets files - LIBS_DIR="$DST_DIR""lib_websockets.xctemplate/libs/libwebsockets" - mkdir -p "$LIBS_DIR" - copy_files external/libwebsockets/ios "$LIBS_DIR" - - LIBS_DIR="$DST_DIR""lib_extensions.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - copy_extensions_files - - echo ...copying template files - copy_files template/xcode4/ "$DST_DIR" - - echo done! - - print_template_banner "Installing Xcode 4 Chipmunk iOS template" - - - LIBS_DIR="$DST_DIR""lib_chipmunk.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - - echo ...copying Chipmunk files - copy_files external/chipmunk "$LIBS_DIR" - copy_files licenses/LICENSE_chipmunk.txt "$LIBS_DIR" - - echo done! - - print_template_banner "Installing Xcode 4 Box2d iOS template" - - - LIBS_DIR="$DST_DIR""lib_box2d.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - - echo ...copying Box2D files - copy_files external/Box2D "$LIBS_DIR" - copy_files licenses/LICENSE_box2d.txt "$LIBS_DIR" - - echo done! - - - print_template_banner "Installing Xcode 4 lua iOS template" - - - LIBS_DIR="$DST_DIR""lib_lua.xctemplate/libs/" - mkdir -p "$LIBS_DIR" - - echo ...copying lua files - copy_files scripting/lua "$LIBS_DIR" - copy_files licenses/LICENSE_lua.txt "$LIBS_DIR" - copy_files licenses/LICENSE_tolua++.txt "$LIBS_DIR" - - echo done! - - print_template_banner "Installing Xcode 4 JS iOS template" - - LIBS_DIR="$DST_DIR""lib_js.xctemplate/libs/javascript" - mkdir -p "$LIBS_DIR" - - echo ...copying js files - copy_files scripting/javascript/bindings "$LIBS_DIR" - copy_files licenses/LICENSE_js.txt "$LIBS_DIR" - - echo done! - - - echo ...copying spidermonkey files - - LIBS_DIR="$DST_DIR""lib_spidermonkey.xctemplate/libs/javascript" - mkdir -p "$LIBS_DIR" - copy_files scripting/javascript/spidermonkey-ios "$LIBS_DIR" - - echo done! - - # Move File Templates to correct position - # DST_DIR="$HOME/Library/Developer/Xcode/Templates/File Templates/cocos2d/" - # OLD_DIR="$HOME/Library/Developer/Xcode/Templates/cocos2d/" - - # print_template_banner "Installing Xcode 4 CCNode file templates..." - - # check_dst_dir - - # mv -f "$OLD_DIR""/CCNode class.xctemplate" "$DST_DIR" - - echo done! - -} - -copy_xcode4_project_templates diff --git a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.cpp b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.cpp index e1277b8759..aa6f3e2fe5 100644 --- a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.cpp +++ b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.cpp @@ -7,6 +7,8 @@ using namespace pluginx; #include "ProtocolIAP.h" #include "ProtocolAds.h" #include "ProtocolShare.h" +#include "ProtocolSocial.h" +#include "ProtocolUser.h" template static JSBool dummy_constructor(JSContext *cx, uint32_t argc, jsval *vp) { @@ -740,38 +742,18 @@ JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, js js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - if (argc == 1) { - cocos2d::plugin::ProtocolAds::AdsType arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - cobj->showAds(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } if (argc == 2) { - cocos2d::plugin::ProtocolAds::AdsType arg0; - int arg1; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + TAdsInfo arg0; + cocos2d::plugin::ProtocolAds::AdsPos arg1; + #pragma warning NO CONVERSION TO NATIVE FOR TAdsInfo; ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->showAds(arg0, arg1); JS_SET_RVAL(cx, vp, JSVAL_VOID); return JS_TRUE; } - if (argc == 3) { - cocos2d::plugin::ProtocolAds::AdsType arg0; - int arg1; - cocos2d::plugin::ProtocolAds::AdsPos arg2; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - ok &= jsval_to_int32(cx, argv[1], (int32_t *)&arg1); - ok &= jsval_to_int32(cx, argv[2], (int32_t *)&arg2); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - cobj->showAds(arg0, arg1, arg2); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); return JS_FALSE; } JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp) @@ -783,8 +765,8 @@ JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, js cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); if (argc == 1) { - cocos2d::plugin::ProtocolAds::AdsType arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); + TAdsInfo arg0; + #pragma warning NO CONVERSION TO NATIVE FOR TAdsInfo; JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); cobj->hideAds(arg0); JS_SET_RVAL(cx, vp, JSVAL_VOID); @@ -809,28 +791,6 @@ JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } -JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp) -{ - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; - JSObject *obj = JS_THIS_OBJECT(cx, vp); - js_proxy_t *proxy = jsb_get_js_proxy(obj); - cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); - JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - if (argc == 2) { - cocos2d::plugin::AdsResultCode arg0; - const char* arg1; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - std::string arg1_tmp; ok &= jsval_to_std_string(cx, argv[1], &arg1_tmp); arg1 = arg1_tmp.c_str(); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - cobj->onAdsResult(arg0, arg1); - JS_SET_RVAL(cx, vp, JSVAL_VOID); - return JS_TRUE; - } - - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); - return JS_FALSE; -} JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); @@ -871,24 +831,28 @@ JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint3 JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } -JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp) +JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp) { - jsval *argv = JS_ARGV(cx, vp); - JSBool ok = JS_TRUE; JSObject *obj = JS_THIS_OBJECT(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::plugin::ProtocolAds* cobj = (cocos2d::plugin::ProtocolAds *)(proxy ? proxy->ptr : NULL); JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); - if (argc == 1) { - int arg0; - ok &= jsval_to_int32(cx, argv[0], (int32_t *)&arg0); - JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); - cobj->onPlayerGetPoints(arg0); - JS_SET_RVAL(cx, vp, JSVAL_VOID); + if (argc == 0) { + cocos2d::plugin::AdsListener* ret = cobj->getAdsListener(); + jsval jsret; + do { + if (ret) { + js_proxy_t *proxy = js_get_or_create_proxy(cx, ret); + jsret = OBJECT_TO_JSVAL(proxy->obj); + } else { + jsret = JSVAL_NULL; + } + } while (0); + JS_SET_RVAL(cx, vp, jsret); return JS_TRUE; } - JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); return JS_FALSE; } @@ -929,13 +893,12 @@ void js_register_pluginx_protocols_ProtocolAds(JSContext *cx, JSObject *global) }; static JSFunctionSpec funcs[] = { - JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("showAds", js_pluginx_protocols_ProtocolAds_showAds, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("hideAds", js_pluginx_protocols_ProtocolAds_hideAds, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("queryPoints", js_pluginx_protocols_ProtocolAds_queryPoints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("onAdsResult", js_pluginx_protocols_ProtocolAds_onAdsResult, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("spendPoints", js_pluginx_protocols_ProtocolAds_spendPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolAds_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), - JS_FN("onPlayerGetPoints", js_pluginx_protocols_ProtocolAds_onPlayerGetPoints, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getAdsListener", js_pluginx_protocols_ProtocolAds_getAdsListener, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), JS_FS_END }; @@ -1109,6 +1072,347 @@ void js_register_pluginx_protocols_ProtocolShare(JSContext *cx, JSObject *global } } + +JSClass *jsb_ProtocolSocial_class; +JSObject *jsb_ProtocolSocial_prototype; + +JSBool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 1) { + const char* arg0; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + cobj->showLeaderboard(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + cobj->showAchievements(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolSocial_submitScore(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 2) { + const char* arg0; + long arg1; + std::string arg0_tmp; ok &= jsval_to_std_string(cx, argv[0], &arg0_tmp); arg0 = arg0_tmp.c_str(); + ok &= jsval_to_long(cx, argv[1], (long *)&arg1); + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + cobj->submitScore(arg0, arg1); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 1) { + TSocialDeveloperInfo arg0; + #pragma warning NO CONVERSION TO NATIVE FOR TSocialDeveloperInfo; + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + cobj->configDeveloperInfo(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolSocial_unlockAchievement(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 1) { + TAchievementInfo arg0; + #pragma warning NO CONVERSION TO NATIVE FOR TAchievementInfo; + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + cobj->unlockAchievement(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + + +extern JSObject *jsb_PluginProtocol_prototype; + +void js_pluginx_protocols_ProtocolSocial_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolSocial)", obj); + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + jsproxy = jsb_get_js_proxy(obj); + if (jsproxy) { + nproxy = jsb_get_native_proxy(jsproxy->ptr); + +// cocos2d::plugin::ProtocolSocial *nobj = static_cast(nproxy->ptr); +// if (nobj) +// delete nobj; + + jsb_remove_proxy(nproxy, jsproxy); + } +} + +void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global) { + jsb_ProtocolSocial_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_ProtocolSocial_class->name = "ProtocolSocial"; + jsb_ProtocolSocial_class->addProperty = JS_PropertyStub; + jsb_ProtocolSocial_class->delProperty = JS_PropertyStub; + jsb_ProtocolSocial_class->getProperty = JS_PropertyStub; + jsb_ProtocolSocial_class->setProperty = JS_StrictPropertyStub; + jsb_ProtocolSocial_class->enumerate = JS_EnumerateStub; + jsb_ProtocolSocial_class->resolve = JS_ResolveStub; + jsb_ProtocolSocial_class->convert = JS_ConvertStub; + jsb_ProtocolSocial_class->finalize = js_pluginx_protocols_ProtocolSocial_finalize; + jsb_ProtocolSocial_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("showLeaderboard", js_pluginx_protocols_ProtocolSocial_showLeaderboard, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("showAchievements", js_pluginx_protocols_ProtocolSocial_showAchievements, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("submitScore", js_pluginx_protocols_ProtocolSocial_submitScore, 2, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolSocial_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("unlockAchievement", js_pluginx_protocols_ProtocolSocial_unlockAchievement, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_ProtocolSocial_prototype = JS_InitClass( + cx, global, + jsb_PluginProtocol_prototype, + jsb_ProtocolSocial_class, + empty_constructor, 0, + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace + JSBool found; + JS_SetPropertyAttributes(cx, global, "ProtocolSocial", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + if (!p) { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->type = typeId; + p->jsclass = jsb_ProtocolSocial_class; + p->proto = jsb_ProtocolSocial_prototype; + p->parentProto = jsb_PluginProtocol_prototype; + HASH_ADD_INT(_js_global_type_ht, type, p); + } +} + + +JSClass *jsb_ProtocolUser_class; +JSObject *jsb_ProtocolUser_prototype; + +JSBool js_pluginx_protocols_ProtocolUser_isLogined(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + bool ret = cobj->isLogined(); + jsval jsret; + jsret = BOOLEAN_TO_JSVAL(ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolUser_logout(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + cobj->logout(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSBool ok = JS_TRUE; + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 1) { + TUserDeveloperInfo arg0; + #pragma warning NO CONVERSION TO NATIVE FOR TUserDeveloperInfo; + JSB_PRECONDITION2(ok, cx, JS_FALSE, "Error processing arguments"); + cobj->configDeveloperInfo(arg0); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolUser_login(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + cobj->login(); + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} +JSBool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp) +{ + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy = jsb_get_js_proxy(obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSB_PRECONDITION2( cobj, cx, JS_FALSE, "Invalid Native Object"); + if (argc == 0) { + std::string ret = cobj->getSessionID(); + jsval jsret; + jsret = std_string_to_jsval(cx, ret); + JS_SET_RVAL(cx, vp, jsret); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 0); + return JS_FALSE; +} + + +extern JSObject *jsb_PluginProtocol_prototype; + +void js_pluginx_protocols_ProtocolUser_finalize(JSFreeOp *fop, JSObject *obj) { + CCLOGINFO("jsbindings: finalizing JS object %p (ProtocolUser)", obj); + js_proxy_t* nproxy; + js_proxy_t* jsproxy; + jsproxy = jsb_get_js_proxy(obj); + if (jsproxy) { + nproxy = jsb_get_native_proxy(jsproxy->ptr); + +// cocos2d::plugin::ProtocolUser *nobj = static_cast(nproxy->ptr); +// if (nobj) +// delete nobj; + + jsb_remove_proxy(nproxy, jsproxy); + } +} + +void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JSObject *global) { + jsb_ProtocolUser_class = (JSClass *)calloc(1, sizeof(JSClass)); + jsb_ProtocolUser_class->name = "ProtocolUser"; + jsb_ProtocolUser_class->addProperty = JS_PropertyStub; + jsb_ProtocolUser_class->delProperty = JS_PropertyStub; + jsb_ProtocolUser_class->getProperty = JS_PropertyStub; + jsb_ProtocolUser_class->setProperty = JS_StrictPropertyStub; + jsb_ProtocolUser_class->enumerate = JS_EnumerateStub; + jsb_ProtocolUser_class->resolve = JS_ResolveStub; + jsb_ProtocolUser_class->convert = JS_ConvertStub; + jsb_ProtocolUser_class->finalize = js_pluginx_protocols_ProtocolUser_finalize; + jsb_ProtocolUser_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); + + static JSPropertySpec properties[] = { + {0, 0, 0, JSOP_NULLWRAPPER, JSOP_NULLWRAPPER} + }; + + static JSFunctionSpec funcs[] = { + JS_FN("isLogined", js_pluginx_protocols_ProtocolUser_isLogined, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("logout", js_pluginx_protocols_ProtocolUser_logout, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("configDeveloperInfo", js_pluginx_protocols_ProtocolUser_configDeveloperInfo, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("login", js_pluginx_protocols_ProtocolUser_login, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FN("getSessionID", js_pluginx_protocols_ProtocolUser_getSessionID, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE), + JS_FS_END + }; + + JSFunctionSpec *st_funcs = NULL; + + jsb_ProtocolUser_prototype = JS_InitClass( + cx, global, + jsb_PluginProtocol_prototype, + jsb_ProtocolUser_class, + empty_constructor, 0, + properties, + funcs, + NULL, // no static properties + st_funcs); + // make the class enumerable in the registered namespace + JSBool found; + JS_SetPropertyAttributes(cx, global, "ProtocolUser", JSPROP_ENUMERATE | JSPROP_READONLY, &found); + + // add the proto and JSClass to the type->js info hash table + TypeTest t; + js_type_class_t *p; + uint32_t typeId = t.s_id(); + HASH_FIND_INT(_js_global_type_ht, &typeId, p); + if (!p) { + p = (js_type_class_t *)malloc(sizeof(js_type_class_t)); + p->type = typeId; + p->jsclass = jsb_ProtocolUser_class; + p->proto = jsb_ProtocolUser_prototype; + p->parentProto = jsb_PluginProtocol_prototype; + HASH_ADD_INT(_js_global_type_ht, type, p); + } +} + void register_all_pluginx_protocols(JSContext* cx, JSObject* obj) { // first, try to get the ns jsval nsval; @@ -1124,8 +1428,10 @@ void register_all_pluginx_protocols(JSContext* cx, JSObject* obj) { obj = ns; js_register_pluginx_protocols_PluginProtocol(cx, obj); + js_register_pluginx_protocols_ProtocolUser(cx, obj); js_register_pluginx_protocols_ProtocolShare(cx, obj); js_register_pluginx_protocols_ProtocolIAP(cx, obj); + js_register_pluginx_protocols_ProtocolSocial(cx, obj); js_register_pluginx_protocols_ProtocolAnalytics(cx, obj); js_register_pluginx_protocols_ProtocolAds(cx, obj); js_register_pluginx_protocols_PluginManager(cx, obj); diff --git a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.hpp b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.hpp index 6c15735955..060395d8b8 100644 --- a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.hpp +++ b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto.hpp @@ -66,10 +66,9 @@ void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolAds_showAds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_hideAds(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_queryPoints(JSContext *cx, uint32_t argc, jsval *vp); -JSBool js_pluginx_protocols_ProtocolAds_onAdsResult(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_spendPoints(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolAds_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); -JSBool js_pluginx_protocols_ProtocolAds_onPlayerGetPoints(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolAds_getAdsListener(JSContext *cx, uint32_t argc, jsval *vp); extern JSClass *jsb_ProtocolShare_class; extern JSObject *jsb_ProtocolShare_prototype; @@ -81,5 +80,31 @@ void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); JSBool js_pluginx_protocols_ProtocolShare_onShareResult(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_share(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_protocols_ProtocolShare_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_ProtocolSocial_class; +extern JSObject *jsb_ProtocolSocial_prototype; + +JSBool js_pluginx_protocols_ProtocolSocial_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_pluginx_protocols_ProtocolSocial_finalize(JSContext *cx, JSObject *obj); +void js_register_pluginx_protocols_ProtocolSocial(JSContext *cx, JSObject *global); +void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); +JSBool js_pluginx_protocols_ProtocolSocial_showLeaderboard(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolSocial_showAchievements(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolSocial_submitScore(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolSocial_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolSocial_unlockAchievement(JSContext *cx, uint32_t argc, jsval *vp); + +extern JSClass *jsb_ProtocolUser_class; +extern JSObject *jsb_ProtocolUser_prototype; + +JSBool js_pluginx_protocols_ProtocolUser_constructor(JSContext *cx, uint32_t argc, jsval *vp); +void js_pluginx_protocols_ProtocolUser_finalize(JSContext *cx, JSObject *obj); +void js_register_pluginx_protocols_ProtocolUser(JSContext *cx, JSObject *global); +void register_all_pluginx_protocols(JSContext* cx, JSObject* obj); +JSBool js_pluginx_protocols_ProtocolUser_isLogined(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolUser_logout(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolUser_configDeveloperInfo(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolUser_login(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_protocols_ProtocolUser_getSessionID(JSContext *cx, uint32_t argc, jsval *vp); #endif diff --git a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto_api.js b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto_api.js index e0a8300d40..b95b7eac6c 100644 --- a/plugin/jsbindings/auto/jsb_pluginx_protocols_auto_api.js +++ b/plugin/jsbindings/auto/jsb_pluginx_protocols_auto_api.js @@ -154,15 +154,14 @@ plugin.ProtocolAds = { /** * @method showAds - * @param {cocos2d::plugin::ProtocolAds::AdsType} - * @param {int} + * @param {TAdsInfo} * @param {cocos2d::plugin::ProtocolAds::AdsPos} */ showAds : function () {}, /** * @method hideAds - * @param {cocos2d::plugin::ProtocolAds::AdsType} + * @param {TAdsInfo} */ hideAds : function () {}, @@ -171,13 +170,6 @@ hideAds : function () {}, */ queryPoints : function () {}, -/** - * @method onAdsResult - * @param {cocos2d::plugin::AdsResultCode} - * @param {const char*} - */ -onAdsResult : function () {}, - /** * @method spendPoints * @param {int} @@ -191,10 +183,10 @@ spendPoints : function () {}, configDeveloperInfo : function () {}, /** - * @method onPlayerGetPoints - * @param {int} + * @method getAdsListener + * @return A value converted from C/C++ "cocos2d::plugin::AdsListener*" */ -onPlayerGetPoints : function () {}, +getAdsListener : function () {}, }; @@ -223,3 +215,75 @@ share : function () {}, configDeveloperInfo : function () {}, }; + +/** + * @class ProtocolSocial + */ +plugin.ProtocolSocial = { + +/** + * @method showLeaderboard + * @param {const char*} + */ +showLeaderboard : function () {}, + +/** + * @method showAchievements + */ +showAchievements : function () {}, + +/** + * @method submitScore + * @param {const char*} + * @param {long} + */ +submitScore : function () {}, + +/** + * @method configDeveloperInfo + * @param {TSocialDeveloperInfo} + */ +configDeveloperInfo : function () {}, + +/** + * @method unlockAchievement + * @param {TAchievementInfo} + */ +unlockAchievement : function () {}, + +}; + +/** + * @class ProtocolUser + */ +plugin.ProtocolUser = { + +/** + * @method isLogined + * @return A value converted from C/C++ "bool" + */ +isLogined : function () {}, + +/** + * @method logout + */ +logout : function () {}, + +/** + * @method configDeveloperInfo + * @param {TUserDeveloperInfo} + */ +configDeveloperInfo : function () {}, + +/** + * @method login + */ +login : function () {}, + +/** + * @method getSessionID + * @return A value converted from C/C++ "std::string" + */ +getSessionID : function () {}, + +}; diff --git a/plugin/jsbindings/js/jsb_pluginx.js b/plugin/jsbindings/js/jsb_pluginx.js index 089ab45456..250b8072e2 100644 --- a/plugin/jsbindings/js/jsb_pluginx.js +++ b/plugin/jsbindings/js/jsb_pluginx.js @@ -16,11 +16,6 @@ plugin.ProtocolAds.AdsResultCode.PointsSpendFailed = 4; plugin.ProtocolAds.AdsResultCode.NetworkError = 5; plugin.ProtocolAds.AdsResultCode.UnknownError = 6; -plugin.ProtocolAds.AdsType = {}; -plugin.ProtocolAds.AdsType.BannerAd = 0; -plugin.ProtocolAds.AdsType.FullScreenAd = 1; -plugin.ProtocolAds.AdsType.MoreApp = 2; - plugin.ProtocolAds.AdsPos = {}; plugin.ProtocolAds.AdsPos.PosCenter = 0; plugin.ProtocolAds.AdsPos.PosTop = 1; @@ -42,3 +37,14 @@ plugin.ProtocolShare.ShareResultCode.ShareFail = 1; plugin.ProtocolShare.ShareResultCode.ShareCancel = 2; plugin.ProtocolShare.ShareResultCode.ShareTimeOut = 3; +plugin.ProtocolSocial.SocialRetCode = {}; +plugin.ProtocolSocial.SocialRetCode.ScoreSubmitSuccess = 1; +plugin.ProtocolSocial.SocialRetCode.ScoreSubmitFailed = 2; +plugin.ProtocolSocial.SocialRetCode.AchUnlockSuccess = 3; +plugin.ProtocolSocial.SocialRetCode.AchUnlockFailed = 4; + +plugin.ProtocolUser.UserActionResultCode = {}; +plugin.ProtocolUser.UserActionResultCode.LoginSucceed = 0; +plugin.ProtocolUser.UserActionResultCode.LoginFailed = 1; +plugin.ProtocolUser.UserActionResultCode.LogoutSucceed = 2; + diff --git a/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp b/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp index 613e6168c1..9df992d19f 100644 --- a/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp +++ b/plugin/jsbindings/manual/jsb_pluginx_basic_conversions.cpp @@ -206,6 +206,11 @@ JSBool jsval_to_TAdsDeveloperInfo(JSContext *cx, jsval v, TAdsDeveloperInfo* ret return jsval_to_TProductInfo(cx, v, ret); } +JSBool jsval_to_TAdsInfo(JSContext *cx, jsval v, TAdsInfo* ret) +{ + return jsval_to_TProductInfo(cx, v, ret); +} + JSBool jsval_to_TShareDeveloperInfo(JSContext *cx, jsval v, TShareDeveloperInfo* ret) { return jsval_to_TProductInfo(cx, v, ret); @@ -221,6 +226,21 @@ JSBool jsval_to_TPaymentInfo(JSContext *cx, jsval v, std::map* ret); +JSBool jsval_to_TUserDeveloperInfo(JSContext *cx, jsval v, TUserDeveloperInfo* ret); JSBool jsval_to_LogEventParamMap(JSContext *cx, jsval v, LogEventParamMap** ret); JSBool jsval_to_StringMap(JSContext *cx, jsval v, StringMap* ret); diff --git a/plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp b/plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp index 54dc5396d0..c63cd864a2 100644 --- a/plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp +++ b/plugin/jsbindings/manual/jsb_pluginx_extension_registration.cpp @@ -14,6 +14,8 @@ extern JSObject *jsb_ProtocolIAP_prototype; extern JSObject *jsb_ProtocolAds_prototype; extern JSObject *jsb_ProtocolShare_prototype; extern JSObject *jsb_PluginProtocol_prototype; +extern JSObject *jsb_ProtocolSocial_prototype; +extern JSObject *jsb_ProtocolUser_prototype; void register_pluginx_js_extensions(JSContext* cx, JSObject* global) { @@ -32,6 +34,8 @@ void register_pluginx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, jsb_ProtocolIAP_prototype, "setResultListener", js_pluginx_ProtocolIAP_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_ProtocolAds_prototype, "setAdsListener", js_pluginx_ProtocolAds_setAdsListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_ProtocolShare_prototype, "setResultListener", js_pluginx_ProtocolShare_setResultListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_ProtocolSocial_prototype, "setListener", js_pluginx_ProtocolSocial_setListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, jsb_ProtocolUser_prototype, "setActionListener", js_pluginx_ProtocolUser_setActionListener, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callFuncWithParam", js_pluginx_PluginProtocol_callFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callStringFuncWithParam", js_pluginx_PluginProtocol_callStringFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, jsb_PluginProtocol_prototype, "callIntFuncWithParam", js_pluginx_PluginProtocol_callIntFuncWithParam, 1, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp b/plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp index 3aa300ab65..aceaf2dd0b 100644 --- a/plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp +++ b/plugin/jsbindings/manual/jsb_pluginx_manual_callback.cpp @@ -235,3 +235,137 @@ JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); return JS_FALSE; } + +class Pluginx_SocialResult : public cocos2d::plugin::SocialListener +{ +public: + virtual void onSocialResult(cocos2d::plugin::SocialRetCode ret, const char* msg) + { + JSContext* cx = s_cx; + + JSBool hasAction; + jsval retval; + jsval temp_retval; + jsval dataVal[2]; + dataVal[0] = INT_TO_JSVAL(ret); + std::string strMsgInfo = msg; + dataVal[1] = std_string_to_jsval(cx, strMsgInfo); + + JSObject* obj = _JSDelegate; + + if (JS_HasProperty(cx, obj, "onSocialResult", &hasAction) && hasAction) { + if(!JS_GetProperty(cx, obj, "onSocialResult", &temp_retval)) { + return; + } + if(temp_retval == JSVAL_VOID) { + return; + } + JSAutoCompartment ac(cx, obj); + JS_CallFunctionName(cx, obj, "onSocialResult", + 2, dataVal, &retval); + } + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + } + +private: + JSObject* _JSDelegate; +}; + +JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + s_cx = cx; + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); + cocos2d::plugin::ProtocolSocial* cobj = (cocos2d::plugin::ProtocolSocial *)(proxy ? proxy->ptr : NULL); + JSBool ok = JS_TRUE; + + if (argc == 1) { + // save the delegate + JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); + Pluginx_SocialResult* nativeDelegate = new Pluginx_SocialResult(); + nativeDelegate->setJSDelegate(jsDelegate); + cobj->setListener(nativeDelegate); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + +class Pluginx_UserActionListener : public cocos2d::plugin::UserActionListener +{ +public: + virtual void onActionResult(ProtocolUser* userPlugin, cocos2d::plugin::UserActionResultCode ret, const char* msg) + { + JSContext* cx = s_cx; + + JSBool hasAction; + jsval retval; + jsval temp_retval; + + js_proxy_t * p; + JS_GET_PROXY(p, userPlugin); + + if (! p) return; + jsval dataVal[3]; + jsval arg1 = OBJECT_TO_JSVAL(p->obj); + dataVal[0] = arg1; + dataVal[1] = INT_TO_JSVAL(ret); + std::string strMsgInfo = msg; + dataVal[2] = std_string_to_jsval(cx, strMsgInfo); + + JSObject* obj = _JSDelegate; + + if (JS_HasProperty(cx, obj, "onActionResult", &hasAction) && hasAction) { + if(!JS_GetProperty(cx, obj, "onActionResult", &temp_retval)) { + return; + } + if(temp_retval == JSVAL_VOID) { + return; + } + JSAutoCompartment ac(cx, obj); + JS_CallFunctionName(cx, obj, "onActionResult", + 3, dataVal, &retval); + } + } + + void setJSDelegate(JSObject* pJSDelegate) + { + _JSDelegate = pJSDelegate; + } + +private: + JSObject* _JSDelegate; +}; + +JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp) +{ + s_cx = cx; + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); + cocos2d::plugin::ProtocolUser* cobj = (cocos2d::plugin::ProtocolUser *)(proxy ? proxy->ptr : NULL); + JSBool ok = JS_TRUE; + + if (argc == 1) { + // save the delegate + JSObject *jsDelegate = JSVAL_TO_OBJECT(argv[0]); + Pluginx_UserActionListener* nativeDelegate = new Pluginx_UserActionListener(); + nativeDelegate->setJSDelegate(jsDelegate); + cobj->setActionListener(nativeDelegate); + + JS_SET_RVAL(cx, vp, JSVAL_VOID); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 1); + return JS_FALSE; +} + diff --git a/plugin/jsbindings/manual/jsb_pluginx_manual_callback.h b/plugin/jsbindings/manual/jsb_pluginx_manual_callback.h index 7aec12d5bb..4a91ce1980 100644 --- a/plugin/jsbindings/manual/jsb_pluginx_manual_callback.h +++ b/plugin/jsbindings/manual/jsb_pluginx_manual_callback.h @@ -7,5 +7,7 @@ JSBool js_pluginx_ProtocolIAP_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolAds_setAdsListener(JSContext *cx, uint32_t argc, jsval *vp); JSBool js_pluginx_ProtocolShare_setResultListener(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_ProtocolSocial_setListener(JSContext *cx, uint32_t argc, jsval *vp); +JSBool js_pluginx_ProtocolUser_setActionListener(JSContext *cx, uint32_t argc, jsval *vp); #endif /* __JS_MANUAL_CALLBACK_H__ */ diff --git a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java index d69ccf83c4..8b19eaf425 100644 --- a/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java +++ b/plugin/plugins/admob/proj.android/src/org/cocos2dx/plugin/AdsAdmob.java @@ -48,11 +48,14 @@ public class AdsAdmob implements InterfaceAds { private Set mTestDevices = null; private WindowManager mWm = null; - private static final int ADMOB_SIZE_BANNER = 0; - private static final int ADMOB_SIZE_IABMRect = 1; - private static final int ADMOB_SIZE_IABBanner = 2; - private static final int ADMOB_SIZE_IABLeaderboard = 3; - private static final int ADMOB_SIZE_Skyscraper = 4; + private static final int ADMOB_SIZE_BANNER = 1; + private static final int ADMOB_SIZE_IABMRect = 2; + private static final int ADMOB_SIZE_IABBanner = 3; + private static final int ADMOB_SIZE_IABLeaderboard = 4; + private static final int ADMOB_SIZE_Skyscraper = 5; + + private static final int ADMOB_TYPE_BANNER = 1; + private static final int ADMOB_TYPE_FULLSCREEN = 2; protected static void LogE(String msg, Exception e) { Log.e(LOG_TAG, msg, e); @@ -91,20 +94,29 @@ public class AdsAdmob implements InterfaceAds { } @Override - public void showAds(int adsType, int sizeEnum, int pos) { - switch (adsType) { - case AdsWrapper.ADS_TYPE_BANNER: - showBannerAd(sizeEnum, pos); - break; - case AdsWrapper.ADS_TYPE_FULL_SCREEN: - LogD("Now not support full screen view in Admob"); - break; - case AdsWrapper.ADS_TYPE_MORE_APP: - LogD("Now not support more app ads in Admob"); - break; - default: - break; - } + public void showAds(Hashtable info, int pos) { + try + { + String strType = info.get("AdmobType"); + int adsType = Integer.parseInt(strType); + + switch (adsType) { + case ADMOB_TYPE_BANNER: + { + String strSize = info.get("AdmobSizeEnum"); + int sizeEnum = Integer.parseInt(strSize); + showBannerAd(sizeEnum, pos); + break; + } + case ADMOB_TYPE_FULLSCREEN: + LogD("Now not support full screen view in Admob"); + break; + default: + break; + } + } catch (Exception e) { + LogE("Error when show Ads ( " + info.toString() + " )", e); + } } @Override @@ -113,16 +125,25 @@ public class AdsAdmob implements InterfaceAds { } @Override - public void hideAds(int adsType) { - switch (adsType) { - case AdsWrapper.ADS_TYPE_BANNER: - hideBannerAd(); - break; - case AdsWrapper.ADS_TYPE_FULL_SCREEN: - break; - default: - break; - } + public void hideAds(Hashtable info) { + try + { + String strType = info.get("AdmobType"); + int adsType = Integer.parseInt(strType); + + switch (adsType) { + case ADMOB_TYPE_BANNER: + hideBannerAd(); + break; + case ADMOB_TYPE_FULLSCREEN: + LogD("Now not support full screen view in Admob"); + break; + default: + break; + } + } catch (Exception e) { + LogE("Error when hide Ads ( " + info.toString() + " )", e); + } } private void showBannerAd(int sizeEnum, int pos) { diff --git a/plugin/plugins/admob/proj.ios/AdsAdmob.h b/plugin/plugins/admob/proj.ios/AdsAdmob.h index ffebe758d4..378ab131c5 100644 --- a/plugin/plugins/admob/proj.ios/AdsAdmob.h +++ b/plugin/plugins/admob/proj.ios/AdsAdmob.h @@ -28,13 +28,18 @@ #import "GADBannerViewDelegate.h" typedef enum { - kSizeBanner = 0, + kSizeBanner = 1, kSizeIABMRect, kSizeIABBanner, kSizeIABLeaderboard, kSizeSkyscraper, } AdmobSizeEnum; +typedef enum { + kTypeBanner = 1, + kTypeFullScreen, +} AdmobType; + @interface AdsAdmob : NSObject { } @@ -48,8 +53,8 @@ typedef enum { interfaces from InterfaceAds */ - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; -- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; -- (void) hideAds: (int) type; +- (void) showAds: (NSMutableDictionary*) info position:(int) pos; +- (void) hideAds: (NSMutableDictionary*) info; - (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) isDebugMode; diff --git a/plugin/plugins/admob/proj.ios/AdsAdmob.m b/plugin/plugins/admob/proj.ios/AdsAdmob.m index f1128e37fc..35896f1208 100644 --- a/plugin/plugins/admob/proj.ios/AdsAdmob.m +++ b/plugin/plugins/admob/proj.ios/AdsAdmob.m @@ -54,7 +54,7 @@ self.strPublishID = (NSString*) [devInfo objectForKey:@"AdmobID"]; } -- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos +- (void) showAds: (NSMutableDictionary*) info position:(int) pos { if (self.strPublishID == nil || [self.strPublishID length] == 0) { @@ -62,31 +62,45 @@ return; } + NSString* strType = [info objectForKey:@"AdmobType"]; + int type = [strType intValue]; switch (type) { case kTypeBanner: - [self showBanner:sizeEnum atPos:pos]; - break; + { + NSString* strSize = [info objectForKey:@"AdmobSizeEnum"]; + int sizeEnum = [strSize intValue]; + [self showBanner:sizeEnum atPos:pos]; + break; + } case kTypeFullScreen: OUTPUT_LOG(@"Now not support full screen view in Admob"); break; - case kTypeMoreApp: - OUTPUT_LOG(@"Now not support more app ads in Admob"); - break; default: + OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)"); break; } } -- (void) hideAds: (int) type +- (void) hideAds: (NSMutableDictionary*) info { - if (type == kTypeBanner) { - if (nil != self.bannerView) { - [self.bannerView removeFromSuperview]; - [self.bannerView release]; - self.bannerView = nil; + NSString* strType = [info objectForKey:@"AdmobType"]; + int type = [strType intValue]; + switch (type) { + case kTypeBanner: + { + if (nil != self.bannerView) { + [self.bannerView removeFromSuperview]; + [self.bannerView release]; + self.bannerView = nil; + } + break; } - } else { + case kTypeFullScreen: OUTPUT_LOG(@"Now not support full screen view in Admob"); + break; + default: + OUTPUT_LOG(@"The value of 'AdmobType' is wrong (should be 1 or 2)"); + break; } } @@ -117,7 +131,7 @@ - (void) showBanner: (int) sizeEnum atPos:(int) pos { - GADAdSize size; + GADAdSize size = kGADAdSizeBanner; switch (sizeEnum) { case kSizeBanner: size = kGADAdSizeBanner; diff --git a/plugin/plugins/qh360/proj.android/ForManifest.xml b/plugin/plugins/qh360/proj.android/ForManifest.xml index d7f0c9bc34..a9d5ffdec2 100644 --- a/plugin/plugins/qh360/proj.android/ForManifest.xml +++ b/plugin/plugins/qh360/proj.android/ForManifest.xml @@ -16,6 +16,7 @@ +  diff --git a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/IAPOnlineQH360.java b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/IAPOnlineQH360.java index 949069f1f0..df989be1ef 100644 --- a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/IAPOnlineQH360.java +++ b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/IAPOnlineQH360.java @@ -181,15 +181,15 @@ public class IAPOnlineQH360 implements InterfaceIAP { // optional params : ext, app order id, pay type String ext1 = pInfo.get("QHExtra1"); - if (null == ext1 && ! TextUtils.isEmpty(ext1)) { + if (null != ext1 && ! TextUtils.isEmpty(ext1)) { bundle.putString(ProtocolKeys.APP_EXT_1, ext1); } String ext2 = pInfo.get("QHExtra2"); - if (null == ext2 && ! TextUtils.isEmpty(ext2)) { + if (null != ext2 && ! TextUtils.isEmpty(ext2)) { bundle.putString(ProtocolKeys.APP_EXT_2, ext2); } String appOrderId = pInfo.get("QHAppOrderID"); - if (null == appOrderId && ! TextUtils.isEmpty(appOrderId)) { + if (null != appOrderId && ! TextUtils.isEmpty(appOrderId)) { bundle.putString(ProtocolKeys.APP_ORDER_ID, appOrderId); } diff --git a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java index 6f2365b975..2181036f02 100644 --- a/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java +++ b/plugin/plugins/qh360/proj.android/src/org/cocos2dx/plugin/QH360Wrapper.java @@ -63,13 +63,13 @@ public class QH360Wrapper { Configuration config = ctx.getResources().getConfiguration(); int orientation = config.orientation; - if (orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || - orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + if (orientation != Configuration.ORIENTATION_LANDSCAPE && + orientation != Configuration.ORIENTATION_PORTRAIT) { - orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + orientation = Configuration.ORIENTATION_PORTRAIT; } - return (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + return (orientation == Configuration.ORIENTATION_LANDSCAPE); } private static boolean mLogined = false; diff --git a/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java b/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java index a519688b3f..f6b011d501 100644 --- a/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java +++ b/plugin/plugins/uc/proj.android/src/org/cocos2dx/plugin/UCWrapper.java @@ -109,13 +109,13 @@ public class UCWrapper { Configuration config = ctx.getResources().getConfiguration(); int orientation = config.orientation; - if (orientation != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || - orientation != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + if (orientation != Configuration.ORIENTATION_LANDSCAPE && + orientation != Configuration.ORIENTATION_PORTRAIT) { - orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + orientation = Configuration.ORIENTATION_PORTRAIT; } - return (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + return (orientation == Configuration.ORIENTATION_LANDSCAPE); } public static String getSDKVersion() { diff --git a/plugin/protocols/include/ProtocolAds.h b/plugin/protocols/include/ProtocolAds.h index 4e38bd1b96..52bb8cc905 100644 --- a/plugin/protocols/include/ProtocolAds.h +++ b/plugin/protocols/include/ProtocolAds.h @@ -31,6 +31,7 @@ THE SOFTWARE. namespace cocos2d { namespace plugin { typedef std::map TAdsDeveloperInfo; +typedef std::map TAdsInfo; typedef enum { @@ -69,12 +70,6 @@ public: ProtocolAds(); virtual ~ProtocolAds(); - typedef enum { - kBannerAd = 0, - kFullScreenAd, - kMoreApp, - } AdsType; - typedef enum { kPosCenter = 0, kPosTop, @@ -96,21 +91,17 @@ public: /** @brief show adview - @param type The adview type need to show. - @param sizeEnum The size of the banner view. - (only used when type is kBannerAd) - In different plugin, it's have different mean. + @param info The information of adview will be shown Pay attention to the subclass definition @param pos The position where the adview be shown. - (only used when type is kBannerAd) */ - void showAds(AdsType type, int sizeEnum = 0, AdsPos pos = kPosCenter); + void showAds(TAdsInfo info, AdsPos pos = kPosCenter); /** @brief Hide the adview - @param type The adview type need to hide. + @param info The information of adview will be hided */ - void hideAds(AdsType type); + void hideAds(TAdsInfo info); /** @brief Query the points of player @@ -127,11 +118,15 @@ public: /** @brief set the Ads listener */ - void setAdsListener(AdsListener* pListener); + inline void setAdsListener(AdsListener* listener) + { + _listener = listener; + } - // For the callbak methods - void onAdsResult(AdsResultCode code, const char* msg); - void onPlayerGetPoints(int points); + inline AdsListener* getAdsListener() + { + return _listener; + } protected: AdsListener* _listener; diff --git a/plugin/protocols/jsb_protocols.ini b/plugin/protocols/jsb_protocols.ini index 1b5b202a91..b2c1de5b9e 100644 --- a/plugin/protocols/jsb_protocols.ini +++ b/plugin/protocols/jsb_protocols.ini @@ -23,11 +23,11 @@ cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s # what headers to parse -headers = %(pluginxdir)s/protocols/include/PluginManager.h %(pluginxdir)s/protocols/include/ProtocolAnalytics.h %(pluginxdir)s/protocols/include/ProtocolIAP.h %(pluginxdir)s/protocols/include/ProtocolAds.h %(pluginxdir)s/protocols/include/ProtocolShare.h +headers = %(pluginxdir)s/protocols/include/PluginManager.h %(pluginxdir)s/protocols/include/ProtocolAnalytics.h %(pluginxdir)s/protocols/include/ProtocolIAP.h %(pluginxdir)s/protocols/include/ProtocolAds.h %(pluginxdir)s/protocols/include/ProtocolShare.h %(pluginxdir)s/protocols/include/ProtocolSocial.h %(pluginxdir)s/protocols/include/ProtocolUser.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^CCMenu*$". -classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds ProtocolShare +classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds ProtocolShare ProtocolSocial ProtocolUser # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -39,6 +39,8 @@ classes = PluginProtocol PluginManager ProtocolIAP ProtocolAnalytics ProtocolAds skip = ProtocolIAP::[setResultListener], ProtocolAds::[setAdsListener], ProtocolShare::[setResultListener], + ProtocolSocial::[setListener getListener], + ProtocolUser::[setActionListener getActionListener], PluginProtocol::[callFuncWithParam callStringFuncWithParam callIntFuncWithParam callBoolFuncWithParam callFloatFuncWithParam] rename_functions = @@ -56,7 +58,7 @@ base_classes_to_skip = # classes that create no constructor # CCSet is special and we will use a hand-written constructor -abstract_classes = PluginProtocol ProtocolIAP ProtocolAnalytics PluginManager ProtocolAds ProtocolShare +abstract_classes = PluginProtocol ProtocolIAP ProtocolAnalytics PluginManager ProtocolAds ProtocolShare ProtocolUser ProtocolSocial # Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'. script_control_cpp = yes diff --git a/plugin/protocols/platform/android/ProtocolAds.cpp b/plugin/protocols/platform/android/ProtocolAds.cpp index e5dcfb7d02..1d70337ffe 100644 --- a/plugin/protocols/platform/android/ProtocolAds.cpp +++ b/plugin/protocols/platform/android/ProtocolAds.cpp @@ -41,7 +41,11 @@ extern "C" { ProtocolAds* pAds = dynamic_cast(pPlugin); if (pAds != NULL) { - pAds->onAdsResult((AdsResultCode) ret, strMsg.c_str()); + AdsListener* listener = pAds->getAdsListener(); + if (listener) + { + listener->onAdsResult((AdsResultCode) ret, strMsg.c_str()); + } } } } @@ -56,7 +60,11 @@ extern "C" { ProtocolAds* pAds = dynamic_cast(pPlugin); if (pAds != NULL) { - pAds->onPlayerGetPoints(points); + AdsListener* listener = pAds->getAdsListener(); + if (listener) + { + listener->onPlayerGetPoints(pAds, points); + } } } } @@ -98,7 +106,7 @@ void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo) } } -void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) +void ProtocolAds::showAds(TAdsInfo info, AdsPos pos) { PluginJavaData* pData = PluginUtils::getPluginJavaData(this); PluginJniMethodInfo t; @@ -107,16 +115,31 @@ void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) if (PluginJniHelper::getMethodInfo(t , pData->jclassName.c_str() , "showAds" - , "(III)V")) + , "(Ljava/util/Hashtable;I)V")) { - t.env->CallVoidMethod(pData->jobj, t.methodID, type, sizeEnum, pos); + jobject obj_Map = PluginUtils::createJavaMapObject(&info); + t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map, pos); + t.env->DeleteLocalRef(obj_Map); t.env->DeleteLocalRef(t.classID); } } -void ProtocolAds::hideAds(AdsType type) +void ProtocolAds::hideAds(TAdsInfo info) { - PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type); + PluginJavaData* pData = PluginUtils::getPluginJavaData(this); + PluginJniMethodInfo t; + + PluginUtils::outputLog("ProtocolAds", "Class name : %s", pData->jclassName.c_str()); + if (PluginJniHelper::getMethodInfo(t + , pData->jclassName.c_str() + , "hideAds" + , "(Ljava/util/Hashtable;)V")) + { + jobject obj_Map = PluginUtils::createJavaMapObject(&info); + t.env->CallVoidMethod(pData->jobj, t.methodID, obj_Map); + t.env->DeleteLocalRef(obj_Map); + t.env->DeleteLocalRef(t.classID); + } } void ProtocolAds::queryPoints() @@ -129,27 +152,4 @@ void ProtocolAds::spendPoints(int points) PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points); } -void ProtocolAds::setAdsListener(AdsListener* pListener) -{ - _listener = pListener; -} - -void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg) -{ - PluginUtils::outputLog("ProtocolAds", "ProtocolAds::adsResult invoked!"); - if (_listener != NULL) - { - _listener->onAdsResult(code, msg); - } -} - -void ProtocolAds::onPlayerGetPoints(int points) -{ - PluginUtils::outputLog("ProtocolAds", "ProtocolAds::onPlayerGetPoints invoked!"); - if (_listener != NULL) - { - _listener->onPlayerGetPoints(this, points); - } -} - }} // namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/platform/ios/AdsWrapper.h b/plugin/protocols/platform/ios/AdsWrapper.h index ff7d176835..5e24d92889 100644 --- a/plugin/protocols/platform/ios/AdsWrapper.h +++ b/plugin/protocols/platform/ios/AdsWrapper.h @@ -38,12 +38,6 @@ typedef enum { kUnknownError, } AdsResult; -typedef enum { - kTypeBanner = 0, - kTypeFullScreen, - kTypeMoreApp, -} AdsTypeEnum; - typedef enum { kPosCenter = 0, kPosTop, @@ -60,6 +54,7 @@ typedef enum { } + (void) onAdsResult:(id) obj withRet:(AdsResult) ret withMsg:(NSString*) msg; ++ (void) onPlayerGetPoints:(id) obj withPoints: (int) points; + (void) addAdView:(UIView*) view atPos:(AdsPosEnum) pos; + (UIViewController *) getCurrentRootViewController; diff --git a/plugin/protocols/platform/ios/AdsWrapper.mm b/plugin/protocols/platform/ios/AdsWrapper.mm index e312ae200b..328a279260 100644 --- a/plugin/protocols/platform/ios/AdsWrapper.mm +++ b/plugin/protocols/platform/ios/AdsWrapper.mm @@ -32,12 +32,31 @@ using namespace cocos2d::plugin; + (void) onAdsResult:(id) obj withRet:(AdsResult) ret withMsg:(NSString*) msg { - PluginProtocol* pPlugin = PluginUtilsIOS::getPluginPtr(obj); - ProtocolAds* pAds = dynamic_cast(pPlugin); - if (pAds) { + PluginProtocol* plugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolAds* adsPlugin = dynamic_cast(plugin); + if (adsPlugin) { const char* chMsg = [msg UTF8String]; AdsResultCode cRet = (AdsResultCode) ret; - pAds->onAdsResult(cRet, chMsg); + AdsListener* listener = adsPlugin->getAdsListener(); + if (listener) + { + listener->onAdsResult(cRet, chMsg); + } + } else { + PluginUtilsIOS::outputLog("Can't find the C++ object of the ads plugin"); + } +} + ++ (void) onPlayerGetPoints:(id) obj withPoints: (int) points +{ + PluginProtocol* plugin = PluginUtilsIOS::getPluginPtr(obj); + ProtocolAds* adsPlugin = dynamic_cast(plugin); + if (adsPlugin) { + AdsListener* listener = adsPlugin->getAdsListener(); + if (listener) + { + listener->onPlayerGetPoints(adsPlugin, points); + } } else { PluginUtilsIOS::outputLog("Can't find the C++ object of the ads plugin"); } diff --git a/plugin/protocols/platform/ios/InterfaceAds.h b/plugin/protocols/platform/ios/InterfaceAds.h index f15b7ab03d..c19cd2747a 100644 --- a/plugin/protocols/platform/ios/InterfaceAds.h +++ b/plugin/protocols/platform/ios/InterfaceAds.h @@ -27,8 +27,8 @@ THE SOFTWARE. @protocol InterfaceAds - (void) configDeveloperInfo: (NSMutableDictionary*) devInfo; -- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos; -- (void) hideAds: (int) type; +- (void) showAds: (NSMutableDictionary*) info position:(int) pos; +- (void) hideAds: (NSMutableDictionary*) info; - (void) queryPoints; - (void) spendPoints: (int) points; - (void) setDebugMode: (BOOL) debug; diff --git a/plugin/protocols/platform/ios/ProtocolAds.mm b/plugin/protocols/platform/ios/ProtocolAds.mm index 49c2a57f34..d73c8a098a 100644 --- a/plugin/protocols/platform/ios/ProtocolAds.mm +++ b/plugin/protocols/platform/ios/ProtocolAds.mm @@ -52,13 +52,13 @@ void ProtocolAds::configDeveloperInfo(TAdsDeveloperInfo devInfo) id ocObj = pData->obj; if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { NSObject* curObj = ocObj; - NSMutableDictionary* pDict = PluginUtilsIOS::createDictFromMap(&devInfo); - [curObj configDeveloperInfo:pDict]; + NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(&devInfo); + [curObj configDeveloperInfo:dict]; } } } -void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) +void ProtocolAds::showAds(TAdsInfo info, AdsPos pos) { PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); assert(pData != NULL); @@ -66,11 +66,12 @@ void ProtocolAds::showAds(AdsType type, int sizeEnum, AdsPos pos) id ocObj = pData->obj; if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { NSObject* curObj = ocObj; - [curObj showAds:type size:sizeEnum position:pos]; + NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(&info); + [curObj showAds:dict position:pos]; } } -void ProtocolAds::hideAds(AdsType type) +void ProtocolAds::hideAds(TAdsInfo info) { PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); assert(pData != NULL); @@ -78,10 +79,16 @@ void ProtocolAds::hideAds(AdsType type) id ocObj = pData->obj; if ([ocObj conformsToProtocol:@protocol(InterfaceAds)]) { NSObject* curObj = ocObj; - [curObj hideAds:type]; + NSMutableDictionary* dict = PluginUtilsIOS::createDictFromMap(&info); + [curObj hideAds:dict]; } } +void ProtocolAds::queryPoints() +{ + PluginUtilsIOS::callOCFunctionWithName(this, "queryPoints"); +} + void ProtocolAds::spendPoints(int points) { PluginOCData* pData = PluginUtilsIOS::getPluginOCData(this); @@ -94,26 +101,4 @@ void ProtocolAds::spendPoints(int points) } } -// For the callbak methods -void ProtocolAds::setAdsListener(AdsListener* pListener) -{ - _listener = pListener; -} - -void ProtocolAds::onAdsResult(AdsResultCode code, const char* msg) -{ - if (_listener != NULL) - { - _listener->onAdsResult(code, msg); - } -} - -void ProtocolAds::onPlayerGetPoints(int points) -{ - if (_listener != NULL) - { - _listener->onPlayerGetPoints(this, points); - } -} - }} //namespace cocos2d { namespace plugin { diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java index 6803baa0d2..5afc4ecc56 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/AdsWrapper.java @@ -37,10 +37,6 @@ public class AdsWrapper { public static final int RESULT_CODE_NetworkError = 5; // Network error public static final int RESULT_CODE_UnknownError = 6; // Unknown error - public static final int ADS_TYPE_BANNER = 0; - public static final int ADS_TYPE_FULL_SCREEN = 1; - public static final int ADS_TYPE_MORE_APP = 2; - public static final int POS_CENTER = 0; public static final int POS_TOP = 1; public static final int POS_TOP_LEFT = 2; diff --git a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java index cd740b9d73..92eb799150 100644 --- a/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java +++ b/plugin/protocols/proj.android/src/org/cocos2dx/plugin/InterfaceAds.java @@ -30,8 +30,8 @@ public interface InterfaceAds { public final int PluginType = 1; public void configDeveloperInfo(Hashtable devInfo); - public void showAds(int type, int sizeEnum, int pos); - public void hideAds(int type); + public void showAds(Hashtable adsInfo, int pos); + public void hideAds(Hashtable adsInfo); public void queryPoints(); public void spendPoints(int points); public void setDebugMode(boolean debug); diff --git a/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp index 26a98e22fe..88bf889744 100644 --- a/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloAnalytics-JS/proj.android/jni/hellocpp/main.cpp @@ -34,9 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp index 26a98e22fe..88bf889744 100644 --- a/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloIAP-JS/proj.android/jni/hellocpp/main.cpp @@ -34,9 +34,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp b/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp index 467d2a3eed..e77c27e7ef 100644 --- a/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp +++ b/plugin/samples/HelloPlugins/Classes/AppDelegate.cpp @@ -18,7 +18,7 @@ bool AppDelegate::applicationDidFinishLaunching() { pDirector->setOpenGLView(pEGLView); - pEGLView->setDesignResolutionSize(960.0f, 640.0f, kResolutionNoBorder); + pEGLView->setDesignResolutionSize(960.0f, 640.0f, ResolutionPolicy::NO_BORDER); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp index eac0c327f0..2df4bc307a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.cpp @@ -32,12 +32,6 @@ const std::string s_aTestCases[] = { "Admob", }; -const std::string s_aTestTypes[] = { - "Banner", - "Full Screen", - "More App", -}; - const std::string s_aTestPoses[] = { "Pos: Center", "Pos: Top", @@ -89,8 +83,8 @@ bool TestAds::init() Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); - Point posMid = ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); - Point posBR = ccp(origin.x + visibleSize.width, origin.y); + Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); + Point posBR = Point(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -99,7 +93,7 @@ bool TestAds::init() // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAds::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); @@ -107,15 +101,15 @@ bool TestAds::init() LabelTTF* label1 = LabelTTF::create("ShowAds", "Arial", 24); MenuItemLabel* pItemShow = MenuItemLabel::create(label1, CC_CALLBACK_1(TestAds::testShow, this)); - pItemShow->setAnchorPoint(ccp(0.5f, 0)); + pItemShow->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(pItemShow, 0); - pItemShow->setPosition(ccpAdd(posMid, ccp(-100, -120))); + pItemShow->setPosition(posMid + Point(-100, -120)); LabelTTF* label2 = LabelTTF::create("HideAds", "Arial", 24); MenuItemLabel* pItemHide = MenuItemLabel::create(label2, CC_CALLBACK_1(TestAds::testHide, this)); - pItemHide->setAnchorPoint(ccp(0.5f, 0)); + pItemHide->setAnchorPoint(Point(0.5f, 0)); pMenu->addChild(pItemHide, 0); - pItemHide->setPosition(ccpAdd(posMid, ccp(100, -120))); + pItemHide->setPosition(posMid + Point(100, -120)); // create optional menu // cases item @@ -127,21 +121,9 @@ bool TestAds::init() { _caseItem->getSubItems()->addObject( MenuItemFont::create( s_aTestCases[i].c_str() ) ); } - _caseItem->setPosition(ccpAdd(posMid, ccp(-200, 120))); + _caseItem->setPosition(posMid + Point(-200, 120)); pMenu->addChild(_caseItem); - // type item - _typeItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::typeChanged, this), - MenuItemFont::create( s_aTestTypes[0].c_str() ), - NULL ); - int typeLen = sizeof(s_aTestTypes) / sizeof(std::string); - for (int i = 1; i < typeLen; ++i) - { - _typeItem->getSubItems()->addObject( MenuItemFont::create( s_aTestTypes[i].c_str() ) ); - } - _typeItem->setPosition(ccpAdd(posMid, ccp(0, 120))); - pMenu->addChild(_typeItem); - // poses item _posItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(TestAds::posChanged, this), MenuItemFont::create( s_aTestPoses[0].c_str() ), @@ -151,13 +133,16 @@ bool TestAds::init() { _posItem->getSubItems()->addObject( MenuItemFont::create( s_aTestPoses[i].c_str() ) ); } - _posItem->setPosition(ccpAdd(posMid, ccp(200, 120))); + _posItem->setPosition(posMid + Point(200, 120)); pMenu->addChild(_posItem); // init options _ads = _admob; _pos = ProtocolAds::kPosCenter; - _type = ProtocolAds::kBannerAd; + + // init the AdsInfo + adInfo["AdmobType"] = "1"; + adInfo["AdmobSizeEnum"] = "1"; this->addChild(pMenu, 1); @@ -166,30 +151,22 @@ bool TestAds::init() void TestAds::testShow(Object* pSender) { - int nSize = 0; - if (_ads == _admob) - { - nSize = 0; - } - if (_ads) { - _ads->showAds(_type, nSize, _pos); + _ads->showAds(adInfo, _pos); } } void TestAds::testHide(Object* pSender) { - _ads->hideAds(_type); + _ads->hideAds(adInfo); } void TestAds::menuBackCallback(Object* pSender) { if (_admob != NULL) { - _admob->hideAds(ProtocolAds::kBannerAd); - _admob->hideAds(ProtocolAds::kFullScreenAd); - _admob->hideAds(ProtocolAds::kMoreApp); + _admob->hideAds(adInfo); PluginManager::getInstance()->unloadPlugin("AdsAdmob"); _admob = NULL; } @@ -219,13 +196,6 @@ void TestAds::caseChanged(Object* pSender) log("case selected change to : %s", strLog.c_str()); } -void TestAds::typeChanged(Object* pSender) -{ - int selectIndex = _typeItem->getSelectedIndex(); - _type = (ProtocolAds::AdsType) selectIndex; - log("type selected change to : %d", _type); -} - void TestAds::posChanged(Object* pSender) { int selectIndex = _posItem->getSelectedIndex(); diff --git a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h index ab3e8af0b5..ffabe943f6 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h +++ b/plugin/samples/HelloPlugins/Classes/TestAds/TestAdsScene.h @@ -61,12 +61,12 @@ private: MyAdsListener* _listener; cocos2d::MenuItemToggle* _caseItem; - cocos2d::MenuItemToggle* _typeItem; cocos2d::MenuItemToggle* _posItem; cocos2d::plugin::ProtocolAds* _ads; cocos2d::plugin::ProtocolAds::AdsPos _pos; - cocos2d::plugin::ProtocolAds::AdsType _type; + + cocos2d::plugin::TAdsInfo adInfo; }; #endif // __TEST_ADS_SCENE_H__ diff --git a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp index a27c210b85..a49d39051b 100644 --- a/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestAnalytics/TestAnalyticsScene.cpp @@ -89,7 +89,7 @@ bool TestAnalytics::init() Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); - Point posBR = ccp(origin.x + visibleSize.width, origin.y); + Point posBR = Point(origin.x + visibleSize.width, origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -98,7 +98,7 @@ bool TestAnalytics::init() // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); @@ -111,15 +111,15 @@ bool TestAnalytics::init() MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); yPos = visibleSize.height - 35*i - 100; - pMenuItem->setPosition( ccp(visibleSize.width / 2, yPos)); + pMenuItem->setPosition( Point(visibleSize.width / 2, yPos)); } std::string strName = _pluginAnalytics->getPluginName(); std::string strVer = _pluginAnalytics->getSDKVersion(); char ret[256] = { 0 }; sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str()); - LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, CCSizeMake(visibleSize.width, 0), kTextAlignmentCenter); - pLabel->setPosition(ccp(visibleSize.width / 2, yPos - 80)); + LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), kTextAlignmentCenter); + pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80)); addChild(pLabel); return true; @@ -225,7 +225,7 @@ void TestAnalytics::eventMenuCallback(Object* pSender) void TestAnalytics::loadPlugins() { - ccLanguageType langType = Application::getInstance()->getCurrentLanguage(); + LanguageType langType = Application::getInstance()->getCurrentLanguage(); std::string umengKey = ""; std::string flurryKey = ""; @@ -240,7 +240,7 @@ void TestAnalytics::loadPlugins() flurryKey = FLURRY_KEY_ANDROID; #endif - if (kLanguageChinese == langType) + if (LanguageType::CHINESE == langType) { pluginName = "AnalyticsUmeng"; strAppKey = umengKey; diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp index 0ad6da036c..02dcdb51e7 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.cpp @@ -48,7 +48,7 @@ MyPurchase::~MyPurchase() } } -MyPurchase* MyPurchase::sharedPurchase() +MyPurchase* MyPurchase::getInstance() { if (s_pPurchase == NULL) { s_pPurchase = new MyPurchase(); diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h index a5d2048864..8a52fbe19d 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/MyPurchase.h @@ -35,7 +35,7 @@ public: class MyPurchase { public: - static MyPurchase* sharedPurchase(); + static MyPurchase* getInstance(); static void purgePurchase(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp index 4d195d2952..217efd6b25 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAP/TestIAPScene.cpp @@ -70,28 +70,28 @@ bool TestIAP::init() return false; } - MyPurchase::sharedPurchase()->loadIAPPlugin(); + MyPurchase::getInstance()->loadIAPPlugin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. EGLView* pEGLView = EGLView::getInstance(); - Point posBR = ccp(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); - Point posTL = ccp(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); + Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y); + Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height); // add a "close" icon to exit the progress. it's an autorelease object MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this)); Size backSize = pBackItem->getContentSize(); - pBackItem->setPosition(ccpAdd(posBR, ccp(- backSize.width / 2, backSize.height / 2))); + pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2)); // create menu, it's an autorelease object Menu* pMenu = Menu::create(pBackItem, NULL); pMenu->setPosition( Point::ZERO ); this->addChild(pMenu, 1); - Point posStep = ccp(220, -150); - Point beginPos = ccpAdd(posTL, ccpMult(posStep, 0.5f)); + Point posStep = Point(220, -150); + Point beginPos = posTL + (posStep * 0.5f); int line = 0; int row = 0; for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) { @@ -99,13 +99,13 @@ bool TestIAP::init() CC_CALLBACK_1(TestIAP::eventMenuCallback, this)); pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag); - Point pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); + Point pos = beginPos + Point(posStep.x * row, posStep.y * line); Size itemSize = pMenuItem->getContentSize(); if ((pos.x + itemSize.width / 2) > posBR.x) { line += 1; row = 0; - pos = ccpAdd(beginPos, ccp(posStep.x * row, posStep.y * line)); + pos = beginPos + Point(posStep.x * row, posStep.y * line); } row += 1; pMenuItem->setPosition(pos); @@ -123,7 +123,7 @@ void TestIAP::eventMenuCallback(Object* pSender) pInfo["productPrice"] = "0.01"; pInfo["productDesc"] = "100个金灿灿的游戏币哦"; pInfo["Nd91ProductId"] = "685994"; - MyPurchase::sharedPurchase()->payByMode(pInfo, mode); + MyPurchase::getInstance()->payByMode(pInfo, mode); } void TestIAP::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp index 50551fda78..83da784f39 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.cpp @@ -49,7 +49,7 @@ MyIAPOLManager::~MyIAPOLManager() } } -MyIAPOLManager* MyIAPOLManager::sharedManager() +MyIAPOLManager* MyIAPOLManager::getInstance() { if (s_pIAPOnline == NULL) { s_pIAPOnline = new MyIAPOLManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h index b508cef1cf..f64749b01f 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/MyIAPOLManager.h @@ -36,7 +36,7 @@ public: class MyIAPOLManager { public: - static MyIAPOLManager* sharedManager(); + static MyIAPOLManager* getInstance(); static void purge(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp index e8d59f9953..6a28504fa4 100644 --- a/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestIAPOnline/TestIAPOnlineScene.cpp @@ -74,7 +74,7 @@ bool TestIAPOnline::init() return false; } - MyIAPOLManager::sharedManager()->loadPlugins(); + MyIAPOLManager::getInstance()->loadPlugins(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -130,10 +130,10 @@ void TestIAPOnline::eventMenuCallback(Object* pSender) pInfo["Nd91ProductId"] = "685994"; if (mode == MyIAPOLManager::eQH360) { - CCLog("To test the IAP online in plugin qh360, you should do this:"); - CCLog("1. Login by UserQH360"); - CCLog("2. Get QH360 user info by your game server (userID, AccessToken)"); - CCLog("3. Fill the product info"); + log("To test the IAP online in plugin qh360, you should do this:"); + log("1. Login by UserQH360"); + log("2. Get QH360 user info by your game server (userID, AccessToken)"); + log("3. Fill the product info"); /** * @warning ProductInfo you need filled @@ -153,7 +153,7 @@ void TestIAPOnline::eventMenuCallback(Object* pSender) // pInfo["QHAppOrderID"] = "Order ID in game"; // The order ID in game (Game defined this) } - MyIAPOLManager::sharedManager()->payByMode(pInfo, mode); + MyIAPOLManager::getInstance()->payByMode(pInfo, mode); } void TestIAPOnline::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp index 97f6d34174..11cd6a70aa 100644 --- a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.cpp @@ -48,7 +48,7 @@ MyShareManager::~MyShareManager() } } -MyShareManager* MyShareManager::sharedManager() +MyShareManager* MyShareManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MyShareManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h index 4521a57b6c..cd8202f3a3 100755 --- a/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestShare/MyShareManager.h @@ -35,7 +35,7 @@ public: class MyShareManager { public: - static MyShareManager* sharedManager(); + static MyShareManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp index 1be29f9439..cf2a308f2c 100644 --- a/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestShare/TestShareScene.cpp @@ -70,7 +70,7 @@ bool TestShare::init() return false; } - MyShareManager::sharedManager()->loadSharePlugin(); + MyShareManager::getInstance()->loadSharePlugin(); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program @@ -120,7 +120,7 @@ void TestShare::eventMenuCallback(Object* pSender) pInfo["SharedText"] = "Share message : HelloShare!"; // pInfo["SharedImagePath"] = "Full/path/to/image"; MyShareManager::MyShareMode mode = (MyShareManager::MyShareMode) (pMenuItem->getTag() - TAG_SHARE_BY_TWWITER + 1); - MyShareManager::sharedManager()->shareByMode(pInfo, mode); + MyShareManager::getInstance()->shareByMode(pInfo, mode); } void TestShare::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp index 97ed27f872..21d790296a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.cpp @@ -41,7 +41,7 @@ MySocialManager::~MySocialManager() unloadPlugins(); } -MySocialManager* MySocialManager::sharedManager() +MySocialManager* MySocialManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MySocialManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h index 69cfee5bba..4df5026163 100755 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/MySocialManager.h @@ -29,7 +29,7 @@ THE SOFTWARE. class MySocialManager : public cocos2d::plugin::SocialListener { public: - static MySocialManager* sharedManager(); + static MySocialManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp b/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp index 2415ca6dd9..a8f1c7e9e3 100644 --- a/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestSocial/TestSocialScene.cpp @@ -59,7 +59,7 @@ bool TestSocial::init() return false; } - MySocialManager::sharedManager()->loadPlugins(); + MySocialManager::getInstance()->loadPlugins(); Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); @@ -119,7 +119,7 @@ bool TestSocial::init() void TestSocial::testSubmit(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->submitScore((MySocialManager::MySocialMode)(nIdx + 1), "0", 30000); + MySocialManager::getInstance()->submitScore((MySocialManager::MySocialMode)(nIdx + 1), "0", 30000); } void TestSocial::testUnlock(Object* pSender) @@ -129,19 +129,19 @@ void TestSocial::testUnlock(Object* pSender) info["AchievementID"] = "MyAchiID"; info["NDDisplayText"] = "Fighter"; info["NDScore"] = "100"; - MySocialManager::sharedManager()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info); + MySocialManager::getInstance()->unlockAchievement((MySocialManager::MySocialMode)(nIdx + 1), info); } void TestSocial::testLeaderboard(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->showLeaderboard((MySocialManager::MySocialMode)(nIdx + 1), "0"); + MySocialManager::getInstance()->showLeaderboard((MySocialManager::MySocialMode)(nIdx + 1), "0"); } void TestSocial::testAchievement(Object* pSender) { int nIdx = _caseItem->getSelectedIndex(); - MySocialManager::sharedManager()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1)); + MySocialManager::getInstance()->showAchievement((MySocialManager::MySocialMode)(nIdx + 1)); } void TestSocial::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp index 8a8836b75f..456b525969 100644 --- a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.cpp @@ -49,7 +49,7 @@ MyUserManager::~MyUserManager() } } -MyUserManager* MyUserManager::sharedManager() +MyUserManager* MyUserManager::getInstance() { if (s_pManager == NULL) { s_pManager = new MyUserManager(); diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h index 721367661d..83ad696372 100755 --- a/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h +++ b/plugin/samples/HelloPlugins/Classes/TestUser/MyUserManager.h @@ -36,7 +36,7 @@ public: class MyUserManager { public: - static MyUserManager* sharedManager(); + static MyUserManager* getInstance(); static void purgeManager(); typedef enum { diff --git a/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp index 20aa643c1a..aebb5d2e0a 100644 --- a/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp +++ b/plugin/samples/HelloPlugins/Classes/TestUser/TestUserScene.cpp @@ -60,7 +60,7 @@ bool TestUser::init() return false; } - MyUserManager::sharedManager()->loadPlugin(); + MyUserManager::getInstance()->loadPlugin(); Size visibleSize = Director::getInstance()->getVisibleSize(); Point origin = Director::getInstance()->getVisibleOrigin(); Point posMid = Point(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2); @@ -117,12 +117,12 @@ void TestUser::caseChanged(Object* pSender) void TestUser::testLogin(Object* pSender) { - MyUserManager::sharedManager()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); + MyUserManager::getInstance()->loginByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } void TestUser::testLogout(Object* pSender) { - MyUserManager::sharedManager()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); + MyUserManager::getInstance()->logoutByMode((MyUserManager::MyUserMode) (_selectedCase + 1)); } void TestUser::menuBackCallback(Object* pSender) diff --git a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp index 5a68d26107..947a965512 100644 --- a/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp +++ b/plugin/samples/HelloPlugins/proj.android/jni/hellocpp/main.cpp @@ -33,9 +33,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp index 95c96b8473..5ed803826a 100644 --- a/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp +++ b/samples/Cpp/AssetsManagerTest/Classes/AppDelegate.cpp @@ -61,16 +61,16 @@ bool AppDelegate::applicationDidFinishLaunching() void AppDelegate::applicationDidEnterBackground() { Director::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); + SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); + SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); + SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); + SimpleAudioEngine::getInstance()->resumeAllEffects(); } UpdateLayer::UpdateLayer() @@ -149,16 +149,16 @@ bool UpdateLayer::init() pItemEnter = MenuItemFont::create("enter", CC_CALLBACK_1(UpdateLayer::enter, this)); pItemUpdate = MenuItemFont::create("update", CC_CALLBACK_1(UpdateLayer::update, this)); - pItemEnter->setPosition(ccp(size.width/2, size.height/2 + 50)); - pItemReset->setPosition(ccp(size.width/2, size.height/2)); - pItemUpdate->setPosition(ccp(size.width/2, size.height/2 - 50)); + pItemEnter->setPosition(Point(size.width/2, size.height/2 + 50)); + pItemReset->setPosition(Point(size.width/2, size.height/2)); + pItemUpdate->setPosition(Point(size.width/2, size.height/2 - 50)); Menu *menu = Menu::create(pItemUpdate, pItemEnter, pItemReset, NULL); - menu->setPosition(ccp(0,0)); + menu->setPosition(Point(0,0)); addChild(menu); pProgressLabel = LabelTTF::create("", "Arial", 20); - pProgressLabel->setPosition(ccp(100, 50)); + pProgressLabel->setPosition(Point(100, 50)); addChild(pProgressLabel); return true; diff --git a/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh b/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh index 15e1e45299..12e6564c5b 100755 --- a/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh +++ b/samples/Cpp/AssetsManagerTest/proj.android/build_native.sh @@ -51,7 +51,7 @@ fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # ... use paths relative to current directory -COCOS2DX_ROOT="../../../../" +COCOS2DX_ROOT="$DIR/../../../.." APP_ROOT="$DIR/.." APP_ANDROID_ROOT="$DIR" BINDINGS_JS_ROOT="$APP_ROOT/../../../scripting/javascript/bindings/js" diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp index ac6f58ba07..19c9a02d06 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/hellocpp/main.cpp @@ -30,9 +30,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp index b22c7e8a6e..0be3f40794 100644 --- a/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/HelloCpp/Classes/AppDelegate.cpp @@ -27,7 +27,7 @@ bool AppDelegate::applicationDidFinishLaunching() { Size size = director->getWinSize(); // Set the design resolution - glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder); + glView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); Size frameSize = glView->getFrameSize(); diff --git a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp index b00c3184c1..e07234d078 100644 --- a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.cpp @@ -77,7 +77,7 @@ bool HelloWorld::init() } -void HelloWorld::menuCloseCallback(Object* pSender) +void HelloWorld::menuCloseCallback(Object* sender) { Director::getInstance()->end(); diff --git a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.h b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.h index 45139f9d67..876073cdb5 100644 --- a/samples/Cpp/HelloCpp/Classes/HelloWorldScene.h +++ b/samples/Cpp/HelloCpp/Classes/HelloWorldScene.h @@ -13,7 +13,7 @@ public: static cocos2d::Scene* scene(); // a selector callback - void menuCloseCallback(Object* pSender); + void menuCloseCallback(Object* sender); // implement the "static node()" method manually CREATE_FUNC(HelloWorld); diff --git a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp index 7d495c10a1..8a40310b9c 100644 --- a/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/HelloCpp/proj.android/jni/hellocpp/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/HelloCpp/proj.emscripten/Makefile b/samples/Cpp/HelloCpp/proj.emscripten/Makefile index 9e47a17ce9..56bb3d7df1 100644 --- a/samples/Cpp/HelloCpp/proj.emscripten/Makefile +++ b/samples/Cpp/HelloCpp/proj.emscripten/Makefile @@ -26,9 +26,9 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST) ifeq ($(shell uname -s),Darwin) -ARIEL_TTF := /Library/Fonts/Arial.ttf +ARIAL_TTF := /Library/Fonts/Arial.ttf else -ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf +ARIAL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf endif $(TARGET).data: @@ -39,15 +39,16 @@ $(TARGET).data: (cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP)) (cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts) # NOTE: we copy the system arial.ttf so that there is always a fallback. - cp $(ARIEL_TTF) $(RESTMP)/fonts/arial.ttf + cp $(ARIAL_TTF) $(RESTMP)/fonts/arial.ttf (cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(RESOURCES)) --preload fonts --pre-run > $(EXECUTABLE).data.js) mv $(RESTMP)/$(EXECUTABLE).data $@ mv $(RESTMP)/$(EXECUTABLE).data.js $@.js rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) diff --git a/samples/Cpp/HelloCpp/proj.emscripten/index.html b/samples/Cpp/HelloCpp/proj.emscripten/index.html deleted file mode 100644 index b8befe726a..0000000000 --- a/samples/Cpp/HelloCpp/proj.emscripten/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - Emscripten-Generated Code - - - -
-
Downloading...
-
- -
-
- -
-
-
- Resize canvas - Lock/hide mouse pointer -     - -
- -
- -
- - - - - diff --git a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp index 961f517e43..c1f7b09f90 100644 --- a/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp +++ b/samples/Cpp/SimpleGame/Classes/AppDelegate.cpp @@ -36,7 +36,7 @@ bool AppDelegate::applicationDidFinishLaunching() { FileUtils::getInstance()->setSearchPaths(searchPaths); - EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); + EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER); // turn on display FPS director->setDisplayStats(true); diff --git a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp index 2f2ed57017..9b7cc00c3a 100644 --- a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp +++ b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.cpp @@ -117,7 +117,7 @@ bool HelloWorld::init() return bRet; } -void HelloWorld::menuCloseCallback(Object* pSender) +void HelloWorld::menuCloseCallback(Object* sender) { // "close" menu item clicked Director::getInstance()->end(); @@ -190,7 +190,7 @@ void HelloWorld::gameLogic(float dt) void HelloWorld::ccTouchesEnded(Set* touches, Event* event) { // Choose one of the touches to work with - Touch* touch = (Touch*)( touches->anyObject() ); + Touch* touch = static_cast( touches->anyObject() ); Point location = touch->getLocation(); log("++++++++after x:%f, y:%f", location.x, location.y); diff --git a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.h b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.h index be943b4724..bb5ac961dc 100644 --- a/samples/Cpp/SimpleGame/Classes/HelloWorldScene.h +++ b/samples/Cpp/SimpleGame/Classes/HelloWorldScene.h @@ -19,7 +19,7 @@ public: static cocos2d::Scene* scene(); // a selector callback - virtual void menuCloseCallback(cocos2d::Object* pSender); + virtual void menuCloseCallback(cocos2d::Object* sender); // implement the "static node()" method manually CREATE_FUNC(HelloWorld); diff --git a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp index e8639bcc2d..eaef41aa5a 100644 --- a/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp +++ b/samples/Cpp/SimpleGame/proj.android/jni/hellocpp/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/SimpleGame/proj.emscripten/Makefile b/samples/Cpp/SimpleGame/proj.emscripten/Makefile index 39559056f2..cc538b4d65 100644 --- a/samples/Cpp/SimpleGame/proj.emscripten/Makefile +++ b/samples/Cpp/SimpleGame/proj.emscripten/Makefile @@ -57,9 +57,10 @@ $(TARGET).data: mv $(RESTMP)/$(EXECUTABLE).data.js $@.js rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) diff --git a/samples/Cpp/SimpleGame/proj.emscripten/index.html b/samples/Cpp/SimpleGame/proj.emscripten/index.html deleted file mode 100644 index a78af31af6..0000000000 --- a/samples/Cpp/SimpleGame/proj.emscripten/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - SimpleGame - - - -
-
Downloading...
-
- -
-
- -
-
-
- Resize canvas - Lock/hide mouse pointer -     - -
- -
- -
- - - - - diff --git a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp index 9260a12bb9..66cb282165 100644 --- a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.cpp @@ -82,7 +82,7 @@ std::string ActionManagerTest::title() return "No title"; } -void ActionManagerTest::restartCallback(Object* pSender) +void ActionManagerTest::restartCallback(Object* sender) { Scene* s = new ActionManagerTestScene(); s->addChild(restartActionManagerAction()); @@ -91,7 +91,7 @@ void ActionManagerTest::restartCallback(Object* pSender) s->release(); } -void ActionManagerTest::nextCallback(Object* pSender) +void ActionManagerTest::nextCallback(Object* sender) { Scene* s = new ActionManagerTestScene(); s->addChild( nextActionManagerAction() ); @@ -99,7 +99,7 @@ void ActionManagerTest::nextCallback(Object* pSender) s->release(); } -void ActionManagerTest::backCallback(Object* pSender) +void ActionManagerTest::backCallback(Object* sender) { Scene* s = new ActionManagerTestScene(); s->addChild( backActionManagerAction() ); diff --git a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.h b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.h index 6e0a3c8522..946c2f4b38 100644 --- a/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionManagerTest/ActionManagerTest.h @@ -17,9 +17,9 @@ public: virtual std::string title(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class CrashTest : public ActionManagerTest diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp index da9e8fa250..b9c6e14145 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.cpp @@ -622,7 +622,7 @@ void EaseSpriteDemo::onEnter() _tamara->setPosition(Point(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5)); } -void EaseSpriteDemo::restartCallback(Object* pSender) +void EaseSpriteDemo::restartCallback(Object* sender) { Scene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild(restartEaseAction()); @@ -631,7 +631,7 @@ void EaseSpriteDemo::restartCallback(Object* pSender) s->release(); } -void EaseSpriteDemo::nextCallback(Object* pSender) +void EaseSpriteDemo::nextCallback(Object* sender) { Scene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( nextEaseAction() ); @@ -639,7 +639,7 @@ void EaseSpriteDemo::nextCallback(Object* pSender) s->release(); } -void EaseSpriteDemo::backCallback(Object* pSender) +void EaseSpriteDemo::backCallback(Object* sender) { Scene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( backEaseAction() ); diff --git a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h index 3ea8b23bec..e202402688 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsEaseTest/ActionsEaseTest.h @@ -23,9 +23,9 @@ public: virtual std::string title(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); void positionForTwo(); }; diff --git a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp index 8585e62243..5f904e8f7b 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.cpp @@ -96,7 +96,7 @@ void SpriteDemo::onEnter() addChild(background, -10); } -void SpriteDemo::restartCallback(Object* pSender) +void SpriteDemo::restartCallback(Object* sender) { Scene* s = new ProgressActionsTestScene(); s->addChild(restartAction()); @@ -105,7 +105,7 @@ void SpriteDemo::restartCallback(Object* pSender) s->release(); } -void SpriteDemo::nextCallback(Object* pSender) +void SpriteDemo::nextCallback(Object* sender) { Scene* s = new ProgressActionsTestScene(); s->addChild( nextAction() ); @@ -113,7 +113,7 @@ void SpriteDemo::nextCallback(Object* pSender) s->release(); } -void SpriteDemo::backCallback(Object* pSender) +void SpriteDemo::backCallback(Object* sender) { Scene* s = new ProgressActionsTestScene(); s->addChild( backAction() ); @@ -136,13 +136,13 @@ void SpriteProgressToRadial::onEnter() ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); - left->setType( kProgressTimerTypeRadial ); + left->setType( ProgressTimer::Type::RADIAL ); addChild(left); left->setPosition(Point(100, s.height/2)); left->runAction( RepeatForever::create(to1)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); - right->setType(kProgressTimerTypeRadial); + right->setType(ProgressTimer::Type::RADIAL); // Makes the ridial CCW right->setReverseProgress(true); addChild(right); @@ -171,7 +171,7 @@ void SpriteProgressToHorizontal::onEnter() ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); - left->setType(kProgressTimerTypeBar); + left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 0 for the x left->setMidpoint(Point(0,0)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change @@ -181,7 +181,7 @@ void SpriteProgressToHorizontal::onEnter() left->runAction( RepeatForever::create(to1)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); - right->setType(kProgressTimerTypeBar); + right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the left since the midpoint is 1 for the x right->setMidpoint(Point(1, 0)); // Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change @@ -211,7 +211,7 @@ void SpriteProgressToVertical::onEnter() ProgressTo *to2 = ProgressTo::create(2, 100); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); - left->setType(kProgressTimerTypeBar); + left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Point(0,0)); @@ -222,7 +222,7 @@ void SpriteProgressToVertical::onEnter() left->runAction( RepeatForever::create(to1)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); - right->setType(kProgressTimerTypeBar); + right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0, 1)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -254,7 +254,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter() * Our image on the left should be a radial progress indicator, clockwise */ ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathBlock)); - left->setType(kProgressTimerTypeRadial); + left->setType(ProgressTimer::Type::RADIAL); addChild(left); left->setMidpoint(Point(0.25f, 0.75f)); left->setPosition(Point(100, s.height/2)); @@ -264,7 +264,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter() * Our image on the left should be a radial progress indicator, counter clockwise */ ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathBlock)); - right->setType(kProgressTimerTypeRadial); + right->setType(ProgressTimer::Type::RADIAL); right->setMidpoint(Point(0.75f, 0.25f)); /** @@ -295,7 +295,7 @@ void SpriteProgressBarVarious::onEnter() ProgressTo *to = ProgressTo::create(2, 100); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); - left->setType(kProgressTimerTypeBar); + left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Point(0.5f, 0.5f)); @@ -306,7 +306,7 @@ void SpriteProgressBarVarious::onEnter() left->runAction(RepeatForever::create(to->clone())); ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); - middle->setType(kProgressTimerTypeBar); + middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -316,7 +316,7 @@ void SpriteProgressBarVarious::onEnter() middle->runAction(RepeatForever::create(to->clone())); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); - right->setType(kProgressTimerTypeBar); + right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -352,7 +352,7 @@ void SpriteProgressBarTintAndFade::onEnter() NULL); ProgressTimer *left = ProgressTimer::create(Sprite::create(s_pathSister1)); - left->setType(kProgressTimerTypeBar); + left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Point(0.5f, 0.5f)); @@ -366,7 +366,7 @@ void SpriteProgressBarTintAndFade::onEnter() left->addChild(LabelTTF::create("Tint", "Marker Felt", 20.0f)); ProgressTimer *middle = ProgressTimer::create(Sprite::create(s_pathSister2)); - middle->setType(kProgressTimerTypeBar); + middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -379,7 +379,7 @@ void SpriteProgressBarTintAndFade::onEnter() middle->addChild(LabelTTF::create("Fade", "Marker Felt", 20.0f)); ProgressTimer *right = ProgressTimer::create(Sprite::create(s_pathSister2)); - right->setType(kProgressTimerTypeBar); + right->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -414,7 +414,7 @@ void SpriteProgressWithSpriteFrame::onEnter() SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist"); ProgressTimer *left = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_01.png")); - left->setType(kProgressTimerTypeBar); + left->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -424,7 +424,7 @@ void SpriteProgressWithSpriteFrame::onEnter() left->runAction(RepeatForever::create(to->clone())); ProgressTimer *middle = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_02.png")); - middle->setType(kProgressTimerTypeBar); + middle->setType(ProgressTimer::Type::BAR); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change @@ -434,7 +434,7 @@ void SpriteProgressWithSpriteFrame::onEnter() middle->runAction(RepeatForever::create(to->clone())); ProgressTimer *right = ProgressTimer::create(Sprite::createWithSpriteFrameName("grossini_dance_03.png")); - right->setType(kProgressTimerTypeRadial); + right->setType(ProgressTimer::Type::RADIAL); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(Point(0.5f, 0.5f)); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change diff --git a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h index 54e6183b27..37b780be51 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsProgressTest/ActionsProgressTest.h @@ -14,9 +14,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class SpriteProgressToRadial : public SpriteDemo diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp index 8a956cd992..2f1f0b3907 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp @@ -142,7 +142,7 @@ void ActionsDemo::onExit() BaseTest::onExit(); } -void ActionsDemo::restartCallback(Object* pSender) +void ActionsDemo::restartCallback(Object* sender) { Scene* s = new ActionsTestScene(); s->addChild( restartAction() ); @@ -150,7 +150,7 @@ void ActionsDemo::restartCallback(Object* pSender) s->release(); } -void ActionsDemo::nextCallback(Object* pSender) +void ActionsDemo::nextCallback(Object* sender) { Scene* s = new ActionsTestScene(); s->addChild( nextAction() ); @@ -158,7 +158,7 @@ void ActionsDemo::nextCallback(Object* pSender) s->release(); } -void ActionsDemo::backCallback(Object* pSender) +void ActionsDemo::backCallback(Object* sender) { Scene* s = new ActionsTestScene(); s->addChild( backAction() ); @@ -852,7 +852,7 @@ std::string ActionCallFuncND::subtitle() return "simulates CallFuncND with std::bind()"; } -void ActionCallFuncND::doRemoveFromParentAndCleanup(Node* pSender, bool cleanup) +void ActionCallFuncND::doRemoveFromParentAndCleanup(Node* sender, bool cleanup) { _grossini->removeFromParentAndCleanup(cleanup); } @@ -1013,11 +1013,11 @@ void ActionRepeatForever::onEnter() _grossini->runAction(action); } -void ActionRepeatForever::repeatForever(Node* pSender) +void ActionRepeatForever::repeatForever(Node* sender) { auto repeat = RepeatForever::create( RotateBy::create(1.0f, 360) ); - pSender->runAction(repeat); + sender->runAction(repeat); } std::string ActionRepeatForever::subtitle() @@ -1297,7 +1297,7 @@ void ActionFollow::draw() float y = winSize.height; Point vertices[] = { Point(5,5), Point(x-5,5), Point(x-5,y-5), Point(5,y-5) }; - ccDrawPoly(vertices, 4, true); + DrawPrimitives::drawPoly(vertices, 4, true); } std::string ActionFollow::subtitle() @@ -1565,10 +1565,10 @@ void ActionCatmullRomStacked::draw() // move to 50,50 since the "by" path will start at 50,50 kmGLPushMatrix(); kmGLTranslatef(50, 50, 0); - ccDrawCatmullRom(_array1,50); + DrawPrimitives::drawCatmullRom(_array1,50); kmGLPopMatrix(); - ccDrawCatmullRom(_array2,50); + DrawPrimitives::drawCatmullRom(_array2,50); } std::string ActionCatmullRomStacked::title() @@ -1660,14 +1660,14 @@ void ActionCardinalSplineStacked::draw() // move to 50,50 since the "by" path will start at 50,50 kmGLPushMatrix(); kmGLTranslatef(50, 50, 0); - ccDrawCardinalSpline(_array, 0, 100); + DrawPrimitives::drawCardinalSpline(_array, 0, 100); kmGLPopMatrix(); auto s = Director::getInstance()->getWinSize(); kmGLPushMatrix(); kmGLTranslatef(s.width/2, 50, 0); - ccDrawCardinalSpline(_array, 1, 100); + DrawPrimitives::drawCardinalSpline(_array, 1, 100); kmGLPopMatrix(); } @@ -1700,7 +1700,7 @@ void Issue1305::onEnter() scheduleOnce(schedule_selector(Issue1305::addSprite), 2); } -void Issue1305::log(Node* pSender) +void Issue1305::log(Node* sender) { cocos2d::log("This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); } @@ -1885,9 +1885,9 @@ std::string Issue1327::subtitle() return "See console: You should see: 0, 45, 90, 135, 180"; } -void Issue1327::logSprRotation(Sprite* pSender) +void Issue1327::logSprRotation(Sprite* sender) { - log("%f", pSender->getRotation()); + log("%f", sender->getRotation()); } //Issue1398 @@ -2012,10 +2012,10 @@ void ActionCatmullRom::draw() // move to 50,50 since the "by" path will start at 50,50 kmGLPushMatrix(); kmGLTranslatef(50, 50, 0); - ccDrawCatmullRom(_array1, 50); + DrawPrimitives::drawCatmullRom(_array1, 50); kmGLPopMatrix(); - ccDrawCatmullRom(_array2,50); + DrawPrimitives::drawCatmullRom(_array2,50); } string ActionCatmullRom::title() @@ -2090,14 +2090,14 @@ void ActionCardinalSpline::draw() // move to 50,50 since the "by" path will start at 50,50 kmGLPushMatrix(); kmGLTranslatef(50, 50, 0); - ccDrawCardinalSpline(_array, 0, 100); + DrawPrimitives::drawCardinalSpline(_array, 0, 100); kmGLPopMatrix(); auto s = Director::getInstance()->getWinSize(); kmGLPushMatrix(); kmGLTranslatef(s.width/2, 50, 0); - ccDrawCardinalSpline(_array, 1, 100); + DrawPrimitives::drawCardinalSpline(_array, 1, 100); kmGLPopMatrix(); } diff --git a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h index 737e1f5502..facb2a01cc 100644 --- a/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.h @@ -32,9 +32,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class ActionManual : public ActionsDemo @@ -240,7 +240,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void callback(Node* pSender); + void callback(Node* sender); }; class ActionCallFuncND : public ActionsDemo @@ -249,7 +249,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void doRemoveFromParentAndCleanup(Node* pSender, bool cleanup); + void doRemoveFromParentAndCleanup(Node* sender, bool cleanup); }; class ActionCallFuncO : public ActionsDemo @@ -351,7 +351,7 @@ class Issue1305 : public ActionsDemo public: virtual void onEnter(); virtual void onExit(); - void log(Node* pSender); + void log(Node* sender); void addSprite(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -393,7 +393,7 @@ public: virtual void onEnter(); virtual std::string subtitle(); virtual std::string title(); - void logSprRotation(Sprite* pSender); + void logSprRotation(Sprite* sender); }; class Issue1398 : public ActionsDemo diff --git a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp index 32536a540e..6755e7af84 100644 --- a/samples/Cpp/TestCpp/Classes/AppDelegate.cpp +++ b/samples/Cpp/TestCpp/Classes/AppDelegate.cpp @@ -48,7 +48,7 @@ bool AppDelegate::applicationDidFinishLaunching() director->setContentScaleFactor(resourceSize.height/designSize.height); } - EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); + EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER); auto scene = Scene::create(); auto layer = new TestController(); diff --git a/samples/Cpp/TestCpp/Classes/BaseTest.cpp b/samples/Cpp/TestCpp/Classes/BaseTest.cpp index de2ef9a17e..5660d4baaa 100644 --- a/samples/Cpp/TestCpp/Classes/BaseTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BaseTest.cpp @@ -64,17 +64,17 @@ std::string BaseTest::subtitle() return ""; } -void BaseTest::restartCallback(Object* pSender) +void BaseTest::restartCallback(Object* sender) { log("override restart!"); } -void BaseTest::nextCallback(Object* pSender) +void BaseTest::nextCallback(Object* sender) { log("override next!"); } -void BaseTest::backCallback(Object* pSender) +void BaseTest::backCallback(Object* sender) { log("override back!"); } diff --git a/samples/Cpp/TestCpp/Classes/BaseTest.h b/samples/Cpp/TestCpp/Classes/BaseTest.h index cf9b5d06b5..d1e77c5a11 100644 --- a/samples/Cpp/TestCpp/Classes/BaseTest.h +++ b/samples/Cpp/TestCpp/Classes/BaseTest.h @@ -20,9 +20,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - virtual void restartCallback(Object* pSender); - virtual void nextCallback(Object* pSender); - virtual void backCallback(Object* pSender); + virtual void restartCallback(Object* sender); + virtual void nextCallback(Object* sender); + virtual void backCallback(Object* sender); }; diff --git a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp index 36913874db..aa75313475 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTest/Box2dTest.cpp @@ -141,7 +141,7 @@ void Box2DTestLayer::draw() Layer::draw(); #if CC_ENABLE_BOX2D_INTEGRATION - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + ccGLEnableVertexAttribs( VERTEX_ATTRIB_FLAG_POSITION ); kmGLPushMatrix(); @@ -213,7 +213,7 @@ void Box2DTestLayer::ccTouchesEnded(Set* touches, Event* event) for( it = touches->begin(); it != touches->end(); it++) { - touch = (Touch*)(*it); + touch = static_cast(*it); if(!touch) break; diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index b07b92d335..aae885e2e4 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -191,7 +191,7 @@ void Box2DView::draw() { Layer::draw(); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); kmGLPushMatrix(); diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/GLES-Render.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/GLES-Render.cpp index 81789e5a35..e6a6e3f7f9 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/GLES-Render.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/GLES-Render.cpp @@ -40,7 +40,7 @@ GLESDebugDraw::GLESDebugDraw( float32 ratio ) void GLESDebugDraw::initShader( void ) { - mShaderProgram = ShaderCache::getInstance()->programForKey(kShader_Position_uColor); + mShaderProgram = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_U_COLOR); mColorLocation = glGetUniformLocation( mShaderProgram->getProgram(), "u_color"); } @@ -59,7 +59,7 @@ void GLESDebugDraw::DrawPolygon(const b2Vec2* old_vertices, int vertexCount, con mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_LINE_LOOP, 0, vertexCount); CC_INCREMENT_GL_DRAWS(1); @@ -82,7 +82,7 @@ void GLESDebugDraw::DrawSolidPolygon(const b2Vec2* old_vertices, int vertexCount mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); @@ -116,7 +116,7 @@ void GLESDebugDraw::DrawCircle(const b2Vec2& center, float32 radius, const b2Col } mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r, color.g, color.b, 1); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINE_LOOP, 0, vertexCount); @@ -147,7 +147,7 @@ void GLESDebugDraw::DrawSolidCircle(const b2Vec2& center, float32 radius, const } mShaderProgram->setUniformLocationWith4f(mColorLocation, color.r*0.5f, color.g*0.5f, color.b*0.5f, 0.5f); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_TRIANGLE_FAN, 0, vertexCount); @@ -176,7 +176,7 @@ void GLESDebugDraw::DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Colo p1.x * mRatio, p1.y * mRatio, p2.x * mRatio, p2.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINES, 0, 2); @@ -209,7 +209,7 @@ void GLESDebugDraw::DrawPoint(const b2Vec2& p, float32 size, const b2Color& colo p.x * mRatio, p.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_POINTS, 0, 1); // glPointSize(1.0f); @@ -240,7 +240,7 @@ void GLESDebugDraw::DrawAABB(b2AABB* aabb, const b2Color& color) aabb->lowerBound.x * mRatio, aabb->upperBound.y * mRatio }; - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, glVertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, glVertices); glDrawArrays(GL_LINE_LOOP, 0, 8); CC_INCREMENT_GL_DRAWS(1); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp index 2798076821..d14bb1ab45 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.cpp @@ -56,7 +56,7 @@ bool Bug1159Layer::init() return false; } -void Bug1159Layer::callBack(Object* pSender) +void Bug1159Layer::callBack(Object* sender) { Director::getInstance()->replaceScene(TransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false)); } diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.h b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.h index f01a1885ce..1c7383a952 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.h +++ b/samples/Cpp/TestCpp/Classes/BugsTest/Bug-1159.h @@ -9,7 +9,7 @@ public: virtual bool init(); virtual void onExit(); static Scene* scene(); - void callBack(Object* pSender); + void callBack(Object* sender); CREATE_FUNC(Bug1159Layer); }; diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp index 392c8f8a74..4c1afe8585 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.cpp @@ -70,16 +70,16 @@ void BugsTestMainLayer::onEnter() setTouchEnabled(true); } -void BugsTestMainLayer::ccTouchesBegan(Set *pTouches, Event *pEvent) +void BugsTestMainLayer::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = (Touch*) pTouches->anyObject(); + Touch* touch = static_cast( touches->anyObject() ); _beginPos = touch->getLocation(); } -void BugsTestMainLayer::ccTouchesMoved(Set *pTouches, Event *pEvent) +void BugsTestMainLayer::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = (Touch*) pTouches->anyObject(); + Touch* touch = static_cast( touches->anyObject() ); Point touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; @@ -122,7 +122,7 @@ void BugsTestBaseLayer::onEnter() addChild(menu); } -void BugsTestBaseLayer::backCallback(Object* pSender) +void BugsTestBaseLayer::backCallback(Object* sender) { // Director::getInstance()->enableRetinaDisplay(false); BugsTestScene* scene = new BugsTestScene(); diff --git a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.h b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.h index d212a44180..2ec930f3be 100644 --- a/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.h +++ b/samples/Cpp/TestCpp/Classes/BugsTest/BugsTest.h @@ -8,8 +8,8 @@ class BugsTestMainLayer : public Layer public: virtual void onEnter(); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); protected: Point _beginPos; @@ -20,7 +20,7 @@ class BugsTestBaseLayer : public Layer { public: virtual void onEnter(); - void backCallback(Object* pSender); + void backCallback(Object* sender); }; class BugsTestScene : public TestScene diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp index 7c17ad36b2..a7b450da09 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.cpp @@ -70,7 +70,7 @@ ChipmunkTestLayer::ChipmunkTestLayer() } -void ChipmunkTestLayer::toggleDebugCallback(Object* pSender) +void ChipmunkTestLayer::toggleDebugCallback(Object* sender) { #if CC_ENABLE_CHIPMUNK_INTEGRATION _debugLayer->setVisible(! _debugLayer->isVisible()); diff --git a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.h b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.h index cf64e0017d..7ff01e4daf 100644 --- a/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.h +++ b/samples/Cpp/TestCpp/Classes/ChipmunkTest/ChipmunkTest.h @@ -23,7 +23,7 @@ public: void addNewSpriteAtPosition(Point p); void update(float dt); - void toggleDebugCallback(Object* pSender); + void toggleDebugCallback(Object* sender); virtual void ccTouchesEnded(Set* touches, Event* event); virtual void didAccelerate(Acceleration* pAccelerationValue); diff --git a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp index c5121c670b..01cef08321 100644 --- a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -37,9 +37,9 @@ MainLayer::MainLayer() )); } -void MainLayer::ccTouchesEnded(Set *pTouches, Event *pEvent) +void MainLayer::ccTouchesEnded(Set *touches, Event *event) { - Touch* touch = (Touch*) pTouches->anyObject(); + Touch* touch = static_cast( touches->anyObject() ); Point location = touch->getLocation(); diff --git a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.h b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.h index 17233755e9..8dae4f5990 100644 --- a/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.h +++ b/samples/Cpp/TestCpp/Classes/ClickAndMoveTest/ClickAndMoveTest.h @@ -13,7 +13,7 @@ class MainLayer : public Layer { public: MainLayer(); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); + virtual void ccTouchesEnded(Set *touches, Event *event); }; #endif diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 211a153627..9f9733ad6e 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -529,9 +529,9 @@ void ScrollViewDemo::setup() this->setTouchEnabled(true); } -void ScrollViewDemo::ccTouchesBegan(Set *pTouches, Event *pEvent) +void ScrollViewDemo::ccTouchesBegan(Set *touches, Event *event) { - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Node *clipper = this->getChildByTag(kTagClipperNode); Point point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); Rect rect = Rect(0, 0, clipper->getContentSize().width, clipper->getContentSize().height); @@ -539,10 +539,10 @@ void ScrollViewDemo::ccTouchesBegan(Set *pTouches, Event *pEvent) _lastPoint = point; } -void ScrollViewDemo::ccTouchesMoved(Set *pTouches, Event *pEvent) +void ScrollViewDemo::ccTouchesMoved(Set *touches, Event *event) { if (!_scrolling) return; - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Node *clipper = this->getChildByTag(kTagClipperNode); Point point = clipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView())); Point diff = point - _lastPoint; @@ -551,7 +551,7 @@ void ScrollViewDemo::ccTouchesMoved(Set *pTouches, Event *pEvent) _lastPoint = point; } -void ScrollViewDemo::ccTouchesEnded(Set *pTouches, Event *pEvent) +void ScrollViewDemo::ccTouchesEnded(Set *touches, Event *event) { if (!_scrolling) return; _scrolling = false; @@ -627,7 +627,7 @@ void RawStencilBufferTest::draw() this->setupStencilForClippingOnPlane(i); CHECK_GL_ERROR_DEBUG(); - ccDrawSolidRect(Point::ZERO, stencilPoint, Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Point::ZERO, stencilPoint, Color4F(1, 1, 1, 1)); kmGLPushMatrix(); this->transform(); @@ -637,7 +637,7 @@ void RawStencilBufferTest::draw() this->setupStencilForDrawingOnPlane(i); CHECK_GL_ERROR_DEBUG(); - ccDrawSolidRect(Point::ZERO, winPoint, _planeColor[i]); + DrawPrimitives::drawSolidRect(Point::ZERO, winPoint, _planeColor[i]); kmGLPushMatrix(); this->transform(); @@ -723,8 +723,8 @@ void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); + GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram(program ); #endif @@ -756,8 +756,8 @@ void RawStencilBufferTest5::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); + GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram( program ); #endif @@ -812,7 +812,7 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glStencilMask(planeMask); glStencilFunc(GL_NEVER, 0, planeMask); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); - ccDrawSolidRect(Point::ZERO, Point(Director::getInstance()->getWinSize()), Color4F(1, 1, 1, 1)); + DrawPrimitives::drawSolidRect(Point::ZERO, Point(Director::getInstance()->getWinSize()), Color4F(1, 1, 1, 1)); glStencilFunc(GL_NEVER, planeMask, planeMask); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); glDisable(GL_DEPTH_TEST); @@ -821,8 +821,8 @@ void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, _alphaThreshold); #else - GLProgram *program = ShaderCache::getInstance()->programForKey(kShader_PositionTextureColorAlphaTest); - GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kUniformAlphaTestValue); + GLProgram *program = ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST); + GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE); program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold); _sprite->setShaderProgram(program); #endif diff --git a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h index fd149c09b7..ec85a98eba 100644 --- a/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/samples/Cpp/TestCpp/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -98,7 +98,7 @@ public: virtual std::string title(); virtual std::string subtitle(); void pokeHoleAtPoint(Point point); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); private: ClippingNode* _outerClipper; Node* _holes; @@ -111,9 +111,9 @@ public: virtual std::string title(); virtual std::string subtitle(); virtual void setup(); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); + virtual void ccTouchesEnded(Set *touches, Event *event); private: bool _scrolling; Point _lastPoint; diff --git a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 368560f9ab..3aae4594f7 100644 --- a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -79,33 +79,33 @@ private: return true; } - bool touchHits(Touch *pTouch) + bool touchHits(Touch *touch) { const Rect area(0, 0, _child->getContentSize().width, _child->getContentSize().height); - return area.containsPoint(_child->convertToNodeSpace(pTouch->getLocation())); + return area.containsPoint(_child->convertToNodeSpace(touch->getLocation())); } - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent) + virtual bool ccTouchBegan(Touch *touch, Event *event) { - CC_UNUSED_PARAM(pEvent); - const bool hits = touchHits(pTouch); + CC_UNUSED_PARAM(event); + const bool hits = touchHits(touch); if (hits) scaleButtonTo(0.9f); return hits; } - virtual void ccTouchEnded(Touch *pTouch, Event *pEvent) + virtual void ccTouchEnded(Touch *touch, Event *event) { - CC_UNUSED_PARAM(pEvent); - const bool hits = touchHits(pTouch); + CC_UNUSED_PARAM(event); + const bool hits = touchHits(touch); if (hits && _onTriggered) _onTriggered(); scaleButtonTo(1); } - virtual void ccTouchCancelled(Touch *pTouch, Event *pEvent) + virtual void ccTouchCancelled(Touch *touch, Event *event) { - CC_UNUSED_PARAM(pEvent); + CC_UNUSED_PARAM(event); scaleButtonTo(1); } diff --git a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp index 2767ee1539..064bfa29fb 100644 --- a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.cpp @@ -84,7 +84,7 @@ void ConfigurationBase::onExit() BaseTest::onExit(); } -void ConfigurationBase::restartCallback(Object* pSender) +void ConfigurationBase::restartCallback(Object* sender) { Scene* s = new ConfigurationTestScene(); s->addChild( restartAction() ); @@ -92,7 +92,7 @@ void ConfigurationBase::restartCallback(Object* pSender) s->release(); } -void ConfigurationBase::nextCallback(Object* pSender) +void ConfigurationBase::nextCallback(Object* sender) { Scene* s = new ConfigurationTestScene(); s->addChild( nextAction() ); @@ -100,7 +100,7 @@ void ConfigurationBase::nextCallback(Object* pSender) s->release(); } -void ConfigurationBase::backCallback(Object* pSender) +void ConfigurationBase::backCallback(Object* sender) { Scene* s = new ConfigurationTestScene(); s->addChild( backAction() ); diff --git a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.h b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.h index 6e3f4feff5..807719cea0 100644 --- a/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.h +++ b/samples/Cpp/TestCpp/Classes/ConfigurationTest/ConfigurationTest.h @@ -27,9 +27,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class ConfigurationLoadConfig : public ConfigurationBase diff --git a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp index 985f5061f4..215d7f4e33 100644 --- a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.cpp @@ -22,7 +22,7 @@ CurlTest::CurlTest() // the test code is // http://curl.haxx.se/mail/lib-2009-12/0071.html -void CurlTest::ccTouchesEnded(Set *pTouches, Event *pEvent) +void CurlTest::ccTouchesEnded(Set *touches, Event *event) { CURL *curl; CURLcode res; diff --git a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.h b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.h index 511abb6526..dfa73adbe6 100644 --- a/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.h +++ b/samples/Cpp/TestCpp/Classes/CurlTest/CurlTest.h @@ -10,7 +10,7 @@ public: CurlTest(); ~CurlTest(); - virtual void ccTouchesEnded(cocos2d::Set *pTouches, cocos2d::Event *pEvent); + virtual void ccTouchesEnded(cocos2d::Set *touches, cocos2d::Event *event); private: cocos2d::LabelTTF* _label; diff --git a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp index 4fca603e08..6cb43bfb67 100644 --- a/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -9,49 +9,49 @@ CurrentLanguageTest::CurrentLanguageTest() LabelTTF *labelLanguage = LabelTTF::create("", "Arial", 20); labelLanguage->setPosition(VisibleRect::center()); - ccLanguageType currentLanguageType = Application::getInstance()->getCurrentLanguage(); + LanguageType currentLanguageType = Application::getInstance()->getCurrentLanguage(); switch (currentLanguageType) { - case kLanguageEnglish: + case LanguageType::ENGLISH: labelLanguage->setString("current language is English"); break; - case kLanguageChinese: + case LanguageType::CHINESE: labelLanguage->setString("current language is Chinese"); break; - case kLanguageFrench: + case LanguageType::FRENCH: labelLanguage->setString("current language is French"); break; - case kLanguageGerman: + case LanguageType::GERMAN: labelLanguage->setString("current language is German"); break; - case kLanguageItalian: + case LanguageType::ITALIAN: labelLanguage->setString("current language is Italian"); break; - case kLanguageRussian: + case LanguageType::RUSSIAN: labelLanguage->setString("current language is Russian"); break; - case kLanguageSpanish: + case LanguageType::SPANISH: labelLanguage->setString("current language is Spanish"); break; - case kLanguageKorean: + case LanguageType::KOREAN: labelLanguage->setString("current language is Korean"); break; - case kLanguageJapanese: + case LanguageType::JAPANESE: labelLanguage->setString("current language is Japanese"); break; - case kLanguageHungarian: + case LanguageType::HUNGARIAN: labelLanguage->setString("current language is Hungarian"); break; - case kLanguagePortuguese: + case LanguageType::PORTUGUESE: labelLanguage->setString("current language is Portuguese"); break; - case kLanguageArabic: + case LanguageType::ARABIC: labelLanguage->setString("current language is Arabic"); break; - case kLanguageNorwegian: + case LanguageType::NORWEGIAN: labelLanguage->setString("current language is Norwegian"); break; - case kLanguagePolish: + case LanguageType::POLISH: labelLanguage->setString("current language is Polish"); break; } diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index db3b1f9d91..114ed7090d 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -123,7 +123,7 @@ void DrawPrimitivesTest::draw() // color: 255,255,255,255 (white, non-transparent) // Anti-Aliased // glEnable(GL_LINE_SMOOTH); - ccDrawLine( VisibleRect::leftBottom(), VisibleRect::rightTop() ); + DrawPrimitives::drawLine( VisibleRect::leftBottom(), VisibleRect::rightTop() ); CHECK_GL_ERROR_DEBUG(); @@ -132,8 +132,8 @@ void DrawPrimitivesTest::draw() // GL_SMOOTH_LINE_WIDTH_RANGE = (1,1) on iPhone // glDisable(GL_LINE_SMOOTH); glLineWidth( 5.0f ); - ccDrawColor4B(255,0,0,255); - ccDrawLine( VisibleRect::leftTop(), VisibleRect::rightBottom() ); + DrawPrimitives::setDrawColor4B(255,0,0,255); + DrawPrimitives::drawLine( VisibleRect::leftTop(), VisibleRect::rightBottom() ); CHECK_GL_ERROR_DEBUG(); @@ -144,81 +144,81 @@ void DrawPrimitivesTest::draw() // Remember: OpenGL is a state-machine. // draw big point in the center - ccPointSize(64); - ccDrawColor4B(0,0,255,128); - ccDrawPoint( VisibleRect::center() ); + DrawPrimitives::setPointSize(64); + DrawPrimitives::setDrawColor4B(0,0,255,128); + DrawPrimitives::drawPoint( VisibleRect::center() ); CHECK_GL_ERROR_DEBUG(); // draw 4 small points Point points[] = { Point(60,60), Point(70,70), Point(60,70), Point(70,60) }; - ccPointSize(4); - ccDrawColor4B(0,255,255,255); - ccDrawPoints( points, 4); + DrawPrimitives::setPointSize(4); + DrawPrimitives::setDrawColor4B(0,255,255,255); + DrawPrimitives::drawPoints( points, 4); CHECK_GL_ERROR_DEBUG(); // draw a green circle with 10 segments glLineWidth(16); - ccDrawColor4B(0, 255, 0, 255); - ccDrawCircle( VisibleRect::center(), 100, 0, 10, false); + DrawPrimitives::setDrawColor4B(0, 255, 0, 255); + DrawPrimitives::drawCircle( VisibleRect::center(), 100, 0, 10, false); CHECK_GL_ERROR_DEBUG(); // draw a green circle with 50 segments with line to center glLineWidth(2); - ccDrawColor4B(0, 255, 255, 255); - ccDrawCircle( VisibleRect::center(), 50, CC_DEGREES_TO_RADIANS(90), 50, true); + DrawPrimitives::setDrawColor4B(0, 255, 255, 255); + DrawPrimitives::drawCircle( VisibleRect::center(), 50, CC_DEGREES_TO_RADIANS(90), 50, true); CHECK_GL_ERROR_DEBUG(); // draw a pink solid circle with 50 segments glLineWidth(2); - ccDrawColor4B(255, 0, 255, 255); - ccDrawSolidCircle( VisibleRect::center() + Point(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 1.0f, 1.0f); + DrawPrimitives::setDrawColor4B(255, 0, 255, 255); + DrawPrimitives::drawSolidCircle( VisibleRect::center() + Point(140,0), 40, CC_DEGREES_TO_RADIANS(90), 50, 1.0f, 1.0f); CHECK_GL_ERROR_DEBUG(); // open yellow poly - ccDrawColor4B(255, 255, 0, 255); + DrawPrimitives::setDrawColor4B(255, 255, 0, 255); glLineWidth(10); Point vertices[] = { Point(0,0), Point(50,50), Point(100,50), Point(100,100), Point(50,100) }; - ccDrawPoly( vertices, 5, false); + DrawPrimitives::drawPoly( vertices, 5, false); CHECK_GL_ERROR_DEBUG(); // filled poly glLineWidth(1); Point filledVertices[] = { Point(0,120), Point(50,120), Point(50,170), Point(25,200), Point(0,170) }; - ccDrawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) ); + DrawPrimitives::drawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) ); // closed purble poly - ccDrawColor4B(255, 0, 255, 255); + DrawPrimitives::setDrawColor4B(255, 0, 255, 255); glLineWidth(2); Point vertices2[] = { Point(30,130), Point(30,230), Point(50,200) }; - ccDrawPoly( vertices2, 3, true); + DrawPrimitives::drawPoly( vertices2, 3, true); CHECK_GL_ERROR_DEBUG(); // draw quad bezier path - ccDrawQuadBezier(VisibleRect::leftTop(), VisibleRect::center(), VisibleRect::rightTop(), 50); + DrawPrimitives::drawQuadBezier(VisibleRect::leftTop(), VisibleRect::center(), VisibleRect::rightTop(), 50); CHECK_GL_ERROR_DEBUG(); // draw cubic bezier path - ccDrawCubicBezier(VisibleRect::center(), Point(VisibleRect::center().x+30,VisibleRect::center().y+50), Point(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100); + DrawPrimitives::drawCubicBezier(VisibleRect::center(), Point(VisibleRect::center().x+30,VisibleRect::center().y+50), Point(VisibleRect::center().x+60,VisibleRect::center().y-50),VisibleRect::right(),100); CHECK_GL_ERROR_DEBUG(); //draw a solid polygon Point vertices3[] = {Point(60,160), Point(70,190), Point(100,190), Point(90,160)}; - ccDrawSolidPoly( vertices3, 4, Color4F(1,1,0,1) ); + DrawPrimitives::drawSolidPoly( vertices3, 4, Color4F(1,1,0,1) ); // restore original values glLineWidth(1); - ccDrawColor4B(255,255,255,255); - ccPointSize(1); + DrawPrimitives::setDrawColor4B(255,255,255,255); + DrawPrimitives::setPointSize(1); CHECK_GL_ERROR_DEBUG(); } diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h index 9f7bbba77a..8b24b3c00a 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.h @@ -12,9 +12,9 @@ class BaseLayer : public BaseTest public: BaseLayer(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); virtual std::string title(); virtual std::string subtitle(); virtual void onEnter(); diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 99f8b79691..910033e094 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -215,7 +215,7 @@ void Effect5::onExit() { EffectAdvanceTextLayer::onExit(); - Director::getInstance()->setProjection(kDirectorProjection3D); + Director::getInstance()->setProjection(Director::Projection::_3D); } //------------------------------------------------------------------ @@ -368,7 +368,7 @@ std::string EffectAdvanceTextLayer::subtitle() return ""; } -void EffectAdvanceTextLayer::restartCallback(Object* pSender) +void EffectAdvanceTextLayer::restartCallback(Object* sender) { Scene* s = new EffectAdvanceScene(); s->addChild(restartEffectAdvanceAction()); @@ -377,7 +377,7 @@ void EffectAdvanceTextLayer::restartCallback(Object* pSender) s->release(); } -void EffectAdvanceTextLayer::nextCallback(Object* pSender) +void EffectAdvanceTextLayer::nextCallback(Object* sender) { Scene* s = new EffectAdvanceScene(); s->addChild( nextEffectAdvanceAction() ); @@ -386,7 +386,7 @@ void EffectAdvanceTextLayer::nextCallback(Object* pSender) s->release(); } -void EffectAdvanceTextLayer::backCallback(Object* pSender) +void EffectAdvanceTextLayer::backCallback(Object* sender) { Scene* s = new EffectAdvanceScene(); s->addChild( backEffectAdvanceAction() ); diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h index c041520641..b64d48dc9e 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h @@ -19,9 +19,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class Effect1 : public EffectAdvanceTextLayer diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp index b26620e1a8..9603c0a0ae 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -408,12 +408,12 @@ void TextLayer::newScene() s->release(); } -void TextLayer::restartCallback(Object* pSender) +void TextLayer::restartCallback(Object* sender) { newScene(); } -void TextLayer::nextCallback(Object* pSender) +void TextLayer::nextCallback(Object* sender) { // update the action index actionIdx++; @@ -422,7 +422,7 @@ void TextLayer::nextCallback(Object* pSender) newScene(); } -void TextLayer::backCallback(Object* pSender) +void TextLayer::backCallback(Object* sender) { // update the action index actionIdx--; diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h index 068cfc8afe..2f65c73711 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h @@ -23,9 +23,9 @@ public: virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); void newScene(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp index 6d722b6ce8..6ca1144601 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.cpp @@ -110,7 +110,7 @@ void ArmatureTestScene::runThisTest() Director::getInstance()->replaceScene(this); } -void ArmatureTestScene::MainMenuCallback(Object* pSender) +void ArmatureTestScene::MainMenuCallback(Object* sender) { removeAllChildren(); ArmatureDataManager::sharedArmatureDataManager()->purgeArmatureSystem(); @@ -154,7 +154,7 @@ void ArmatureTestLayer::onEnter() addChild(menu, 100); - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } void ArmatureTestLayer::onExit() @@ -170,21 +170,21 @@ std::string ArmatureTestLayer::subtitle() return ""; } -void ArmatureTestLayer::restartCallback(Object* pSender) +void ArmatureTestLayer::restartCallback(Object* sender) { Scene* s = new ArmatureTestScene(); s->addChild( RestartTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void ArmatureTestLayer::nextCallback(Object* pSender) +void ArmatureTestLayer::nextCallback(Object* sender) { Scene* s = new ArmatureTestScene(); s->addChild( NextTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void ArmatureTestLayer::backCallback(Object* pSender) +void ArmatureTestLayer::backCallback(Object* sender) { Scene* s = new ArmatureTestScene(); s->addChild( BackTest() ); @@ -450,7 +450,7 @@ std::string TestParticleDisplay::subtitle() { return "Touch to change animation"; } -bool TestParticleDisplay::ccTouchBegan(Touch *pTouch, Event *pEvent) +bool TestParticleDisplay::ccTouchBegan(Touch *touch, Event *event) { ++animationID; animationID = animationID % armature->getAnimation()->getMovementCount(); @@ -496,7 +496,7 @@ std::string TestUseMutiplePicture::subtitle() { return "weapon and armature are in different picture"; } -bool TestUseMutiplePicture::ccTouchBegan(Touch *pTouch, Event *pEvent) +bool TestUseMutiplePicture::ccTouchBegan(Touch *touch, Event *event) { ++displayIndex; displayIndex = (displayIndex) % 6; @@ -539,7 +539,7 @@ std::string TestBox2DDetector::title() } void TestBox2DDetector::draw() { - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); kmGLPushMatrix(); @@ -581,8 +581,8 @@ void TestBoundingBox::draw() rect = RectApplyAffineTransform(armature->getBoundingBox(), armature->getNodeToParentTransform()); - ccDrawColor4B(100, 100, 100, 255); - ccDrawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY())); + DrawPrimitives::setDrawColor4B(100, 100, 100, 255); + DrawPrimitives::drawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY())); } @@ -631,7 +631,7 @@ std::string TestArmatureNesting::title() { return "Test Armature Nesting"; } -bool TestArmatureNesting::ccTouchBegan(Touch *pTouch, Event *pEvent) +bool TestArmatureNesting::ccTouchBegan(Touch *touch, Event *event) { ++weaponIndex; weaponIndex = weaponIndex % 4; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h index 454f079ffd..8115958e0f 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ArmatureTest/ArmatureScene.h @@ -31,7 +31,7 @@ public: virtual void runThisTest(); // The CallBack for back to the main menu scene - virtual void MainMenuCallback(Object* pSender); + virtual void MainMenuCallback(Object* sender); }; enum { @@ -60,9 +60,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); virtual void draw(); }; @@ -139,7 +139,7 @@ class TestUseMutiplePicture : public ArmatureTestLayer virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); virtual void registerWithTouchDispatcher(); int displayIndex; @@ -151,7 +151,7 @@ class TestParticleDisplay : public ArmatureTestLayer virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); virtual void registerWithTouchDispatcher(); int animationID; @@ -195,7 +195,7 @@ class TestArmatureNesting : public ArmatureTestLayer public: virtual void onEnter(); virtual std::string title(); - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); virtual void registerWithTouchDispatcher(); cocos2d::extension::armature::Armature *armature; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp index aefc75f099..a57d3020ee 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.cpp @@ -12,12 +12,12 @@ AnimationsTestLayer::~AnimationsTestLayer() CC_SAFE_RELEASE_NULL(mAnimationManager); } -SEL_MenuHandler AnimationsTestLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) +SEL_MenuHandler AnimationsTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { return NULL; } -SEL_CCControlHandler AnimationsTestLayer::onResolveCCBControlSelector(Object *pTarget, const char*pSelectorName) { +SEL_CCControlHandler AnimationsTestLayer::onResolveCCBCCControlSelector(Object *pTarget, const char*pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonIdleClicked", AnimationsTestLayer::onControlButtonIdleClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonWaveClicked", AnimationsTestLayer::onControlButtonWaveClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonJumpClicked", AnimationsTestLayer::onControlButtonJumpClicked); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h index b92d1192fb..d72757d3ce 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/AnimationsTest/AnimationsTestLayer.h @@ -15,14 +15,14 @@ public: AnimationsTestLayer(); virtual ~AnimationsTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonIdleClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonWaveClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonJumpClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onControlButtonFunkyClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonIdleClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonWaveClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonJumpClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonFunkyClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); void setAnimationManager(cocos2d::extension::CCBAnimationManager *pAnimationManager); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp index 0b3924e655..ca907cb4ca 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -12,11 +12,11 @@ ButtonTestLayer::~ButtonTestLayer() CC_SAFE_RELEASE(mControlEventLabel); } -SEL_MenuHandler ButtonTestLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { return NULL; } -SEL_CCControlHandler ButtonTestLayer::onResolveCCBControlSelector(Object * pTarget, const char * pSelectorName) { +SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onControlButtonClicked", ButtonTestLayer::onControlButtonClicked); return NULL; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index a8d9c06c86..f79a54576b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -15,11 +15,11 @@ public: ButtonTestLayer(); virtual ~ButtonTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onControlButtonClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onControlButtonClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); private: cocos2d::LabelBMFont * mControlEventLabel; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 1458d1b5d2..8942ac199c 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -68,11 +68,11 @@ void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::Node * node, cocos2d::extens } -SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { return NULL; } -SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBControlSelector(Object * pTarget, const char * pSelectorName) { +SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); @@ -126,19 +126,19 @@ bool HelloCocosBuilderLayer::onAssignCCBCustomProperty(Object* pTarget, const ch return bRet; } -void HelloCocosBuilderLayer::onMenuTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onMenuTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestMenus.ccbi", "TestMenusLayer", MenuTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onSpriteTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onSpriteTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestSprites.ccbi", "TestSpritesLayer", SpriteTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onButtonTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onButtonTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestButtons.ccbi", "TestButtonsLayer", ButtonTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { /* Create an autorelease NodeLoaderLibrary. */ NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); @@ -179,16 +179,16 @@ void HelloCocosBuilderLayer::onAnimationsTestClicked(Object * pSender, cocos2d:: //this->openTest("TestAnimations.ccbi", "TestAnimationsLayer", AnimationsTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) { +void HelloCocosBuilderLayer::onParticleSystemTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestParticleSystems.ccbi", "TestParticleSystemsLayer", ParticleSystemTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onScrollViewTestClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestScrollViews.ccbi", "TestScrollViewsLayer", ScrollViewTestLayerLoader::loader()); } -void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * pSender, cocos2d::extension::ControlEvent pControlEvent) +void HelloCocosBuilderLayer::onTimelineCallbackSoundClicked(Object * sender, cocos2d::extension::ControlEvent pControlEvent) { this->openTest("ccb/ccb/TestTimelineCallback.ccbi", "TimelineCallbackTestLayer", TimelineCallbackTestLayerLoader::loader()); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 267a9adad8..9a8cabf042 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -28,19 +28,19 @@ class HelloCocosBuilderLayer void openTest(const char * pCCBFileName, const char * nodeName = NULL, cocos2d::extension::NodeLoader * nodeLoader = NULL); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); virtual bool onAssignCCBCustomProperty(Object* pTarget, const char* pMemberVariableName, cocos2d::extension::CCBValue* pCCBValue); virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); - void onMenuTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onSpriteTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onButtonTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onAnimationsTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onParticleSystemTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onScrollViewTestClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); - void onTimelineCallbackSoundClicked(cocos2d::Object * pSender, cocos2d::extension::ControlEvent pControlEvent); + void onMenuTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onSpriteTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onButtonTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onAnimationsTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onParticleSystemTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onScrollViewTestClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); + void onTimelineCallbackSoundClicked(cocos2d::Object * sender, cocos2d::extension::ControlEvent pControlEvent); private: cocos2d::Sprite * mBurstSprite; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp index 3d42048cf0..36bcf964e9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp @@ -12,7 +12,7 @@ MenuTestLayer::~MenuTestLayer() CC_SAFE_RELEASE(mMenuItemStatusLabelBMFont); } -SEL_MenuHandler MenuTestLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemAClicked", MenuTestLayer::onMenuItemAClicked); CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemBClicked", MenuTestLayer::onMenuItemBClicked); CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemCClicked", MenuTestLayer::onMenuItemCClicked); @@ -20,7 +20,7 @@ SEL_MenuHandler MenuTestLayer::onResolveCCBMenuItemSelector(Object * pTarget, co return NULL; } -SEL_CCControlHandler MenuTestLayer::onResolveCCBControlSelector(Object * pTarget, const char * pSelectorName) { +SEL_CCControlHandler MenuTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index 95f3994f59..8533e38dda 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -15,13 +15,13 @@ class MenuTestLayer MenuTestLayer(); virtual ~MenuTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); - void onMenuItemAClicked(cocos2d::Object * pSender); - void onMenuItemBClicked(cocos2d::Object * pSender); - void onMenuItemCClicked(cocos2d::Object * pSender); + void onMenuItemAClicked(cocos2d::Object * sender); + void onMenuItemBClicked(cocos2d::Object * sender); + void onMenuItemCClicked(cocos2d::Object * sender); private: cocos2d::LabelBMFont * mMenuItemStatusLabelBMFont; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp index 7de128ab96..6129a5faa8 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp @@ -3,13 +3,13 @@ USING_NS_CC; USING_NS_CC_EXT; -SEL_MenuHandler TestHeaderLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onBackClicked", TestHeaderLayer::onBackClicked); return NULL; } -SEL_CCControlHandler TestHeaderLayer::onResolveCCBControlSelector(Object * pTarget, const char * pSelectorName) { +SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 40a020bc6e..3a8f2dc84d 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -12,11 +12,11 @@ class TestHeaderLayer public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual void onNodeLoaded(cocos2d::Node * node, cocos2d::extension::NodeLoader * nodeLoader); - void onBackClicked(cocos2d::Object * pSender); + void onBackClicked(cocos2d::Object * sender); }; #endif \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp index 37ed182c6e..fecb8219da 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.cpp @@ -14,11 +14,11 @@ TimelineCallbackTestLayer::~TimelineCallbackTestLayer() CocosDenshion::SimpleAudioEngine::end(); } -SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBMenuItemSelector(Object * pTarget, const char * pSelectorName) { +SEL_MenuHandler TimelineCallbackTestLayer::onResolveCCBCCMenuItemSelector(Object * pTarget, const char * pSelectorName) { return NULL; } -SEL_CCControlHandler TimelineCallbackTestLayer::onResolveCCBControlSelector(Object * pTarget, const char * pSelectorName) { +SEL_CCControlHandler TimelineCallbackTestLayer::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { return NULL; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h index d9b045fb16..37059f41f9 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocosBuilderTest/TimelineCallbackTest/TimelineCallbackTestLayer.h @@ -15,8 +15,8 @@ class TimelineCallbackTestLayer TimelineCallbackTestLayer(); virtual ~TimelineCallbackTestLayer(); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual cocos2d::SEL_CallFuncN onResolveCCBCallFuncSelector(Object * pTarget, const char* pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * node); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp index 8b3ba010ff..2c62142516 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/EnemyController.cpp @@ -35,17 +35,18 @@ void EnemyController::onEnter() // Determine speed of the target - int minDuration = (int)2.0; - int maxDuration = (int)4.0; + int minDuration = 2; + int maxDuration = 4; int rangeDuration = maxDuration - minDuration; // srand( TimGetTicks() ); int actualDuration = ( rand() % rangeDuration ) + minDuration; // Create the actions - FiniteTimeAction* actionMove = MoveTo::create( (float)actualDuration, + FiniteTimeAction* actionMove = MoveTo::create( actualDuration, Point(0 - getOwner()->getContentSize().width/2, actualY) ); - FiniteTimeAction* actionMoveDone = CallFuncN::create(getOwner()->getParent()->getComponent("SceneController"), - callfuncN_selector(SceneController::spriteMoveFinished)); + FiniteTimeAction* actionMoveDone = CallFuncN::create( + CC_CALLBACK_1(SceneController::spriteMoveFinished, static_cast( getOwner()->getParent()->getComponent("SceneController") ))); + _owner->runAction( Sequence::create(actionMove, actionMoveDone, NULL) ); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp index 01042b3d99..2b451647e7 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.cpp @@ -35,10 +35,10 @@ void PlayerController::update(float delta) } -void PlayerController::ccTouchesEnded(Set *pTouches, Event *pEvent) +void PlayerController::ccTouchesEnded(Set *touches, Event *event) { // Choose one of the touches to work with - Touch* touch = (Touch*)( pTouches->anyObject() ); + Touch* touch = static_cast( touches->anyObject() ); Point location = touch->getLocation(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h index c23e8fa751..61ec49dc4e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/PlayerController.h @@ -12,7 +12,7 @@ protected: virtual ~PlayerController(void); public: - virtual void ccTouchesEnded(cocos2d::Set *pTouches, cocos2d::Event *pEvent); + virtual void ccTouchesEnded(cocos2d::Set *touches, cocos2d::Event *event); public: virtual bool init(); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp index 3a3995f430..61fe94b312 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ComponentsTest/ProjectileController.cpp @@ -93,6 +93,10 @@ ProjectileController* ProjectileController::create(void) return pRet; } +void freeFunction( Node *ignore ) +{ + log("hello"); +} void ProjectileController::move(float flocationX, float flocationY) { @@ -121,19 +125,25 @@ void ProjectileController::move(float flocationX, float flocationY) float velocity = 480/1; // 480pixels/1sec float realMoveDuration = length/velocity; - // Move projectile to actual endpoint - _owner->runAction( Sequence::create( - MoveTo::create(realMoveDuration, realDest), - CallFuncN::create(getOwner()->getParent()->getComponent("SceneController"), - callfuncN_selector(SceneController::spriteMoveFinished)), - NULL) ); + auto callfunc = CallFuncN::create( + CC_CALLBACK_1( + SceneController::spriteMoveFinished, + static_cast( getOwner()->getParent()->getComponent("SceneController") + ) ) ); + // Move projectile to actual endpoint + _owner->runAction( + Sequence::create( + MoveTo::create(realMoveDuration, realDest), + callfunc, + NULL) + ); } void ProjectileController::die() { Component *com = _owner->getParent()->getComponent("SceneController"); - cocos2d::Array *_projectiles = ((SceneController*)com)->getProjectiles(); + cocos2d::Array *_projectiles = static_cast(com)->getProjectiles(); _projectiles->removeObject(_owner); _owner->removeFromParentAndCleanup(true); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp index ba96f3d391..514b672c27 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -111,16 +111,16 @@ void ExtensionsMainLayer::onEnter() addChild(_itemMenu); } -void ExtensionsMainLayer::ccTouchesBegan(Set *pTouches, Event *pEvent) +void ExtensionsMainLayer::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = static_cast(pTouches->anyObject()); + Touch* touch = static_cast(touches->anyObject()); _beginPos = touch->getLocation(); } -void ExtensionsMainLayer::ccTouchesMoved(Set *pTouches, Event *pEvent) +void ExtensionsMainLayer::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = static_cast(pTouches->anyObject()); + Touch* touch = static_cast(touches->anyObject()); Point touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.h index 3b1a77a13d..67b0fb374b 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/ExtensionsTest.h @@ -8,8 +8,8 @@ class ExtensionsMainLayer : public Layer public: virtual void onEnter(); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); Point _beginPos; Menu* _itemMenu; diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp index cb118e8595..a203dc5110 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/SocketIOTest.cpp @@ -81,7 +81,7 @@ SocketIOTestLayer::SocketIOTestLayer(void) menuRequest->addChild(itemTestEndpointDisconnect); // Sahred Status Label - _sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), kTextAlignmentLeft); + _sioClientStatus = LabelTTF::create("Not connected...", "Arial", 14, Size(320, 100), Label::HAlignment::LEFT); _sioClientStatus->setAnchorPoint(Point(0, 0)); _sioClientStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y)); this->addChild(_sioClientStatus); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp index d25c594d67..96b92e2199 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/NetworkTest/WebSocketTest.cpp @@ -49,19 +49,19 @@ WebSocketTestLayer::WebSocketTestLayer() // Send Text Status Label - _sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); + _sendTextStatus = LabelTTF::create("Send Text WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::TOP); _sendTextStatus->setAnchorPoint(Point(0, 0)); _sendTextStatus->setPosition(Point(VisibleRect::left().x, VisibleRect::rightBottom().y + 25)); this->addChild(_sendTextStatus); // Send Binary Status Label - _sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); + _sendBinaryStatus = LabelTTF::create("Send Binary WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::TOP); _sendBinaryStatus->setAnchorPoint(Point(0, 0)); _sendBinaryStatus->setPosition(Point(VisibleRect::left().x + 160, VisibleRect::rightBottom().y + 25)); this->addChild(_sendBinaryStatus); // Error Label - _errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), kTextAlignmentCenter, kVerticalTextAlignmentTop); + _errorStatus = LabelTTF::create("Error WS is waiting...", "Arial", 14, Size(160, 100), Label::HAlignment::CENTER, Label::VAlignment::TOP); _errorStatus->setAnchorPoint(Point(0, 0)); _errorStatus->setPosition(Point(VisibleRect::left().x + 320, VisibleRect::rightBottom().y + 25)); this->addChild(_errorStatus); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp index d70b165c7e..c12f388ce3 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/TableViewTest/CustomTableViewCell.cpp @@ -14,6 +14,6 @@ void CustomTableViewCell::draw() // Point(pos.x+size.width-1, pos.y+size.height-1), // Point(pos.x+1, pos.y+size.height-1), // }; -// ccDrawColor4B(0, 0, 255, 255); -// ccDrawPoly(vertices, 4, true); +// DrawPrimitives::drawColor4B(0, 0, 255, 255); +// DrawPrimitives::drawPoly(vertices, 4, true); } diff --git a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp index f8dc9a46b9..f8444c4ae9 100644 --- a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.cpp @@ -68,7 +68,7 @@ void FileUtilsDemo::onEnter() BaseTest::onEnter(); } -void FileUtilsDemo::backCallback(Object* pSender) +void FileUtilsDemo::backCallback(Object* sender) { Scene* scene = new FileUtilsTestScene(); Layer* layer = backAction(); @@ -78,7 +78,7 @@ void FileUtilsDemo::backCallback(Object* pSender) scene->release(); } -void FileUtilsDemo::nextCallback(Object* pSender) +void FileUtilsDemo::nextCallback(Object* sender) { Scene* scene = new FileUtilsTestScene(); Layer* layer = nextAction(); @@ -88,7 +88,7 @@ void FileUtilsDemo::nextCallback(Object* pSender) scene->release(); } -void FileUtilsDemo::restartCallback(Object* pSender) +void FileUtilsDemo::restartCallback(Object* sender) { Scene* scene = new FileUtilsTestScene(); Layer* layer = restartAction(); diff --git a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.h b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.h index 79ecc65b57..d524d81a4b 100644 --- a/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.h +++ b/samples/Cpp/TestCpp/Classes/FileUtilsTest/FileUtilsTest.h @@ -19,9 +19,9 @@ public: virtual void onEnter(); virtual string title(); virtual string subtitle(); - void backCallback(Object* pSender); - void nextCallback(Object* pSender); - void restartCallback(Object* pSender); + void backCallback(Object* sender); + void nextCallback(Object* sender); + void restartCallback(Object* sender); }; class TestResolutionDirectories : public FileUtilsDemo diff --git a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp index 04c5f2288d..1a2eda4167 100644 --- a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp +++ b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.cpp @@ -39,11 +39,11 @@ static std::string fontList[] = static int fontCount = sizeof(fontList) / sizeof(*fontList); static int vAlignIdx = 0; -static VerticalTextAlignment verticalAlignment[] = +static Label::VAlignment verticalAlignment[] = { - kVerticalTextAlignmentTop, - kVerticalTextAlignmentCenter, - kVerticalTextAlignmentBottom, + Label::VAlignment::TOP, + Label::VAlignment::CENTER, + Label::VAlignment::BOTTOM, }; static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment); @@ -99,11 +99,11 @@ void FontTest::showFont(const char *pFont) LabelTTF *top = LabelTTF::create(pFont, pFont, 24); LabelTTF *left = LabelTTF::create("alignment left", pFont, fontSize, - blockSize, kTextAlignmentLeft, verticalAlignment[vAlignIdx]); + blockSize, Label::HAlignment::LEFT, verticalAlignment[vAlignIdx]); LabelTTF *center = LabelTTF::create("alignment center", pFont, fontSize, - blockSize, kTextAlignmentCenter, verticalAlignment[vAlignIdx]); + blockSize, Label::HAlignment::CENTER, verticalAlignment[vAlignIdx]); LabelTTF *right = LabelTTF::create("alignment right", pFont, fontSize, - blockSize, kTextAlignmentRight, verticalAlignment[vAlignIdx]); + blockSize, Label::HAlignment::RIGHT, verticalAlignment[vAlignIdx]); LayerColor *leftColor = LayerColor::create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height); LayerColor *centerColor = LayerColor::create(Color4B(200, 100, 100, 255), blockSize.width, blockSize.height); @@ -139,12 +139,12 @@ void FontTest::showFont(const char *pFont) this->addChild(top, 0, kTagLabel4); } -void FontTest::backCallback(Object* pSender) +void FontTest::backCallback(Object* sender) { showFont(backAction()); } -void FontTest::nextCallback(Object* pSender) +void FontTest::nextCallback(Object* sender) { showFont(nextAction()); } @@ -154,7 +154,7 @@ std::string FontTest::title() return "Font test"; } -void FontTest::restartCallback(Object* pSender) +void FontTest::restartCallback(Object* sender) { showFont(restartAction()); } diff --git a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.h b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.h index e84098ef99..1cbf6190d8 100644 --- a/samples/Cpp/TestCpp/Classes/FontTest/FontTest.h +++ b/samples/Cpp/TestCpp/Classes/FontTest/FontTest.h @@ -17,9 +17,9 @@ public: FontTest(); void showFont(const char *pFont); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); virtual std::string title(); CREATE_FUNC(FontTest); diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp index bd8a693b4d..7dd610a3a0 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.cpp @@ -132,7 +132,7 @@ void AtlasDemo::onEnter() BaseTest::onEnter(); } -void AtlasDemo::restartCallback(Object* pSender) +void AtlasDemo::restartCallback(Object* sender) { Scene* s = new AtlasTestScene(); s->addChild(restartAtlasAction()); @@ -141,7 +141,7 @@ void AtlasDemo::restartCallback(Object* pSender) s->release(); } -void AtlasDemo::nextCallback(Object* pSender) +void AtlasDemo::nextCallback(Object* sender) { Scene* s = new AtlasTestScene(); s->addChild( nextAtlasAction() ); @@ -149,7 +149,7 @@ void AtlasDemo::nextCallback(Object* pSender) s->release(); } -void AtlasDemo::backCallback(Object* pSender) +void AtlasDemo::backCallback(Object* sender) { Scene* s = new AtlasTestScene(); s->addChild( backAtlasAction() ); @@ -348,19 +348,19 @@ LabelTTFAlignment::LabelTTFAlignment() Size s = Director::getInstance()->getWinSize(); LabelTTF* ttf0 = LabelTTF::create("Alignment 0\nnew line", "Helvetica", 12, - Size(256, 32), kTextAlignmentLeft); + Size(256, 32), Label::HAlignment::LEFT); ttf0->setPosition(Point(s.width/2,(s.height/6)*2)); ttf0->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf0); LabelTTF* ttf1 = LabelTTF::create("Alignment 1\nnew line", "Helvetica", 12, - Size(245, 32), kTextAlignmentCenter); + Size(245, 32), Label::HAlignment::CENTER); ttf1->setPosition(Point(s.width/2,(s.height/6)*3)); ttf1->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf1); LabelTTF* ttf2 = LabelTTF::create("Alignment 2\nnew line", "Helvetica", 12, - Size(245, 32), kTextAlignmentRight); + Size(245, 32), Label::HAlignment::RIGHT); ttf2->setPosition(Point(s.width/2,(s.height/6)*4)); ttf2->setAnchorPoint(Point(0.5f,0.5f)); this->addChild(ttf2); @@ -523,8 +523,8 @@ Atlas4::Atlas4() void Atlas4::draw() { Size s = Director::getInstance()->getWinSize(); - ccDrawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); - ccDrawLine( Point(s.width/2, 0), Point(s.width/2, s.height) ); + DrawPrimitives::drawLine( Point(0, s.height/2), Point(s.width, s.height/2) ); + DrawPrimitives::drawLine( Point(s.width/2, 0), Point(s.width/2, s.height) ); } void Atlas4::step(float dt) @@ -953,8 +953,8 @@ LabelTTFTest::LabelTTFTest() this->addChild(menu); _plabel = NULL; - _horizAlign = kTextAlignmentLeft; - _vertAlign = kVerticalTextAlignmentTop; + _horizAlign = Label::HAlignment::LEFT; + _vertAlign = Label::VAlignment::TOP; this->updateAlignment(); } @@ -986,39 +986,39 @@ void LabelTTFTest::updateAlignment() this->addChild(_plabel); } -void LabelTTFTest::setAlignmentLeft(Object* pSender) +void LabelTTFTest::setAlignmentLeft(Object* sender) { - _horizAlign = kTextAlignmentLeft; + _horizAlign = Label::HAlignment::LEFT; this->updateAlignment(); } -void LabelTTFTest::setAlignmentCenter(Object* pSender) +void LabelTTFTest::setAlignmentCenter(Object* sender) { - _horizAlign = kTextAlignmentCenter; + _horizAlign = Label::HAlignment::CENTER; this->updateAlignment(); } -void LabelTTFTest::setAlignmentRight(Object* pSender) +void LabelTTFTest::setAlignmentRight(Object* sender) { - _horizAlign = kTextAlignmentRight; + _horizAlign = Label::HAlignment::RIGHT; this->updateAlignment(); } -void LabelTTFTest::setAlignmentTop(Object* pSender) +void LabelTTFTest::setAlignmentTop(Object* sender) { - _vertAlign = kVerticalTextAlignmentTop; + _vertAlign = Label::VAlignment::TOP; this->updateAlignment(); } -void LabelTTFTest::setAlignmentMiddle(Object* pSender) +void LabelTTFTest::setAlignmentMiddle(Object* sender) { - _vertAlign = kVerticalTextAlignmentCenter; + _vertAlign = Label::VAlignment::CENTER; this->updateAlignment(); } -void LabelTTFTest::setAlignmentBottom(Object* pSender) +void LabelTTFTest::setAlignmentBottom(Object* sender) { - _vertAlign = kVerticalTextAlignmentBottom; + _vertAlign = Label::VAlignment::BOTTOM; this->updateAlignment(); } @@ -1027,24 +1027,24 @@ const char* LabelTTFTest::getCurrentAlignment() const char* vertical = NULL; const char* horizontal = NULL; switch (_vertAlign) { - case kVerticalTextAlignmentTop: + case Label::VAlignment::TOP: vertical = "Top"; break; - case kVerticalTextAlignmentCenter: + case Label::VAlignment::CENTER: vertical = "Middle"; break; - case kVerticalTextAlignmentBottom: + case Label::VAlignment::BOTTOM: vertical = "Bottom"; break; } switch (_horizAlign) { - case kTextAlignmentLeft: + case Label::HAlignment::LEFT: horizontal = "Left"; break; - case kTextAlignmentCenter: + case Label::HAlignment::CENTER: horizontal = "Center"; break; - case kTextAlignmentRight: + case Label::HAlignment::RIGHT: horizontal = "Right"; break; } @@ -1070,8 +1070,8 @@ LabelTTFMultiline::LabelTTFMultiline() "Paint Boy", 32, Size(s.width/2,200), - kTextAlignmentCenter, - kVerticalTextAlignmentTop); + Label::HAlignment::CENTER, + Label::VAlignment::TOP); center->setPosition(Point(s.width / 2, 150)); @@ -1141,7 +1141,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() Size size = Director::getInstance()->getWinSize(); // create and initialize a Label - this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kTextAlignmentCenter); + this->_labelShouldRetain = LabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, Label::HAlignment::CENTER); this->_labelShouldRetain->retain(); this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png"); @@ -1250,13 +1250,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) switch(item->getTag()) { case LeftAlign: - this->_labelShouldRetain->setAlignment(kTextAlignmentLeft); + this->_labelShouldRetain->setAlignment(Label::HAlignment::LEFT); break; case CenterAlign: - this->_labelShouldRetain->setAlignment(kTextAlignmentCenter); + this->_labelShouldRetain->setAlignment(Label::HAlignment::CENTER); break; case RightAlign: - this->_labelShouldRetain->setAlignment(kTextAlignmentRight); + this->_labelShouldRetain->setAlignment(Label::HAlignment::RIGHT); break; default: @@ -1266,9 +1266,9 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::Object *sender) this->snapArrowsToEdge(); } -void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *pTouches, cocos2d::Event *pEvent) +void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *touches, cocos2d::Event *event) { - Touch *touch = (Touch *)pTouches->anyObject(); + Touch *touch = (Touch *)touches->anyObject(); Point location = touch->getLocationInView(); if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location)) @@ -1278,7 +1278,7 @@ void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *pTouches, cocos2 } } -void BitmapFontMultiLineAlignment::ccTouchesEnded(cocos2d::Set *pTouches, cocos2d::Event *pEvent) +void BitmapFontMultiLineAlignment::ccTouchesEnded(cocos2d::Set *touches, cocos2d::Event *event) { _drag = false; this->snapArrowsToEdge(); @@ -1286,14 +1286,14 @@ void BitmapFontMultiLineAlignment::ccTouchesEnded(cocos2d::Set *pTouches, cocos2 this->_arrowsBarShouldRetain->setVisible(false); } -void BitmapFontMultiLineAlignment::ccTouchesMoved(cocos2d::Set *pTouches, cocos2d::Event *pEvent) +void BitmapFontMultiLineAlignment::ccTouchesMoved(cocos2d::Set *touches, cocos2d::Event *event) { if (! _drag) { return; } - Touch *touch = (Touch *)pTouches->anyObject(); + Touch *touch = (Touch *)touches->anyObject(); Point location = touch->getLocationInView(); Size winSize = Director::getInstance()->getWinSize(); @@ -1348,11 +1348,11 @@ BMFontOneAtlas::BMFontOneAtlas() { Size s = Director::getInstance()->getWinSize(); - auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point::ZERO); + auto label1 = LabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kLabelAutomaticWidth, Label::HAlignment::LEFT, Point::ZERO); addChild(label1); label1->setPosition(Point(s.width/2, s.height/3*2)); - auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, kTextAlignmentLeft, Point(0, 128)); + auto label2 = LabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kLabelAutomaticWidth, Label::HAlignment::LEFT, Point(0, 128)); addChild(label2); label2->setPosition(Point(s.width/2, s.height/3*1)); } @@ -1379,7 +1379,7 @@ BMFontUnicode::BMFontUnicode() Size s = Director::getInstance()->getWinSize(); - auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kTextAlignmentLeft); + auto label1 = LabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, Label::HAlignment::LEFT); addChild(label1); label1->setPosition(Point(s.width/2, s.height/5*4)); @@ -1611,6 +1611,6 @@ void LabelBMFontBounds::draw() Point(labelSize.width + origin.width, labelSize.height + origin.height), Point(origin.width, labelSize.height + origin.height) }; - ccDrawPoly(vertices, 4, true); + DrawPrimitives::drawPoly(vertices, 4, true); } diff --git a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h index df57d27b7d..dec68cacaf 100644 --- a/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h +++ b/samples/Cpp/TestCpp/Classes/LabelTest/LabelTest.h @@ -16,9 +16,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; @@ -181,18 +181,18 @@ public: virtual std::string title(); virtual std::string subtitle(); private: - void setAlignmentLeft(Object* pSender); - void setAlignmentCenter(Object* pSender); - void setAlignmentRight(Object* pSender); - void setAlignmentTop(Object* pSender); - void setAlignmentMiddle(Object* pSender); - void setAlignmentBottom(Object* pSender); + void setAlignmentLeft(Object* sender); + void setAlignmentCenter(Object* sender); + void setAlignmentRight(Object* sender); + void setAlignmentTop(Object* sender); + void setAlignmentMiddle(Object* sender); + void setAlignmentBottom(Object* sender); void updateAlignment(); const char* getCurrentAlignment(); private: LabelTTF* _plabel; - TextAlignment _horizAlign; - VerticalTextAlignment _vertAlign; + Label::HAlignment _horizAlign; + Label::VAlignment _vertAlign; }; class LabelTTFMultiline : public AtlasDemo @@ -227,9 +227,9 @@ public: virtual std::string subtitle(); void stringChanged(Object *sender); void alignmentChanged(Object *sender); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesEnded(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); public: LabelBMFont *_labelShouldRetain; diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index 1cf2d902a6..ea266cc6b7 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -89,7 +89,7 @@ void LayerTest::onEnter() BaseTest::onEnter(); } -void LayerTest::restartCallback(Object* pSender) +void LayerTest::restartCallback(Object* sender) { Scene* s = new LayerTestScene(); s->addChild(restartAction()); @@ -98,7 +98,7 @@ void LayerTest::restartCallback(Object* pSender) s->release(); } -void LayerTest::nextCallback(Object* pSender) +void LayerTest::nextCallback(Object* sender) { Scene* s = new LayerTestScene(); s->addChild( nextAction() ); @@ -106,7 +106,7 @@ void LayerTest::nextCallback(Object* pSender) s->release(); } -void LayerTest::backCallback(Object* pSender) +void LayerTest::backCallback(Object* sender) { Scene* s = new LayerTestScene(); s->addChild( backAction() ); @@ -470,22 +470,22 @@ void LayerTest1::updateSize(Point &touchLocation) l->setContentSize( newSize ); } -void LayerTest1::ccTouchesBegan(Set *pTouches, Event *pEvent) +void LayerTest1::ccTouchesBegan(Set *touches, Event *event) { - ccTouchesMoved(pTouches, pEvent); + ccTouchesMoved(touches, event); } -void LayerTest1::ccTouchesMoved(Set *pTouches, Event *pEvent) +void LayerTest1::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Point touchLocation = touch->getLocation(); updateSize(touchLocation); } -void LayerTest1::ccTouchesEnded(Set *pTouches, Event *pEvent) +void LayerTest1::ccTouchesEnded(Set *touches, Event *event) { - ccTouchesMoved(pTouches, pEvent); + ccTouchesMoved(touches, event); } std::string LayerTest1::title() @@ -858,10 +858,7 @@ LayerExtendedBlendOpacityTest::LayerExtendedBlendOpacityTest() layer3->setEndColor(Color3B(255, 0, 255)); layer3->setStartOpacity(255); layer3->setEndOpacity(255); - BlendFunc blend; - blend.src = GL_SRC_ALPHA; - blend.dst = GL_ONE_MINUS_SRC_ALPHA; - layer3->setBlendFunc(blend); + layer3->setBlendFunc( BlendFunc::ALPHA_NON_PREMULTIPLIED ); addChild(layer3); } diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h index 7dd3186959..eba08c1dab 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h @@ -18,9 +18,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class LayerTestCascadingOpacityA : public LayerTest @@ -74,9 +74,9 @@ public: void updateSize(Point &touchLocation); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); + virtual void ccTouchesEnded(Set *touches, Event *event); }; class LayerTest2 : public LayerTest diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index 835349b3b2..444ced5b9e 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -26,8 +26,8 @@ enum { MenuLayerMainMenu::MenuLayerMainMenu() { setTouchEnabled(true); - setTouchPriority(kMenuHandlerPriority + 1); - setTouchMode(kTouchesOneByOne); + setTouchPriority(Menu::HANDLER_PRIORITY + 1); + setTouchMode(Touch::DispatchMode::ONE_BY_ONE); // Font Item Sprite* spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23)); @@ -114,20 +114,20 @@ MenuLayerMainMenu::MenuLayerMainMenu() menu->setPosition(Point(s.width/2, s.height/2)); } -bool MenuLayerMainMenu::ccTouchBegan(Touch *touch, Event * pEvent) +bool MenuLayerMainMenu::ccTouchBegan(Touch *touch, Event * event) { return true; } -void MenuLayerMainMenu::ccTouchEnded(Touch *touch, Event * pEvent) +void MenuLayerMainMenu::ccTouchEnded(Touch *touch, Event * event) { } -void MenuLayerMainMenu::ccTouchCancelled(Touch *touch, Event * pEvent) +void MenuLayerMainMenu::ccTouchCancelled(Touch *touch, Event * event) { } -void MenuLayerMainMenu::ccTouchMoved(Touch *touch, Event * pEvent) +void MenuLayerMainMenu::ccTouchMoved(Touch *touch, Event * event) { } @@ -149,7 +149,7 @@ void MenuLayerMainMenu::menuCallbackConfig(Object* sender) void MenuLayerMainMenu::allowTouches(float dt) { Director* director = Director::getInstance(); - director->getTouchDispatcher()->setPriority(kMenuHandlerPriority+1, this); + director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY+1, this); unscheduleAllSelectors(); log("TOUCHES ALLOWED AGAIN"); } @@ -158,7 +158,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(Object* sender) { // hijack all touch events for 5 seconds Director* director = Director::getInstance(); - director->getTouchDispatcher()->setPriority(kMenuHandlerPriority-1, this); + director->getTouchDispatcher()->setPriority(Menu::HANDLER_PRIORITY-1, this); schedule(schedule_selector(MenuLayerMainMenu::allowTouches), 5.0f); log("TOUCHES DISABLED FOR 5 SECONDS"); } @@ -168,7 +168,7 @@ void MenuLayerMainMenu::menuCallback2(Object* sender) static_cast(_parent)->switchTo(2); } -void MenuLayerMainMenu::menuCallbackPriorityTest(Object* pSender) +void MenuLayerMainMenu::menuCallbackPriorityTest(Object* sender) { static_cast(_parent)->switchTo(4); } @@ -491,10 +491,10 @@ MenuLayerPriorityTest::MenuLayerPriorityTest() MenuItemFont::setFontSize(48); item1 = MenuItemFont::create("Toggle priority", [&](Object *sender) { if( _priority) { - _menu2->setHandlerPriority(kMenuHandlerPriority + 20); + _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY + 20); _priority = false; } else { - _menu2->setHandlerPriority(kMenuHandlerPriority - 20); + _menu2->setHandlerPriority(Menu::HANDLER_PRIORITY - 20); _priority = true; } }); @@ -509,7 +509,7 @@ MenuLayerPriorityTest::~MenuLayerPriorityTest() } -void MenuLayerPriorityTest::menuCallback(Object* pSender) +void MenuLayerPriorityTest::menuCallback(Object* sender) { static_cast(_parent)->switchTo(0); // [[Director sharedDirector] poscene]; @@ -590,12 +590,12 @@ void RemoveMenuItemWhenMove::registerWithTouchDispatcher(void) Director::getInstance()->getTouchDispatcher()->addTargetedDelegate(this, -129, false); } -bool RemoveMenuItemWhenMove::ccTouchBegan(Touch *pTouch, Event *pEvent) +bool RemoveMenuItemWhenMove::ccTouchBegan(Touch *touch, Event *event) { return true; } -void RemoveMenuItemWhenMove::ccTouchMoved(Touch *pTouch, Event *pEvent) +void RemoveMenuItemWhenMove::ccTouchMoved(Touch *touch, Event *event) { if (item) { diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h index 1a2600b0ff..1f227402f4 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h @@ -14,19 +14,19 @@ public: ~MenuLayerMainMenu(); public: - virtual bool ccTouchBegan(Touch *touch, Event * pEvent); - virtual void ccTouchEnded(Touch *touch, Event * pEvent); - virtual void ccTouchCancelled(Touch *touch, Event * pEvent); - virtual void ccTouchMoved(Touch *touch, Event * pEvent); + virtual bool ccTouchBegan(Touch *touch, Event * event); + virtual void ccTouchEnded(Touch *touch, Event * event); + virtual void ccTouchCancelled(Touch *touch, Event * event); + virtual void ccTouchMoved(Touch *touch, Event * event); void allowTouches(float dt); - void menuCallback(Object* pSender); - void menuCallbackConfig(Object* pSender); - void menuCallbackDisabled(Object* pSender); - void menuCallback2(Object* pSender); - void menuCallbackPriorityTest(Object* pSender); + void menuCallback(Object* sender); + void menuCallbackConfig(Object* sender); + void menuCallbackDisabled(Object* sender); + void menuCallback2(Object* sender); + void menuCallbackPriorityTest(Object* sender); void menuCallbackBugsTest(Object *pSender); - void onQuit(Object* pSender); + void onQuit(Object* sender); void menuMovingCallback(Object *pSender); //CREATE_NODE(MenuLayer1); @@ -46,9 +46,9 @@ public: ~MenuLayer2(); public: - void menuCallback(Object* pSender); - void menuCallbackOpacity(Object* pSender); - void menuCallbackAlign(Object* pSender); + void menuCallback(Object* sender); + void menuCallbackOpacity(Object* sender); + void menuCallbackAlign(Object* sender); //CREATE_NODE(MenuLayer2); }; @@ -72,8 +72,8 @@ public: ~MenuLayer4(); public: - void menuCallback(Object* pSender); - void backCallback(Object* pSender); + void menuCallback(Object* sender); + void backCallback(Object* sender); //CREATE_NODE(MenuLayer4); }; @@ -84,7 +84,7 @@ public: MenuLayerPriorityTest(); ~MenuLayerPriorityTest(); - void menuCallback(Object* pSender); + void menuCallback(Object* sender); private: Menu* _menu1; Menu* _menu2; @@ -108,8 +108,8 @@ public: ~RemoveMenuItemWhenMove(); virtual void registerWithTouchDispatcher(void); - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); - virtual void ccTouchMoved(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); + virtual void ccTouchMoved(Touch *touch, Event *event); void goBack(Object *pSender); diff --git a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp index b8a2019e55..54aaf4db86 100644 --- a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.cpp @@ -234,7 +234,7 @@ void MotionStreakTest::modeCallback(Object *pSender) streak->setFastMode(! fastMode); } -void MotionStreakTest::restartCallback(Object* pSender) +void MotionStreakTest::restartCallback(Object* sender) { Scene* s = new MotionStreakTestScene();//CCScene::create(); s->addChild(restartMotionAction()); @@ -243,7 +243,7 @@ void MotionStreakTest::restartCallback(Object* pSender) s->release(); } -void MotionStreakTest::nextCallback(Object* pSender) +void MotionStreakTest::nextCallback(Object* sender) { Scene* s = new MotionStreakTestScene();//CCScene::create(); s->addChild( nextMotionAction() ); @@ -251,7 +251,7 @@ void MotionStreakTest::nextCallback(Object* pSender) s->release(); } -void MotionStreakTest::backCallback(Object* pSender) +void MotionStreakTest::backCallback(Object* sender) { Scene* s = new MotionStreakTestScene;//CCScene::create(); s->addChild( backMotionAction() ); diff --git a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.h b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.h index eb4adfd0d5..84ee4437aa 100644 --- a/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.h +++ b/samples/Cpp/TestCpp/Classes/MotionStreakTest/MotionStreakTest.h @@ -17,10 +17,10 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); - void modeCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); + void modeCallback(Object* sender); protected: MotionStreak *streak; }; diff --git a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp index c58e0944f2..0a2b9875cb 100644 --- a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.cpp @@ -14,18 +14,18 @@ class TouchPoint : public Node public: TouchPoint() { - setShaderProgram(ShaderCache::getInstance()->programForKey(kShader_PositionTextureColor)); + setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } virtual void draw() { - ccDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255); + DrawPrimitives::setDrawColor4B(_touchColor.r, _touchColor.g, _touchColor.b, 255); glLineWidth(10); - ccDrawLine( Point(0, _touchPoint.y), Point(getContentSize().width, _touchPoint.y) ); - ccDrawLine( Point(_touchPoint.x, 0), Point(_touchPoint.x, getContentSize().height) ); + DrawPrimitives::drawLine( Point(0, _touchPoint.y), Point(getContentSize().width, _touchPoint.y) ); + DrawPrimitives::drawLine( Point(_touchPoint.x, 0), Point(_touchPoint.x, getContentSize().height) ); glLineWidth(1); - ccPointSize(30); - ccDrawPoint(_touchPoint); + DrawPrimitives::setPointSize(30); + DrawPrimitives::drawPoint(_touchPoint); } void setTouchPos(const Point& pt) @@ -69,50 +69,50 @@ void MutiTouchTestLayer::registerWithTouchDispatcher(void) Director::getInstance()->getTouchDispatcher()->addStandardDelegate(this, 0); } -void MutiTouchTestLayer::ccTouchesBegan(Set *touches, Event *pEvent) +void MutiTouchTestLayer::ccTouchesBegan(Set *touches, Event *event) { for ( auto &item: *touches ) { - Touch* pTouch = (Touch*)item; - TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this); - Point location = pTouch->getLocation(); + Touch* touch = static_cast(item); + TouchPoint* touchPoint = TouchPoint::touchPointWithParent(this); + Point location = touch->getLocation(); - pTouchPoint->setTouchPos(location); - pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]); + touchPoint->setTouchPos(location); + touchPoint->setTouchColor(s_TouchColors[touch->getID()]); - addChild(pTouchPoint); - s_dic.setObject(pTouchPoint, pTouch->getID()); + addChild(touchPoint); + s_dic.setObject(touchPoint, touch->getID()); } } -void MutiTouchTestLayer::ccTouchesMoved(Set *touches, Event *pEvent) +void MutiTouchTestLayer::ccTouchesMoved(Set *touches, Event *event) { for( auto &item: *touches) { - Touch* pTouch = (Touch*)item; - TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); - Point location = pTouch->getLocation(); + Touch* touch = static_cast(item); + TouchPoint* pTP = static_cast(s_dic.objectForKey(touch->getID())); + Point location = touch->getLocation(); pTP->setTouchPos(location); } } -void MutiTouchTestLayer::ccTouchesEnded(Set *touches, Event *pEvent) +void MutiTouchTestLayer::ccTouchesEnded(Set *touches, Event *event) { for ( auto &item: *touches ) { - Touch* pTouch = (Touch*)item; - TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID()); + Touch* touch = static_cast(item); + TouchPoint* pTP = static_cast(s_dic.objectForKey(touch->getID())); removeChild(pTP, true); - s_dic.removeObjectForKey(pTouch->getID()); + s_dic.removeObjectForKey(touch->getID()); } } -void MutiTouchTestLayer::ccTouchesCancelled(Set *pTouches, Event *pEvent) +void MutiTouchTestLayer::ccTouchesCancelled(Set *touches, Event *event) { - ccTouchesEnded(pTouches, pEvent); + ccTouchesEnded(touches, event); } void MutiTouchTestScene::runThisTest() diff --git a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.h b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.h index d6d8e263b1..0f3190c6ce 100644 --- a/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.h +++ b/samples/Cpp/TestCpp/Classes/MutiTouchTest/MutiTouchTest.h @@ -9,10 +9,10 @@ public: bool init(); virtual void registerWithTouchDispatcher(void); - virtual void ccTouchesBegan(cocos2d::Set *pTouches, cocos2d::Event *pEvent); - virtual void ccTouchesMoved(cocos2d::Set *pTouches, cocos2d::Event *pEvent); - virtual void ccTouchesEnded(cocos2d::Set *pTouches, cocos2d::Event *pEvent); - virtual void ccTouchesCancelled(cocos2d::Set *pTouches, cocos2d::Event *pEvent); + virtual void ccTouchesBegan(cocos2d::Set *touches, cocos2d::Event *event); + virtual void ccTouchesMoved(cocos2d::Set *touches, cocos2d::Event *event); + virtual void ccTouchesEnded(cocos2d::Set *touches, cocos2d::Event *event); + virtual void ccTouchesCancelled(cocos2d::Set *touches, cocos2d::Event *event); CREATE_FUNC(MutiTouchTestLayer) }; diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp index c16bee5a37..d48313c472 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.cpp @@ -103,7 +103,7 @@ void TestCocosNodeDemo::onEnter() BaseTest::onEnter(); } -void TestCocosNodeDemo::restartCallback(Object* pSender) +void TestCocosNodeDemo::restartCallback(Object* sender) { Scene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild(restartCocosNodeAction()); @@ -112,7 +112,7 @@ void TestCocosNodeDemo::restartCallback(Object* pSender) s->release(); } -void TestCocosNodeDemo::nextCallback(Object* pSender) +void TestCocosNodeDemo::nextCallback(Object* sender) { Scene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild( nextCocosNodeAction() ); @@ -120,7 +120,7 @@ void TestCocosNodeDemo::nextCallback(Object* pSender) s->release(); } -void TestCocosNodeDemo::backCallback(Object* pSender) +void TestCocosNodeDemo::backCallback(Object* sender) { Scene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild( backCocosNodeAction() ); @@ -512,12 +512,12 @@ std::string NodeToWorld::title() void CameraOrbitTest::onEnter() { TestCocosNodeDemo::onEnter(); - Director::getInstance()->setProjection(kDirectorProjection3D); + Director::getInstance()->setProjection(Director::Projection::_3D); } void CameraOrbitTest::onExit() { - Director::getInstance()->setProjection(kDirectorProjection2D); + Director::getInstance()->setProjection(Director::Projection::_2D); TestCocosNodeDemo::onExit(); } @@ -584,12 +584,12 @@ void CameraZoomTest::onEnter() { TestCocosNodeDemo::onEnter(); - Director::getInstance()->setProjection(kDirectorProjection3D); + Director::getInstance()->setProjection(Director::Projection::_3D); } void CameraZoomTest::onExit() { - Director::getInstance()->setProjection(kDirectorProjection2D); + Director::getInstance()->setProjection(Director::Projection::_2D); TestCocosNodeDemo::onExit(); } @@ -797,8 +797,7 @@ NodeOpaqueTest::NodeOpaqueTest() for (int i = 0; i < 50; i++) { background = Sprite::create("Images/background1.png"); - BlendFunc blendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}; - background->setBlendFunc(blendFunc); + background->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); background->setAnchorPoint(Point::ZERO); addChild(background); } @@ -823,7 +822,7 @@ NodeNonOpaqueTest::NodeNonOpaqueTest() for (int i = 0; i < 50; i++) { background = Sprite::create("Images/background1.jpg"); - background->setBlendFunc(BlendFunc::BLEND_FUNC_DISABLE); + background->setBlendFunc(BlendFunc::DISABLE); background->setAnchorPoint(Point::ZERO); addChild(background); } diff --git a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h index ff220a6bff..a507f60599 100644 --- a/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h +++ b/samples/Cpp/TestCpp/Classes/NodeTest/NodeTest.h @@ -15,9 +15,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class Test2 : public TestCocosNodeDemo diff --git a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp index 0ede68f9cf..31d9fca350 100644 --- a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.cpp @@ -132,9 +132,9 @@ Parallax2::Parallax2() addChild(voidNode, 0, kTagNode); } -void Parallax2::ccTouchesMoved(Set *pTouches, Event *pEvent) +void Parallax2::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Point diff = touch->getDelta(); Node* node = getChildByTag(kTagNode); @@ -219,7 +219,7 @@ void ParallaxDemo::onEnter() BaseTest::onEnter(); } -void ParallaxDemo::restartCallback(Object* pSender) +void ParallaxDemo::restartCallback(Object* sender) { Scene* s = new ParallaxTestScene(); s->addChild(restartParallaxAction()); @@ -228,7 +228,7 @@ void ParallaxDemo::restartCallback(Object* pSender) s->release(); } -void ParallaxDemo::nextCallback(Object* pSender) +void ParallaxDemo::nextCallback(Object* sender) { Scene* s = new ParallaxTestScene(); s->addChild( nextParallaxAction() ); @@ -236,7 +236,7 @@ void ParallaxDemo::nextCallback(Object* pSender) s->release(); } -void ParallaxDemo::backCallback(Object* pSender) +void ParallaxDemo::backCallback(Object* sender) { Scene* s = new ParallaxTestScene(); s->addChild( backParallaxAction() ); diff --git a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.h b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.h index 24cd640da0..1dded76eb7 100644 --- a/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.h +++ b/samples/Cpp/TestCpp/Classes/ParallaxTest/ParallaxTest.h @@ -16,9 +16,9 @@ public: virtual std::string title(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class Parallax1 : public ParallaxDemo @@ -43,7 +43,7 @@ protected: public: Parallax2(); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesMoved(Set *touches, Event *event); virtual std::string title(); }; diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp index 4236714244..7347ab5ce2 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.cpp @@ -1,11 +1,5 @@ #include "ParticleTest.h" -// #include "CCActionInterval.h" -// #include "CCMenu.h" -// #include "CCLabelTTF.h" -// #include "CCLabelAtlas.h" -// #include "touch_dispatcher/CCTouchDispatcher.h" #include "../testResource.h" -/*#include "support/CCPointExtension.h"*/ enum { kTagParticleCount = 1, @@ -200,7 +194,7 @@ void DemoBigFlower::onEnter() // size, in pixels _emitter->setStartSize(80.0f); _emitter->setStartSizeVar(40.0f); - _emitter->setEndSize(kParticleStartSizeEqualToEndSize); + _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); @@ -285,7 +279,7 @@ void DemoRotFlower::onEnter() // size, in pixels _emitter->setStartSize(30.0f); _emitter->setStartSizeVar(00.0f); - _emitter->setEndSize(kParticleStartSizeEqualToEndSize); + _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles()/_emitter->getLife()); @@ -650,10 +644,10 @@ void RadiusMode1::onEnter() _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); // duration - _emitter->setDuration(kParticleDurationInfinity); + _emitter->setDuration(ParticleSystem::DURATION_INFINITY); // radius mode - _emitter->setEmitterMode(kParticleModeRadius); + _emitter->setEmitterMode(ParticleSystem::Mode::RADIUS); // radius mode: start and end radius in pixels _emitter->setStartRadius(0); @@ -701,7 +695,7 @@ void RadiusMode1::onEnter() // size, in pixels _emitter->setStartSize(32); _emitter->setStartSizeVar(0); - _emitter->setEndSize(kParticleStartSizeEqualToEndSize); + _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); @@ -734,15 +728,15 @@ void RadiusMode2::onEnter() _emitter->setTexture(TextureCache::getInstance()->addImage("Images/stars-grayscale.png")); // duration - _emitter->setDuration(kParticleDurationInfinity); + _emitter->setDuration(ParticleSystem::DURATION_INFINITY); // radius mode - _emitter->setEmitterMode(kParticleModeRadius); + _emitter->setEmitterMode(ParticleSystem::Mode::RADIUS); // radius mode: start and end radius in pixels _emitter->setStartRadius(100); _emitter->setStartRadiusVar(0); - _emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius); + _emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS); _emitter->setEndRadiusVar(0); // radius mode: degrees per second @@ -785,7 +779,7 @@ void RadiusMode2::onEnter() // size, in pixels _emitter->setStartSize(32); _emitter->setStartSizeVar(0); - _emitter->setEndSize(kParticleStartSizeEqualToEndSize); + _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); @@ -818,15 +812,15 @@ void Issue704::onEnter() _emitter->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // duration - _emitter->setDuration(kParticleDurationInfinity); + _emitter->setDuration(ParticleSystem::DURATION_INFINITY); // radius mode - _emitter->setEmitterMode(kParticleModeRadius); + _emitter->setEmitterMode(ParticleSystem::Mode::RADIUS); // radius mode: start and end radius in pixels _emitter->setStartRadius(50); _emitter->setStartRadiusVar(0); - _emitter->setEndRadius(kParticleStartRadiusEqualToEndRadius); + _emitter->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS); _emitter->setEndRadiusVar(0); // radius mode: degrees per second @@ -869,7 +863,7 @@ void Issue704::onEnter() // size, in pixels _emitter->setStartSize(16); _emitter->setStartSizeVar(0); - _emitter->setEndSize(kParticleStartSizeEqualToEndSize); + _emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second _emitter->setEmissionRate(_emitter->getTotalParticles() / _emitter->getLife()); @@ -1120,19 +1114,19 @@ std::string ParticleDemo::subtitle() return "No titile"; } -void ParticleDemo::ccTouchesBegan(Set *pTouches, Event *pEvent) +void ParticleDemo::ccTouchesBegan(Set *touches, Event *event) { - ccTouchesEnded(pTouches, pEvent); + ccTouchesEnded(touches, event); } -void ParticleDemo::ccTouchesMoved(Set *pTouches, Event *pEvent) +void ParticleDemo::ccTouchesMoved(Set *touches, Event *event) { - return ccTouchesEnded(pTouches, pEvent); + return ccTouchesEnded(touches, event); } -void ParticleDemo::ccTouchesEnded(Set *pTouches, Event *pEvent) +void ParticleDemo::ccTouchesEnded(Set *touches, Event *event) { - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Point location = touch->getLocation(); @@ -1159,20 +1153,20 @@ void ParticleDemo::update(float dt) } } -void ParticleDemo::toggleCallback(Object* pSender) +void ParticleDemo::toggleCallback(Object* sender) { if (_emitter != NULL) { - if( _emitter->getPositionType() == kPositionTypeGrouped ) - _emitter->setPositionType( kPositionTypeFree ); - else if (_emitter->getPositionType() == kPositionTypeFree) - _emitter->setPositionType(kPositionTypeRelative); - else if (_emitter->getPositionType() == kPositionTypeRelative) - _emitter->setPositionType( kPositionTypeGrouped ); + if (_emitter->getPositionType() == ParticleSystem::PositionType::GROUPED) + _emitter->setPositionType(ParticleSystem::PositionType::FREE); + else if (_emitter->getPositionType() == ParticleSystem::PositionType::FREE) + _emitter->setPositionType(ParticleSystem::PositionType::RELATIVE); + else if (_emitter->getPositionType() == ParticleSystem::PositionType::RELATIVE) + _emitter->setPositionType(ParticleSystem::PositionType::GROUPED ); } } -void ParticleDemo::restartCallback(Object* pSender) +void ParticleDemo::restartCallback(Object* sender) { if (_emitter != NULL) { @@ -1180,7 +1174,7 @@ void ParticleDemo::restartCallback(Object* pSender) } } -void ParticleDemo::nextCallback(Object* pSender) +void ParticleDemo::nextCallback(Object* sender) { Scene* s = new ParticleTestScene(); s->addChild( nextParticleAction() ); @@ -1188,7 +1182,7 @@ void ParticleDemo::nextCallback(Object* pSender) s->release(); } -void ParticleDemo::backCallback(Object* pSender) +void ParticleDemo::backCallback(Object* sender) { Scene* s = new ParticleTestScene(); s->addChild( backParticleAction() ); @@ -1403,10 +1397,10 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) setBlendAdditive(false); // duration - setDuration(kParticleDurationInfinity); + setDuration(ParticleSystem::DURATION_INFINITY); // Gravity Mode - setEmitterMode(kParticleModeGravity); + setEmitterMode(ParticleSystem::Mode::GRAVITY); // Gravity Mode: gravity setGravity(Point(0,0)); @@ -1436,7 +1430,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) // size, in pixels setStartSize(25.0f); setStartSizeVar(0); - setEndSize(kParticleStartSizeEqualToEndSize); + setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per seconds setEmissionRate(getTotalParticles()/getLife()); @@ -1513,7 +1507,7 @@ void MultipleParticleSystems::onEnter() particleSystem->setPosition(Point(i*50 ,i*50)); - particleSystem->setPositionType(kPositionTypeGrouped); + particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); addChild(particleSystem); } @@ -1570,7 +1564,7 @@ void MultipleParticleSystemsBatched::onEnter() ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/SpinningPeas.plist"); - particleSystem->setPositionType(kPositionTypeGrouped); + particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setPosition(Point(i*50 ,i*50)); batchNode->setTexture(particleSystem->getTexture()); @@ -1633,7 +1627,7 @@ void AddAndDeleteParticleSystems::onEnter() ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); _batchNode->setTexture(particleSystem->getTexture()); - particleSystem->setPositionType(kPositionTypeGrouped); + particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setTotalParticles(200); particleSystem->setPosition(Point(i*15 +100,i*15+100)); @@ -1660,7 +1654,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) ParticleSystemQuad *particleSystem = ParticleSystemQuad::create("Particles/Spiral.plist"); //add new - particleSystem->setPositionType(kPositionTypeGrouped); + particleSystem->setPositionType(ParticleSystem::PositionType::GROUPED); particleSystem->setTotalParticles(200); particleSystem->setPosition(Point(rand() % 300 ,rand() % 400)); @@ -1724,15 +1718,15 @@ void ReorderParticleSystems::onEnter() particleSystem->setTexture(_batchNode->getTexture()); // duration - particleSystem->setDuration(kParticleDurationInfinity); + particleSystem->setDuration(ParticleSystem::DURATION_INFINITY); // radius mode - particleSystem->setEmitterMode(kParticleModeRadius); + particleSystem->setEmitterMode(ParticleSystem::Mode::RADIUS); // radius mode: 100 pixels from center particleSystem->setStartRadius(100); particleSystem->setStartRadiusVar(0); - particleSystem->setEndRadius(kParticleStartRadiusEqualToEndRadius); + particleSystem->setEndRadius(ParticleSystem::START_RADIUS_EQUAL_TO_END_RADIUS); particleSystem->setEndRadiusVar(0); // not used when start == end // radius mode: degrees per second @@ -1776,7 +1770,7 @@ void ReorderParticleSystems::onEnter() // size, in pixels particleSystem->setStartSize(32); particleSystem->setStartSizeVar(0); - particleSystem->setEndSize(kParticleStartSizeEqualToEndSize); + particleSystem->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE); // emits per second particleSystem->setEmissionRate(particleSystem->getTotalParticles()/particleSystem->getLife()); @@ -1787,7 +1781,7 @@ void ReorderParticleSystems::onEnter() _batchNode->addChild(particleSystem); - particleSystem->setPositionType(kPositionTypeFree); + particleSystem->setPositionType(ParticleSystem::PositionType::FREE); particleSystem->release(); @@ -1864,8 +1858,7 @@ void PremultipliedAlphaTest::onEnter() //this->emitter.blendFunc = (BlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors) - BlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; - _emitter->setBlendFunc(tBlendFunc); + _emitter->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); CCASSERT(_emitter->isOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h index b95730891c..65e6478d5a 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h @@ -28,14 +28,14 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); - void toggleCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); + void toggleCallback(Object* sender); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); - virtual void ccTouchesEnded(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); + virtual void ccTouchesEnded(Set *touches, Event *event); virtual void update(float dt); void setEmitterPosition(); diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp index a70b5c1d08..d2670f69d6 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.cpp @@ -202,17 +202,17 @@ void ParticleMainScene::createParticleSystem() switch( subtestNumber) { case 1: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 2: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 3: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; @@ -222,17 +222,17 @@ void ParticleMainScene::createParticleSystem() // particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); // break; case 4: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 5: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; case 6: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); particleSystem->initWithTotalParticles(quantityParticles); particleSystem->setTexture(TextureCache::getInstance()->addImage("Images/fire.png")); break; @@ -252,15 +252,15 @@ void ParticleMainScene::createParticleSystem() doTest(); // restore the default pixel format - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); } -void ParticleMainScene::testNCallback(Object* pSender) +void ParticleMainScene::testNCallback(Object* sender) { - subtestNumber = ((Node*)pSender)->getTag(); + subtestNumber = static_cast(sender)->getTag(); - ParticleMenuLayer* menu = (ParticleMenuLayer*)getChildByTag(kTagMenuLayer); - menu->restartCallback(pSender); + auto menu = static_cast( getChildByTag(kTagMenuLayer) ); + menu->restartCallback(sender); } void ParticleMainScene::updateQuantityLabel() diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.h index 6dad0146f0..2412ba975f 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceParticleTest.h @@ -18,7 +18,7 @@ public: void step(float dt); void createParticleSystem(); - void testNCallback(Object* pSender); + void testNCallback(Object* sender); void updateQuantityLabel(); int getSubTestNum() { return subtestNumber; } int getParticlesNum() { return quantityParticles; } diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp index 1777c1aa72..8fc2774af8 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.cpp @@ -67,36 +67,36 @@ void SubTest::initWithSubTest(int nSubTest, Node* p) break; /// case 2: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; case 3: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); batchNode = SpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; /// case 5: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; case 6: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); batchNode = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; /// case 8: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; case 9: - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); batchNode = SpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; @@ -110,13 +110,13 @@ void SubTest::initWithSubTest(int nSubTest, Node* p) batchNode->retain(); } - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); } Sprite* SubTest::createSpriteWithTag(int tag) { // create - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); Sprite* sprite = NULL; switch (subtestNumber) @@ -194,7 +194,7 @@ Sprite* SubTest::createSpriteWithTag(int tag) break; } - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); return sprite; } @@ -354,11 +354,11 @@ SpriteMainScene::~SpriteMainScene() } } -void SpriteMainScene::testNCallback(Object* pSender) +void SpriteMainScene::testNCallback(Object* sender) { - subtestNumber = ((MenuItemFont*) pSender)->getTag(); - SpriteMenuLayer* menu = (SpriteMenuLayer*)getChildByTag(kTagMenuLayer); - menu->restartCallback(pSender); + subtestNumber = static_cast(sender)->getTag(); + auto menu = static_cast( getChildByTag(kTagMenuLayer) ); + menu->restartCallback(sender); } void SpriteMainScene::updateNodes() @@ -374,7 +374,7 @@ void SpriteMainScene::updateNodes() } } -void SpriteMainScene::onIncrease(Object* pSender) +void SpriteMainScene::onIncrease(Object* sender) { if( quantityNodes >= kMaxNodes) return; @@ -389,7 +389,7 @@ void SpriteMainScene::onIncrease(Object* pSender) updateNodes(); } -void SpriteMainScene::onDecrease(Object* pSender) +void SpriteMainScene::onDecrease(Object* sender) { if( quantityNodes <= 0 ) return; diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.h index 9fd16220dc..da7f009ec3 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceSpriteTest.h @@ -37,9 +37,9 @@ public: void initWithSubTest(int nSubTest, int nNodes); void updateNodes(); - void testNCallback(Object* pSender); - void onIncrease(Object* pSender); - void onDecrease(Object* pSender); + void testNCallback(Object* sender); + void onIncrease(Object* sender); + void onDecrease(Object* sender); virtual void doTest(Sprite* sprite) = 0; diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp index 4f852ad552..6321671805 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.cpp @@ -91,7 +91,7 @@ void PerformBasicLayer::onEnter() addChild(menu); } -void PerformBasicLayer::toMainLayer(Object* pSender) +void PerformBasicLayer::toMainLayer(Object* sender) { PerformanceTestScene* scene = new PerformanceTestScene(); scene->runThisTest(); @@ -99,12 +99,12 @@ void PerformBasicLayer::toMainLayer(Object* pSender) scene->release(); } -void PerformBasicLayer::restartCallback(Object* pSender) +void PerformBasicLayer::restartCallback(Object* sender) { showCurrentTest(); } -void PerformBasicLayer::nextCallback(Object* pSender) +void PerformBasicLayer::nextCallback(Object* sender) { _curCase++; _curCase = _curCase % _maxCases; @@ -112,7 +112,7 @@ void PerformBasicLayer::nextCallback(Object* pSender) showCurrentTest(); } -void PerformBasicLayer::backCallback(Object* pSender) +void PerformBasicLayer::backCallback(Object* sender) { _curCase--; if( _curCase < 0 ) diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.h b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.h index 844c148595..95f0d38464 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.h +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTest.h @@ -16,12 +16,12 @@ public: virtual void onEnter(); - virtual void restartCallback(Object* pSender); - virtual void nextCallback(Object* pSender); - virtual void backCallback(Object* pSender); + virtual void restartCallback(Object* sender); + virtual void nextCallback(Object* sender); + virtual void backCallback(Object* sender); virtual void showCurrentTest() = 0; - virtual void toMainLayer(Object* pSender); + virtual void toMainLayer(Object* sender); protected: bool _controlMenuVisible; diff --git a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp index 3abf1fb776..6a0e7a6aee 100644 --- a/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/PerformanceTest/PerformanceTextureTest.cpp @@ -87,7 +87,7 @@ void TextureTest::performTestsPNG(const char* filename) TextureCache *cache = TextureCache::getInstance(); log("RGBA 8888"); - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) @@ -97,7 +97,7 @@ void TextureTest::performTestsPNG(const char* filename) cache->removeTexture(texture); log("RGBA 4444"); - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) @@ -107,7 +107,7 @@ void TextureTest::performTestsPNG(const char* filename) cache->removeTexture(texture); log("RGBA 5551"); - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) @@ -117,7 +117,7 @@ void TextureTest::performTestsPNG(const char* filename) cache->removeTexture(texture); log("RGB 565"); - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565); gettimeofday(&now, NULL); texture = cache->addImage(filename); if( texture ) diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp index 0c9743b3b6..8c93958856 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.cpp @@ -55,7 +55,7 @@ void RenderTextureTest::onEnter() BaseTest::onEnter(); } -void RenderTextureTest::restartCallback(Object* pSender) +void RenderTextureTest::restartCallback(Object* sender) { Scene* s = new RenderTextureScene(); s->addChild(restartTestCase()); @@ -64,7 +64,7 @@ void RenderTextureTest::restartCallback(Object* pSender) s->release(); } -void RenderTextureTest::nextCallback(Object* pSender) +void RenderTextureTest::nextCallback(Object* sender) { Scene* s = new RenderTextureScene(); s->addChild( nextTestCase() ); @@ -72,7 +72,7 @@ void RenderTextureTest::nextCallback(Object* pSender) s->release(); } -void RenderTextureTest::backCallback(Object* pSender) +void RenderTextureTest::backCallback(Object* sender) { Scene* s = new RenderTextureScene(); s->addChild( backTestCase() ); @@ -98,7 +98,7 @@ RenderTextureSave::RenderTextureSave() Size s = Director::getInstance()->getWinSize(); // create a render texture, this is what we are going to draw into - _target = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA8888); + _target = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA8888); _target->retain(); _target->setPosition(Point(s.width / 2, s.height / 2)); @@ -147,8 +147,8 @@ void RenderTextureSave::saveImage(cocos2d::Object *pSender) char jpg[20]; sprintf(jpg, "image-%d.jpg", counter); - _target->saveToFile(png, kImageFormatPNG); - _target->saveToFile(jpg, kImageFormatJPEG); + _target->saveToFile(png, Image::Format::PNG); + _target->saveToFile(jpg, Image::Format::JPG); Image *pImage = _target->newImage(); @@ -243,7 +243,7 @@ RenderTextureIssue937::RenderTextureIssue937() /* A2 & B2 setup */ - RenderTexture *rend = RenderTexture::create(32, 64, kTexture2DPixelFormat_RGBA8888); + RenderTexture *rend = RenderTexture::create(32, 64, Texture2D::PixelFormat::RGBA8888); if (NULL == rend) { @@ -441,7 +441,7 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() Sprite *sprite = Sprite::create("Images/fire.png"); sprite->setPosition(Point(s.width * 0.25f, 0)); sprite->setScale(10); - RenderTexture *rend = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8); + RenderTexture *rend = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444, GL_DEPTH24_STENCIL8); glStencilMask(0xFF); rend->beginWithClear(0, 0, 0, 0, 0, 0); @@ -505,7 +505,7 @@ RenderTextureTargetNode::RenderTextureTargetNode() Size s = Director::getInstance()->getWinSize(); /* Create the render texture */ - RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, kTexture2DPixelFormat_RGBA4444); + RenderTexture *renderTexture = RenderTexture::create(s.width, s.height, Texture2D::PixelFormat::RGBA4444); this->renderTexture = renderTexture; renderTexture->setPosition(Point(s.width/2, s.height/2)); @@ -591,7 +591,7 @@ void SpriteRenderTextureBug::SimpleSprite::draw() { Size s = Director::getInstance()->getWinSize(); rt = new RenderTexture(); - rt->initWithWidthAndHeight(s.width, s.height, kTexture2DPixelFormat_RGBA8888); + rt->initWithWidthAndHeight(s.width, s.height, Texture2D::PixelFormat::RGBA8888); } rt->beginWithClear(0.0f, 0.0f, 0.0f, 1.0f); rt->end(); @@ -599,30 +599,30 @@ void SpriteRenderTextureBug::SimpleSprite::draw() CC_NODE_DRAW_SETUP(); BlendFunc blend = getBlendFunc(); - ccGLBlendFunc(blend.src, blend.dst); + GL::blendFunc(blend.src, blend.dst); - ccGLBindTexture2D(getTexture()->getName()); + GL::bindTexture2D(getTexture()->getName()); // // Attributes // - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex); + GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX); #define kQuadSize sizeof(_quad.bl) long offset = (long)&_quad; // vertex int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } diff --git a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h index e220be3289..e0a3b891dd 100644 --- a/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h +++ b/samples/Cpp/TestCpp/Classes/RenderTextureTest/RenderTextureTest.h @@ -12,9 +12,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class RenderTextureSave : public RenderTextureTest diff --git a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp index 018f9ec325..4c175f8ede 100644 --- a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.cpp @@ -60,7 +60,7 @@ SceneTestLayer1::~SceneTestLayer1() //NSLog(@"SceneTestLayer1 - dealloc"); } -void SceneTestLayer1::onPushScene(Object* pSender) +void SceneTestLayer1::onPushScene(Object* sender) { Scene* scene = new SceneTestScene(); Layer* layer = new SceneTestLayer2(); @@ -70,7 +70,7 @@ void SceneTestLayer1::onPushScene(Object* pSender) layer->release(); } -void SceneTestLayer1::onPushSceneTran(Object* pSender) +void SceneTestLayer1::onPushSceneTran(Object* sender) { Scene* scene = new SceneTestScene(); Layer* layer = new SceneTestLayer2(); @@ -82,7 +82,7 @@ void SceneTestLayer1::onPushSceneTran(Object* pSender) } -void SceneTestLayer1::onQuit(Object* pSender) +void SceneTestLayer1::onQuit(Object* sender) { //getCocosApp()->exit(); //CCDirector::getInstance()->poscene(); @@ -130,12 +130,12 @@ void SceneTestLayer2::testDealloc(float dt) // onReplaceScene(this); } -void SceneTestLayer2::onGoBack(Object* pSender) +void SceneTestLayer2::onGoBack(Object* sender) { Director::getInstance()->popScene(); } -void SceneTestLayer2::onReplaceScene(Object* pSender) +void SceneTestLayer2::onReplaceScene(Object* sender) { Scene* scene = new SceneTestScene(); Layer* layer = SceneTestLayer3::create(); @@ -145,7 +145,7 @@ void SceneTestLayer2::onReplaceScene(Object* pSender) } -void SceneTestLayer2::onReplaceSceneTran(Object* pSender) +void SceneTestLayer2::onReplaceSceneTran(Object* sender) { Scene* scene = new SceneTestScene(); Layer* layer = SceneTestLayer3::create(); @@ -198,24 +198,24 @@ void SceneTestLayer3::testDealloc(float dt) log("Layer3:testDealloc"); } -void SceneTestLayer3::item0Clicked(Object* pSender) +void SceneTestLayer3::item0Clicked(Object* sender) { Scene *newScene = Scene::create(); newScene->addChild(SceneTestLayer3::create()); Director::getInstance()->pushScene(TransitionFade::create(0.5, newScene, Color3B(0,255,255))); } -void SceneTestLayer3::item1Clicked(Object* pSender) +void SceneTestLayer3::item1Clicked(Object* sender) { Director::getInstance()->popScene(); } -void SceneTestLayer3::item2Clicked(Object* pSender) +void SceneTestLayer3::item2Clicked(Object* sender) { Director::getInstance()->popToRootScene(); } -void SceneTestLayer3::item3Clicked(Object* pSender) +void SceneTestLayer3::item3Clicked(Object* sender) { Director::getInstance()->popToSceneStackLevel(2); } diff --git a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.h b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.h index ba6302e8fc..b79ff0a656 100644 --- a/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.h +++ b/samples/Cpp/TestCpp/Classes/SceneTest/SceneTest.h @@ -14,9 +14,9 @@ public: virtual void onEnterTransitionDidFinish(); void testDealloc(float dt); - void onPushScene(Object* pSender); - void onPushSceneTran(Object* pSender); - void onQuit(Object* pSender); + void onPushScene(Object* sender); + void onPushSceneTran(Object* sender); + void onQuit(Object* sender); //CREATE_NODE(SceneTestLayer1); } ; @@ -28,9 +28,9 @@ public: SceneTestLayer2(); void testDealloc(float dt); - void onGoBack(Object* pSender); - void onReplaceScene(Object* pSender); - void onReplaceSceneTran(Object* pSender); + void onGoBack(Object* sender); + void onReplaceScene(Object* sender); + void onReplaceSceneTran(Object* sender); //CREATE_NODE(SceneTestLayer2); } ; @@ -41,10 +41,10 @@ public: SceneTestLayer3(); bool init(); virtual void testDealloc(float dt); - void item0Clicked(Object* pSender); - void item1Clicked(Object* pSender); - void item2Clicked(Object* pSender); - void item3Clicked(Object* pSender); + void item0Clicked(Object* sender); + void item1Clicked(Object* sender); + void item2Clicked(Object* sender); + void item3Clicked(Object* sender); CREATE_FUNC(SceneTestLayer3) } ; diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp index b4d8cc5de6..6244072167 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.cpp @@ -94,7 +94,7 @@ void SchedulerTestLayer::onEnter() BaseTest::onEnter(); } -void SchedulerTestLayer::backCallback(Object* pSender) +void SchedulerTestLayer::backCallback(Object* sender) { Scene* scene = new SchedulerTestScene(); Layer* layer = backSchedulerTest(); @@ -104,7 +104,7 @@ void SchedulerTestLayer::backCallback(Object* pSender) scene->release(); } -void SchedulerTestLayer::nextCallback(Object* pSender) +void SchedulerTestLayer::nextCallback(Object* sender) { Scene* scene = new SchedulerTestScene(); Layer* layer = nextSchedulerTest(); @@ -114,7 +114,7 @@ void SchedulerTestLayer::nextCallback(Object* pSender) scene->release(); } -void SchedulerTestLayer::restartCallback(Object* pSender) +void SchedulerTestLayer::restartCallback(Object* sender) { Scene* scene = new SchedulerTestScene(); Layer* layer = restartSchedulerTest(); @@ -359,7 +359,7 @@ void SchedulerPauseResumeAllUser::pause(float dt) { log("Pausing"); Director* director = Director::getInstance(); - _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(kPriorityNonSystemMin); + _pausedTargets = director->getScheduler()->pauseAllTargetsWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN); CC_SAFE_RETAIN(_pausedTargets); } @@ -463,7 +463,7 @@ void SchedulerUnscheduleAllHard::onExit() if(!_actionManagerActive) { // Restore the director's action manager. Director* director = Director::getInstance(); - director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), kPrioritySystem, false); + director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), Scheduler::PRIORITY_SYSTEM, false); } } @@ -548,7 +548,7 @@ void SchedulerUnscheduleAllUserLevel::tick4(float dt) void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt) { - Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(kPriorityNonSystemMin); + Director::getInstance()->getScheduler()->unscheduleAllWithMinPriority(Scheduler::PRIORITY_NON_SYSTEM_MIN); } std::string SchedulerUnscheduleAllUserLevel::title() @@ -874,9 +874,9 @@ ControlSlider* SchedulerTimeScale::sliderCtl() return slider; } -void SchedulerTimeScale::sliderAction(Object* pSender, ControlEvent controlEvent) +void SchedulerTimeScale::sliderAction(Object* sender, ControlEvent controlEvent) { - ControlSlider* pSliderCtl = static_cast(pSender); + ControlSlider* pSliderCtl = static_cast(sender); float scale; scale = pSliderCtl->getValue(); diff --git a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h index 464ffff35a..34ea78d2bf 100644 --- a/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h +++ b/samples/Cpp/TestCpp/Classes/SchedulerTest/SchedulerTest.h @@ -16,9 +16,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void backCallback(Object* pSender); - void nextCallback(Object* pSender); - void restartCallback(Object* pSender); + void backCallback(Object* sender); + void nextCallback(Object* sender); + void restartCallback(Object* sender); }; // class SchedulerTestLayer : Layer @@ -228,7 +228,7 @@ public: virtual std::string title(); virtual std::string subtitle(); ControlSlider* sliderCtl(); - void sliderAction(Object* pSender, ControlEvent controlEvent); + void sliderAction(Object* sender, ControlEvent controlEvent); ControlSlider* _sliderCtl; }; diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp index f5cd6d9ad0..55cd368e61 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.cpp @@ -62,7 +62,7 @@ ShaderTestDemo::ShaderTestDemo() } -void ShaderTestDemo::backCallback(Object* pSender) +void ShaderTestDemo::backCallback(Object* sender) { Scene* s = new ShaderTestScene(); s->addChild( backAction() ); @@ -70,7 +70,7 @@ void ShaderTestDemo::backCallback(Object* pSender) s->release(); } -void ShaderTestDemo::nextCallback(Object* pSender) +void ShaderTestDemo::nextCallback(Object* sender) { Scene* s = new ShaderTestScene();//CCScene::create(); s->addChild( nextAction() ); @@ -88,7 +88,7 @@ std::string ShaderTestDemo::subtitle() return ""; } -void ShaderTestDemo::restartCallback(Object* pSender) +void ShaderTestDemo::restartCallback(Object* sender) { Scene* s = new ShaderTestScene(); s->addChild(restartAction()); @@ -166,7 +166,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) GLProgram *shader = new GLProgram(); shader->initWithVertexShaderFilename(vert, frag); - shader->addAttribute("aVertex", kVertexAttrib_Position); + shader->addAttribute("aVertex", GLProgram::VERTEX_ATTRIB_POSITION); shader->link(); shader->updateUniforms(); @@ -208,9 +208,9 @@ void ShaderNode::draw() // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version glUniform1f(_uniformTime, _time); - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); + GL::enableVertexAttribs( cocos2d::GL::VERTEX_ATTRIB_FLAG_POSITION ); - glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLES, 0, 6); @@ -499,9 +499,9 @@ void SpriteBlur::initProgram() CHECK_GL_ERROR_DEBUG(); - getShaderProgram()->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - getShaderProgram()->addAttribute(kAttributeNameColor, kVertexAttrib_Color); - getShaderProgram()->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR); + getShaderProgram()->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); CHECK_GL_ERROR_DEBUG(); @@ -521,16 +521,16 @@ void SpriteBlur::initProgram() void SpriteBlur::draw() { - ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex ); + GL::enableVertexAttribs(cocos2d::GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX ); BlendFunc blend = getBlendFunc(); - ccGLBlendFunc(blend.src, blend.dst); + GL::blendFunc(blend.src, blend.dst); getShaderProgram()->use(); getShaderProgram()->setUniformsForBuiltins(); getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y); getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1); - ccGLBindTexture2D( getTexture()->getName()); + GL::bindTexture2D( getTexture()->getName()); // // Attributes @@ -540,15 +540,15 @@ void SpriteBlur::draw() // vertex int diff = offsetof( V3F_C4B_T2F, vertices); - glVertexAttribPointer(kVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff)); // texCoods diff = offsetof( V3F_C4B_T2F, texCoords); - glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff)); // color diff = offsetof( V3F_C4B_T2F, colors); - glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); + glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff)); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -646,8 +646,8 @@ bool ShaderRetroEffect::init() GLProgram *p = new GLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); p->link(); p->updateUniforms(); @@ -740,8 +740,8 @@ ShaderFail::ShaderFail() GLProgram *p = new GLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, shader_frag_fail); - p->addAttribute(kAttributeNamePosition, kVertexAttrib_Position); - p->addAttribute(kAttributeNameTexCoord, kVertexAttrib_TexCoords); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION); + p->addAttribute(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS); p->link(); p->updateUniforms(); diff --git a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h index 09f70b987c..6ab3ed7559 100644 --- a/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h +++ b/samples/Cpp/TestCpp/Classes/ShaderTest/ShaderTest.h @@ -15,9 +15,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); CREATE_FUNC(ShaderTestDemo); }; diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id index ddf3d1f722..e04e178c10 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -715f77e7fdc777c303783dad8b6ce3e1b19526d7 \ No newline at end of file +8853550dc382b38c368250fb940660f35ee5ad4d \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h index ea4d175666..7cd867b38c 100644 --- a/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h +++ b/samples/Cpp/TestCpp/Classes/SpriteTest/SpriteTest.h @@ -19,9 +19,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class Sprite1 : public SpriteTestDemo diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp index cda39d5f81..55ccc82be6 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.cpp @@ -78,7 +78,7 @@ TextInputTest::TextInputTest() } -void TextInputTest::restartCallback(Object* pSender) +void TextInputTest::restartCallback(Object* sender) { Scene* s = new TextInputTestScene(); s->addChild(restartTextInputTest()); @@ -87,7 +87,7 @@ void TextInputTest::restartCallback(Object* pSender) s->release(); } -void TextInputTest::nextCallback(Object* pSender) +void TextInputTest::nextCallback(Object* sender) { Scene* s = new TextInputTestScene(); s->addChild( nextTextInputTest() ); @@ -95,7 +95,7 @@ void TextInputTest::nextCallback(Object* pSender) s->release(); } -void TextInputTest::backCallback(Object* pSender) +void TextInputTest::backCallback(Object* sender) { Scene* s = new TextInputTestScene(); s->addChild( backTextInputTest() ); @@ -175,21 +175,21 @@ void KeyboardNotificationLayer::keyboardWillShow(IMEKeyboardNotificationInfo& in // Layer function -bool KeyboardNotificationLayer::ccTouchBegan(Touch *pTouch, Event *pEvent) +bool KeyboardNotificationLayer::ccTouchBegan(Touch *touch, Event *event) { CCLOG("++++++++++++++++++++++++++++++++++++++++++++"); - _beginPos = pTouch->getLocation(); + _beginPos = touch->getLocation(); return true; } -void KeyboardNotificationLayer::ccTouchEnded(Touch *pTouch, Event *pEvent) +void KeyboardNotificationLayer::ccTouchEnded(Touch *touch, Event *event) { if (! _trackNode) { return; } - Point endPos = pTouch->getLocation(); + Point endPos = touch->getLocation(); float delta = 5.0f; if (::abs(endPos.x - _beginPos.x) > delta @@ -202,7 +202,7 @@ void KeyboardNotificationLayer::ccTouchEnded(Touch *pTouch, Event *pEvent) // decide the trackNode is clicked. Rect rect; - Point point = convertTouchToNodeSpaceAR(pTouch); + Point point = convertTouchToNodeSpaceAR(touch); CCLOG("KeyboardNotificationLayer:clickedAt(%f,%f)", point.x, point.y); rect = getRect(_trackNode); @@ -331,7 +331,7 @@ void TextFieldTTFActionTest::onExit() } // TextFieldDelegate protocol -bool TextFieldTTFActionTest::onTextFieldAttachWithIME(TextFieldTTF * pSender) +bool TextFieldTTFActionTest::onTextFieldAttachWithIME(TextFieldTTF * sender) { if (! _action) { @@ -341,7 +341,7 @@ bool TextFieldTTFActionTest::onTextFieldAttachWithIME(TextFieldTTF * pSender) return false; } -bool TextFieldTTFActionTest::onTextFieldDetachWithIME(TextFieldTTF * pSender) +bool TextFieldTTFActionTest::onTextFieldDetachWithIME(TextFieldTTF * sender) { if (_action) { @@ -352,7 +352,7 @@ bool TextFieldTTFActionTest::onTextFieldDetachWithIME(TextFieldTTF * pSender) return false; } -bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen) +bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * sender, const char * text, int nLen) { // if insert enter, treat as default to detach with ime if ('\n' == *text) @@ -361,7 +361,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const } // if the textfield's char count more than _charLimit, doesn't insert text anymore. - if (pSender->getCharCount() >= _charLimit) + if (sender->getCharCount() >= _charLimit) { return true; } @@ -373,10 +373,10 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const label->setColor(color); // move the sprite from top to position - Point endPos = pSender->getPosition(); - if (pSender->getCharCount()) + Point endPos = sender->getPosition(); + if (sender->getCharCount()) { - endPos.x += pSender->getContentSize().width / 2; + endPos.x += sender->getContentSize().width / 2; } Size inputTextSize = label->getContentSize(); Point beginPos(endPos.x, Director::getInstance()->getWinSize().height - inputTextSize.height * 2); @@ -397,15 +397,15 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(TextFieldTTF * pSender, const return false; } -bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen) +bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, int nLen) { // create a delete text sprite and do some action LabelTTF * label = LabelTTF::create(delText, FONT_NAME, FONT_SIZE); this->addChild(label); // move the sprite to fly out - Point beginPos = pSender->getPosition(); - Size textfieldSize = pSender->getContentSize(); + Point beginPos = sender->getPosition(); + Size textfieldSize = sender->getContentSize(); Size labelSize = label->getContentSize(); beginPos.x += (textfieldSize.width - labelSize.width) / 2.0f; @@ -431,7 +431,7 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(TextFieldTTF * pSender, c return false; } -bool TextFieldTTFActionTest::onDraw(TextFieldTTF * pSender) +bool TextFieldTTFActionTest::onDraw(TextFieldTTF * sender) { return false; } diff --git a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h index ed4ed39a35..237a62c615 100644 --- a/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h +++ b/samples/Cpp/TestCpp/Classes/TextInputTest/TextInputTest.h @@ -15,9 +15,9 @@ class TextInputTest : public BaseTest public: TextInputTest(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); std::string title(); void addKeyboardNotificationLayer(KeyboardNotificationLayer * layer); @@ -41,8 +41,8 @@ public: virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info); // Layer - virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent); - virtual void ccTouchEnded(Touch *pTouch, Event *pEvent); + virtual bool ccTouchBegan(Touch *touch, Event *event); + virtual void ccTouchEnded(Touch *touch, Event *event); protected: Node * _trackNode; @@ -87,11 +87,11 @@ public: virtual void onExit(); // TextFieldDelegate - virtual bool onTextFieldAttachWithIME(TextFieldTTF * pSender); - virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender); - virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen); - virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen); - virtual bool onDraw(TextFieldTTF * pSender); + virtual bool onTextFieldAttachWithIME(TextFieldTTF * sender); + virtual bool onTextFieldDetachWithIME(TextFieldTTF * sender); + virtual bool onTextFieldInsertText(TextFieldTTF * sender, const char * text, int nLen); + virtual bool onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, int nLen); + virtual bool onDraw(TextFieldTTF * sender); }; class TextInputTestScene : public TestScene diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp index 918c66eb44..f3e7aa92a2 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.cpp @@ -10,6 +10,8 @@ enum { static std::function createFunctions[] = { + CL(TexturePVRv3Premult), + CL(TextureMemoryAlloc), CL(TextureAlias), CL(TexturePVRMipMap), @@ -128,7 +130,7 @@ TextureDemo::~TextureDemo() TextureCache::getInstance()->dumpCachedTextureInfo(); } -void TextureDemo::restartCallback(Object* pSender) +void TextureDemo::restartCallback(Object* sender) { Scene *s = new TextureTestScene(); s->addChild(restartTextureTest()); @@ -136,7 +138,7 @@ void TextureDemo::restartCallback(Object* pSender) s->autorelease(); } -void TextureDemo::nextCallback(Object* pSender) +void TextureDemo::nextCallback(Object* sender) { Scene *s = new TextureTestScene(); s->addChild(nextTextureTest()); @@ -144,7 +146,7 @@ void TextureDemo::nextCallback(Object* pSender) s->autorelease(); } -void TextureDemo::backCallback(Object* pSender) +void TextureDemo::backCallback(Object* sender) { Scene *s = new TextureTestScene(); s->addChild(backTextureTest()); @@ -1313,7 +1315,7 @@ void TexturePixelFormat::onEnter() addChild(background, -1); // RGBA 8888 image (32-bit) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); Sprite *sprite1 = Sprite::create("Images/test-rgba1.png"); sprite1->setPosition(Point(1*s.width/7, s.height/2+32)); addChild(sprite1, 0); @@ -1322,7 +1324,7 @@ void TexturePixelFormat::onEnter() TextureCache::getInstance()->removeTexture(sprite1->getTexture()); // RGBA 4444 image (16-bit) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA4444); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA4444); Sprite *sprite2 = Sprite::create("Images/test-rgba1.png"); sprite2->setPosition(Point(2*s.width/7, s.height/2-32)); addChild(sprite2, 0); @@ -1331,7 +1333,7 @@ void TexturePixelFormat::onEnter() TextureCache::getInstance()->removeTexture(sprite2->getTexture()); // RGB5A1 image (16-bit) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB5A1); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB5A1); Sprite *sprite3 = Sprite::create("Images/test-rgba1.png"); sprite3->setPosition(Point(3*s.width/7, s.height/2+32)); addChild(sprite3, 0); @@ -1340,7 +1342,7 @@ void TexturePixelFormat::onEnter() TextureCache::getInstance()->removeTexture(sprite3->getTexture()); // RGB888 image - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB888); Sprite *sprite4 = Sprite::create("Images/test-rgba1.png"); sprite4->setPosition(Point(4*s.width/7, s.height/2-32)); addChild(sprite4, 0); @@ -1349,7 +1351,7 @@ void TexturePixelFormat::onEnter() TextureCache::getInstance()->removeTexture(sprite4->getTexture()); // RGB565 image (16-bit) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGB565); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGB565); Sprite *sprite5 = Sprite::create("Images/test-rgba1.png"); sprite5->setPosition(Point(5*s.width/7, s.height/2+32)); addChild(sprite5, 0); @@ -1358,7 +1360,7 @@ void TexturePixelFormat::onEnter() TextureCache::getInstance()->removeTexture(sprite5->getTexture()); // A8 image (8-bit) - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_A8); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::A8); Sprite *sprite6 = Sprite::create("Images/test-rgba1.png"); sprite6->setPosition(Point(6*s.width/7, s.height/2-32)); addChild(sprite6, 0); @@ -1382,7 +1384,7 @@ void TexturePixelFormat::onEnter() sprite5->runAction(seq_4ever5); // restore default - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_Default); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::DEFAULT); TextureCache::getInstance()->dumpCachedTextureInfo(); } @@ -1412,8 +1414,7 @@ void TextureBlend::onEnter() Sprite *cloud = Sprite::create("Images/test_blend.png"); addChild(cloud, i+1, 100+i); cloud->setPosition(Point(50+25*i, 80)); - BlendFunc blendFunc1 = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; - cloud->setBlendFunc(blendFunc1); + cloud->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED ); // CENTER sprites have also alpha pre-multiplied // they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA @@ -1937,7 +1938,7 @@ TexturePVRv3Premult::TexturePVRv3Premult() transformSprite(pvr2); // PNG - Texture2D::setDefaultAlphaPixelFormat(kTexture2DPixelFormat_RGBA8888); + Texture2D::setDefaultAlphaPixelFormat(Texture2D::PixelFormat::RGBA8888); TextureCache::getInstance()->removeTextureForKey("Images/grossinis_sister1-testalpha.png"); Sprite *png = Sprite::create("Images/grossinis_sister1-testalpha.png"); addChild(png, 0); diff --git a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h index b557237c98..581c4b59bb 100644 --- a/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h +++ b/samples/Cpp/TestCpp/Classes/Texture2dTest/Texture2dTest.h @@ -13,9 +13,9 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); }; class TextureTIFF : public TextureDemo diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp index 876478a58a..943f9d6485 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.cpp @@ -150,12 +150,12 @@ void TMXOrthoTest::onEnter() { TileDemo::onEnter(); - Director::getInstance()->setProjection(kDirectorProjection3D); + Director::getInstance()->setProjection(Director::Projection::_3D); } void TMXOrthoTest::onExit() { - Director::getInstance()->setProjection(kDirectorProjection2D); + Director::getInstance()->setProjection(Director::Projection::_2D); TileDemo::onExit(); } @@ -659,10 +659,10 @@ void TMXOrthoObjectsTest::draw() glLineWidth(3); - ccDrawLine( Point((float)x, (float)y), Point((float)(x+width), (float)y) ); - ccDrawLine( Point((float)(x+width), (float)y), Point((float)(x+width), (float)(y+height)) ); - ccDrawLine( Point((float)(x+width), (float)(y+height)), Point((float)x, (float)(y+height)) ); - ccDrawLine( Point((float)x, (float)(y+height)), Point((float)x, (float)y) ); + DrawPrimitives::drawLine( Point((float)x, (float)y), Point((float)(x+width), (float)y) ); + DrawPrimitives::drawLine( Point((float)(x+width), (float)y), Point((float)(x+width), (float)(y+height)) ); + DrawPrimitives::drawLine( Point((float)(x+width), (float)(y+height)), Point((float)x, (float)(y+height)) ); + DrawPrimitives::drawLine( Point((float)x, (float)(y+height)), Point((float)x, (float)y) ); glLineWidth(1); } @@ -736,10 +736,10 @@ void TMXIsoObjectsTest::draw() glLineWidth(3); - ccDrawLine( Point(x,y), Point(x+width,y) ); - ccDrawLine( Point(x+width,y), Point(x+width,y+height) ); - ccDrawLine( Point(x+width,y+height), Point(x,y+height) ); - ccDrawLine( Point(x,y+height), Point(x,y) ); + DrawPrimitives::drawLine( Point(x,y), Point(x+width,y) ); + DrawPrimitives::drawLine( Point(x+width,y), Point(x+width,y+height) ); + DrawPrimitives::drawLine( Point(x+width,y+height), Point(x,y+height) ); + DrawPrimitives::drawLine( Point(x,y+height), Point(x,y) ); glLineWidth(1); } @@ -973,13 +973,13 @@ void TMXIsoVertexZ::onEnter() TileDemo::onEnter(); // TIP: 2d projection should be used - Director::getInstance()->setProjection(kDirectorProjection2D); + Director::getInstance()->setProjection(Director::Projection::_2D); } void TMXIsoVertexZ::onExit() { // At exit use any other projection. - // Director::getInstance()->setProjection:kDirectorProjection3D); + // Director::getInstance()->setProjection:Director::Projection::_3D); TileDemo::onExit(); } @@ -1042,13 +1042,13 @@ void TMXOrthoVertexZ::onEnter() TileDemo::onEnter(); // TIP: 2d projection should be used - Director::getInstance()->setProjection(kDirectorProjection2D); + Director::getInstance()->setProjection(Director::Projection::_2D); } void TMXOrthoVertexZ::onExit() { // At exit use any other projection. - // Director::getInstance()->setProjection:kDirectorProjection3D); + // Director::getInstance()->setProjection:Director::Projection::_3D); TileDemo::onExit(); } @@ -1452,7 +1452,7 @@ void TileDemo::onEnter() BaseTest::onEnter(); } -void TileDemo::restartCallback(Object* pSender) +void TileDemo::restartCallback(Object* sender) { Scene* s = new TileMapTestScene(); s->addChild(restartTileMapAction()); @@ -1461,7 +1461,7 @@ void TileDemo::restartCallback(Object* pSender) s->release(); } -void TileDemo::nextCallback(Object* pSender) +void TileDemo::nextCallback(Object* sender) { Scene* s = new TileMapTestScene(); s->addChild( nextTileMapAction() ); @@ -1469,7 +1469,7 @@ void TileDemo::nextCallback(Object* pSender) s->release(); } -void TileDemo::backCallback(Object* pSender) +void TileDemo::backCallback(Object* sender) { Scene* s = new TileMapTestScene(); s->addChild( backTileMapAction() ); @@ -1477,9 +1477,9 @@ void TileDemo::backCallback(Object* pSender) s->release(); } -void TileDemo::ccTouchesMoved(Set *pTouches, Event *pEvent) +void TileDemo::ccTouchesMoved(Set *touches, Event *event) { - Touch *touch = (Touch*)pTouches->anyObject(); + Touch *touch = static_cast(touches->anyObject()); Point diff = touch->getDelta(); Node *node = getChildByTag(kTagTileMap); @@ -1540,10 +1540,10 @@ void TMXGIDObjectsTest::draw() glLineWidth(3); - ccDrawLine(Point(x, y), Point(x + width, y)); - ccDrawLine(Point(x + width, y), Point(x + width, y + height)); - ccDrawLine(Point(x + width,y + height), Point(x,y + height)); - ccDrawLine(Point(x,y + height), Point(x,y)); + DrawPrimitives::drawLine(Point(x, y), Point(x + width, y)); + DrawPrimitives::drawLine(Point(x + width, y), Point(x + width, y + height)); + DrawPrimitives::drawLine(Point(x + width,y + height), Point(x,y + height)); + DrawPrimitives::drawLine(Point(x,y + height), Point(x,y)); glLineWidth(1); } diff --git a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h index 0eb38c8196..a3aa9ae0e0 100644 --- a/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h +++ b/samples/Cpp/TestCpp/Classes/TileMapTest/TileMapTest.h @@ -14,11 +14,11 @@ public: virtual std::string subtitle(); virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesMoved(Set *touches, Event *event); }; class TileMapTest : public TileDemo diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp index 9c192f0ba8..e79f1c58a6 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.cpp @@ -18,7 +18,7 @@ class FlipXLeftOver : public TransitionFlipX public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipX::create(t, s, kTransitionOrientationLeftOver); + return TransitionFlipX::create(t, s, TransitionScene::Orientation::LEFT_OVER); } }; @@ -27,7 +27,7 @@ class FlipXRightOver : public TransitionFlipX public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipX::create(t, s, kTransitionOrientationRightOver); + return TransitionFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } }; @@ -36,7 +36,7 @@ class FlipYUpOver : public TransitionFlipY public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipY::create(t, s, kTransitionOrientationUpOver); + return TransitionFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } }; @@ -45,7 +45,7 @@ class FlipYDownOver : public TransitionFlipY public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipY::create(t, s, kTransitionOrientationDownOver); + return TransitionFlipY::create(t, s, TransitionScene::Orientation::DOWN_OVER); } }; @@ -54,7 +54,7 @@ class FlipAngularLeftOver : public TransitionFlipAngular public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipAngular::create(t, s, kTransitionOrientationLeftOver); + return TransitionFlipAngular::create(t, s, TransitionScene::Orientation::LEFT_OVER); } }; @@ -63,7 +63,7 @@ class FlipAngularRightOver : public TransitionFlipAngular public: static TransitionScene* create(float t, Scene* s) { - return TransitionFlipAngular::create(t, s, kTransitionOrientationRightOver); + return TransitionFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } }; @@ -72,7 +72,7 @@ class ZoomFlipXLeftOver : public TransitionZoomFlipX public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipX::create(t, s, kTransitionOrientationLeftOver); + return TransitionZoomFlipX::create(t, s, TransitionScene::Orientation::LEFT_OVER); } }; @@ -81,7 +81,7 @@ class ZoomFlipXRightOver : public TransitionZoomFlipX public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipX::create(t, s, kTransitionOrientationRightOver); + return TransitionZoomFlipX::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } }; @@ -90,7 +90,7 @@ class ZoomFlipYUpOver : public TransitionZoomFlipY public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipY::create(t, s, kTransitionOrientationUpOver); + return TransitionZoomFlipY::create(t, s, TransitionScene::Orientation::UP_OVER); } }; @@ -100,7 +100,7 @@ class ZoomFlipYDownOver : public TransitionZoomFlipY public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipY::create(t, s, kTransitionOrientationDownOver); + return TransitionZoomFlipY::create(t, s, TransitionScene::Orientation::DOWN_OVER); } }; @@ -109,7 +109,7 @@ class ZoomFlipAngularLeftOver : public TransitionZoomFlipAngular public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationLeftOver); + return TransitionZoomFlipAngular::create(t, s, TransitionScene::Orientation::LEFT_OVER); } }; @@ -118,7 +118,7 @@ class ZoomFlipAngularRightOver : public TransitionZoomFlipAngular public: static TransitionScene* create(float t, Scene* s) { - return TransitionZoomFlipAngular::create(t, s, kTransitionOrientationRightOver); + return TransitionZoomFlipAngular::create(t, s, TransitionScene::Orientation::RIGHT_OVER); } }; @@ -318,7 +318,7 @@ TestLayer1::~TestLayer1(void) } -void TestLayer1::restartCallback(Object* pSender) +void TestLayer1::restartCallback(Object* sender) { Scene* s = new TransitionsTestScene(); @@ -334,7 +334,7 @@ void TestLayer1::restartCallback(Object* pSender) } } -void TestLayer1::nextCallback(Object* pSender) +void TestLayer1::nextCallback(Object* sender) { s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; @@ -353,7 +353,7 @@ void TestLayer1::nextCallback(Object* pSender) } } -void TestLayer1::backCallback(Object* pSender) +void TestLayer1::backCallback(Object* sender) { s_nSceneIdx--; int total = MAX_LAYER; @@ -447,7 +447,7 @@ TestLayer2::~TestLayer2() } -void TestLayer2::restartCallback(Object* pSender) +void TestLayer2::restartCallback(Object* sender) { Scene* s = new TransitionsTestScene(); @@ -463,7 +463,7 @@ void TestLayer2::restartCallback(Object* pSender) } } -void TestLayer2::nextCallback(Object* pSender) +void TestLayer2::nextCallback(Object* sender) { s_nSceneIdx++; s_nSceneIdx = s_nSceneIdx % MAX_LAYER; @@ -482,7 +482,7 @@ void TestLayer2::nextCallback(Object* pSender) } } -void TestLayer2::backCallback(Object* pSender) +void TestLayer2::backCallback(Object* sender) { s_nSceneIdx--; int total = MAX_LAYER; diff --git a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h index c488a15361..ccf7ba3100 100644 --- a/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h +++ b/samples/Cpp/TestCpp/Classes/TransitionsTest/TransitionsTest.h @@ -17,9 +17,9 @@ public: TestLayer1(void); ~TestLayer1(void); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); void step(float dt); @@ -35,9 +35,9 @@ public: TestLayer2(void); ~TestLayer2(void); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); void step(float dt); diff --git a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp index ef3b133d5e..afb4388c5d 100644 --- a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.cpp @@ -61,21 +61,21 @@ void ZwoptexTest::onEnter() BaseTest::onEnter(); } -void ZwoptexTest::restartCallback(Object* pSender) +void ZwoptexTest::restartCallback(Object* sender) { Scene *s = ZwoptexTestScene::create(); s->addChild(restartZwoptexTest()); Director::getInstance()->replaceScene(s); } -void ZwoptexTest::nextCallback(Object* pSender) +void ZwoptexTest::nextCallback(Object* sender) { Scene *s = ZwoptexTestScene::create(); s->addChild(nextZwoptexTest()); Director::getInstance()->replaceScene(s); } -void ZwoptexTest::backCallback(Object* pSender) +void ZwoptexTest::backCallback(Object* sender) { Scene *s = ZwoptexTestScene::create(); s->addChild(backZwoptexTest()); diff --git a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.h b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.h index 6b3f25744b..76b8cc0ef4 100644 --- a/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.h +++ b/samples/Cpp/TestCpp/Classes/ZwoptexTest/ZwoptexTest.h @@ -9,9 +9,9 @@ class ZwoptexTest : public BaseTest public: virtual void onEnter(); - void restartCallback(Object* pSender); - void nextCallback(Object* pSender); - void backCallback(Object* pSender); + void restartCallback(Object* sender); + void nextCallback(Object* sender); + void backCallback(Object* sender); virtual std::string title(); virtual std::string subtitle(); diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index 522bb1c052..7846a7332d 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -129,13 +129,13 @@ TestController::~TestController() { } -void TestController::menuCallback(Object * pSender) +void TestController::menuCallback(Object * sender) { Director::getInstance()->purgeCachedData(); // get the userdata, it's the index of the menu item clicked - MenuItem* menuItem = (MenuItem *)(pSender); + MenuItem* menuItem = static_cast(sender); int idx = menuItem->getZOrder() - 10000; // create the test scene and run it @@ -148,7 +148,7 @@ void TestController::menuCallback(Object * pSender) } } -void TestController::closeCallback(Object * pSender) +void TestController::closeCallback(Object * sender) { Director::getInstance()->end(); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) @@ -156,16 +156,16 @@ void TestController::closeCallback(Object * pSender) #endif } -void TestController::ccTouchesBegan(Set *pTouches, Event *pEvent) +void TestController::ccTouchesBegan(Set *touches, Event *event) { - Touch* touch = (Touch*)pTouches->anyObject(); + Touch* touch = static_cast(touches->anyObject()); _beginPos = touch->getLocation(); } -void TestController::ccTouchesMoved(Set *pTouches, Event *pEvent) +void TestController::ccTouchesMoved(Set *touches, Event *event) { - Touch* touch = (Touch*)pTouches->anyObject(); + Touch* touch = static_cast(touches->anyObject()); Point touchLocation = touch->getLocation(); float nMoveY = touchLocation.y - _beginPos.y; diff --git a/samples/Cpp/TestCpp/Classes/controller.h b/samples/Cpp/TestCpp/Classes/controller.h index 52b1d52a37..0dd5998640 100644 --- a/samples/Cpp/TestCpp/Classes/controller.h +++ b/samples/Cpp/TestCpp/Classes/controller.h @@ -11,11 +11,11 @@ public: TestController(); ~TestController(); - void menuCallback(Object * pSender); - void closeCallback(Object * pSender); + void menuCallback(Object * sender); + void closeCallback(Object * sender); - virtual void ccTouchesBegan(Set *pTouches, Event *pEvent); - virtual void ccTouchesMoved(Set *pTouches, Event *pEvent); + virtual void ccTouchesBegan(Set *touches, Event *event); + virtual void ccTouchesMoved(Set *touches, Event *event); private: Point _beginPos; diff --git a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp index e503aab97c..6833c086ca 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp +++ b/samples/Cpp/TestCpp/proj.android/jni/testcpp/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile index 6f069f65bd..7673cd7ee5 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/Makefile +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -143,9 +143,10 @@ $(TARGET).data: $(CORE_MAKEFILE_LIST) $(patsubst %,$(RESOURCE_PATH)/%,$(RESOURCE cp -av $(RESOURCE_PATH)/* $(shell dirname $@) rm -rf $(RESTMP) -$(BIN_DIR)/index.html: index.html $(CORE_MAKEFILE_LIST) +$(BIN_DIR)/$(HTMLTPL_FILE): $(HTMLTPL_DIR)/$(HTMLTPL_FILE) $(CORE_MAKEFILE_LIST) @mkdir -p $(@D) - cp index.html $(@D) + @cp -Rf $(HTMLTPL_DIR)/* $(BIN_DIR) + @sed -i -e "s/JS_APPLICATION/$(EXECUTABLE)/g" $(BIN_DIR)/$(HTMLTPL_FILE) ####### Compile $(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST) diff --git a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp index 9f454eb009..54248f8c7a 100644 --- a/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp +++ b/samples/Javascript/CocosDragonJS/Classes/AppDelegate.cpp @@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching() // initialize director Director *pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); - pDirector->setProjection(kDirectorProjection2D); + pDirector->setProjection(Director::Projection::_2D); Size screenSize = EGLView::getInstance()->getFrameSize(); @@ -109,7 +109,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setContentScaleFactor(resourceSize.width/designSize.width); - EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder); + EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::NO_BORDER); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk b/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk index 5397489269..8e3c31147c 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/Application.mk @@ -1,4 +1,4 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -std=c++11 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION= +APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 NDK_TOOLCHAIN_VERSION=4.7 diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/cocosdragonjs/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp index 26bca4ea04..5c96cee8e8 100644 --- a/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp +++ b/samples/Javascript/CrystalCraze/Classes/AppDelegate.cpp @@ -21,7 +21,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - ScriptEngineManager::purgeSharedManager(); + ScriptEngineManager::destroyInstance(); } bool AppDelegate::applicationDidFinishLaunching() @@ -29,7 +29,7 @@ bool AppDelegate::applicationDidFinishLaunching() // initialize director Director *pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); - pDirector->setProjection(kDirectorProjection2D); + pDirector->setProjection(Director::Projection::_2D); Size screenSize = EGLView::getInstance()->getFrameSize(); @@ -91,7 +91,7 @@ bool AppDelegate::applicationDidFinishLaunching() } pDirector->setContentScaleFactor(resourceSize.width/designSize.width); - EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionShowAll); + EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::SHOW_ALL); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp +++ b/samples/Javascript/CrystalCraze/proj.android/jni/crystalcraze/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp index a779b340be..f186a261fb 100644 --- a/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp +++ b/samples/Javascript/MoonWarriors/Classes/AppDelegate.cpp @@ -21,7 +21,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - ScriptEngineManager::purgeSharedManager(); + ScriptEngineManager::destroyInstance(); } bool AppDelegate::applicationDidFinishLaunching() @@ -29,10 +29,10 @@ bool AppDelegate::applicationDidFinishLaunching() // initialize director Director *pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); - pDirector->setProjection(kDirectorProjection2D); + pDirector->setProjection(Director::Projection::_2D); // Set the design resolution - EGLView::getInstance()->setDesignResolutionSize(320, 480, kResolutionShowAll); + EGLView::getInstance()->setDesignResolutionSize(320, 480, ResolutionPolicy::SHOW_ALL); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp +++ b/samples/Javascript/MoonWarriors/proj.android/jni/moonwarriors/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp index 66d43c205c..efb7ba7e43 100644 --- a/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp +++ b/samples/Javascript/TestJavascript/Classes/AppDelegate.cpp @@ -33,7 +33,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(EGLView::getInstance()); // JS-Test in Html5 uses 800x450 as design resolution - EGLView::getInstance()->setDesignResolutionSize(800, 450, kResolutionFixedHeight); + EGLView::getInstance()->setDesignResolutionSize(800, 450, ResolutionPolicy::FIXED_HEIGHT); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp +++ b/samples/Javascript/TestJavascript/proj.android/jni/testjavascript/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp index 12225bddb9..7ea95f5ebf 100644 --- a/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp +++ b/samples/Javascript/WatermelonWithMe/Classes/AppDelegate.cpp @@ -36,7 +36,7 @@ bool AppDelegate::applicationDidFinishLaunching() // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); - EGLView::getInstance()->setDesignResolutionSize(480, 320, kResolutionFixedHeight); + EGLView::getInstance()->setDesignResolutionSize(480, 320, ResolutionPolicy::FIXED_HEIGHT); ScriptingCore* sc = ScriptingCore::getInstance(); sc->addRegisterCallback(register_all_cocos2dx); diff --git a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp +++ b/samples/Javascript/WatermelonWithMe/proj.android/jni/watermelonwithme/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Lua/HelloLua/Classes/AppDelegate.cpp b/samples/Lua/HelloLua/Classes/AppDelegate.cpp index 1f965adfb4..3116264745 100644 --- a/samples/Lua/HelloLua/Classes/AppDelegate.cpp +++ b/samples/Lua/HelloLua/Classes/AppDelegate.cpp @@ -26,7 +26,7 @@ bool AppDelegate::applicationDidFinishLaunching() Director *pDirector = Director::getInstance(); pDirector->setOpenGLView(EGLView::getInstance()); - EGLView::getInstance()->setDesignResolutionSize(480, 320, kResolutionNoBorder); + EGLView::getInstance()->setDesignResolutionSize(480, 320, ResolutionPolicy::NO_BORDER); // turn on display FPS pDirector->setDisplayStats(true); @@ -35,7 +35,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setAnimationInterval(1.0 / 60); // register lua engine - LuaEngine* pEngine = LuaEngine::defaultEngine(); + LuaEngine* pEngine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); std::string path = FileUtils::getInstance()->fullPathForFilename("hello.lua"); diff --git a/samples/Lua/HelloLua/Resources/hello.lua b/samples/Lua/HelloLua/Resources/hello.lua index 6fde4f0f63..e1224291d1 100644 --- a/samples/Lua/HelloLua/Resources/hello.lua +++ b/samples/Lua/HelloLua/Resources/hello.lua @@ -31,9 +31,9 @@ local function main() -- create dog animate local textureDog = CCTextureCache:getInstance():addImage("dog.png") - local rect = CCRectMake(0, 0, frameWidth, frameHeight) + local rect = CCRect(0, 0, frameWidth, frameHeight) local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) - rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) + rect = CCRect(frameWidth, 0, frameWidth, frameHeight) local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) local spriteDog = CCSprite:createWithSpriteFrame(frame0) @@ -86,7 +86,7 @@ local function main() end -- add crop - local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create("crop.png", CCRect(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); @@ -151,14 +151,14 @@ local function main() local function menuCallbackClosePopup() -- stop test sound effect - SimpleAudioEngine:sharedEngine():stopEffect(effectID) + SimpleAudioEngine:getInstance():stopEffect(effectID) menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath) + effectID = SimpleAudioEngine:getInstance():playEffect(effectPath) menuPopup:setVisible(true) end @@ -189,9 +189,9 @@ local function main() -- uncomment below for the BlackBerry version -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg") local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3") - SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true) + SimpleAudioEngine:getInstance():playBackgroundMusic(bgMusicPath, true) local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - SimpleAudioEngine:sharedEngine():preloadEffect(effectPath) + SimpleAudioEngine:getInstance():preloadEffect(effectPath) -- run local sceneGame = CCScene:create() diff --git a/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp b/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp index 51516c9603..9b1079cf1d 100644 --- a/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp +++ b/samples/Lua/HelloLua/proj.android/jni/hellolua/main.cpp @@ -31,9 +31,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index 896ae6b614..8b763a80bd 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -44,10 +44,10 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setContentScaleFactor(resourceSize.height/designSize.height); } - EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionFixedHeight); + EGLView::getInstance()->setDesignResolutionSize(designSize.width, designSize.height, ResolutionPolicy::FIXED_HEIGHT); // register lua engine - LuaEngine* pEngine = LuaEngine::defaultEngine(); + LuaEngine* pEngine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); std::vector searchPaths = pFileUtils->getSearchPaths(); diff --git a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua index 8d8eea7784..65c0313efd 100644 --- a/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/AccelerometerTest/AccelerometerTest.lua @@ -9,16 +9,16 @@ local function AccelerometerMainLayer() local pLabel = CCLabelTTF:create(title(), "Arial", 32) pLayer:addChild(pLabel, 1) - pLabel:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y - 50) ) + pLabel:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 50) ) local pBall = CCSprite:create("Images/ball.png") - pBall:setPosition(ccp(VisibleRect:center().x, VisibleRect:center().y)) + pBall:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:center().y)) pLayer:addChild(pBall) pBall:retain() local function didAccelerate(x,y,z,timestamp) - local pDir = CCDirector:sharedDirector() + local pDir = CCDirector:getInstance() if nil == pBall then return @@ -28,12 +28,12 @@ local function AccelerometerMainLayer() local ptNowX,ptNowY = pBall:getPosition() - local ptTmp = pDir:convertToUI(CCPointMake(ptNowX,ptNowY)) + local ptTmp = pDir:convertToUI(CCPoint(ptNowX,ptNowY)) ptTmp.x = ptTmp.x + x * 9.81 ptTmp.y = ptTmp.y - y * 9.81 - local ptNext = pDir:convertToGL(CCPointMake(ptTmp.x,ptTmp.y)) + local ptNext = pDir:convertToGL(CCPoint(ptTmp.x,ptTmp.y)) local nMinX = math.floor(VisibleRect:left().x + szBall.width / 2.0) local nMaxX = math.floor(VisibleRect:right().x - szBall.width / 2.0) if ptNext.x < nMinX then @@ -50,7 +50,7 @@ local function AccelerometerMainLayer() ptNext.y = nMaxY end - pBall:setPosition(CCPointMake(ptNext.x,ptNext.y)) + pBall:setPosition(CCPoint(ptNext.x,ptNext.y)) end diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua index 65b2c12063..3ef748ffe4 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionManagerTest/ActionManagerTest.lua @@ -1,7 +1,7 @@ local kTagNode = 0 local kTagGrossini = 1 local kTagSequence = 2 -local scheduler = CCDirector:sharedDirector():getScheduler() +local scheduler = CCDirector:getInstance():getScheduler() -------------------------------------------------------------------- -- -- Test1 @@ -49,7 +49,7 @@ local function LogicTest() grossini:setPosition(VisibleRect:center()) local arr = CCArray:create() - arr:addObject(CCMoveBy:create(1, ccp(150,0))) + arr:addObject(CCMoveBy:create(1, CCPoint(150,0))) local function bugMe(node) node:stopAllActions() --After this stop next action not working, if remove this stop everything is working @@ -75,7 +75,7 @@ local function PauseTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local node = ret:getChildByTag( kTagGrossini ) - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() pDirector:getActionManager():resumeTarget(node) end @@ -83,15 +83,15 @@ local function PauseTest() if event == "enter" then local l = CCLabelTTF:create("After 3 seconds grossini should move", "Thonburi", 16) ret:addChild(l) - l:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y-75) ) + l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-75) ) local grossini = CCSprite:create(s_pPathGrossini) ret:addChild(grossini, 0, kTagGrossini) grossini:setPosition(VisibleRect:center() ) - local action = CCMoveBy:create(1, ccp(150,0)) + local action = CCMoveBy:create(1, CCPoint(150,0)) - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() pDirector:getActionManager():addAction(action, grossini, true) schedulerEntry = scheduler:scheduleScriptFunc(unpause, 3.0, false) @@ -116,9 +116,9 @@ local function RemoveTest() local ret = createTestLayer("Remove Test") local l = CCLabelTTF:create("Should not crash", "Thonburi", 16) ret:addChild(l) - l:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y - 75) ) + l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75) ) - local pMove = CCMoveBy:create(2, ccp(200, 0)) + local pMove = CCMoveBy:create(2, CCPoint(200, 0)) local function stopAction() local pSprite = ret:getChildByTag(kTagGrossini) pSprite:stopActionByTag(kTagSequence) @@ -153,7 +153,7 @@ local function ResumeTest() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local pGrossini = ret:getChildByTag(kTagGrossini) - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() pDirector:getActionManager():resumeTarget(pGrossini) end @@ -162,7 +162,7 @@ local function ResumeTest() if event == "enter" then local l = CCLabelTTF:create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16) ret:addChild(l) - l:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y - 75)) + l:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - 75)) local pGrossini = CCSprite:create(s_pPathGrossini) ret:addChild(pGrossini, 0, kTagGrossini) @@ -170,7 +170,7 @@ local function ResumeTest() pGrossini:runAction(CCScaleBy:create(2, 2)) - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() pDirector:getActionManager():pauseTarget(pGrossini) pGrossini:runAction(CCRotateBy:create(2, 360)) @@ -191,7 +191,7 @@ end function ActionManagerTestMain() cclog("ActionManagerTestMain") Helper.index = 1 - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) local scene = CCScene:create() Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua index 4311c5dbd9..b13fe75638 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsEaseTest/ActionsEaseTest.lua @@ -2,11 +2,11 @@ local kTagAction1 = 1 local kTagAction2 = 2 local kTagSlider = 1 -local s = CCDirector:sharedDirector():getWinSize() -local scheduler = CCDirector:sharedDirector():getScheduler() +local s = CCDirector:getInstance():getWinSize() +local scheduler = CCDirector:getInstance():getScheduler() local function createSimpleMoveBy() - return CCMoveBy:create(3, CCPointMake(s.width - 130, 0)) + return CCMoveBy:create(3, CCPoint(s.width - 130, 0)) end local function createSimpleDelayTime() @@ -14,8 +14,8 @@ local function createSimpleDelayTime() end local function positionForTwo() - grossini:setPosition(CCPointMake(60, s.height * 1 / 5)) - tamara:setPosition(CCPointMake(60, s.height * 4 / 5)) + grossini:setPosition(CCPoint(60, s.height * 1 / 5)) + tamara:setPosition(CCPoint(60, s.height * 4 / 5)) kathia:setVisible(false) end @@ -30,9 +30,9 @@ local function getBaseLayer() layer:addChild(kathia, 2) layer:addChild(tamara, 1) - grossini:setPosition(CCPointMake(60, s.height * 1 / 5)) - kathia:setPosition(CCPointMake(60, s.height * 2.5 / 5)) - tamara:setPosition(CCPointMake(60, s.height * 4 / 5)) + grossini:setPosition(CCPoint(60, s.height * 1 / 5)) + kathia:setPosition(CCPoint(60, s.height * 2.5 / 5)) + tamara:setPosition(CCPoint(60, s.height * 4 / 5)) Helper.initWithLayer(layer) @@ -614,7 +614,7 @@ end local function SpeedTest() local layer = getBaseLayer() - local jump1 = CCJumpBy:create(4, CCPointMake(- s.width + 80, 0), 100, 4) + local jump1 = CCJumpBy:create(4, CCPoint(- s.width + 80, 0), 100, 4) local jump2 = jump1:reverse() local rot1 = CCRotateBy:create(4, 360 * 2) local rot2 = rot1:reverse() diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua index 496281dc95..392ca18048 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsProgressTest/ActionsProgressTest.lua @@ -1,5 +1,5 @@ -local s = CCDirector:sharedDirector():getWinSize() +local s = CCDirector:getInstance():getWinSize() ------------------------------------ -- SpriteProgressToRadial @@ -13,7 +13,7 @@ local function SpriteProgressToRadial() local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) left:setType(kCCProgressTimerTypeRadial) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(to1)) layer:addChild(left) @@ -21,7 +21,7 @@ local function SpriteProgressToRadial() right:setType(kCCProgressTimerTypeRadial) -- Makes the ridial CCW right:setReverseProgress(true) - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(to2)) layer:addChild(right) @@ -42,20 +42,20 @@ local function SpriteProgressToHorizontal() local left = CCProgressTimer:create(CCSprite:create(s_pPathSister1)) left:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the left since the midpoint is 0 for the x - left:setMidpoint(CCPointMake(0, 0)) + left:setMidpoint(CCPoint(0, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - left:setBarChangeRate(CCPointMake(1, 0)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setBarChangeRate(CCPoint(1, 0)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(to1)) layer:addChild(left) local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) right:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the left since the midpoint is 1 for the x - right:setMidpoint(CCPointMake(1, 0)) + right:setMidpoint(CCPoint(1, 0)) -- Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change - right:setBarChangeRate(CCPointMake(1, 0)) - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setBarChangeRate(CCPoint(1, 0)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(to2)) layer:addChild(right) @@ -77,20 +77,20 @@ local function SpriteProgressToVertical() left:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPointMake(0,0)) + left:setMidpoint(CCPoint(0,0)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPointMake(0, 1)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setBarChangeRate(CCPoint(0, 1)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(to1)) layer:addChild(left) local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) right:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPointMake(0, 1)) + right:setMidpoint(CCPoint(0, 1)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPointMake(0, 1)) - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setBarChangeRate(CCPoint(0, 1)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(to2)) layer:addChild(right) @@ -110,21 +110,21 @@ local function SpriteProgressToRadialMidpointChanged() -- Our image on the left should be a radial progress indicator, clockwise local left = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) left:setType(kCCProgressTimerTypeRadial) - left:setMidpoint(CCPointMake(0.25, 0.75)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setMidpoint(CCPoint(0.25, 0.75)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) layer:addChild(left) -- Our image on the left should be a radial progress indicator, counter clockwise local right = CCProgressTimer:create(CCSprite:create(s_pPathBlock)) right:setType(kCCProgressTimerTypeRadial) - right:setMidpoint(CCPointMake(0.75, 0.25)) + right:setMidpoint(CCPoint(0.75, 0.25)) --[[ Note the reverse property (default=NO) is only added to the right image. That's how we get a counter clockwise progress. ]] - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) layer:addChild(right) @@ -145,30 +145,30 @@ local function SpriteProgressBarVarious() left:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPointMake(0.5, 0.5)) + left:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPointMake(1, 0)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setBarChangeRate(CCPoint(1, 0)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) layer:addChild(left) local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) middle:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPointMake(0.5, 0.5)) + middle:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPointMake(1, 1)) - middle:setPosition(CCPointMake(s.width/2, s.height/2)) + middle:setBarChangeRate(CCPoint(1, 1)) + middle:setPosition(CCPoint(s.width/2, s.height/2)) middle:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) layer:addChild(middle) local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) right:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPointMake(0.5, 0.5)) + right:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPointMake(0, 1)) - right:setPosition(CCPointMake(s.width-100, s.height/2)) + right:setBarChangeRate(CCPoint(0, 1)) + right:setPosition(CCPoint(s.width-100, s.height/2)) right:runAction(CCRepeatForever:create(CCProgressTo:create(2, 100))) layer:addChild(right) @@ -197,10 +197,10 @@ local function SpriteProgressBarTintAndFade() left:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPointMake(0.5, 0.5)) + left:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPointMake(1, 0)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setBarChangeRate(CCPoint(1, 0)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) left:runAction(CCRepeatForever:create(CCSequence:create(array))) layer:addChild(left) @@ -210,10 +210,10 @@ local function SpriteProgressBarTintAndFade() local middle = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) middle:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPointMake(0.5, 0.5)) + middle:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPointMake(1, 1)) - middle:setPosition(CCPointMake(s.width / 2, s.height / 2)) + middle:setBarChangeRate(CCPoint(1, 1)) + middle:setPosition(CCPoint(s.width / 2, s.height / 2)) middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) local fade2 = CCSequence:createWithTwoActions( @@ -227,10 +227,10 @@ local function SpriteProgressBarTintAndFade() local right = CCProgressTimer:create(CCSprite:create(s_pPathSister2)) right:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPointMake(0.5, 0.5)) + right:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPointMake(0, 1)) - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setBarChangeRate(CCPoint(0, 1)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) right:runAction(CCRepeatForever:create(CCSequence:create(array))) right:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions( @@ -253,35 +253,35 @@ local function SpriteProgressWithSpriteFrame() local to = CCProgressTo:create(6, 100) - CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("zwoptex/grossini.plist") + CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") local left = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_01.png")) left:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - left:setMidpoint(CCPointMake(0.5, 0.5)) + left:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - left:setBarChangeRate(CCPointMake(1, 0)) - left:setPosition(CCPointMake(100, s.height / 2)) + left:setBarChangeRate(CCPoint(1, 0)) + left:setPosition(CCPoint(100, s.height / 2)) left:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) layer:addChild(left) local middle = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_02.png")) middle:setType(kCCProgressTimerTypeBar) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - middle:setMidpoint(CCPointMake(0.5, 0.5)) + middle:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - middle:setBarChangeRate(CCPointMake(1, 1)) - middle:setPosition(CCPointMake(s.width / 2, s.height / 2)) + middle:setBarChangeRate(CCPoint(1, 1)) + middle:setPosition(CCPoint(s.width / 2, s.height / 2)) middle:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) layer:addChild(middle) local right = CCProgressTimer:create(CCSprite:createWithSpriteFrameName("grossini_dance_03.png")) right:setType(kCCProgressTimerTypeRadial) -- Setup for a bar starting from the bottom since the midpoint is 0 for the y - right:setMidpoint(CCPointMake(0.5, 0.5)) + right:setMidpoint(CCPoint(0.5, 0.5)) -- Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change - right:setBarChangeRate(CCPointMake(0, 1)) - right:setPosition(CCPointMake(s.width - 100, s.height / 2)) + right:setBarChangeRate(CCPoint(0, 1)) + right:setPosition(CCPoint(s.width - 100, s.height / 2)) right:runAction(CCRepeatForever:create(CCProgressTo:create(6, 100))) layer:addChild(right) @@ -305,5 +305,5 @@ function ProgressActionsTest() scene:addChild(SpriteProgressToRadial()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end diff --git a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua index 3b071732b2..89f6232fee 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ActionsTest/ActionsTest.lua @@ -1,4 +1,4 @@ -local size = CCDirector:sharedDirector():getWinSize() +local size = CCDirector:getInstance():getWinSize() local function initWithLayer(layer) grossini = CCSprite:create(s_pPathGrossini) @@ -9,9 +9,9 @@ local function initWithLayer(layer) layer:addChild(tamara, 2) layer:addChild(kathia, 3) - grossini:setPosition(ccp(size.width / 2, size.height / 3)) - tamara:setPosition(ccp(size.width / 2, 2 * size.height / 3)) - kathia:setPosition(ccp(size.width / 2, size.height / 2)) + grossini:setPosition(CCPoint(size.width / 2, size.height / 3)) + tamara:setPosition(CCPoint(size.width / 2, 2 * size.height / 3)) + kathia:setPosition(CCPoint(size.width / 2, size.height / 2)) Helper.initWithLayer(layer) end @@ -25,15 +25,15 @@ local function centerSprites(numberOfSprites) elseif numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(ccp(size.width / 2, size.height / 2)) + grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(ccp(size.width / 3, size.height / 2)) - tamara:setPosition(ccp(2 * size.width / 3, size.height / 2)) + kathia:setPosition(CCPoint(size.width / 3, size.height / 2)) + tamara:setPosition(CCPoint(2 * size.width / 3, size.height / 2)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(ccp(size.width / 2, size.height / 2)) - tamara:setPosition(ccp(size.width / 4, size.height / 2)) - kathia:setPosition(ccp(3 * size.width / 4, size.height / 2)) + grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) + tamara:setPosition(CCPoint(size.width / 4, size.height / 2)) + kathia:setPosition(CCPoint(3 * size.width / 4, size.height / 2)) end end @@ -41,15 +41,15 @@ local function alignSpritesLeft(numberOfSprites) if numberOfSprites == 1 then tamara:setVisible(false) kathia:setVisible(false) - grossini:setPosition(ccp(60, size.height / 2)) + grossini:setPosition(CCPoint(60, size.height / 2)) elseif numberOfSprites == 2 then - kathia:setPosition(ccp(60, size.height / 3)) - tamara:setPosition(ccp(60, 2 * size.height / 3)) + kathia:setPosition(CCPoint(60, size.height / 3)) + tamara:setPosition(CCPoint(60, 2 * size.height / 3)) grossini:setVisible(false) elseif numberOfSprites == 3 then - grossini:setPosition(ccp(60, size.height / 2)) - tamara:setPosition(ccp(60, 2 * size.height / 3)) - kathia:setPosition(ccp(60, size.height / 3)) + grossini:setPosition(CCPoint(60, size.height / 2)) + tamara:setPosition(CCPoint(60, 2 * size.height / 3)) + kathia:setPosition(CCPoint(60, size.height / 3)) end end @@ -63,14 +63,14 @@ local function ActionManual() tamara:setScaleX(2.5) tamara:setScaleY(-1.0) - tamara:setPosition(ccp(100, 70)) + tamara:setPosition(CCPoint(100, 70)) tamara:setOpacity(128) grossini:setRotation(120) - grossini:setPosition(ccp(size.width / 2, size.height / 2)) + grossini:setPosition(CCPoint(size.width / 2, size.height / 2)) grossini:setColor(Color3B(255, 0, 0)) - kathia:setPosition(ccp(size.width - 100, size.height / 2)) + kathia:setPosition(CCPoint(size.width - 100, size.height / 2)) kathia:setColor(Color3B(0, 0, 255)) Helper.subtitleLabel:setString("Manual Transformation") @@ -85,12 +85,12 @@ local function ActionMove() initWithLayer(layer) centerSprites(3) - local actionBy = CCMoveBy:create(2, ccp(80, 80)) + local actionBy = CCMoveBy:create(2, CCPoint(80, 80)) local actionByBack = actionBy:reverse() - tamara:runAction(CCMoveTo:create(2, ccp(size.width - 40, size.height - 40))) + tamara:runAction(CCMoveTo:create(2, CCPoint(size.width - 40, size.height - 40))) grossini:runAction(CCSequence:createWithTwoActions(actionBy, actionByBack)) - kathia:runAction(CCMoveTo:create(1, ccp(40, 40))) + kathia:runAction(CCMoveTo:create(1, CCPoint(40, 40))) Helper.subtitleLabel:setString("MoveTo / MoveBy") return layer @@ -176,16 +176,16 @@ local function ActionRotationalSkewVSStandardSkew() grossini:removeFromParentAndCleanup(true); kathia:removeFromParentAndCleanup(true); - local s = CCDirector:sharedDirector():getWinSize(); - local boxSize = CCSizeMake(100.0, 100.0); + local s = CCDirector:getInstance():getWinSize(); + local boxSize = CCSize(100.0, 100.0); local box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(ccp(0.5,0.5)); + box:setAnchorPoint(CCPoint(0.5,0.5)); box:setContentSize( boxSize ); box:ignoreAnchorPointForPosition(false); - box:setPosition(ccp(s.width/2, s.height - 100 - box:getContentSize().height/2)); + box:setPosition(CCPoint(s.width/2, s.height - 100 - box:getContentSize().height/2)); layer:addChild(box); local label = CCLabelTTF:create("Standard cocos2d Skew", "Marker Felt", 16); - label:setPosition(ccp(s.width/2, s.height - 100 + label:getContentSize().height)); + label:setPosition(CCPoint(s.width/2, s.height - 100 + label:getContentSize().height)); layer:addChild(label); local actionTo = CCSkewBy:create(2, 360, 0); local actionToBack = CCSkewBy:create(2, -360, 0); @@ -194,13 +194,13 @@ local function ActionRotationalSkewVSStandardSkew() box:runAction(seq); box = CCLayerColor:create(Color4B(255,255,0,255)); - box:setAnchorPoint(ccp(0.5,0.5)); + box:setAnchorPoint(CCPoint(0.5,0.5)); box:setContentSize(boxSize); box:ignoreAnchorPointForPosition(false); - box:setPosition(ccp(s.width/2, s.height - 250 - box:getContentSize().height/2)); + box:setPosition(CCPoint(s.width/2, s.height - 250 - box:getContentSize().height/2)); layer:addChild(box); label = CCLabelTTF:create("Rotational Skew", "Marker Felt", 16); - label:setPosition(ccp(s.width/2, s.height - 250 + label:getContentSize().height/2)); + label:setPosition(CCPoint(s.width/2, s.height - 250 + label:getContentSize().height/2)); layer:addChild(label); local actionTo2 = CCRotateBy:create(2, 360); local actionToBack2 = CCRotateBy:create(2, -360); @@ -222,25 +222,25 @@ local function ActionSkewRotate() grossini:removeFromParentAndCleanup(true) kathia:removeFromParentAndCleanup(true) - local boxSize = CCSizeMake(100.0, 100.0) + local boxSize = CCSize(100.0, 100.0) local box = CCLayerColor:create(Color4B(255, 255, 0, 255)) - box:setAnchorPoint(ccp(0, 0)) + box:setAnchorPoint(CCPoint(0, 0)) box:setPosition(190, 110) box:setContentSize(boxSize) local markrside = 10.0 local uL = CCLayerColor:create(Color4B(255, 0, 0, 255)) box:addChild(uL) - uL:setContentSize(CCSizeMake(markrside, markrside)) + uL:setContentSize(CCSize(markrside, markrside)) uL:setPosition(0, boxSize.height - markrside) - uL:setAnchorPoint(ccp(0, 0)) + uL:setAnchorPoint(CCPoint(0, 0)) local uR = CCLayerColor:create(Color4B(0, 0, 255, 255)) box:addChild(uR) - uR:setContentSize(CCSizeMake(markrside, markrside)) + uR:setContentSize(CCSize(markrside, markrside)) uR:setPosition(boxSize.width - markrside, boxSize.height - markrside) - uR:setAnchorPoint(ccp(0, 0)) + uR:setAnchorPoint(CCPoint(0, 0)) layer:addChild(box) local actionTo = CCSkewTo:create(2, 0, 2) @@ -268,9 +268,9 @@ local function ActionJump() centerSprites(3) - local actionTo = CCJumpTo:create(2, ccp(300,300), 50, 4) - local actionBy = CCJumpBy:create(2, ccp(300,0), 50, 4) - local actionUp = CCJumpBy:create(2, ccp(0,0), 80, 4) + local actionTo = CCJumpTo:create(2, CCPoint(300,300), 50, 4) + local actionBy = CCJumpBy:create(2, CCPoint(300,0), 50, 4) + local actionUp = CCJumpBy:create(2, CCPoint(0,0), 80, 4) local actionByBack = actionBy:reverse() tamara:runAction(actionTo) @@ -303,24 +303,24 @@ local function ActionCardinalSpline() centerSprites(2) local array = CCPointArray:create(20) - array:addControlPoint(ccp(0, 0)) - array:addControlPoint(ccp(size.width / 2 - 30, 0)) - array:addControlPoint(ccp(size.width / 2 - 30, size.height - 80)) - array:addControlPoint(ccp(0, size.height - 80)) - array:addControlPoint(ccp(0, 0)) + array:addControlPoint(CCPoint(0, 0)) + array:addControlPoint(CCPoint(size.width / 2 - 30, 0)) + array:addControlPoint(CCPoint(size.width / 2 - 30, size.height - 80)) + array:addControlPoint(CCPoint(0, size.height - 80)) + array:addControlPoint(CCPoint(0, 0)) local action = CCCardinalSplineBy:create(3, array, 0) local reverse = action:reverse() local seq = CCSequence:createWithTwoActions(action, reverse) - tamara:setPosition(ccp(50, 50)) + tamara:setPosition(CCPoint(50, 50)) tamara:runAction(seq) local action2 = CCCardinalSplineBy:create(3, array, 1) local reverse2 = action2:reverse() local seq2 = CCSequence:createWithTwoActions(action2, reverse2) - kathia:setPosition(ccp(size.width / 2, 50)) + kathia:setPosition(CCPoint(size.width / 2, 50)) kathia:runAction(seq2) drawCardinalSpline(array) @@ -348,16 +348,16 @@ local function ActionCatmullRom() centerSprites(2) - tamara:setPosition(ccp(50, 50)) + tamara:setPosition(CCPoint(50, 50)) local array = CCPointArray:create(20) - array:addControlPoint(ccp(0, 0)) - array:addControlPoint(ccp(80, 80)) - array:addControlPoint(ccp(size.width - 80, 80)) - array:addControlPoint(ccp(size.width - 80, size.height - 80)) - array:addControlPoint(ccp(80, size.height - 80)) - array:addControlPoint(ccp(80, 80)) - array:addControlPoint(ccp(size.width / 2, size.height / 2)) + array:addControlPoint(CCPoint(0, 0)) + array:addControlPoint(CCPoint(80, 80)) + array:addControlPoint(CCPoint(size.width - 80, 80)) + array:addControlPoint(CCPoint(size.width - 80, size.height - 80)) + array:addControlPoint(CCPoint(80, size.height - 80)) + array:addControlPoint(CCPoint(80, 80)) + array:addControlPoint(CCPoint(size.width / 2, size.height / 2)) local action = CCCatmullRomBy:create(3, array) local reverse = action:reverse() @@ -365,11 +365,11 @@ local function ActionCatmullRom() tamara:runAction(seq) local array2 = CCPointArray:create(20) - array2:addControlPoint(ccp(size.width / 2, 30)) - array2:addControlPoint(ccp(size.width -80, 30)) - array2:addControlPoint(ccp(size.width - 80, size.height - 80)) - array2:addControlPoint(ccp(size.width / 2, size.height - 80)) - array2:addControlPoint(ccp(size.width / 2, 30)) + array2:addControlPoint(CCPoint(size.width / 2, 30)) + array2:addControlPoint(CCPoint(size.width -80, 30)) + array2:addControlPoint(CCPoint(size.width - 80, size.height - 80)) + array2:addControlPoint(CCPoint(size.width / 2, size.height - 80)) + array2:addControlPoint(CCPoint(size.width / 2, 30)) local action2 = CCCatmullRomTo:create(3, array2) local reverse2 = action2:reverse() @@ -394,25 +394,25 @@ local function ActionBezier() -- sprite 1 local bezier = ccBezierConfig() - bezier.controlPoint_1 = ccp(0, size.height / 2) - bezier.controlPoint_2 = ccp(300, - size.height / 2) - bezier.endPosition = ccp(300, 100) + bezier.controlPoint_1 = CCPoint(0, size.height / 2) + bezier.controlPoint_2 = CCPoint(300, - size.height / 2) + bezier.endPosition = CCPoint(300, 100) local bezierForward = CCBezierBy:create(3, bezier) local bezierBack = bezierForward:reverse() local rep = CCRepeatForever:create(CCSequence:createWithTwoActions(bezierForward, bezierBack)) -- sprite 2 - tamara:setPosition(ccp(80,160)) + tamara:setPosition(CCPoint(80,160)) local bezier2 = ccBezierConfig() - bezier2.controlPoint_1 = ccp(100, size.height / 2) - bezier2.controlPoint_2 = ccp(200, - size.height / 2) - bezier2.endPosition = ccp(240, 160) + bezier2.controlPoint_1 = CCPoint(100, size.height / 2) + bezier2.controlPoint_2 = CCPoint(200, - size.height / 2) + bezier2.endPosition = CCPoint(240, 160) local bezierTo1 = CCBezierTo:create(2, bezier2) -- sprite 3 - kathia:setPosition(ccp(400,160)) + kathia:setPosition(CCPoint(400,160)) local bezierTo2 = CCBezierTo:create(2, bezier2) grossini:runAction(rep) @@ -515,7 +515,7 @@ local function ActionAnimate() local action = CCAnimate:create(animation) grossini:runAction(CCSequence:createWithTwoActions(action, action:reverse())) - local cache = CCAnimationCache:sharedAnimationCache() + local cache = CCAnimationCache:getInstance() cache:addAnimationsWithFile("animations/animations-2.plist") local animation2 = cache:animationByName("dance_1") @@ -545,7 +545,7 @@ local function ActionSequence() alignSpritesLeft(1) local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, ccp(240,0)), + CCMoveBy:create(2, CCPoint(240,0)), CCRotateBy:create(2, 540)) grossini:runAction(action) @@ -569,14 +569,14 @@ end local function ActionSequenceCallback2(sender) local label = CCLabelTTF:create("callback 2 called", "Marker Felt", 16) - label:setPosition(ccp(size.width / 4 * 2, size.height / 2)) + label:setPosition(CCPoint(size.width / 4 * 2, size.height / 2)) actionSequenceLayer:addChild(label) end local function ActionSequenceCallback3(sender) local label = CCLabelTTF:create("callback 3 called", "Marker Felt", 16) - label:setPosition(ccp(size.width / 4 * 3, size.height / 2)) + label:setPosition(CCPoint(size.width / 4 * 3, size.height / 2)) actionSequenceLayer:addChild(label) end @@ -589,9 +589,9 @@ local function ActionSequence2() grossini:setVisible(false) local array = CCArray:create() - array:addObject(CCPlace:create(ccp(200,200))) + array:addObject(CCPlace:create(CCPoint(200,200))) array:addObject(CCShow:create()) - array:addObject(CCMoveBy:create(1, ccp(100,0))) + array:addObject(CCMoveBy:create(1, CCPoint(100,0))) array:addObject(CCCallFunc:create(ActionSequenceCallback1)) array:addObject(CCCallFunc:create(ActionSequenceCallback2)) array:addObject(CCCallFunc:create(ActionSequenceCallback3)) @@ -614,7 +614,7 @@ local function ActionSpawn() alignSpritesLeft(1) local action = CCSpawn:createWithTwoActions( - CCJumpBy:create(2, ccp(300,0), 50, 4), + CCJumpBy:create(2, CCPoint(300,0), 50, 4), CCRotateBy:create( 2, 720)) grossini:runAction(action) @@ -633,7 +633,7 @@ local function ActionReverse() alignSpritesLeft(1) - local jump = CCJumpBy:create(2, ccp(300,0), 50, 4) + local jump = CCJumpBy:create(2, CCPoint(300,0), 50, 4) local action = CCSequence:createWithTwoActions(jump, jump:reverse()) grossini:runAction(action) @@ -652,7 +652,7 @@ local function ActionDelaytime() alignSpritesLeft(1) - local move = CCMoveBy:create(1, ccp(150,0)) + local move = CCMoveBy:create(1, CCPoint(150,0)) local array = CCArray:create() array:addObject(move) array:addObject(CCDelayTime:create(2)) @@ -674,10 +674,10 @@ local function ActionRepeat() alignSpritesLeft(2) - local a1 = CCMoveBy:create(1, ccp(150,0)) - local action1 = CCRepeat:create(CCSequence:createWithTwoActions(CCPlace:create(ccp(60,60)), a1), 3) + local a1 = CCMoveBy:create(1, CCPoint(150,0)) + local action1 = CCRepeat:create(CCSequence:createWithTwoActions(CCPlace:create(CCPoint(60,60)), a1), 3) - local a2 = CCMoveBy:create(1, ccp(150,0)) + local a2 = CCMoveBy:create(1, CCPoint(150,0)) local action2 = CCRepeatForever:create(CCSequence:createWithTwoActions(a2, a1:reverse())) kathia:runAction(action1) @@ -796,7 +796,7 @@ local function ActionCallFunc() centerSprites(3) local action = CCSequence:createWithTwoActions( - CCMoveBy:create(2, ccp(200,0)), + CCMoveBy:create(2, CCPoint(200,0)), CCCallFunc:create(CallFucnCallback1) ) local array = CCArray:create() @@ -845,8 +845,8 @@ local function ActionReverseSequence() alignSpritesLeft(1) - local move1 = CCMoveBy:create(1, ccp(250,0)) - local move2 = CCMoveBy:create(1, ccp(0,50)) + local move1 = CCMoveBy:create(1, CCPoint(250,0)) + local move2 = CCMoveBy:create(1, CCPoint(0,50)) local array = CCArray:create() array:addObject(move1) array:addObject(move2) @@ -871,8 +871,8 @@ local function ActionReverseSequence2() -- Test: -- Sequence should work both with IntervalAction and InstantActions - local move1 = CCMoveBy:create(1, ccp(250,0)) - local move2 = CCMoveBy:create(1, ccp(0,50)) + local move1 = CCMoveBy:create(1, CCPoint(250,0)) + local move2 = CCMoveBy:create(1, CCPoint(0,50)) local tog1 = CCToggleVisibility:create() local tog2 = CCToggleVisibility:create() local array = CCArray:createWithCapacity(10) @@ -888,8 +888,8 @@ local function ActionReverseSequence2() -- Also test that the reverse of Hide is Show, and vice-versa kathia:runAction(action) - local move_tamara = CCMoveBy:create(1, ccp(100,0)) - local move_tamara2 = CCMoveBy:create(1, ccp(50,0)) + local move_tamara = CCMoveBy:create(1, CCPoint(100,0)) + local move_tamara2 = CCMoveBy:create(1, CCPoint(50,0)) local hide = CCHide:create() local array2 = CCArray:createWithCapacity(10) array2:addObject(move_tamara) @@ -925,7 +925,7 @@ local function ActionOrbit() tamara:runAction(CCRepeatForever:create(action2)) grossini:runAction(CCRepeatForever:create(action3)) - local move = CCMoveBy:create(3, ccp(100,-100)) + local move = CCMoveBy:create(3, CCPoint(100,-100)) local move_back = move:reverse() local seq = CCSequence:createWithTwoActions(move, move_back) local rfe = CCRepeatForever:create(seq) @@ -947,15 +947,15 @@ local function ActionFollow() centerSprites(1) - grossini:setPosition(ccp(-200, size.height / 2)) - local move = CCMoveBy:create(2, ccp(size.width * 3, 0)) + grossini:setPosition(CCPoint(-200, size.height / 2)) + local move = CCMoveBy:create(2, CCPoint(size.width * 3, 0)) local move_back = move:reverse() local seq = CCSequence:createWithTwoActions(move, move_back) local rep = CCRepeatForever:create(seq) grossini:runAction(rep) - layer:runAction(CCFollow:create(grossini, CCRectMake(0, 0, size.width * 2 - 100, size.height))) + layer:runAction(CCFollow:create(grossini, CCRect(0, 0, size.width * 2 - 100, size.height))) Helper.subtitleLabel:setString("Follow action") return layer @@ -970,8 +970,8 @@ local function ActionTargeted() centerSprites(2) - local jump1 = CCJumpBy:create(2, ccp(0, 0), 100, 3) - local jump2 = CCJumpBy:create(2, ccp(0, 0), 100, 3) + local jump1 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) + local jump2 = CCJumpBy:create(2, CCPoint(0, 0), 100, 3) local rot1 = CCRotateBy:create(1, 360) local rot2 = CCRotateBy:create(1, 360) @@ -1004,10 +1004,10 @@ local PauseResumeActions_resumeEntry = nil local function ActionPause(dt) cclog("Pausing") - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_pauseEntry) - local director = CCDirector:sharedDirector() + local director = CCDirector:getInstance() pausedTargets = director:getActionManager():pauseAllRunningActions() pausedTargets:retain() end @@ -1015,10 +1015,10 @@ end local function ActionResume(dt) cclog("Resuming") - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() scheduler:unscheduleScriptEntry(PauseResumeActions_resumeEntry) - local director = CCDirector:sharedDirector() + local director = CCDirector:getInstance() if pausedTargets ~= nil then -- problem: will crash here. Try fixing me! director:getActionManager():resumeTargets(pausedTargets) @@ -1027,7 +1027,7 @@ local function ActionResume(dt) end local function PauseResumeActions_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then PauseResumeActions_pauseEntry = scheduler:scheduleScriptFunc(ActionPause, 3, false) PauseResumeActions_resumeEntry = scheduler:scheduleScriptFunc(ActionResume, 5, false) @@ -1065,15 +1065,15 @@ local function Issue1305_log(sender) end local function addSprite(dt) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() scheduler:unscheduleScriptEntry(Issue1305_entry) - spriteTmp:setPosition(ccp(250, 250)) + spriteTmp:setPosition(CCPoint(250, 250)) Issue1305_layer:addChild(spriteTmp) end local function Issue1305_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then Issue1305_entry = scheduler:scheduleScriptFunc(addSprite, 2, false) elseif tag == "exit" then @@ -1123,16 +1123,16 @@ local function ActionIssue1305_2() centerSprites(0) local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(ccp(200,200)) + spr:setPosition(CCPoint(200,200)) layer:addChild(spr) - local act1 = CCMoveBy:create(2 ,ccp(0, 100)) + local act1 = CCMoveBy:create(2 ,CCPoint(0, 100)) local act2 = CCCallFunc:create(Issue1305_2_log1) - local act3 = CCMoveBy:create(2, ccp(0, -100)) + local act3 = CCMoveBy:create(2, CCPoint(0, -100)) local act4 = CCCallFunc:create(Issue1305_2_log2) - local act5 = CCMoveBy:create(2, ccp(100, -100)) + local act5 = CCMoveBy:create(2, CCPoint(100, -100)) local act6 = CCCallFunc:create(Issue1305_2_log3) - local act7 = CCMoveBy:create(2, ccp(-100, 0)) + local act7 = CCMoveBy:create(2, CCPoint(-100, 0)) local act8 = CCCallFunc:create(Issue1305_2_log4) local array = CCArray:create() @@ -1146,7 +1146,7 @@ local function ActionIssue1305_2() array:addObject(act8) local actF = CCSequence:create(array) - CCDirector:sharedDirector():getActionManager():addAction(actF ,spr, false) + CCDirector:getInstance():getActionManager():addAction(actF ,spr, false) Helper.titleLabel:setString("Issue 1305 #2") Helper.subtitleLabel:setString("See console. You should only see one message for each block") @@ -1163,10 +1163,10 @@ local function ActionIssue1288() centerSprites(0) local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(ccp(100, 100)) + spr:setPosition(CCPoint(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, ccp(100, 0)) + local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) local act2 = act1:reverse() local act3 = CCSequence:createWithTwoActions(act1, act2) local act4 = CCRepeat:create(act3, 2) @@ -1188,10 +1188,10 @@ local function ActionIssue1288_2() centerSprites(0) local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(ccp(100, 100)) + spr:setPosition(CCPoint(100, 100)) layer:addChild(spr) - local act1 = CCMoveBy:create(0.5, ccp(100, 0)) + local act1 = CCMoveBy:create(0.5, CCPoint(100, 0)) spr:runAction(CCRepeat:create(act1, 1)) Helper.titleLabel:setString("Issue 1288 #2") @@ -1213,7 +1213,7 @@ local function ActionIssue1327() centerSprites(0) local spr = CCSprite:create("Images/grossini.png") - spr:setPosition(ccp(100, 100)) + spr:setPosition(CCPoint(100, 100)) layer:addChild(spr) local act1 = CCCallFunc:create(logSprRotation) diff --git a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua index 16c22f163e..829cc14534 100644 --- a/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/BugsTest/BugsTest.lua @@ -2,7 +2,7 @@ local MAX_COUNT = 9; local LINE_SPACE = 40; local kItemTagBasic = 5432; -local Winsize = CCDirector:sharedDirector():getWinSize(); +local Winsize = CCDirector:getInstance():getWinSize(); local testNames = { "Bug-350", @@ -20,17 +20,17 @@ local function CreateBugsTestBackMenuItem(pLayer) CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24); local pMenuItemFont = CCMenuItemFont:create("Back"); - pMenuItemFont:setPosition(ccp(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) local function menuCallback() local pScene = BugsTestMain() if pScene ~= nil then - CCDirector:sharedDirector():replaceScene(pScene) + CCDirector:getInstance():replaceScene(pScene) end end pMenuItemFont:registerScriptTapHandler(menuCallback) local pMenu = CCMenu:create() pMenu:addChild(pMenuItemFont) - pMenu:setPosition(ccp(0, 0)) + pMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pMenu) end @@ -38,7 +38,7 @@ end local function BugTest350() local pLayer = CCLayer:create() local pBackground = CCSprite:create("Hello.png"); - pBackground:setPosition(ccp(Winsize.width/2, Winsize.height/2)); + pBackground:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)); pLayer:addChild(pBackground); return pLayer end @@ -76,7 +76,7 @@ local function BugTest422() pMenu:alignItemsVertically() local fX = math.random() * 50 local fY = math.random() * 50 - pMenu:setPosition(ccpAdd(ccp(pMenu:getPosition()),ccp(fX,fY))) + pMenu:setPosition(CCPoint.__add(CCPoint(pMenu:getPosition()),CCPoint(fX,fY))) pResetLayer:addChild(pMenu,0,nLocalTag) end @@ -100,7 +100,7 @@ local function BugTest458() local nWidth = Winsize.width * 0.9 - (pCorner:getContentSize().width * 2); local nHeight = Winsize.height * 0.15 - (pCorner:getContentSize().height * 2); local pColorLayer = CCLayerColor:create(Color4B(255, 255, 255, 255 * .75), nWidth, nHeight); - pColorLayer:setPosition(ccp(-nWidth / 2, -nHeight / 2)); + pColorLayer:setPosition(CCPoint(-nWidth / 2, -nHeight / 2)); --First button is blue,Second is red,Used for testing - change later if (0 == nColorFlag) then pLabel:setColor(Color3B(0,0,255)) @@ -111,47 +111,47 @@ local function BugTest458() nColorFlag = nColorFlag + 1; pSprite:addChild(pColorLayer); - pCorner:setPosition(ccp(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2))); + pCorner:setPosition(CCPoint(-(nWidth / 2 + pCorner:getContentSize().width / 2), -(nHeight / 2 + pCorner:getContentSize().height / 2))); pSprite:addChild(pCorner); local nX,nY = pCorner:getPosition() local pCorner2 = CCSprite:create("Images/bugs/corner.png"); - pCorner2:setPosition(ccp(-nX, nY)); + pCorner2:setPosition(CCPoint(-nX, nY)); pCorner2:setFlipX(true); pSprite:addChild(pCorner2); local pCorner3 = CCSprite:create("Images/bugs/corner.png"); - pCorner3:setPosition(ccp(nX, -nY)); + pCorner3:setPosition(CCPoint(nX, -nY)); pCorner3:setFlipY(true); pSprite:addChild(pCorner3); local pCorner4 = CCSprite:create("Images/bugs/corner.png"); - pCorner4:setPosition(ccp(-nX, -nY)); + pCorner4:setPosition(CCPoint(-nX, -nY)); pCorner4:setFlipX(true); pCorner4:setFlipY(true); pSprite:addChild(pCorner4); local pEdge = CCSprite:create("Images/bugs/edge.png"); pEdge:setScaleX(nWidth); - pEdge:setPosition(ccp(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY)); + pEdge:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), nY)); pSprite:addChild(pEdge); local pEdge2 = CCSprite:create("Images/bugs/edge.png"); pEdge2:setScaleX(nWidth); - pEdge2:setPosition(ccp(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY)); + pEdge2:setPosition(CCPoint(nX + (pCorner:getContentSize().width / 2) + (nWidth / 2), -nY)); pEdge2:setFlipY(true); pSprite:addChild(pEdge2); local pEdge3 = CCSprite:create("Images/bugs/edge.png"); pEdge3:setRotation(90); pEdge3:setScaleX(nHeight); - pEdge3:setPosition(ccp(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); + pEdge3:setPosition(CCPoint(nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); pSprite:addChild(pEdge3); local pEdge4 = CCSprite:create("Images/bugs/edge.png"); pEdge4:setRotation(270); pEdge4:setScaleX(nHeight); - pEdge4:setPosition(ccp(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); + pEdge4:setPosition(CCPoint(-nX, nY + (pCorner:getContentSize().height / 2) + (nHeight / 2))); pSprite:addChild(pEdge4); pSprite:addChild(pLabel); @@ -180,7 +180,7 @@ local function BugTest458() arr:addObject(pMenuItemSprite2) local pMenu = CCMenu:createWithArray(arr) pMenu:alignItemsVerticallyWithPadding(100); - pMenu:setPosition(ccp(Winsize.width / 2, Winsize.height / 2)); + pMenu:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); -- add the label as a child to this Layer pLayer:addChild(pMenu); @@ -196,25 +196,25 @@ local function BugTest624() local pLayer = CCLayer:create() local pLabel = CCLabelTTF:create("Layer1", "Marker Felt", 36); - pLabel:setPosition(ccp(Winsize.width / 2, Winsize.height / 2)); + pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); pLayer:addChild(pLabel); pLayer:setAccelerometerEnabled(true); -- schedule(schedule_selector(Bug624Layer::switchLayer), 5.0f); local function BugTest624_SwitchLayer() - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() scheduler:unscheduleScriptEntry(BugTest624_entry) local pScene = CCScene:create(); local pNewPlayer = BugTest624_2() CreateBugsTestBackMenuItem(pNewPlayer) pScene:addChild(pNewPlayer); - CCDirector:sharedDirector():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,255,255))); + CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,255,255))); end local function BugTest624_OnEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then BugTest624_entry = scheduler:scheduleScriptFunc(BugTest624_SwitchLayer, 5.0, false) elseif tag == "exit" then @@ -235,23 +235,23 @@ function BugTest624_2() local pLayer = CCLayer:create() local pLabel = CCLabelTTF:create("Layer2", "Marker Felt", 36); - pLabel:setPosition(ccp(Winsize.width / 2, Winsize.height / 2)); + pLabel:setPosition(CCPoint(Winsize.width / 2, Winsize.height / 2)); pLayer:addChild(pLabel); pLayer:setAccelerometerEnabled(true); local function BugTest624_2_SwitchLayer() - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() scheduler:unscheduleScriptEntry(BugTest624_2_entry) local pScene = CCScene:create(); local pNewPlayer = BugTest624() CreateBugsTestBackMenuItem(pNewPlayer) pScene:addChild(pNewPlayer); - CCDirector:sharedDirector():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,0,0))); + CCDirector:getInstance():replaceScene(CCTransitionFade:create(2.0, pScene, Color3B(255,0,0))); end local function BugTest624_2_OnEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then BugTest624_2_entry = scheduler:scheduleScriptFunc(BugTest624_2_SwitchLayer, 5.0, false) elseif tag == "exit" then @@ -273,15 +273,15 @@ local function BugTest886() local pLayer = CCLayer:create() local pSprite1 = CCSprite:create("Images/bugs/bug886.jpg") - pSprite1:setAnchorPoint(ccp(0, 0)) - pSprite1:setPosition(ccp(0, 0)) + pSprite1:setAnchorPoint(CCPoint(0, 0)) + pSprite1:setPosition(CCPoint(0, 0)) pSprite1:setScaleX(0.6) pLayer:addChild(pSprite1) local pSprite2 = CCSprite:create("Images/bugs/bug886.jpg") - pSprite2:setAnchorPoint(ccp(0, 0)) + pSprite2:setAnchorPoint(CCPoint(0, 0)) pSprite2:setScaleX(0.6) - pSprite2:setPosition(ccp(pSprite1:getContentSize().width * 0.6 + 10, 0)) + pSprite2:setPosition(CCPoint(pSprite1:getContentSize().width * 0.6 + 10, 0)) pLayer:addChild(pSprite2) return pLayer @@ -293,7 +293,7 @@ local function BugTest899() local pBg = CCSprite:create("Images/bugs/RetinaDisplay.jpg") pLayer:addChild(pBg,0) - pBg:setAnchorPoint(ccp(0, 0)) + pBg:setAnchorPoint(CCPoint(0, 0)) return pLayer end @@ -308,9 +308,9 @@ local function BugTest914() for i = 0, 4 do pLayerColor = CCLayerColor:create(Color4B(i*20, i*20, i*20,255)) - pLayerColor:setContentSize(CCSizeMake(i*100, i*100)); - pLayerColor:setPosition(ccp(Winsize.width/2, Winsize.height/2)) - pLayerColor:setAnchorPoint(ccp(0.5, 0.5)); + pLayerColor:setContentSize(CCSize(i*100, i*100)); + pLayerColor:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)) + pLayerColor:setAnchorPoint(CCPoint(0.5, 0.5)); pLayerColor:ignoreAnchorPointForPosition(false); pLayer:addChild(pLayerColor, -1-i); end @@ -321,12 +321,12 @@ local function BugTest914() local pLayer = BugTest914() CreateBugsTestBackMenuItem(pLayer) pScene:addChild(pLayer); - CCDirector:sharedDirector():replaceScene(pScene) + CCDirector:getInstance():replaceScene(pScene) end local label = CCLabelTTF:create("Hello World", "Marker Felt", 64) --position the label on the center of the screen - label:setPosition(ccp( Winsize.width /2 , Winsize.height/2 )); + label:setPosition(CCPoint( Winsize.width /2 , Winsize.height/2 )); pLayer:addChild(label); local item1 = CCMenuItemFont:create("restart") @@ -336,7 +336,7 @@ local function BugTest914() local menu = CCMenu:create() menu:addChild(item1) menu:alignItemsVertically() - menu:setPosition(ccp(Winsize.width/2, 100)) + menu:setPosition(CCPoint(Winsize.width/2, 100)) pLayer:addChild(menu) -- handling touch events @@ -365,28 +365,28 @@ end local function BugTest1159() local pLayer = CCLayer:create() - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) local background = CCLayerColor:create(Color4B(255, 0, 255, 255)) pLayer:addChild(background) local sprite_a = CCLayerColor:create(Color4B(255, 0, 0, 255), 700, 700) - sprite_a:setAnchorPoint(ccp(0.5, 0.5)) + sprite_a:setAnchorPoint(CCPoint(0.5, 0.5)) sprite_a:ignoreAnchorPointForPosition(false) - sprite_a:setPosition(ccp(0.0, Winsize.height/2)) + sprite_a:setPosition(CCPoint(0.0, Winsize.height/2)) pLayer:addChild(sprite_a) local arr = CCArray:create() - arr:addObject(CCMoveTo:create(1.0, ccp(1024.0, 384.0))) - arr:addObject(CCMoveTo:create(1.0, ccp(0.0, 384.0))) + arr:addObject(CCMoveTo:create(1.0, CCPoint(1024.0, 384.0))) + arr:addObject(CCMoveTo:create(1.0, CCPoint(0.0, 384.0))) local seq = CCSequence:create(arr) sprite_a:runAction(CCRepeatForever:create(seq)) local sprite_b = CCLayerColor:create(Color4B(0, 0, 255, 255), 400, 400); - sprite_b:setAnchorPoint(ccp(0.5, 0.5)) + sprite_b:setAnchorPoint(CCPoint(0.5, 0.5)) sprite_b:ignoreAnchorPointForPosition(false); - sprite_b:setPosition(ccp(Winsize.width/2, Winsize.height/2)); + sprite_b:setPosition(CCPoint(Winsize.width/2, Winsize.height/2)); pLayer:addChild(sprite_b); local function menuCallback() @@ -394,13 +394,13 @@ local function BugTest1159() local pLayer = BugTest1159() CreateBugsTestBackMenuItem(pLayer) pScene:addChild(pLayer); - CCDirector:sharedDirector():replaceScene(CCTransitionPageTurn:create(1.0, pScene, false)) + CCDirector:getInstance():replaceScene(CCTransitionPageTurn:create(1.0, pScene, false)) end local label = CCMenuItemLabel:create(CCLabelTTF:create("Flip Me", "Helvetica", 24)); label:registerScriptTapHandler(menuCallback) local menu = CCMenu:create(); menu:addChild(label) - menu:setPosition(ccp(Winsize.width - 200.0, 50.0)); + menu:setPosition(CCPoint(Winsize.width - 200.0, 50.0)); pLayer:addChild(menu); local function onNodeEvent(event) @@ -410,7 +410,7 @@ local function BugTest1159() scheduler:unscheduleScriptEntry(schedulerEntry) end ]]-- - CCDirector:sharedDirector():setDepthTest(false) + CCDirector:getInstance():setDepthTest(false) end end @@ -424,13 +424,13 @@ local function BugTest1174() local pLayer = CCLayer:create() local function check_for_error(p1,p2,p3,p4,s,t) - local p4_p3 = ccpSub(p4,p3) - local p4_p3_t = ccpMult(p4_p3,t) - local hitPoint1 = ccpAdd(p3,p4_p3_t) + local p4_p3 = CCPoint.__sub(p4,p3) + local p4_p3_t = CCPoint.__mul(p4_p3,t) + local hitPoint1 = CCPoint.__add(p3,p4_p3_t) - local p2_p1 = ccpSub(p2,p1) - local p2_p1_s = ccpMult(p2_p1,s) - local hitPoint2 = ccpAdd(p1,p2_p1_s) + local p2_p1 = CCPoint.__sub(p2,p1) + local p2_p1_s = CCPoint.__mul(p2_p1,s) + local hitPoint2 = CCPoint.__add(p1,p2_p1_s) if math.abs(hitPoint1.x - hitPoint2.x ) > 0.1 or math.abs(hitPoint1.y - hitPoint2.y) > 0.1 then local strErr = "ERROR: ("..hitPoint1.x..","..hitPoint1.y..") != ("..hitPoint2.x..","..hitPoint2.y..")" @@ -480,12 +480,12 @@ local function BugTest1174() local cx = math.random() * -5000 local cy = math.random() * -5000 - A = ccp(ax,ay) - B = ccp(bx,by) - C = ccp(cx,cy) - D = ccp(dx,dy) + A = CCPoint(ax,ay) + B = CCPoint(bx,by) + C = CCPoint(cx,cy) + D = CCPoint(dx,dy) - bRet,s,t = ccpLineIntersect( A, D, B, C, s, t) + bRet,s,t = CCPoint:isLineIntersect( A, D, B, C, s, t) if true == bRet then if 1 == check_for_error(A,D,B,C,s,t) then err = err + 1 @@ -501,13 +501,13 @@ local function BugTest1174() -------- print("Test2 - Start") - p1 = ccp(220,480); - p2 = ccp(304,325); - p3 = ccp(264,416); - p4 = ccp(186,416); + p1 = CCPoint(220,480); + p2 = CCPoint(304,325); + p3 = CCPoint(264,416); + p4 = CCPoint(186,416); s = 0.0; t = 0.0; - bRet,s,t = ccpLineIntersect( p1, p2, p3, p4, s, t) + bRet,s,t = CCPoint:isLineIntersect( p1, p2, p3, p4, s, t) if true == bRet then check_for_error(p1, p2, p3, p4, s, t) end @@ -526,13 +526,13 @@ local function BugTest1174() -- c | d local ax = math.random() * -500 local ay = math.random() * 500 - p1 = ccp(ax,ay); + p1 = CCPoint(ax,ay); -- a | b -- ----- -- c | D local dx = math.random() * 500 local dy = math.random() * -500 - p2 = ccp(dx,dy) + p2 = CCPoint(dx,dy) ------- @@ -542,17 +542,17 @@ local function BugTest1174() -- ----- -- C | d local cx = math.random() * -500 - p3 = ccp(cx,y) + p3 = CCPoint(cx,y) -- a | B -- ----- -- c | d local bx = math.random() * 500 - p4 = ccp(bx,y) + p4 = CCPoint(bx,y) s = 0.0 t = 0.0 - bRet,s,t = ccpLineIntersect(p1, p2, p3, p4, s, t) + bRet,s,t = CCPoint:isLineIntersect(p1, p2, p3, p4, s, t) if true == bRet then if 1 == check_for_error(p1, p2, p3, p4, s,t ) then err = err + 1 @@ -584,7 +584,7 @@ local function CreateBugsTestScene(nBugNo) local pLayer = CreateBugsTestTable[nBugNo]() CreateBugsTestBackMenuItem(pLayer) pNewscene:addChild(pLayer) - CCDirector:sharedDirector():replaceScene(pNewscene) + CCDirector:getInstance():replaceScene(pNewscene) --pLayer:autorelease() end @@ -597,7 +597,7 @@ local function BugsTestMainLayer() local nIdx = pMenuItem:getZOrder() - kItemTagBasic local BugTestScene = CreateBugsTestScene(nIdx) if nil ~= testScene then - CCDirector:sharedDirector():replaceScene(testScene) + CCDirector:getInstance():replaceScene(testScene) end end @@ -611,10 +611,10 @@ local function BugsTestMainLayer() local pMenuItem = CCMenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) pItemMenu:addChild(pMenuItem, i + kItemTagBasic) - pMenuItem:setPosition( ccp( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) + pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) end - pItemMenu:setPosition(ccp(0, 0)) + pItemMenu:setPosition(CCPoint(0, 0)) ret:addChild(pItemMenu) ret:setTouchEnabled(true) diff --git a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua index ac194e390a..c17adf676d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua @@ -1,4 +1,4 @@ -local size = CCDirector:sharedDirector():getWinSize() +local size = CCDirector:getInstance():getWinSize() local layer = nil local kTagSprite = 1 @@ -9,9 +9,9 @@ local function initWithLayer() layer:addChild(bgLayer, -1) layer:addChild(sprite, 0, kTagSprite) - sprite:setPosition(CCPointMake(20,150)) + sprite:setPosition(CCPoint(20,150)) - sprite:runAction(CCJumpTo:create(4, CCPointMake(300,48), 100, 4)) + sprite:runAction(CCJumpTo:create(4, CCPoint(300,48), 100, 4)) bgLayer:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions( CCFadeIn:create(1), @@ -20,7 +20,7 @@ local function initWithLayer() local function onTouchEnded(x, y) local s = layer:getChildByTag(kTagSprite) s:stopAllActions() - s:runAction(CCMoveTo:create(1, CCPointMake(x, y))) + s:runAction(CCMoveTo:create(1, CCPoint(x, y))) local posX, posY = s:getPosition() local o = x - posX local a = y - posY diff --git a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua index c23502fc10..156771af21 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocosDenshionTest/CocosDenshionTest.lua @@ -7,7 +7,7 @@ local LINE_SPACE = 40 local function CocosDenshionTest() local ret = CCLayer:create() local m_pItmeMenu = nil - local m_tBeginPos = ccp(0, 0) + local m_tBeginPos = CCPoint(0, 0) local m_nSoundId = 0 local testItems = { @@ -102,11 +102,11 @@ local function CocosDenshionTest() local pMenuItem = CCMenuItemLabel:create(label) pMenuItem:registerScriptTapHandler(menuCallback) m_pItmeMenu:addChild(pMenuItem, i + 10000 -1) - pMenuItem:setPosition( ccp( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) + pMenuItem:setPosition( CCPoint( VisibleRect:center().x, (VisibleRect:top().y - i * LINE_SPACE) )) end - m_pItmeMenu:setContentSize(CCSizeMake(VisibleRect:getVisibleRect().size.width, (m_nTestCount + 1) * LINE_SPACE)) - m_pItmeMenu:setPosition(ccp(0, 0)) + m_pItmeMenu:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, (m_nTestCount + 1) * LINE_SPACE)) + m_pItmeMenu:setPosition(CCPoint(0, 0)) ret:addChild(m_pItmeMenu) ret:setTouchEnabled(true) @@ -122,7 +122,7 @@ local function CocosDenshionTest() if event == "enter" then elseif event == "exit" then - --SimpleAudioEngine:sharedEngine():endToLua() + --SimpleAudioEngine:getInstance():endToLua() end end @@ -133,21 +133,21 @@ local function CocosDenshionTest() if eventType == "began" then prev.x = x prev.y = y - m_tBeginPos = ccp(x, y) + m_tBeginPos = CCPoint(x, y) return true elseif eventType == "moved" then - local touchLocation = ccp(x, y) + local touchLocation = CCPoint(x, y) local nMoveY = touchLocation.y - m_tBeginPos.y local curPosX, curPosY = m_pItmeMenu:getPosition() - local curPos = ccp(curPosX, curPosY) - local nextPos = ccp(curPos.x, curPos.y + nMoveY) + local curPos = CCPoint(curPosX, curPosY) + local nextPos = CCPoint(curPos.x, curPos.y + nMoveY) if nextPos.y < 0.0 then - m_pItmeMenu:setPosition(ccp(0, 0)) + m_pItmeMenu:setPosition(CCPoint(0, 0)) end if nextPos.y > ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height) then - m_pItmeMenu:setPosition(ccp(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height))) + m_pItmeMenu:setPosition(CCPoint(0, ((m_nTestCount + 1)* LINE_SPACE - VisibleRect:getVisibleRect().size.height))) end m_pItmeMenu:setPosition(nextPos) diff --git a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua index 6a56ea1904..d1bda7abc1 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CurrentLanguageTest/CurrentLanguageTest.lua @@ -2,7 +2,7 @@ local function CurrentLanguageTest() local ret = CCLayer:create() local label = CCLabelTTF:create("Current language Test", "Arial", 28) ret:addChild(label, 0) - label:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y-50) ) + label:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y-50) ) local labelLanguage = CCLabelTTF:create("", "Arial", 20) labelLanguage:setPosition(VisibleRect:center()) diff --git a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua index ee8cc649b9..b984fb4e37 100644 --- a/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/DrawPrimitivesTest/DrawPrimitivesTest.lua @@ -43,7 +43,7 @@ local function drawPrimitivesMainLayer() item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - ordercallbackmenu:setPosition(ccp(0, 0)) + ordercallbackmenu:setPosition(CCPoint(0, 0)) return ordercallbackmenu end diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua index 936bf7e4fa..e742be019d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsAdvancedTest/EffectsAdvancedTest.lua @@ -14,7 +14,7 @@ local function createTestLayer(title, subtitle) local grossini = CCSprite:create("Images/grossinis_sister2.png") bg:addChild(grossini, 1, kTagSprite1) - grossini:setPosition( ccp(VisibleRect:left().x+VisibleRect:getVisibleRect().size.width/3.0, VisibleRect:bottom().y+ 200) ) + grossini:setPosition( CCPoint(VisibleRect:left().x+VisibleRect:getVisibleRect().size.width/3.0, VisibleRect:bottom().y+ 200) ) local sc = CCScaleBy:create(2, 5) local sc_back = sc:reverse() local arr = CCArray:create() @@ -24,7 +24,7 @@ local function createTestLayer(title, subtitle) local tamara = CCSprite:create("Images/grossinis_sister1.png") bg:addChild(tamara, 1, kTagSprite2) - tamara:setPosition( ccp(VisibleRect:left().x+2*VisibleRect:getVisibleRect().size.width/3.0,VisibleRect:bottom().y+200) ) + tamara:setPosition( CCPoint(VisibleRect:left().x+2*VisibleRect:getVisibleRect().size.width/3.0,VisibleRect:bottom().y+200) ) local sc2 = CCScaleBy:create(2, 5) local sc2_back = sc2:reverse() arr = CCArray:create() @@ -50,9 +50,9 @@ local function Effect1() -- Lens3D is Grid3D and it's size is (15,10) -- Waves3D is Grid3D and it's size is (15,10) - local size = CCDirector:sharedDirector():getWinSize() - local lens = CCLens3D:create(0.0, CCSizeMake(15,10), ccp(size.width/2,size.height/2), 240) - local waves = CCWaves3D:create(10, CCSizeMake(15,10), 18, 15) + local size = CCDirector:getInstance():getWinSize() + local lens = CCLens3D:create(0.0, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240) + local waves = CCWaves3D:create(10, CCSize(15,10), 18, 15) local reuse = CCReuseGrid:create(1) local delay = CCDelayTime:create(8) @@ -86,9 +86,9 @@ local function Effect2() -- ShakyTiles is TiledGrid3D and it's size is (15,10) -- Shuffletiles is TiledGrid3D and it's size is (15,10) -- TurnOfftiles is TiledGrid3D and it's size is (15,10) - local shaky = CCShakyTiles3D:create(5, CCSizeMake(15,10), 4, false) - local shuffle = CCShuffleTiles:create(0, CCSizeMake(15,10), 3) - local turnoff = CCTurnOffTiles:create(0, CCSizeMake(15,10), 3) + local shaky = CCShakyTiles3D:create(5, CCSize(15,10), 4, false) + local shuffle = CCShuffleTiles:create(0, CCSize(15,10), 3) + local turnoff = CCTurnOffTiles:create(0, CCSize(15,10), 3) local turnon = turnoff:reverse() -- reuse 2 times: @@ -122,14 +122,14 @@ local function Effect3() local target1 = bg:getChildByTag(kTagSprite1) local target2 = bg:getChildByTag(kTagSprite2) - local waves = CCWaves:create(5, CCSizeMake(15,10), 5, 20, true, false) - local shaky = CCShaky3D:create(5, CCSizeMake(15,10), 4, false) + local waves = CCWaves:create(5, CCSize(15,10), 5, 20, true, false) + local shaky = CCShaky3D:create(5, CCSize(15,10), 4, false) target1:runAction( CCRepeatForever:create( waves ) ) target2:runAction( CCRepeatForever:create( shaky ) ) -- moving background. Testing issue #244 - local move = CCMoveBy:create(3, ccp(200,0) ) + local move = CCMoveBy:create(3, CCPoint(200,0) ) local arr = CCArray:create() arr:addObject(move) arr:addObject(move:reverse()) @@ -174,8 +174,8 @@ end local function Effect4() local ret = createTestLayer("Jumpy Lens3D") - local lens = CCLens3D:create(10, CCSizeMake(32,24), ccp(100,180), 150) - local move = CCJumpBy:create(5, ccp(380,0), 100, 4) + local lens = CCLens3D:create(10, CCSize(32,24), CCPoint(100,180), 150) + local move = CCJumpBy:create(5, CCPoint(380,0), 100, 4) local move_back = move:reverse() local arr = CCArray:create() arr:addObject(move) @@ -187,7 +187,7 @@ local function Effect4() -- so we make an encapsulation for CCLens3D to achieve that. -- */ - local director = CCDirector:sharedDirector() + local director = CCDirector:getInstance() -- local pTarget = Lens3DTarget:create(lens) -- -- Please make sure the target been added to its parent. -- ret:addChild(pTarget) @@ -205,7 +205,7 @@ end local function Effect5() local ret = createTestLayer("Test Stop-Copy-Restar") - local effect = CCLiquid:create(2, CCSizeMake(32,24), 1, 20) + local effect = CCLiquid:create(2, CCSize(32,24), 1, 20) local arr = CCArray:create() arr:addObject(effect) arr:addObject(CCDelayTime:create(2)) @@ -216,7 +216,7 @@ local function Effect5() bg:runAction(stopEffect) local function onNodeEvent(event) if event == "exit" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection3D) + CCDirector:getInstance():setProjection(kCCDirectorProjection3D) end end @@ -235,7 +235,7 @@ local function Issue631() "Effect image should be 100% opaque. Testing issue #631") local arr = CCArray:create() arr:addObject(CCDelayTime:create(2.0)) - arr:addObject(CCShaky3D:create(5.0, CCSizeMake(5, 5), 16, false)) + arr:addObject(CCShaky3D:create(5.0, CCSize(5, 5), 16, false)) local effect = CCSequence:create(arr) -- cleanup @@ -246,7 +246,7 @@ local function Issue631() local layer = CCLayerColor:create( Color4B(255,0,0,255) ) ret:addChild(layer, -10) local sprite = CCSprite:create("Images/grossini.png") - sprite:setPosition( ccp(50,80) ) + sprite:setPosition( CCPoint(50,80) ) layer:addChild(sprite, 10) -- foreground diff --git a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua index 690431ce24..71da8fb91f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/EffectsTest/EffectsTest.lua @@ -2,7 +2,7 @@ require "luaScript/EffectsTest/EffectsName" local ActionIdx = -1 -local size = CCDirector:sharedDirector():getWinSize() +local size = CCDirector:getInstance():getWinSize() local kTagTextLayer = 1 local kTagBackground = 1 local kTagLabel = 2 @@ -18,7 +18,7 @@ local function checkAnim(dt) return end - if s2:numberOfRunningActions() == 0 then + if s2:getNumberOfRunningActions() == 0 then if s2:getGrid() ~= nil then s2:setGrid(nil) end @@ -26,7 +26,7 @@ local function checkAnim(dt) end local function onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then entry = scheduler:scheduleScriptFunc(checkAnim, 0, false) elseif tag == "exit" then @@ -60,7 +60,7 @@ local function backCallback(sender) scene:addChild(backAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function restartCallback(sender) @@ -69,7 +69,7 @@ local function restartCallback(sender) scene:addChild(restartAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function nextCallback(sender) @@ -78,21 +78,21 @@ local function nextCallback(sender) scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end -------------------------------------- -- Shaky3DDemo -------------------------------------- local function Shaky3DDemo(t) - return CCShaky3D:create(t, CCSizeMake(15,10), 5, false); + return CCShaky3D:create(t, CCSize(15,10), 5, false); end -------------------------------------- -- Waves3DDemo -------------------------------------- local function Waves3DDemo(t) - return CCWaves3D:create(t, CCSizeMake(15,10), 5, 40); + return CCWaves3D:create(t, CCSize(15,10), 5, 40); end -------------------------------------- @@ -129,56 +129,56 @@ end -- Lens3DDemo -------------------------------------- local function Lens3DDemo(t) - return CCLens3D:create(t, CCSizeMake(15,10), ccp(size.width/2,size.height/2), 240); + return CCLens3D:create(t, CCSize(15,10), CCPoint(size.width/2,size.height/2), 240); end -------------------------------------- -- Ripple3DDemo -------------------------------------- local function Ripple3DDemo(t) - return CCRipple3D:create(t, CCSizeMake(32,24), ccp(size.width/2,size.height/2), 240, 4, 160); + return CCRipple3D:create(t, CCSize(32,24), CCPoint(size.width/2,size.height/2), 240, 4, 160); end -------------------------------------- -- LiquidDemo -------------------------------------- local function LiquidDemo(t) - return CCLiquid:create(t, CCSizeMake(16,12), 4, 20); + return CCLiquid:create(t, CCSize(16,12), 4, 20); end -------------------------------------- -- WavesDemo -------------------------------------- local function WavesDemo(t) - return CCWaves:create(t, CCSizeMake(16,12), 4, 20, true, true); + return CCWaves:create(t, CCSize(16,12), 4, 20, true, true); end -------------------------------------- -- TwirlDemo -------------------------------------- local function TwirlDemo(t) - return CCTwirl:create(t, CCSizeMake(12,8), ccp(size.width/2, size.height/2), 1, 2.5); + return CCTwirl:create(t, CCSize(12,8), CCPoint(size.width/2, size.height/2), 1, 2.5); end -------------------------------------- -- ShakyTiles3DDemo -------------------------------------- local function ShakyTiles3DDemo(t) - return CCShakyTiles3D:create(t, CCSizeMake(16,12), 5, false); + return CCShakyTiles3D:create(t, CCSize(16,12), 5, false); end -------------------------------------- -- ShatteredTiles3DDemo -------------------------------------- local function ShatteredTiles3DDemo(t) - return CCShatteredTiles3D:create(t, CCSizeMake(16,12), 5, false); + return CCShatteredTiles3D:create(t, CCSize(16,12), 5, false); end -------------------------------------- -- ShuffleTilesDemo -------------------------------------- local function ShuffleTilesDemo(t) - local shuffle = CCShuffleTiles:create(t, CCSizeMake(16,12), 25); + local shuffle = CCShuffleTiles:create(t, CCSize(16,12), 25); local shuffle_back = shuffle:reverse() local delay = CCDelayTime:create(2) @@ -193,7 +193,7 @@ end -- FadeOutTRTilesDemo -------------------------------------- local function FadeOutTRTilesDemo(t) - local fadeout = CCFadeOutTRTiles:create(t, CCSizeMake(16,12)); + local fadeout = CCFadeOutTRTiles:create(t, CCSize(16,12)); local back = fadeout:reverse() local delay = CCDelayTime:create(0.5) @@ -208,7 +208,7 @@ end -- FadeOutBLTilesDemo -------------------------------------- local function FadeOutBLTilesDemo(t) - local fadeout = CCFadeOutBLTiles:create(t, CCSizeMake(16,12)); + local fadeout = CCFadeOutBLTiles:create(t, CCSize(16,12)); local back = fadeout:reverse() local delay = CCDelayTime:create(0.5) @@ -223,7 +223,7 @@ end -- FadeOutUpTilesDemo -------------------------------------- local function FadeOutUpTilesDemo(t) - local fadeout = CCFadeOutUpTiles:create(t, CCSizeMake(16,12)); + local fadeout = CCFadeOutUpTiles:create(t, CCSize(16,12)); local back = fadeout:reverse() local delay = CCDelayTime:create(0.5) @@ -238,7 +238,7 @@ end -- FadeOutDownTilesDemo -------------------------------------- local function FadeOutDownTilesDemo(t) - local fadeout = CCFadeOutDownTiles:create(t, CCSizeMake(16,12)); + local fadeout = CCFadeOutDownTiles:create(t, CCSize(16,12)); local back = fadeout:reverse() local delay = CCDelayTime:create(0.5) @@ -253,7 +253,7 @@ end -- TurnOffTilesDemo -------------------------------------- local function TurnOffTilesDemo(t) - local fadeout = CCTurnOffTiles:create(t, CCSizeMake(48,32), 25); + local fadeout = CCTurnOffTiles:create(t, CCSize(48,32), 25); local back = fadeout:reverse() local delay = CCDelayTime:create(0.5) @@ -268,14 +268,14 @@ end -- WavesTiles3DDemo -------------------------------------- local function WavesTiles3DDemo(t) - return CCWavesTiles3D:create(t, CCSizeMake(15,10), 4, 120); + return CCWavesTiles3D:create(t, CCSize(15,10), 4, 120); end -------------------------------------- -- JumpTiles3DDemo -------------------------------------- local function JumpTiles3DDemo(t) - return CCJumpTiles3D:create(t, CCSizeMake(15,10), 2, 30); + return CCJumpTiles3D:create(t, CCSize(15,10), 2, 30); end -------------------------------------- @@ -296,15 +296,15 @@ end -- PageTurn3DDemo -------------------------------------- local function PageTurn3DDemo(t) - CCDirector:sharedDirector():setDepthTest(true) - return CCPageTurn3D:create(t, CCSizeMake(15,10)); + CCDirector:getInstance():setDepthTest(true) + return CCPageTurn3D:create(t, CCSize(15,10)); end -------------------------------------- -- Effects Test -------------------------------------- local function createEffect(idx, t) - CCDirector:sharedDirector():setDepthTest(false) + CCDirector:getInstance():setDepthTest(false) local action = nil if idx == 0 then @@ -368,18 +368,18 @@ function CreateEffectsTestLayer() local bg = CCSprite:create(s_back3) node:addChild(bg, 0) - bg:setPosition(CCPointMake(size.width / 2, size.height / 2)) + bg:setPosition(CCPoint(size.width / 2, size.height / 2)) local grossini = CCSprite:create(s_pPathSister2) node:addChild(grossini, 1) - grossini:setPosition( CCPointMake(x / 3, y / 2) ) + grossini:setPosition( CCPoint(x / 3, y / 2) ) local sc = CCScaleBy:create(2, 5) local sc_back = sc:reverse() grossini:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc, sc_back))) local tamara = CCSprite:create(s_pPathSister1) node:addChild(tamara, 1) - tamara:setPosition(CCPointMake(2 * x / 3, y / 2)) + tamara:setPosition(CCPoint(2 * x / 3, y / 2)) local sc2 = CCScaleBy:create(2, 5) local sc2_back = sc2:reverse() tamara:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(sc2, sc2_back))) @@ -401,10 +401,10 @@ function CreateEffectsTestLayer() menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPointMake(0, 0)) - item1:setPosition(CCPointMake(size.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width/2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(CCPoint(0, 0)) + item1:setPosition(CCPoint(size.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width/2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) testLayer:addChild(menu, 1) diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua index e4ba61b1f0..08bde4efab 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/CocosBuilderTest.lua @@ -96,7 +96,7 @@ local function onMenuTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -105,7 +105,7 @@ TestMenusLayer["onMenuItemBClicked"] = onMenuItemBClicked TestMenusLayer["pressedC:"] = pressedC local function onBackClicked() - CCDirector:sharedDirector():popScene(); + CCDirector:getInstance():popScene(); end TestHeaderLayer["onBackClicked"] = onBackClicked @@ -125,7 +125,7 @@ local function onSpriteTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -144,7 +144,7 @@ local function onButtonTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -171,7 +171,7 @@ local function onAnimationsTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -190,7 +190,7 @@ local function onParticleSystemTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -250,7 +250,7 @@ local function onScrollViewTestClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end @@ -269,7 +269,7 @@ local function onTimelineCallbackSoundClicked() if nil ~= scene then scene:addChild(layer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, scene, Color3B(0,0,0))); end end diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua index 02a24eed9f..4d7d78b849 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/ExtensionTest.lua @@ -35,14 +35,14 @@ function CreateExtensionsBasicLayerMenu(pMenu) local function toMainLayer() local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:sharedDirector():replaceScene(pScene) + CCDirector:getInstance():replaceScene(pScene) end end --Create BackMneu CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24) local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(ccp(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -65,16 +65,16 @@ local function runNotificationCenterTest() if nil == pLayer then return end - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local function toggleSwitch(tag,menuItem) local toggleItem = tolua.cast(menuItem,"CCMenuItemToggle") local nIndex = toggleItem:getSelectedIndex() - local selectedItem = toggleItem:selectedItem() + local selectedItem = toggleItem:getSelectedItem() if 0 == nIndex then selectedItem = nil end - CCNotificationCenter:sharedNotificationCenter():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) + CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE,selectedItem) end local switchlabel1 = CCLabelTTF:create("switch off", "Marker Felt", 26) @@ -88,11 +88,11 @@ local function runNotificationCenterTest() switchitem:setSelectedIndex(1) local menu = CCMenu:create() menu:addChild(switchitem) - menu:setPosition(ccp(s.width/2+100, s.height/2)) + menu:setPosition(CCPoint(s.width/2+100, s.height/2)) pLayer:addChild(menu) local menuConnect = CCMenu:create() - menuConnect:setPosition(ccp(0,0)) + menuConnect:setPosition(CCPoint(0,0)) pLayer:addChild(menuConnect) local i = 1 local bSwitchOn = false @@ -129,9 +129,9 @@ local function runNotificationCenterTest() local function setIsConnectToSwitch(pLight,bConnect,nIdx) bConnectArray[nIdx] = bConnect if bConnect then - CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) + CCNotificationCenter:getInstance():registerScriptObserver(pLight, switchStateChanged,NotificationCenterParam.MSG_SWITCH_STATE) else - CCNotificationCenter:sharedNotificationCenter():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) + CCNotificationCenter:getInstance():unregisterScriptObserver(pLight,NotificationCenterParam.MSG_SWITCH_STATE) end updateLightState() end @@ -140,7 +140,7 @@ local function runNotificationCenterTest() for i = 1, 3 do lightArray[i] = CCSprite:create("Images/Pea.png") lightArray[i]:setTag(NotificationCenterParam.kTagLight + i) - lightArray[i]:setPosition(ccp(100, s.height / 4 * i) ) + lightArray[i]:setPosition(CCPoint(100, s.height / 4 * i) ) pLayer:addChild(lightArray[i]) local connectlabel1 = CCLabelTTF:create("not connected", "Marker Felt", 26) @@ -165,7 +165,7 @@ local function runNotificationCenterTest() connectitem:registerScriptTapHandler(connectToSwitch) local nX,nY = lightArray[i]:getPosition() - connectitem:setPosition(ccp(nX,nY+50)) + connectitem:setPosition(CCPoint(nX,nY+50)) menuConnect:addChild(connectitem, 0,connectitem:getTag()) @@ -182,52 +182,52 @@ local function runNotificationCenterTest() setIsConnectToSwitch(lightArray[i],bConnectArray[i],i) end local toggleSelectIndex = switchitem:getSelectedIndex() - local toggleSelectedItem = switchitem:selectedItem() + local toggleSelectedItem = switchitem:getSelectedItem() if 0 == toggleSelectIndex then toggleSelectedItem = nil end - CCNotificationCenter:sharedNotificationCenter():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) + CCNotificationCenter:getInstance():postNotification(NotificationCenterParam.MSG_SWITCH_STATE, toggleSelectedItem) --for testing removeAllObservers */ local function doNothing() end - CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pNewLayer,doNothing, "random-observer1") - CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pNewLayer,doNothing, "random-observer2") - CCNotificationCenter:sharedNotificationCenter():registerScriptObserver(pNewLayer,doNothing, "random-observer3") + CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer1") + CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer2") + CCNotificationCenter:getInstance():registerScriptObserver(pNewLayer,doNothing, "random-observer3") local function CreateToMainMenu(pMenu) if nil == pMenu then return end local function toMainLayer() - local numObserversRemoved = CCNotificationCenter:sharedNotificationCenter():removeAllObservers(pNewLayer) + local numObserversRemoved = CCNotificationCenter:getInstance():removeAllObservers(pNewLayer) if 3 ~= numObserversRemoved then print("All observers were not removed!") end for i = 1 , 3 do if bConnectArray[i] then - CCNotificationCenter:sharedNotificationCenter():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) + CCNotificationCenter:getInstance():unregisterScriptObserver(lightArray[i],NotificationCenterParam.MSG_SWITCH_STATE) end end local pScene = ExtensionsTestMain() if pScene ~= nil then - CCDirector:sharedDirector():replaceScene(pScene) + CCDirector:getInstance():replaceScene(pScene) end end --Create BackMneu CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24) local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(ccp(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end --Add Menu local pToMainMenu = CCMenu:create() CreateToMainMenu(pToMainMenu) - pToMainMenu:setPosition(ccp(0, 0)) + pToMainMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pToMainMenu,10) end @@ -307,7 +307,7 @@ local function runCCControlTest() CurrentControlScene() end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) @@ -318,10 +318,10 @@ local function runCCControlTest() pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:sharedDirector():getWinSize() - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = CCDirector:getInstance():getWinSize() + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end @@ -332,7 +332,7 @@ local function runCCControlTest() --Add Menu local pToMainMenu = CCMenu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(ccp(0, 0)) + pToMainMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pToMainMenu,10) --Add the generated background @@ -341,20 +341,20 @@ local function runCCControlTest() pLayer:addChild(pBackground) --Add the ribbon - local pRibbon = CCScale9Sprite:create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55)) - pRibbon:setContentSize(CCSizeMake(VisibleRect:getVisibleRect().size.width, 57)) - pRibbon:setPosition(ccp(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) + local pRibbon = CCScale9Sprite:create("extensions/ribbon.png", CCRect(1, 1, 48, 55)) + pRibbon:setContentSize(CCSize(VisibleRect:getVisibleRect().size.width, 57)) + pRibbon:setPosition(CCPoint(VisibleRect:center().x, VisibleRect:top().y - pRibbon:getContentSize().height / 2.0)) pLayer:addChild(pRibbon) --Add the title pSceneTitleLabel = CCLabelTTF:create("Title", "Arial", 12) - pSceneTitleLabel:setPosition(ccp (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) + pSceneTitleLabel:setPosition(CCPoint (VisibleRect:center().x, VisibleRect:top().y - pSceneTitleLabel:getContentSize().height / 2 - 5)) pLayer:addChild(pSceneTitleLabel, 1) pSceneTitleLabel:setString(pStrTitle) local pOperateMenu = CCMenu:create() CreateBasicMenu(pOperateMenu) - pOperateMenu:setPosition(ccp(0, 0)) + pOperateMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pOperateMenu,1) end @@ -363,12 +363,12 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() --Add a label in which the slider value will be displayed local pDisplayValueLabel = CCLabelTTF:create("Move the slider thumb!\nThe lower slider is restricted." ,"Marker Felt", 32) pDisplayValueLabel:retain() - pDisplayValueLabel:setAnchorPoint(ccp(0.5, -1.0)) - pDisplayValueLabel:setPosition(ccp(screenSize.width / 1.7, screenSize.height / 2.0)) + pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1.0)) + pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 1.7, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel) local function valueChanged(pSender) @@ -389,23 +389,23 @@ local function runCCControlTest() end --Add the slider local pSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pSlider:setAnchorPoint(ccp(0.5, 1.0)) + pSlider:setAnchorPoint(CCPoint(0.5, 1.0)) pSlider:setMinimumValue(0.0) pSlider:setMaximumValue(5.0) - pSlider:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) + pSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 + 16)) pSlider:setTag(1) --When the value of the slider will change, the given selector will be call pSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) local pRestrictSlider = CCControlSlider:create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png") - pRestrictSlider:setAnchorPoint(ccp(0.5, 1.0)) + pRestrictSlider:setAnchorPoint(CCPoint(0.5, 1.0)) pRestrictSlider:setMinimumValue(0.0) pRestrictSlider:setMaximumValue(5.0) pRestrictSlider:setMaximumAllowedValue(4.0) pRestrictSlider:setMinimumAllowedValue(1.5) pRestrictSlider:setValue(3.0) - pRestrictSlider:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) + pRestrictSlider:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0 - 24)) pRestrictSlider:setTag(2) --same with restricted pRestrictSlider:registerControlEventHandler(valueChanged, CCControlEventValueChanged) @@ -418,11 +418,11 @@ local function runCCControlTest() if nil == pLayer then return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local pColorLabel = nil local pNode = CCNode:create() - pNode:setPosition(ccp (screenSize.width / 2, screenSize.height / 2)) + pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 @@ -439,7 +439,7 @@ local function runCCControlTest() end local pColourPicker = CCControlColourPicker:create() pColourPicker:setColor(Color3B(37, 46, 252)) - pColourPicker:setPosition(ccp (pColourPicker:getContentSize().width / 2, 0)) + pColourPicker:setPosition(CCPoint (pColourPicker:getContentSize().width / 2, 0)) pColourPicker:registerControlEventHandler(colourValueChanged, CCControlEventValueChanged) pNode:addChild(pColourPicker) @@ -447,8 +447,8 @@ local function runCCControlTest() --Add the black background for the text local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSizeMake(150, 50)) - pBackground:setPosition(ccp(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + pBackground:setContentSize(CCSize(150, 50)) + pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width @@ -458,8 +458,8 @@ local function runCCControlTest() pNode:addChild(pColorLabel) --Set the layer size - pNode:setContentSize(CCSizeMake(dLayer_width, 0)) - pNode:setAnchorPoint(ccp (0.5, 0.5)) + pNode:setContentSize(CCSize(dLayer_width, 0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) --Update the color text colourValueChanged(pColourPicker) @@ -471,18 +471,18 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local pNode = CCNode:create() - pNode:setPosition(ccp (screenSize.width / 2, screenSize.height / 2)) + pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 --Add the black background for the text local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSizeMake(80, 50)) - pBackground:setPosition(ccp(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + pBackground:setContentSize(CCSize(80, 50)) + pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width @@ -513,13 +513,13 @@ local function runCCControlTest() CCLabelTTF:create("On", "Arial-BoldMT", 16), CCLabelTTF:create("Off", "Arial-BoldMT", 16) ) - pSwitchControl:setPosition(ccp (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) + pSwitchControl:setPosition(CCPoint (dLayer_width + 10 + pSwitchControl:getContentSize().width / 2, 0)) pNode:addChild(pSwitchControl) pSwitchControl:registerControlEventHandler(valueChanged, CCControlEventValueChanged) --Set the layer size - pNode:setContentSize(CCSizeMake(dLayer_width, 0)) - pNode:setAnchorPoint(ccp (0.5, 0.5)) + pNode:setContentSize(CCSize(dLayer_width, 0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) --Update the value label valueChanged(pSwitchControl) @@ -547,7 +547,7 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local strArray = CCArray:create() strArray:addObject(CCString:create("Hello")) strArray:addObject(CCString:create("Variable")) @@ -566,7 +566,7 @@ local function runCCControlTest() pObj = tolua.cast(strArray:objectAtIndex(i), "CCString") --Creates a button with pLayer string as title local pButton = HvsStandardButtonWithTitle(pObj:getCString()) - pButton:setPosition(ccp (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) + pButton:setPosition(CCPoint (dTotalWidth + pButton:getContentSize().width / 2, pButton:getContentSize().height / 2)) pNode:addChild(pButton) --Compute the size of the layer @@ -574,22 +574,22 @@ local function runCCControlTest() dTotalWidth = dTotalWidth + pButton:getContentSize().width end - pNode:setAnchorPoint(ccp (0.5, 0.5)) - pNode:setContentSize(CCSizeMake(dTotalWidth, dHeight)) - pNode:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(CCSize(dTotalWidth, dHeight)) + pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSizeMake(dTotalWidth + 14, dHeight + 14)) - pBackground:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pBackground:setContentSize(CCSize(dTotalWidth + 14, dHeight + 14)) + pBackground:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackground) end local function StylingStandardButtonWithTitle(pStrTitle) local pBackgroundButton = CCScale9Sprite:create("extensions/button.png") - pBackgroundButton:setPreferredSize(CCSizeMake(45, 45)) + pBackgroundButton:setPreferredSize(CCSize(45, 45)) local pBackgroundHighlightedButton = CCScale9Sprite:create("extensions/buttonHighlighted.png") - pBackgroundHighlightedButton:setPreferredSize(CCSizeMake(45, 45)) + pBackgroundHighlightedButton:setPreferredSize(CCSize(45, 45)) local pTitleButton = CCLabelTTF:create(pStrTitle, "Marker Felt", 30) @@ -607,7 +607,7 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local pNode = CCNode:create() pLayer:addChild(pNode, 1) @@ -624,7 +624,7 @@ local function runCCControlTest() local strFmt = string.format("%d",math.random(0,32767) % 30) local pButton = StylingStandardButtonWithTitle(CCString:create(strFmt):getCString()) pButton:setAdjustBackgroundImage(false) - pButton:setPosition(ccp (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, + pButton:setPosition(CCPoint (pButton:getContentSize().width / 2 + (pButton:getContentSize().width + nSpace) * i, pButton:getContentSize().height / 2 + (pButton:getContentSize().height + nSpace) * j)) pNode:addChild(pButton) @@ -635,14 +635,14 @@ local function runCCControlTest() end - pNode:setAnchorPoint(ccp (0.5, 0.5)) - pNode:setContentSize(CCSizeMake(nMax_w, nMax_h)) - pNode:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) + pNode:setContentSize(CCSize(nMax_w, nMax_h)) + pNode:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) --Add the black background local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSizeMake(nMax_w + 14, nMax_h + 14)) - pBackgroundButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pBackgroundButton:setContentSize(CCSize(nMax_w + 14, nMax_h + 14)) + pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end @@ -651,13 +651,13 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() --Add a label in which the button events will be displayed local pDisplayValueLabel = nil pDisplayValueLabel = CCLabelTTF:create("No Event", "Marker Felt", 32) - pDisplayValueLabel:setAnchorPoint(ccp(0.5, -1)) - pDisplayValueLabel:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pDisplayValueLabel:setAnchorPoint(CCPoint(0.5, -1)) + pDisplayValueLabel:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pDisplayValueLabel, 1) --Add the button @@ -728,8 +728,8 @@ local function runCCControlTest() pControlButton:setBackgroundSpriteForState(pBackgroundHighlightedButton, CCControlStateHighlighted) pControlButton:setTitleColorForState(Color3B(255, 255, 255), CCControlStateHighlighted) - pControlButton:setAnchorPoint(ccp(0.5, 1)) - pControlButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pControlButton:setAnchorPoint(CCPoint(0.5, 1)) + pControlButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) pControlButton:registerControlEventHandler(touchDownAction,CCControlEventTouchDown) pControlButton:registerControlEventHandler(touchDragInsideAction,CCControlEventTouchDragInside) pControlButton:registerControlEventHandler(touchDragOutsideAction,CCControlEventTouchDragOutside) @@ -742,8 +742,8 @@ local function runCCControlTest() --Add the black background local pBackgroundButton = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackgroundButton:setContentSize(CCSizeMake(300, 170)) - pBackgroundButton:setPosition(ccp(screenSize.width / 2.0, screenSize.height / 2.0)) + pBackgroundButton:setContentSize(CCSize(300, 170)) + pBackgroundButton:setPosition(CCPoint(screenSize.width / 2.0, screenSize.height / 2.0)) pLayer:addChild(pBackgroundButton) end --PotentiometerTest @@ -752,18 +752,18 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local pNode = CCNode:create() - pNode:setPosition(ccp (screenSize.width / 2, screenSize.height / 2)) + pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local dLayer_width = 0 -- Add the black background for the text local pBackground = CCScale9Sprite:create("extensions/buttonBackground.png") - pBackground:setContentSize(CCSizeMake(80, 50)) - pBackground:setPosition(ccp(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) + pBackground:setContentSize(CCSize(80, 50)) + pBackground:setPosition(CCPoint(dLayer_width + pBackground:getContentSize().width / 2.0, 0)) pNode:addChild(pBackground) dLayer_width = dLayer_width + pBackground:getContentSize().width @@ -784,7 +784,7 @@ local function runCCControlTest() end local pPotentiometer = CCControlPotentiometer:create("extensions/potentiometerTrack.png","extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png") - pPotentiometer:setPosition(ccp (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) + pPotentiometer:setPosition(CCPoint (dLayer_width + 10 + pPotentiometer:getContentSize().width / 2, 0)) -- When the value of the slider will change, the given selector will be call pPotentiometer:registerControlEventHandler(valueChanged, CCControlEventValueChanged) @@ -794,8 +794,8 @@ local function runCCControlTest() dLayer_width = dLayer_width + pPotentiometer:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSizeMake(dLayer_width, 0)) - pNode:setAnchorPoint(ccp (0.5, 0.5)) + pNode:setContentSize(CCSize(dLayer_width, 0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) -- Update the value label valueChanged(pPotentiometer) @@ -806,18 +806,18 @@ local function runCCControlTest() return end - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local pNode = CCNode:create() - pNode:setPosition(ccp (screenSize.width / 2, screenSize.height / 2)) + pNode:setPosition(CCPoint (screenSize.width / 2, screenSize.height / 2)) pLayer:addChild(pNode, 1) local layer_width = 0 -- Add the black background for the text local background = CCScale9Sprite:create("extensions/buttonBackground.png") - background:setContentSize(CCSizeMake(100, 50)) - background:setPosition(ccp(layer_width + background:getContentSize().width / 2.0, 0)) + background:setContentSize(CCSize(100, 50)) + background:setPosition(CCPoint(layer_width + background:getContentSize().width / 2.0, 0)) pNode:addChild(background) local pDisplayValueLabel = CCLabelTTF:create("0", "HelveticaNeue-Bold", 30) @@ -840,15 +840,15 @@ local function runCCControlTest() pDisplayValueLabel:setString(CCString:create(strFmt):getCString()) end local stepper = CCControlStepper:create(minusSprite, plusSprite) - stepper:setPosition(ccp (layer_width + 10 + stepper:getContentSize().width / 2, 0)) + stepper:setPosition(CCPoint (layer_width + 10 + stepper:getContentSize().width / 2, 0)) stepper:registerControlEventHandler(valueChanged, CCControlEventValueChanged) pNode:addChild(stepper) layer_width = layer_width + stepper:getContentSize().width -- Set the layer size - pNode:setContentSize(CCSizeMake(layer_width, 0)) - pNode:setAnchorPoint(ccp (0.5, 0.5)) + pNode:setContentSize(CCSize(layer_width, 0)) + pNode:setAnchorPoint(CCPoint (0.5, 0.5)) -- Update the value label valueChanged(stepper) @@ -882,7 +882,7 @@ local function runCCControlTest() InitSpecialSceneLayer(pNewLayer) pNewScene:addChild(pNewLayer) if nil ~= pNewScene then - CCDirector:sharedDirector():replaceScene(pNewScene) + CCDirector:getInstance():replaceScene(pNewScene) end end @@ -898,24 +898,24 @@ end local function runEditBoxTest() local newScene = CCScene:create() local newLayer = CCLayer:create() - local visibleOrigin = CCEGLView:sharedOpenGLView():getVisibleOrigin() - local visibleSize = CCEGLView:sharedOpenGLView():getVisibleSize() + local visibleOrigin = CCEGLView:getInstance():getVisibleOrigin() + local visibleSize = CCEGLView:getInstance():getVisibleSize() local pBg = CCSprite:create("Images/HelloWorld.png") - pBg:setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + pBg:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) newLayer:addChild(pBg) local TTFShowEditReturn = CCLabelTTF:create("No edit control return!", "", 30) - TTFShowEditReturn:setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) + TTFShowEditReturn:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y + visibleSize.height - 50)) newLayer:addChild(TTFShowEditReturn) -- Back Menu local pToMainMenu = CCMenu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(ccp(0, 0)) + pToMainMenu:setPosition(CCPoint(0, 0)) newLayer:addChild(pToMainMenu,10) - local editBoxSize = CCSizeMake(visibleSize.width - 100, 60) + local editBoxSize = CCSize(visibleSize.width - 100, 60) local EditName = nil local EditPassword = nil local EditEmail = nil @@ -946,7 +946,7 @@ local function runEditBoxTest() end -- top EditName = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/green_edit.png")) - EditName:setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) + EditName:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height*3/4)) local targetPlatform = CCApplication:getInstance():getTargetPlatform() if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditName:setFontName("Paint Boy") @@ -965,7 +965,7 @@ local function runEditBoxTest() --middle EditPassword = CCEditBox:create(editBoxSize, CCScale9Sprite:create("extensions/orange_edit.png")) - EditPassword:setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) + EditPassword:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/2)) if kTargetIphone == targetPlatform or kTargetIpad == targetPlatform then EditPassword:setFont("American Typewriter", 30) else @@ -982,14 +982,14 @@ local function runEditBoxTest() newLayer:addChild(EditPassword) --bottom - EditEmail = CCEditBox:create(CCSizeMake(editBoxSize.width, editBoxSize.height), CCScale9Sprite:create("extensions/yellow_edit.png")) - EditEmail:setPosition(ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) - EditEmail:setAnchorPoint(ccp(0.5, 1.0)) + EditEmail = CCEditBox:create(CCSize(editBoxSize.width, editBoxSize.height), CCScale9Sprite:create("extensions/yellow_edit.png")) + EditEmail:setPosition(CCPoint(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/4)) + EditEmail:setAnchorPoint(CCPoint(0.5, 1.0)) EditEmail:setPlaceHolder("Email:") EditEmail:setInputMode(kEditBoxInputModeEmailAddr) EditEmail:registerScriptEditBoxHandler(editBoxTextEventHandle) newLayer:addChild(EditEmail) - newLayer:setPosition(ccp(10, 20)) + newLayer:setPosition(CCPoint(10, 20)) newScene:addChild(newLayer) @@ -1003,14 +1003,14 @@ local function runScrollViewTest() -- Back Menu local pToMainMenu = CCMenu:create() CreateExtensionsBasicLayerMenu(pToMainMenu) - pToMainMenu:setPosition(ccp(0, 0)) + pToMainMenu:setPosition(CCPoint(0, 0)) newLayer:addChild(pToMainMenu,10) local layerColor = CCLayerColor:create(Color4B(128,64,0,255)) newLayer:addChild(layerColor) local scrollView1 = CCScrollView:create() - local screenSize = CCDirector:sharedDirector():getWinSize() + local screenSize = CCDirector:getInstance():getWinSize() local function scrollView1DidScroll() print("scrollView1DidScroll") end @@ -1018,8 +1018,8 @@ local function runScrollViewTest() print("scrollView1DidZoom") end if nil ~= scrollView1 then - scrollView1:setViewSize(CCSizeMake(screenSize.width / 2,screenSize.height)) - scrollView1:setPosition(CCPointMake(0,0)) + scrollView1:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) + scrollView1:setPosition(CCPoint(0,0)) scrollView1:setScale(1.0) scrollView1:ignoreAnchorPointForPosition(true) local flowersprite1 = CCSprite:create("ccb/flower.jpg") @@ -1044,8 +1044,8 @@ local function runScrollViewTest() print("scrollView2DidZoom") end if nil ~= scrollView2 then - scrollView2:setViewSize(CCSizeMake(screenSize.width / 2,screenSize.height)) - scrollView2:setPosition(CCPointMake(screenSize.width / 2,0)) + scrollView2:setViewSize(CCSize(screenSize.width / 2,screenSize.height)) + scrollView2:setPosition(CCPoint(screenSize.width / 2,0)) scrollView2:setScale(1.0) scrollView2:ignoreAnchorPointForPosition(true) local flowersprite2 = CCSprite:create("ccb/flower.jpg") @@ -1082,7 +1082,7 @@ local CreateExtensionsTestTable = local function ExtensionsMainLayer() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local function CreateExtensionsTestScene(nPerformanceNo) local pNewscene = CreateExtensionsTestTable[nPerformanceNo]() @@ -1094,13 +1094,13 @@ local function ExtensionsMainLayer() local nIdx = pMenuItem:getZOrder() - kItemTagBasic local ExtensionsTestScene = CreateExtensionsTestScene(nIdx) if nil ~= ExtensionsTestScene then - CCDirector:sharedDirector():replaceScene(ExtensionsTestScene) + CCDirector:getInstance():replaceScene(ExtensionsTestScene) end end local layer = CCLayer:create() local menu = CCMenu:create() - menu:setPosition(CCPointMake(0, 0)) + menu:setPosition(CCPoint(0, 0)) CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24) local targetPlatform = CCApplication:getInstance():getTargetPlatform() diff --git a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua index 3edad1188f..1c8a26bfef 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ExtensionTest/WebProxyTest.lua @@ -1,7 +1,7 @@ local function WebSocketTestLayer() local layer = CCLayer:create() - local winSize = CCDirector:sharedDirector():getWinSize() + local winSize = CCDirector:getInstance():getWinSize() local MARGIN = 40 local SPACE = 35 @@ -16,11 +16,11 @@ local receiveBinaryTimes = 0 local label = CCLabelTTF:create("WebSocket Test", "Arial", 28) - label:setPosition(ccp( winSize.width / 2, winSize.height - MARGIN)) + label:setPosition(CCPoint( winSize.width / 2, winSize.height - MARGIN)) layer:addChild(label, 0) local menuRequest = CCMenu:create() - menuRequest:setPosition(ccp(0, 0)) + menuRequest:setPosition(CCPoint(0, 0)) layer:addChild(menuRequest) --Send Text @@ -39,7 +39,7 @@ local labelSendText = CCLabelTTF:create("Send Text", "Arial", 22) local itemSendText = CCMenuItemLabel:create(labelSendText) itemSendText:registerScriptTapHandler(onMenuSendTextClicked) - itemSendText:setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - SPACE)) + itemSendText:setPosition(CCPoint(winSize.width / 2, winSize.height - MARGIN - SPACE)) menuRequest:addChild(itemSendText) --Send Binary @@ -60,30 +60,30 @@ local labelSendBinary = CCLabelTTF:create("Send Binary", "Arial", 22) local itemSendBinary = CCMenuItemLabel:create(labelSendBinary) itemSendBinary:registerScriptTapHandler(onMenuSendBinaryClicked) - itemSendBinary:setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) + itemSendBinary:setPosition(CCPoint(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE)) menuRequest:addChild(itemSendBinary) --Send Text Status Label - sendTextStatus = CCLabelTTF:create("Send Text WS is waiting...", "Arial", 14,CCSizeMake(160, 100),kCCVerticalTextAlignmentCenter,kCCVerticalTextAlignmentTop) - sendTextStatus:setAnchorPoint(ccp(0, 0)) - sendTextStatus:setPosition(ccp(0, 25)) + sendTextStatus = CCLabelTTF:create("Send Text WS is waiting...", "Arial", 14,CCSize(160, 100),kCCVerticalTextAlignmentCenter,kCCVerticalTextAlignmentTop) + sendTextStatus:setAnchorPoint(CCPoint(0, 0)) + sendTextStatus:setPosition(CCPoint(0, 25)) layer:addChild(sendTextStatus) --Send Binary Status Label - sendBinaryStatus = CCLabelTTF:create("Send Binary WS is waiting...", "Arial", 14, CCSizeMake(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) - sendBinaryStatus:setAnchorPoint(ccp(0, 0)) - sendBinaryStatus:setPosition(ccp(160, 25)) + sendBinaryStatus = CCLabelTTF:create("Send Binary WS is waiting...", "Arial", 14, CCSize(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) + sendBinaryStatus:setAnchorPoint(CCPoint(0, 0)) + sendBinaryStatus:setPosition(CCPoint(160, 25)) layer:addChild(sendBinaryStatus) --Error Label - errorStatus = CCLabelTTF:create("Error WS is waiting...", "Arial", 14, CCSizeMake(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) - errorStatus:setAnchorPoint(ccp(0, 0)) - errorStatus:setPosition(ccp(320, 25)) + errorStatus = CCLabelTTF:create("Error WS is waiting...", "Arial", 14, CCSize(160, 100), kCCVerticalTextAlignmentCenter, kCCVerticalTextAlignmentTop) + errorStatus:setAnchorPoint(CCPoint(0, 0)) + errorStatus:setPosition(CCPoint(320, 25)) layer:addChild(errorStatus) local toMainMenu = CCMenu:create() CreateExtensionsBasicLayerMenu(toMainMenu) - toMainMenu:setPosition(ccp(0, 0)) + toMainMenu:setPosition(CCPoint(0, 0)) layer:addChild(toMainMenu,10) wsSendText = WebSocket:create("ws://echo.websocket.org") diff --git a/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua b/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua index 90b2771701..9628577d25 100644 --- a/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/FontTest/FontTest.lua @@ -27,9 +27,9 @@ local vAlignCount = table.getn(verticalAlignment) local function showFont(ret, pFont) cclog("vAlignIdx="..vAlignIdx) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local blockSize = CCSizeMake(s.width/3, 200) + local blockSize = CCSize(s.width/3, 200) local fontSize = 26 ret:removeChildByTag(kTagLabel1, true) @@ -53,20 +53,20 @@ local function showFont(ret, pFont) centerColor:ignoreAnchorPointForPosition(false) rightColor:ignoreAnchorPointForPosition(false) - top:setAnchorPoint(ccp(0.5, 1)) - left:setAnchorPoint(ccp(0,0.5)) - leftColor:setAnchorPoint(ccp(0,0.5)) - center:setAnchorPoint(ccp(0,0.5)) - centerColor:setAnchorPoint(ccp(0,0.5)) - right:setAnchorPoint(ccp(0,0.5)) - rightColor:setAnchorPoint(ccp(0,0.5)) + top:setAnchorPoint(CCPoint(0.5, 1)) + left:setAnchorPoint(CCPoint(0,0.5)) + leftColor:setAnchorPoint(CCPoint(0,0.5)) + center:setAnchorPoint(CCPoint(0,0.5)) + centerColor:setAnchorPoint(CCPoint(0,0.5)) + right:setAnchorPoint(CCPoint(0,0.5)) + rightColor:setAnchorPoint(CCPoint(0,0.5)) - top:setPosition(ccp(s.width/2,s.height-20)) - left:setPosition(ccp(0,s.height/2)) + top:setPosition(CCPoint(s.width/2,s.height-20)) + left:setPosition(CCPoint(0,s.height/2)) leftColor:setPosition(left:getPosition()) - center:setPosition(ccp(blockSize.width, s.height/2)) + center:setPosition(CCPoint(blockSize.width, s.height/2)) centerColor:setPosition(center:getPosition()) - right:setPosition(ccp(blockSize.width*2, s.height/2)) + right:setPosition(CCPoint(blockSize.width*2, s.height/2)) rightColor:setPosition(right:getPosition()) ret:addChild(leftColor, -1) diff --git a/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua b/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua index d381693594..1011f0da0c 100644 --- a/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/IntervalTest/IntervalTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:sharedDirector():getScheduler() +local scheduler = CCDirector:getInstance():getScheduler() local SID_STEP1 = 100 local SID_STEP2 = 101 local SID_STEP3 = 102 @@ -12,11 +12,11 @@ local function IntervalLayer() local m_time3 = 0 local m_time4 = 0 - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() -- sun local sun = CCParticleSun:create() - sun:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/fire.png")) - sun:setPosition( ccp(VisibleRect:rightTop().x-32,VisibleRect:rightTop().y-32) ) + sun:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) + sun:setPosition( CCPoint(VisibleRect:rightTop().x-32,VisibleRect:rightTop().y-32) ) sun:setTotalParticles(130) sun:setLife(0.6) @@ -77,8 +77,8 @@ local function IntervalLayer() scheduler:unscheduleScriptEntry(schedulerEntry2) scheduler:unscheduleScriptEntry(schedulerEntry3) scheduler:unscheduleScriptEntry(schedulerEntry4) - if CCDirector:sharedDirector():isPaused() then - CCDirector:sharedDirector():resume() + if CCDirector:getInstance():isPaused() then + CCDirector:getInstance():resume() end end end @@ -86,11 +86,11 @@ local function IntervalLayer() ret:registerScriptHandler(onNodeEvent) - m_label0:setPosition(ccp(s.width*1/6, s.height/2)) - m_label1:setPosition(ccp(s.width*2/6, s.height/2)) - m_label2:setPosition(ccp(s.width*3/6, s.height/2)) - m_label3:setPosition(ccp(s.width*4/6, s.height/2)) - m_label4:setPosition(ccp(s.width*5/6, s.height/2)) + m_label0:setPosition(CCPoint(s.width*1/6, s.height/2)) + m_label1:setPosition(CCPoint(s.width*2/6, s.height/2)) + m_label2:setPosition(CCPoint(s.width*3/6, s.height/2)) + m_label3:setPosition(CCPoint(s.width*4/6, s.height/2)) + m_label4:setPosition(CCPoint(s.width*5/6, s.height/2)) ret:addChild(m_label0) ret:addChild(m_label1) @@ -100,9 +100,9 @@ local function IntervalLayer() -- Sprite local sprite = CCSprite:create(s_pPathGrossini) - sprite:setPosition( ccp(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) ) + sprite:setPosition( CCPoint(VisibleRect:left().x + 40, VisibleRect:bottom().y + 50) ) - local jump = CCJumpBy:create(3, ccp(s.width-80,0), 50, 4) + local jump = CCJumpBy:create(3, CCPoint(s.width-80,0), 50, 4) ret:addChild(sprite) local arr = CCArray:create() @@ -112,16 +112,16 @@ local function IntervalLayer() -- pause button local item1 = CCMenuItemFont:create("Pause") local function onPause(tag, pSender) - if CCDirector:sharedDirector():isPaused() then - CCDirector:sharedDirector():resume() + if CCDirector:getInstance():isPaused() then + CCDirector:getInstance():resume() else - CCDirector:sharedDirector():pause() + CCDirector:getInstance():pause() end end item1:registerScriptTapHandler(onPause) local menu = CCMenu:createWithItem(item1) - menu:setPosition( ccp(s.width/2, s.height-50) ) + menu:setPosition( CCPoint(s.width/2, s.height-50) ) ret:addChild( menu ) diff --git a/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua b/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua index 5dc796e900..64ad3cf358 100644 --- a/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/KeypadTest/KeypadTest.lua @@ -1,16 +1,16 @@ local function KeypadMainLayer() local pLayer = CCLayer:create() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label = CCLabelTTF:create("Keypad Test", "Arial", 28) pLayer:addChild(label, 0) - label:setPosition( ccp(s.width/2, s.height-50) ) + label:setPosition( CCPoint(s.width/2, s.height-50) ) pLayer:setKeypadEnabled(true) -- create a label to display the tip string local pLabelTip = CCLabelTTF:create("Please press any key...", "Arial", 22) - pLabelTip:setPosition(ccp(s.width / 2, s.height / 2)) + pLabelTip:setPosition(CCPoint(s.width / 2, s.height / 2)) pLayer:addChild(pLabelTip, 0) pLabelTip:retain() diff --git a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua index bc2bfee58a..3a1041f636 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LabelTest/LabelTest.lua @@ -1,5 +1,5 @@ -local size = CCDirector:sharedDirector():getWinSize() -local scheduler = CCDirector:sharedDirector():getScheduler() +local size = CCDirector:getInstance():getWinSize() +local scheduler = CCDirector:getInstance():getScheduler() local kTagTileMap = 1 local kTagSpriteManager = 1 @@ -56,12 +56,12 @@ function LabelAtlasTest.create() local label1 = CCLabelAtlas:create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label1, 0, kTagSprite1) - label1:setPosition( ccp(10,100) ) + label1:setPosition( CCPoint(10,100) ) label1:setOpacity( 200 ) local label2 = CCLabelAtlas:create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label2, 0, kTagSprite2) - label2:setPosition( ccp(10,200) ) + label2:setPosition( CCPoint(10,200) ) label2:setOpacity( 32 ) layer:scheduleUpdateWithPriorityLua(LabelAtlasTest.step, 0) @@ -117,12 +117,12 @@ function LabelAtlasColorTest.create() local label1 = CCLabelAtlas:create("123 Test", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label1, 0, kTagSprite1) - label1:setPosition( ccp(10,100) ) + label1:setPosition( CCPoint(10,100) ) label1:setOpacity( 200 ) local label2 = CCLabelAtlas:create("0123456789", "fonts/tuffy_bold_italic-charmap.plist") layer:addChild(label2, 0, kTagSprite2) - label2:setPosition( ccp(10,200) ) + label2:setPosition( CCPoint(10,200) ) label2:setColor(Color3B(255, 0, 0)) local fade = CCFadeOut:create(1.0) @@ -182,7 +182,7 @@ function Atlas3.create() local label1 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label1:setAnchorPoint( ccp(0,0) ) + label1:setAnchorPoint( CCPoint(0,0) ) layer:addChild(label1, 0, kTagBitmapAtlas1) local fade = CCFadeOut:create(1.0) @@ -202,7 +202,7 @@ function Atlas3.create() local label2 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label2:setAnchorPoint( ccp(0.5, 0.5) ) + label2:setAnchorPoint( CCPoint(0.5, 0.5) ) label2:setColor(Color3B(255, 0, 0 )) layer:addChild(label2, 0, kTagBitmapAtlas2) @@ -210,7 +210,7 @@ function Atlas3.create() local label3 = CCLabelBMFont:create("Test", "fonts/bitmapFontTest2.fnt") -- testing anchors - label3:setAnchorPoint( ccp(1,1) ) + label3:setAnchorPoint( CCPoint(1,1) ) layer:addChild(label3, 0, kTagBitmapAtlas3) label1:setPosition( VisibleRect:leftBottom() ) @@ -275,10 +275,10 @@ function Atlas4.create() local label = CCLabelBMFont:create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt") layer:addChild(label) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - label:setPosition( ccp(s.width/2, s.height/2) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/2) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) local BChar = label:getChildByTag(0) @@ -298,7 +298,7 @@ function Atlas4.create() local scale_seq = CCSequence:create(action_arr) local scale_4ever = CCRepeatForever:create(scale_seq) - local jump = CCJumpBy:create(0.5, ccp(0, 0), 60, 1) + local jump = CCJumpBy:create(0.5, CCPoint(0, 0), 60, 1) local jump_4ever = CCRepeatForever:create(jump) local fade_out = CCFadeOut:create(1) @@ -319,7 +319,7 @@ function Atlas4.create() -- Bottom Label local label2 = CCLabelBMFont:create("00.0", "fonts/bitmapFontTest.fnt") layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:setPosition( ccp(s.width/2.0, 80) ) + label2:setPosition( CCPoint(s.width/2.0, 80) ) local lastChar = label2:getChildByTag(3) lastChar:runAction(tolua.cast( rot_4ever:clone(), "CCAction" )) @@ -332,9 +332,9 @@ function Atlas4.create() end function Atlas4.draw() - local s = CCDirector:sharedDirector():getWinSize() - ccDrawLine( ccp(0, s.height/2), ccp(s.width, s.height/2) ) - ccDrawLine( ccp(s.width/2, 0), ccp(s.width/2, s.height) ) + local s = CCDirector:getInstance():getWinSize() + ccDrawLine( CCPoint(0, s.height/2), CCPoint(s.width, s.height/2) ) + ccDrawLine( CCPoint(s.width/2, 0), CCPoint(s.width/2, s.height) ) end function Atlas4.step(dt) @@ -369,10 +369,10 @@ function Atlas5:create() local label = CCLabelBMFont:create("abcdefg", "fonts/bitmapFontTest4.fnt") layer:addChild(label) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - label:setPosition( ccp(s.width/2, s.height/2) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/2) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) Helper.titleLabel:setString("CCLabelBMFont") Helper.subtitleLabel:setString("Testing padding") @@ -399,21 +399,21 @@ function Atlas6:create() Helper.initWithLayer(layer) Atlas6.layer = layer - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label = CCLabelBMFont:create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( ccp(s.width/2, s.height/2+50) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/2+50) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) label = CCLabelBMFont:create("fafefifofu", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( ccp(s.width/2, s.height/2) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/2) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) label = CCLabelBMFont:create("aeiou", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( ccp(s.width/2, s.height/2-50) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/2-50) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) Helper.titleLabel:setString("CCLabelBMFont") Helper.subtitleLabel:setString("Rendering should be OK. Testing offset") @@ -437,24 +437,24 @@ function AtlasBitmapColor:create() AtlasBitmapColor.layer = layer Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label = CCLabelBMFont:create("Blue", "fonts/bitmapFontTest5.fnt") label:setColor( Color3B(0, 0, 255 )) layer:addChild(label) - label:setPosition( ccp(s.width/2, s.height/4) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, s.height/4) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) label = CCLabelBMFont:create("Red", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( ccp(s.width/2, 2*s.height/4) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, 2*s.height/4) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) label:setColor( Color3B(255, 0, 0) ) label = CCLabelBMFont:create("G", "fonts/bitmapFontTest5.fnt") layer:addChild(label) - label:setPosition( ccp(s.width/2, 3*s.height/4) ) - label:setAnchorPoint( ccp(0.5, 0.5) ) + label:setPosition( CCPoint(s.width/2, 3*s.height/4) ) + label:setAnchorPoint( CCPoint(0.5, 0.5) ) label:setColor( Color3B(0, 255, 0 )) label:setString("Green") @@ -489,11 +489,11 @@ function AtlasFastBitmap:create() local label = CCLabelBMFont:create(str, "fonts/bitmapFontTest.fnt") layer:addChild(label) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local p = ccp( math.random() * s.width, math.random() * s.height) + local p = CCPoint( math.random() * s.width, math.random() * s.height) label:setPosition( p ) - label:setAnchorPoint(ccp(0.5, 0.5)) + label:setAnchorPoint(CCPoint(0.5, 0.5)) end Helper.titleLabel:setString("CCLabelBMFont") @@ -521,7 +521,7 @@ function BitmapFontMultiLine:create() -- Left local label1 = CCLabelBMFont:create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt") - label1:setAnchorPoint(ccp(0,0)) + label1:setAnchorPoint(CCPoint(0,0)) layer:addChild(label1, 0, kTagBitmapAtlas1) s = label1:getContentSize() @@ -530,7 +530,7 @@ function BitmapFontMultiLine:create() -- Center local label2 = CCLabelBMFont:create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt") - label2:setAnchorPoint(ccp(0.5, 0.5)) + label2:setAnchorPoint(CCPoint(0.5, 0.5)) layer:addChild(label2, 0, kTagBitmapAtlas2) s= label2:getContentSize() @@ -538,7 +538,7 @@ function BitmapFontMultiLine:create() -- right local label3 = CCLabelBMFont:create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt") - label3:setAnchorPoint(ccp(1, 1)) + label3:setAnchorPoint(CCPoint(1, 1)) layer:addChild(label3, 0, kTagBitmapAtlas3) s = label3:getContentSize() @@ -579,22 +579,22 @@ function LabelsEmpty.create() LabelsEmpty.layer = layer Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() -- CCLabelBMFont local label1 = CCLabelBMFont:create("", "fonts/bitmapFontTest3.fnt") layer:addChild(label1, 0, kTagBitmapAtlas1) - label1:setPosition(ccp(s.width/2, s.height-100)) + label1:setPosition(CCPoint(s.width/2, s.height-100)) -- CCLabelTTF local label2 = CCLabelTTF:create("", "Arial", 24) layer:addChild(label2, 0, kTagBitmapAtlas2) - label2:setPosition(ccp(s.width/2, s.height/2)) + label2:setPosition(CCPoint(s.width/2, s.height/2)) -- CCLabelAtlas local label3 = CCLabelAtlas:create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, string.byte(" ")) layer:addChild(label3, 0, kTagBitmapAtlas3) - label3:setPosition(ccp(s.width/2, 0+100)) + label3:setPosition(CCPoint(s.width/2, 0+100)) layer:registerScriptHandler(LabelsEmpty.onNodeEvent) @@ -635,12 +635,12 @@ function LabelBMFontHD.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() -- CCLabelBMFont local label1 = CCLabelBMFont:create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt") layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/2)) + label1:setPosition(CCPoint(s.width/2, s.height/2)) Helper.titleLabel:setString("Testing Retina Display BMFont") Helper.subtitleLabel:setString("loading arista16 or arista16-hd") @@ -657,14 +657,14 @@ function LabelAtlasHD.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() -- CCLabelBMFont local label1 = CCLabelAtlas:create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist") - label1:setAnchorPoint(ccp(0.5, 0.5)) + label1:setAnchorPoint(CCPoint(0.5, 0.5)) layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/2)) + label1:setPosition(CCPoint(s.width/2, s.height/2)) Helper.titleLabel:setString("LabelAtlas with Retina Display") Helper.subtitleLabel:setString("loading larabie-16 / larabie-16-hd") @@ -682,7 +682,7 @@ function LabelGlyphDesigner.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local colorlayer = CCLayerColor:create(Color4B(128,128,128,255)) layer:addChild(colorlayer, -10) @@ -690,7 +690,7 @@ function LabelGlyphDesigner.create() -- CCLabelBMFont local label1 = CCLabelBMFont:create("Testing Glyph Designer", "fonts/futura-48.fnt") layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/2)) + label1:setPosition(CCPoint(s.width/2, s.height/2)) Helper.titleLabel:setString("Testing Glyph Designer") Helper.subtitleLabel:setString("You should see a font with shawdows and outline") @@ -718,12 +718,12 @@ function LabelTTFTest.create() LabelTTFTest._eHorizAlign = kCCTextAlignmentLeft LabelTTFTest._eVertAlign = kCCVerticalTextAlignmentTop - local blockSize = CCSizeMake(200, 160) - local s = CCDirector:sharedDirector():getWinSize() + local blockSize = CCSize(200, 160) + local s = CCDirector:getInstance():getWinSize() local colorLayer = CCLayerColor:create(Color4B(100, 100, 100, 255), blockSize.width, blockSize.height) - colorLayer:setAnchorPoint(ccp(0,0)) - colorLayer:setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)) + colorLayer:setAnchorPoint(CCPoint(0,0)) + colorLayer:setPosition(CCPoint((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)) layer:addChild(colorLayer) @@ -740,7 +740,7 @@ function LabelTTFTest.create() menu:addChild(item2) menu:addChild(item3) menu:alignItemsVerticallyWithPadding(4) - menu:setPosition(ccp(50, s.height / 2 - 20)) + menu:setPosition(CCPoint(50, s.height / 2 - 20)) layer:addChild(menu) menu = CCMenu:create() @@ -757,7 +757,7 @@ function LabelTTFTest.create() menu:addChild(item3) menu:alignItemsVerticallyWithPadding(4) - menu:setPosition(ccp(s.width - 50, s.height / 2 - 20)) + menu:setPosition(CCPoint(s.width - 50, s.height / 2 - 20)) layer:addChild(menu) LabelTTFTest.updateAlignment() @@ -779,8 +779,8 @@ function LabelTTFTest.onNodeEvent(tag) end function LabelTTFTest.updateAlignment() - local blockSize = CCSizeMake(200, 160) - local s = CCDirector:sharedDirector():getWinSize() + local blockSize = CCSize(200, 160) + local s = CCDirector:getInstance():getWinSize() if LabelTTFTest._plabel ~= nil then LabelTTFTest._plabel:removeFromParentAndCleanup(true) @@ -791,8 +791,8 @@ function LabelTTFTest.updateAlignment() blockSize, LabelTTFTest._eHorizAlign, LabelTTFTest._eVertAlign) LabelTTFTest._plabel:retain() - LabelTTFTest._plabel:setAnchorPoint(ccp(0,0)) - LabelTTFTest._plabel:setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )) + LabelTTFTest._plabel:setAnchorPoint(CCPoint(0,0)) + LabelTTFTest._plabel:setPosition(CCPoint((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )) LabelTTFTest._layer:addChild(LabelTTFTest._plabel) end @@ -858,7 +858,7 @@ end --{ -- m_textureAtlas = CCTextureAtlas:create(s_AtlasTest, 3); m_textureAtlas:retain(); -- --- CCSize s = CCDirector:sharedDirector():getWinSize(); +-- CCSize s = CCDirector:getInstance():getWinSize(); -- -- -- -- -- Notice: u,v tex coordinates are inverted @@ -928,16 +928,16 @@ function LabelTTFMultiline.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local center = CCLabelTTF:create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", "Paint Boy", 32, - CCSizeMake(s.width/2,200), + CCSize(s.width/2,200), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop) - center:setPosition(ccp(s.width / 2, 150)) + center:setPosition(CCPoint(s.width / 2, 150)) layer:addChild(center) Helper.titleLabel:setString("Testing CCLabelTTF Word Wrap") @@ -951,9 +951,9 @@ local LabelTTFChinese = {} function LabelTTFChinese.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local pLable = CCLabelTTF:create("中国", "Marker Felt", 30) - pLable:setPosition(ccp(size.width / 2, size.height /2)) + pLable:setPosition(CCPoint(size.width / 2, size.height /2)) layer:addChild(pLable) Helper.titleLabel:setString("Testing CCLabelTTF with Chinese character") return layer @@ -964,9 +964,9 @@ function LabelBMFontChinese.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local pLable = CCLabelBMFont:create("中国", "fonts/bitmapFontChinese.fnt") - pLable:setPosition(ccp(size.width / 2, size.height /2)) + pLable:setPosition(CCPoint(size.width / 2, size.height /2)) layer:addChild(pLable) Helper.titleLabel:setString("Testing CCLabelBMFont with Chinese character") @@ -1008,7 +1008,7 @@ function BitmapFontMultiLineAlignment.create() layer:setTouchEnabled(true) -- ask director the the window size - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() -- create and initialize a Label BitmapFontMultiLineAlignment._pLabelShouldRetain = CCLabelBMFont:create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter) @@ -1062,7 +1062,7 @@ function BitmapFontMultiLineAlignment.create() right:setTag(RightAlign) -- position the label on the center of the screen - BitmapFontMultiLineAlignment._pLabelShouldRetain:setPosition(ccp(size.width/2, size.height/2)) + BitmapFontMultiLineAlignment._pLabelShouldRetain:setPosition(CCPoint(size.width/2, size.height/2)) BitmapFontMultiLineAlignment._pArrowsBarShouldRetain:setVisible(false) @@ -1072,8 +1072,8 @@ function BitmapFontMultiLineAlignment.create() BitmapFontMultiLineAlignment.snapArrowsToEdge() - stringMenu:setPosition(ccp(size.width/2, size.height - menuItemPaddingCenter)) - alignmentMenu:setPosition(ccp(size.width/2, menuItemPaddingCenter+15)) + stringMenu:setPosition(CCPoint(size.width/2, size.height - menuItemPaddingCenter)) + alignmentMenu:setPosition(CCPoint(size.width/2, menuItemPaddingCenter+15)) layer:addChild(BitmapFontMultiLineAlignment._pLabelShouldRetain) layer:addChild(BitmapFontMultiLineAlignment._pArrowsBarShouldRetain) @@ -1134,7 +1134,7 @@ end function BitmapFontMultiLineAlignment.onTouchEvent(eventType, x, y) -- cclog("type:"..eventType.."["..x..","..y.."]") if eventType == "began" then - if BitmapFontMultiLineAlignment._pArrowsShouldRetain:boundingBox():containsPoint(ccp(x, y)) then + if BitmapFontMultiLineAlignment._pArrowsShouldRetain:getBoundingBox():containsPoint(CCPoint(x, y)) then BitmapFontMultiLineAlignment._drag = true BitmapFontMultiLineAlignment._pArrowsBarShouldRetain:setVisible(true) return true @@ -1148,7 +1148,7 @@ function BitmapFontMultiLineAlignment.onTouchEvent(eventType, x, y) return end - local winSize = CCDirector:sharedDirector():getWinSize() + local winSize = CCDirector:getInstance():getWinSize() BitmapFontMultiLineAlignment._pArrowsShouldRetain:setPosition( math.max(math.min(x, ArrowsMax*winSize.width), ArrowsMin*winSize.width), BitmapFontMultiLineAlignment._pArrowsShouldRetain:getPositionY()) @@ -1174,7 +1174,7 @@ function LabelTTFA8Test.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local colorlayer = CCLayerColor:create(Color4B(128, 128, 128, 255)) layer:addChild(colorlayer, -10) @@ -1183,7 +1183,7 @@ function LabelTTFA8Test.create() local label1 = CCLabelTTF:create("Testing A8 Format", "Marker Felt", 48) layer:addChild(label1) label1:setColor(Color3B(255, 0, 0)) - label1:setPosition(ccp(s.width/2, s.height/2)) + label1:setPosition(CCPoint(s.width/2, s.height/2)) local fadeOut = CCFadeOut:create(2) local fadeIn = CCFadeIn:create(2) @@ -1206,15 +1206,15 @@ function BMFontOneAtlas.create() local layer = CCLayer:create() Helper.initWithLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local label1 = CCLabelBMFont:create("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 0)) + local label1 = CCLabelBMFont:create("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPoint(0, 0)) layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/3*2)) + label1:setPosition(CCPoint(s.width/2, s.height/3*2)) - local label2 = CCLabelBMFont:create("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 128)) + local label2 = CCLabelBMFont:create("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPoint(0, 128)) layer:addChild(label2) - label2:setPosition(ccp(s.width/2, s.height/3*1)) + label2:setPosition(CCPoint(s.width/2, s.height/3*1)) Helper.titleLabel:setString("CCLabelBMFont with one texture") Helper.subtitleLabel:setString("Using 2 .fnt definitions that share the same texture atlas.") return layer @@ -1228,19 +1228,19 @@ function BMFontUnicode.create() Helper.titleLabel:setString("CCLabelBMFont with Unicode support") Helper.subtitleLabel:setString("You should see 3 differnt labels: In Spanish, Chinese and Korean") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label1 = CCLabelBMFont:create("Buen día", "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft) layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/4*3)) + label1:setPosition(CCPoint(s.width/2, s.height/4*3)) local label2 = CCLabelBMFont:create("美好的一天", "fonts/arial-unicode-26.fnt") layer:addChild(label2) - label2:setPosition(ccp(s.width/2, s.height/4*2)) + label2:setPosition(CCPoint(s.width/2, s.height/4*2)) local label3 = CCLabelBMFont:create("良い一日を", "fonts/arial-unicode-26.fnt") layer:addChild(label3) - label3:setPosition(ccp(s.width/2, s.height/4*1)) + label3:setPosition(CCPoint(s.width/2, s.height/4*1)) return layer end @@ -1254,7 +1254,7 @@ function BMFontInit.create() Helper.titleLabel:setString("CCLabelBMFont init") Helper.subtitleLabel:setString("Test for support of init method without parameters.") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local bmFont = CCLabelBMFont:new() bmFont:init() @@ -1263,7 +1263,7 @@ function BMFontInit.create() bmFont:setFntFile("fonts/helvetica-32.fnt") bmFont:setString("It is working!") layer:addChild(bmFont) - bmFont:setPosition(ccp(s.width/2,s.height/4*2)) + bmFont:setPosition(CCPoint(s.width/2,s.height/4*2)) return layer end @@ -1277,7 +1277,7 @@ function TTFFontInit.create() Helper.titleLabel:setString("CCLabelTTF init") Helper.subtitleLabel:setString("Test for support of init method without parameters.") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local font = CCLabelTTF:new() font:init() @@ -1286,7 +1286,7 @@ function TTFFontInit.create() font:setFontSize(48) font:setString("It is working!") layer:addChild(font) - font:setPosition(ccp(s.width/2,s.height/4*2)) + font:setPosition(CCPoint(s.width/2,s.height/4*2)) return layer end @@ -1299,7 +1299,7 @@ function Issue1343.create() Helper.titleLabel:setString("Issue 1343") Helper.subtitleLabel:setString("You should see: ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local bmFont = CCLabelBMFont:new() bmFont:init() @@ -1309,7 +1309,7 @@ function Issue1343.create() bmFont:release() bmFont:setScale(0.3) - bmFont:setPosition(ccp(s.width/2,s.height/4*2)) + bmFont:setPosition(CCPoint(s.width/2,s.height/4*2)) return layer end @@ -1320,7 +1320,7 @@ function LabelBMFontBounds.create() Helper.titleLabel:setString("Testing LabelBMFont Bounds") Helper.subtitleLabel:setString("You should see string enclosed by a box") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local colorlayer = CCLayerColor:create(Color4B(128,128,128,255)) layer:addChild(colorlayer, -10) @@ -1330,24 +1330,24 @@ function LabelBMFontBounds.create() layer:addChild(label1) - label1:setPosition(ccp(s.width/2, s.height/2)) + label1:setPosition(CCPoint(s.width/2, s.height/2)) return layer end function LabelBMFontBounds.draw() -- CCSize labelSize = label1:getContentSize() - -- CCSize origin = CCDirector:sharedDirector():getWinSize() + -- CCSize origin = CCDirector:getInstance():getWinSize() -- origin.width = origin.width / 2 - (labelSize.width / 2) -- origin.height = origin.height / 2 - (labelSize.height / 2) -- CCPoint vertices[4]= - -- ccp(origin.width, origin.height), - -- ccp(labelSize.width + origin.width, origin.height), - -- ccp(labelSize.width + origin.width, labelSize.height + origin.height), - -- ccp(origin.width, labelSize.height + origin.height) + -- CCPoint(origin.width, origin.height), + -- CCPoint(labelSize.width + origin.width, origin.height), + -- CCPoint(labelSize.width + origin.width, labelSize.height + origin.height), + -- CCPoint(origin.width, labelSize.height + origin.height) -- end -- ccDrawPoly(vertices, 4, true) end @@ -1364,24 +1364,24 @@ function LabelTTFAlignment.create() Helper.titleLabel:setString("CCLabelTTF alignment") Helper.subtitleLabel:setString("Tests alignment values") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local ttf0 = CCLabelTTF:create("Alignment 0\nnew line", "Helvetica", 12, - CCSizeMake(256, 32), kCCTextAlignmentLeft) - ttf0:setPosition(ccp(s.width/2,(s.height/6)*2)) - ttf0:setAnchorPoint(ccp(0.5,0.5)) + CCSize(256, 32), kCCTextAlignmentLeft) + ttf0:setPosition(CCPoint(s.width/2,(s.height/6)*2)) + ttf0:setAnchorPoint(CCPoint(0.5,0.5)) layer:addChild(ttf0) local ttf1 = CCLabelTTF:create("Alignment 1\nnew line", "Helvetica", 12, - CCSizeMake(245, 32), kCCTextAlignmentCenter) - ttf1:setPosition(ccp(s.width/2,(s.height/6)*3)) - ttf1:setAnchorPoint(ccp(0.5,0.5)) + CCSize(245, 32), kCCTextAlignmentCenter) + ttf1:setPosition(CCPoint(s.width/2,(s.height/6)*3)) + ttf1:setAnchorPoint(CCPoint(0.5,0.5)) layer:addChild(ttf1) local ttf2 = CCLabelTTF:create("Alignment 2\nnew line", "Helvetica", 12, - CCSizeMake(245, 32), kCCTextAlignmentRight) - ttf2:setPosition(ccp(s.width/2,(s.height/6)*4)) - ttf2:setAnchorPoint(ccp(0.5,0.5)) + CCSize(245, 32), kCCTextAlignmentRight) + ttf2:setPosition(CCPoint(s.width/2,(s.height/6)*4)) + ttf2:setAnchorPoint(CCPoint(0.5,0.5)) layer:addChild(ttf2) return layer end diff --git a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua index 026157bed8..c8560484dd 100644 --- a/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/LayerTest/LayerTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:sharedDirector():getScheduler() +local scheduler = CCDirector:getInstance():getScheduler() local kTagLayer = 1 local function createLayerDemoLayer(title, subtitle) @@ -22,7 +22,7 @@ local function createLayerDemoLayer(title, subtitle) -- local diffX = x - prev.x -- local diffY = y - prev.y - -- node:setPosition( ccpAdd(ccp(newX, newY), ccp(diffX, diffY)) ) + -- node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) -- prev.x = x -- prev.y = y -- end @@ -63,7 +63,7 @@ end -- LayerTestCascadingOpacityA local function LayerTestCascadingOpacityA() local ret = createLayerDemoLayer("LayerRGBA: cascading opacity") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerRGBA:create() local sister1 = CCSprite:create("Images/grossinis_sister1.png") @@ -75,9 +75,9 @@ local function LayerTestCascadingOpacityA() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, s.height/2)) - sister2:setPosition( ccp( s.width*2/3, s.height/2)) - label:setPosition( ccp( s.width/2, s.height/2)) + sister1:setPosition( CCPoint( s.width*1/3, s.height/2)) + sister2:setPosition( CCPoint( s.width*2/3, s.height/2)) + label:setPosition( CCPoint( s.width/2, s.height/2)) local arr = CCArray:create() arr:addObject(CCFadeTo:create(4, 0)) @@ -102,11 +102,11 @@ end local function LayerTestCascadingOpacityB() local ret = createLayerDemoLayer("CCLayerColor: cascading opacity") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create(Color4B(192, 0, 0, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) - layer1:setPosition( ccp(0, s.height/2)) + layer1:setPosition( CCPoint(0, s.height/2)) local sister1 = CCSprite:create("Images/grossinis_sister1.png") local sister2 = CCSprite:create("Images/grossinis_sister2.png") @@ -117,9 +117,9 @@ local function LayerTestCascadingOpacityB() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, 0)) - sister2:setPosition( ccp( s.width*2/3, 0)) - label:setPosition( ccp( s.width/2, 0)) + sister1:setPosition( CCPoint( s.width*1/3, 0)) + sister2:setPosition( CCPoint( s.width*2/3, 0)) + label:setPosition( CCPoint( s.width/2, 0)) local arr = CCArray:create() arr:addObject(CCFadeTo:create(4, 0)) @@ -146,12 +146,12 @@ end local function LayerTestCascadingOpacityC() local ret = createLayerDemoLayer("CCLayerColor: non-cascading opacity") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create(Color4B(192, 0, 0, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) layer1:setCascadeOpacityEnabled(false) - layer1:setPosition( ccp(0, s.height/2)) + layer1:setPosition( CCPoint(0, s.height/2)) local sister1 = CCSprite:create("Images/grossinis_sister1.png") local sister2 = CCSprite:create("Images/grossinis_sister2.png") @@ -162,9 +162,9 @@ local function LayerTestCascadingOpacityC() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, 0)) - sister2:setPosition( ccp( s.width*2/3, 0)) - label:setPosition( ccp( s.width/2, 0)) + sister1:setPosition( CCPoint( s.width*1/3, 0)) + sister2:setPosition( CCPoint( s.width*2/3, 0)) + label:setPosition( CCPoint( s.width/2, 0)) local arr = CCArray:create() arr:addObject(CCFadeTo:create(4, 0)) @@ -195,7 +195,7 @@ end local function LayerTestCascadingColorA() local ret = createLayerDemoLayer("LayerRGBA: cascading color") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerRGBA:create() local sister1 = CCSprite:create("Images/grossinis_sister1.png") @@ -207,9 +207,9 @@ local function LayerTestCascadingColorA() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, s.height/2)) - sister2:setPosition( ccp( s.width*2/3, s.height/2)) - label:setPosition( ccp( s.width/2, s.height/2)) + sister1:setPosition( CCPoint( s.width*1/3, s.height/2)) + sister2:setPosition( CCPoint( s.width*2/3, s.height/2)) + label:setPosition( CCPoint( s.width/2, s.height/2)) local arr = CCArray:create() arr:addObject(CCTintTo:create(6, 255, 0, 255)) @@ -244,10 +244,10 @@ end local function LayerTestCascadingColorB() local ret = createLayerDemoLayer("CCLayerColor: cascading color") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create(Color4B(255, 255, 255, 255), s.width, s.height/2) - layer1:setPosition( ccp(0, s.height/2)) + layer1:setPosition( CCPoint(0, s.height/2)) local sister1 = CCSprite:create("Images/grossinis_sister1.png") local sister2 = CCSprite:create("Images/grossinis_sister2.png") @@ -258,9 +258,9 @@ local function LayerTestCascadingColorB() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, 0)) - sister2:setPosition( ccp( s.width*2/3, 0)) - label:setPosition( ccp( s.width/2, 0)) + sister1:setPosition( CCPoint( s.width*1/3, 0)) + sister2:setPosition( CCPoint( s.width*2/3, 0)) + label:setPosition( CCPoint( s.width/2, 0)) local arr = CCArray:create() arr:addObject(CCTintTo:create(6, 255, 0, 255)) @@ -295,10 +295,10 @@ end local function LayerTestCascadingColorC() local ret = createLayerDemoLayer("CCLayerColor: non-cascading color") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create(Color4B(255, 255, 255, 255), s.width, s.height/2) layer1:setCascadeColorEnabled(false) - layer1:setPosition( ccp(0, s.height/2)) + layer1:setPosition( CCPoint(0, s.height/2)) local sister1 = CCSprite:create("Images/grossinis_sister1.png") local sister2 = CCSprite:create("Images/grossinis_sister2.png") @@ -309,9 +309,9 @@ local function LayerTestCascadingColorC() layer1:addChild(label) ret:addChild( layer1, 0, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, 0)) - sister2:setPosition( ccp( s.width*2/3, 0)) - label:setPosition( ccp( s.width/2, 0)) + sister1:setPosition( CCPoint( s.width*1/3, 0)) + sister2:setPosition( CCPoint( s.width*2/3, 0)) + label:setPosition( CCPoint( s.width/2, 0)) local arr = CCArray:create() arr:addObject(CCTintTo:create(6, 255, 0, 255)) @@ -349,17 +349,17 @@ local function LayerTest1() ret:setTouchEnabled(true) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer = CCLayerColor:create( Color4B(0xFF, 0x00, 0x00, 0x80), 200, 200) layer:ignoreAnchorPointForPosition(false) - layer:setPosition( ccp(s.width/2, s.height/2) ) + layer:setPosition( CCPoint(s.width/2, s.height/2) ) ret:addChild(layer, 1, kTagLayer) local function updateSize(x, y) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local newSize = CCSizeMake( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2) + local newSize = CCSize( math.abs(x - s.width/2)*2, math.abs(y - s.height/2)*2) local l = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerColor") @@ -386,14 +386,14 @@ end local function LayerTest2() local ret = createLayerDemoLayer("ColorLayer: fade and tint") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create( Color4B(255, 255, 0, 80), 100, 300) - layer1:setPosition(ccp(s.width/3, s.height/2)) + layer1:setPosition(CCPoint(s.width/3, s.height/2)) layer1:ignoreAnchorPointForPosition(false) ret:addChild(layer1, 1) local layer2 = CCLayerColor:create( Color4B(0, 0, 255, 255), 100, 300) - layer2:setPosition(ccp((s.width/3)*2, s.height/2)) + layer2:setPosition(CCPoint((s.width/3)*2, s.height/2)) layer2:ignoreAnchorPointForPosition(false) ret:addChild(layer2, 1) @@ -424,7 +424,7 @@ end local function LayerTestBlend() local ret = createLayerDemoLayer("ColorLayer: blend") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local layer1 = CCLayerColor:create( Color4B(255, 255, 255, 80) ) local sister1 = CCSprite:create(s_pPathSister1) @@ -434,8 +434,8 @@ local function LayerTestBlend() ret:addChild(sister2) ret:addChild(layer1, 100, kTagLayer) - sister1:setPosition( ccp( s.width*1/3, s.height/2) ) - sister2:setPosition( ccp( s.width*2/3, s.height/2) ) + sister1:setPosition( CCPoint( s.width*1/3, s.height/2) ) + sister2:setPosition( CCPoint( s.width*2/3, s.height/2) ) local function newBlend(dt) local layer = tolua.cast(ret:getChildByTag(kTagLayer), "CCLayerColor") @@ -478,7 +478,7 @@ end -------------------------------------------------------------------- local function LayerGradient() local ret = createLayerDemoLayer("LayerGradient", "Touch the screen and move your finger") - local layer1 = CCLayerGradient:create(Color4B(255,0,0,255), Color4B(0,255,0,255), ccp(0.9, 0.9)) + local layer1 = CCLayerGradient:create(Color4B(255,0,0,255), Color4B(0,255,0,255), CCPoint(0.9, 0.9)) ret:addChild(layer1, 0, kTagLayer) ret:setTouchEnabled(true) @@ -500,18 +500,18 @@ local function LayerGradient() local menu = CCMenu:createWithItem(item) ret:addChild(menu) - local s = CCDirector:sharedDirector():getWinSize() - menu:setPosition(ccp(s.width / 2, 100)) + local s = CCDirector:getInstance():getWinSize() + menu:setPosition(CCPoint(s.width / 2, 100)) local function onTouchEvent(eventType, x, y) if eventType == "began" then return true elseif eventType == "moved" then - local s = CCDirector:sharedDirector():getWinSize() - local start = ccp(x, y) + local s = CCDirector:getInstance():getWinSize() + local start = CCPoint(x, y) - local diff = ccpSub( ccp(s.width/2,s.height/2), start) - diff = ccpNormalize(diff) + local diff = CCPoint.__sub( CCPoint(s.width/2,s.height/2), start) + diff = diff:normalize() local gradient = tolua.cast(ret:getChildByTag(1), "CCLayerGradient") gradient:setVector(diff) @@ -530,14 +530,14 @@ local kLayerIgnoreAnchorPoint = 1000 local function LayerIgnoreAnchorPointPos() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Position", "Ignoring Anchor Point for position") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 150, 150) - l:setAnchorPoint(ccp(0.5, 0.5)) - l:setPosition(ccp( s.width/2, s.height/2)) + l:setAnchorPoint(CCPoint(0.5, 0.5)) + l:setPosition(CCPoint( s.width/2, s.height/2)) - local move = CCMoveBy:create(2, ccp(100,2)) + local move = CCMoveBy:create(2, CCPoint(100,2)) local back = tolua.cast(move:reverse(), "CCMoveBy") local arr = CCArray:create() arr:addObject(move) @@ -549,7 +549,7 @@ local function LayerIgnoreAnchorPointPos() local child = CCSprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(ccp(lsize.width/2, lsize.height/2)) + child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -563,7 +563,7 @@ local function LayerIgnoreAnchorPointPos() local menu = CCMenu:createWithItem(item) ret:addChild(menu) - menu:setPosition(ccp(s.width/2, s.height/2)) + menu:setPosition(CCPoint(s.width/2, s.height/2)) return ret end @@ -572,12 +572,12 @@ end local function LayerIgnoreAnchorPointRot() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Rotation", "Ignoring Anchor Point for rotations") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 200, 200) - l:setAnchorPoint(ccp(0.5, 0.5)) - l:setPosition(ccp( s.width/2, s.height/2)) + l:setAnchorPoint(CCPoint(0.5, 0.5)) + l:setPosition(CCPoint( s.width/2, s.height/2)) ret:addChild(l, 0, kLayerIgnoreAnchorPoint) @@ -588,7 +588,7 @@ local function LayerIgnoreAnchorPointRot() local child = CCSprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(ccp(lsize.width/2, lsize.height/2)) + child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -602,19 +602,19 @@ local function LayerIgnoreAnchorPointRot() local menu = CCMenu:createWithItem(item) ret:addChild(menu) - menu:setPosition(ccp(s.width/2, s.height/2)) + menu:setPosition(CCPoint(s.width/2, s.height/2)) return ret end -- LayerIgnoreAnchorPointScale local function LayerIgnoreAnchorPointScale() local ret = createLayerDemoLayer("IgnoreAnchorPoint - Scale", "Ignoring Anchor Point for scale") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local l = CCLayerColor:create(Color4B(255, 0, 0, 255), 200, 200) - l:setAnchorPoint(ccp(0.5, 1.0)) - l:setPosition(ccp( s.width/2, s.height/2)) + l:setAnchorPoint(CCPoint(0.5, 1.0)) + l:setPosition(CCPoint( s.width/2, s.height/2)) local scale = CCScaleBy:create(2, 2) @@ -631,7 +631,7 @@ local function LayerIgnoreAnchorPointScale() local child = CCSprite:create("Images/grossini.png") l:addChild(child) local lsize = l:getContentSize() - child:setPosition(ccp(lsize.width/2, lsize.height/2)) + child:setPosition(CCPoint(lsize.width/2, lsize.height/2)) local function onToggle(pObject) local pLayer = ret:getChildByTag(kLayerIgnoreAnchorPoint) @@ -646,7 +646,7 @@ local function LayerIgnoreAnchorPointScale() local menu = CCMenu:createWithItem(item) ret:addChild(menu) - menu:setPosition(ccp(s.width/2, s.height/2)) + menu:setPosition(CCPoint(s.width/2, s.height/2)) return ret end @@ -654,18 +654,18 @@ end local function LayerExtendedBlendOpacityTest() local ret = createLayerDemoLayer("Extended Blend & Opacity", "You should see 3 layers") local layer1 = CCLayerGradient:create(Color4B(255, 0, 0, 255), Color4B(255, 0, 255, 255)) - layer1:setContentSize(CCSizeMake(80, 80)) - layer1:setPosition(ccp(50,50)) + layer1:setContentSize(CCSize(80, 80)) + layer1:setPosition(CCPoint(50,50)) ret:addChild(layer1) local layer2 = CCLayerGradient:create(Color4B(0, 0, 0, 127), Color4B(255, 255, 255, 127)) - layer2:setContentSize(CCSizeMake(80, 80)) - layer2:setPosition(ccp(100,90)) + layer2:setContentSize(CCSize(80, 80)) + layer2:setPosition(CCPoint(100,90)) ret:addChild(layer2) local layer3 = CCLayerGradient:create() - layer3:setContentSize(CCSizeMake(80, 80)) - layer3:setPosition(ccp(150,140)) + layer3:setContentSize(CCSize(80, 80)) + layer3:setPosition(CCPoint(150,140)) layer3:setStartColor(Color3B(255, 0, 0)) layer3:setEndColor(Color3B(255, 0, 255)) layer3:setStartOpacity(255) @@ -681,7 +681,7 @@ end function LayerTestMain() cclog("LayerTestMain") Helper.index = 1 - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) local scene = CCScene:create() Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index 7a48954b45..6f9d193543 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -27,9 +27,9 @@ local function MenuLayerMainMenu() ret:setTouchMode(kCCTouchesOneByOne) -- Font Item - local spriteNormal = CCSprite:create(s_MenuItem, CCRectMake(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRectMake(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRectMake(0,23*0,115,23)) + local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) + local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) + local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) local item1 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) @@ -49,9 +49,9 @@ local function MenuLayerMainMenu() local schedulerEntry = nil - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() local function allowTouches(dt) - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority+1, ret) if nil ~= schedulerEntry then scheduler:unscheduleScriptEntry(schedulerEntry) @@ -63,7 +63,7 @@ local function MenuLayerMainMenu() local function menuCallbackDisabled(sender) -- hijack all touch events for 5 seconds - local pDirector = CCDirector:sharedDirector() + local pDirector = CCDirector:getInstance() --pDirector:getTouchDispatcher():setPriority(kCCMenuHandlerPriority-1, ret) schedulerEntry = scheduler:scheduleScriptFunc(allowTouches, 5, false) cclog("TOUCHES DISABLED FOR 5 SECONDS") @@ -154,7 +154,7 @@ local function MenuLayerMainMenu() menu:alignItemsVertically() -- elastic effect - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local i = 0 local child = nil @@ -173,8 +173,8 @@ local function MenuLayerMainMenu() if i % 2 == 0 then offset = 0-offset end - child:setPosition( ccp( dstPointX + offset, dstPointY) ) - child:runAction( CCEaseElasticOut:create(CCMoveBy:create(2, ccp(dstPointX - offset,0)), 0.35) ) + child:setPosition( CCPoint( dstPointX + offset, dstPointY) ) + child:runAction( CCEaseElasticOut:create(CCMoveBy:create(2, CCPoint(dstPointX - offset,0)), 0.35) ) end m_disabledItem = item3 @@ -183,7 +183,7 @@ local function MenuLayerMainMenu() m_disabledItem:setEnabled( false ) ret:addChild(menu) - menu:setPosition(ccp(s.width/2, s.height/2)) + menu:setPosition(CCPoint(s.width/2, s.height/2)) -- local schedulerEntry = nil local function onNodeEvent(event) @@ -221,12 +221,12 @@ local function MenuLayer2() -- TIP: if no padding, padding = 5 menu:alignItemsHorizontally() local x, y = menu:getPosition() - menu:setPosition( ccpAdd(ccp(x, y), ccp(0,30)) ) + menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(0,30)) ) else -- TIP: but padding is configurable menu:alignItemsHorizontallyWithPadding(40) local x, y = menu:getPosition() - menu:setPosition( ccpSub(ccp(x, y), ccp(0,30)) ) + menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(0,30)) ) end end end @@ -240,12 +240,12 @@ local function MenuLayer2() -- TIP: if no padding, padding = 5 menu:alignItemsVertically() local x, y = menu:getPosition() - menu:setPosition( ccpAdd(ccp(x, y), ccp(100,0)) ) + menu:setPosition( CCPoint.__add(CCPoint(x, y), CCPoint(100,0)) ) else -- TIP: but padding is configurable menu:alignItemsVerticallyWithPadding(40) local x, y = menu:getPosition() - menu:setPosition( ccpSub(ccp(x, y), ccp(100,0)) ) + menu:setPosition( CCPoint.__sub(CCPoint(x, y), CCPoint(100,0)) ) end end end @@ -295,15 +295,15 @@ local function MenuLayer2() menu:addChild(item2) menu:addChild(item3) - local s = CCDirector:sharedDirector():getWinSize() - menu:setPosition(ccp(s.width/2, s.height/2)) + local s = CCDirector:getInstance():getWinSize() + menu:setPosition(CCPoint(s.width/2, s.height/2)) menu:setTag( kTagMenu ) ret:addChild(menu, 0, 100+i) local x, y = menu:getPosition() - m_centeredMenu = ccp(x, y) + m_centeredMenu = CCPoint(x, y) end m_alignedH = true @@ -344,9 +344,9 @@ local function MenuLayer3() local item2 = CCMenuItemFont:create("--- Go Back ---") item2:registerScriptTapHandler(menuCallback) - local spriteNormal = CCSprite:create(s_MenuItem, CCRectMake(0,23*2,115,23)) - local spriteSelected = CCSprite:create(s_MenuItem, CCRectMake(0,23*1,115,23)) - local spriteDisabled = CCSprite:create(s_MenuItem, CCRectMake(0,23*0,115,23)) + local spriteNormal = CCSprite:create(s_MenuItem, CCRect(0,23*2,115,23)) + local spriteSelected = CCSprite:create(s_MenuItem, CCRect(0,23*1,115,23)) + local spriteDisabled = CCSprite:create(s_MenuItem, CCRect(0,23*0,115,23)) local item3 = CCMenuItemSprite:create(spriteNormal, spriteSelected, spriteDisabled) @@ -361,15 +361,15 @@ local function MenuLayer3() menu:addChild(item2) menu:addChild(item3) - menu:setPosition( ccp(0,0) ) + menu:setPosition( CCPoint(0,0) ) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - item1:setPosition( ccp(s.width/2 - 150, s.height/2) ) - item2:setPosition( ccp(s.width/2 - 200, s.height/2) ) - item3:setPosition( ccp(s.width/2, s.height/2 - 100) ) + item1:setPosition( CCPoint(s.width/2 - 150, s.height/2) ) + item2:setPosition( CCPoint(s.width/2 - 200, s.height/2) ) + item3:setPosition( CCPoint(s.width/2, s.height/2 - 100) ) - local jump = CCJumpBy:create(3, ccp(400,0), 50, 4) + local jump = CCJumpBy:create(3, CCPoint(400,0), 50, 4) local arr = CCArray:create() arr:addObject(jump) arr:addObject(jump:reverse()) @@ -385,7 +385,7 @@ local function MenuLayer3() ret:addChild( menu ) - menu:setPosition(ccp(0,0)) + menu:setPosition(CCPoint(0,0)) local function onNodeEvent(event) if event == "exit" then @@ -492,8 +492,8 @@ local function MenuLayer4() ret:addChild(menu) - local s = CCDirector:sharedDirector():getWinSize() - menu:setPosition(ccp(s.width/2, s.height/2)) + local s = CCDirector:getInstance():getWinSize() + menu:setPosition(CCPoint(s.width/2, s.height/2)) return ret end @@ -596,18 +596,18 @@ local function BugsTest() ret:addChild(menu) menu:alignItemsVertically() - local s = CCDirector:sharedDirector():getWinSize() - menu:setPosition(ccp(s.width/2, s.height/2)) + local s = CCDirector:getInstance():getWinSize() + menu:setPosition(CCPoint(s.width/2, s.height/2)) return ret end local function RemoveMenuItemWhenMove() local ret = CCLayer:create() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label = CCLabelTTF:create("click item and move, should not crash", "Arial", 20) - label:setPosition(ccp(s.width/2, s.height - 30)) + label:setPosition(CCPoint(s.width/2, s.height - 30)) ret:addChild(label) local item = CCMenuItemFont:create("item 1") @@ -627,13 +627,13 @@ local function RemoveMenuItemWhenMove() ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(ccp(s.width/2, s.height/2)) + menu:setPosition(CCPoint(s.width/2, s.height/2)) ret:setTouchEnabled(true) --[[ local function onNodeEvent(event) if event == "enter" then - CCDirector:sharedDirector():getTouchDispatcher():addTargetedDelegate(ret, -129, false) + CCDirector:getInstance():getTouchDispatcher():addTargetedDelegate(ret, -129, false) elseif event == "exit" then -- item:release() end diff --git a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua index 57215ad307..b4458da4dc 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MotionStreakTest/MotionStreakTest.lua @@ -3,8 +3,8 @@ local streak = nil local titleLabel = nil local subtitleLabel = nil -local s = CCDirector:sharedDirector():getWinSize() -local scheduler = CCDirector:sharedDirector():getScheduler() +local s = CCDirector:getInstance():getWinSize() +local scheduler = CCDirector:getInstance():getScheduler() local firstTick = nil @@ -25,7 +25,7 @@ local function getBaseLayer() itemMode:registerScriptTapHandler(modeCallback) local menuMode = CCMenu:create() menuMode:addChild(itemMode) - menuMode:setPosition(ccp(s.width / 2, s.height / 4)) + menuMode:setPosition(CCPoint(s.width / 2, s.height / 4)) layer:addChild(menuMode) Helper.initWithLayer(layer) @@ -47,7 +47,7 @@ local function MotionStreakTest1_update(dt) return end - streak:setPosition(target:convertToWorldSpace(ccp(0, 0))) + streak:setPosition(target:convertToWorldSpace(CCPoint(0, 0))) end local function MotionStreakTest1_onEnterOrExit(tag) @@ -63,11 +63,11 @@ local function MotionStreakTest1() root = CCSprite:create(s_pPathR1) layer:addChild(root, 1) - root:setPosition(ccp(s.width / 2, s.height / 2)) + root:setPosition(CCPoint(s.width / 2, s.height / 2)) target = CCSprite:create(s_pPathR1) root:addChild(target) - target:setPosition(ccp(s.width / 4, 0)) + target:setPosition(CCPoint(s.width / 4, 0)) streak = CCMotionStreak:create(2, 3, 32, Color3B(0, 255, 0), s_streak) layer:addChild(streak) @@ -75,7 +75,7 @@ local function MotionStreakTest1() local a1 = CCRotateBy:create(2, 360) local action1 = CCRepeatForever:create(a1) - local motion = CCMoveBy:create(2, CCPointMake(100,0)) + local motion = CCMoveBy:create(2, CCPoint(100,0)) root:runAction(CCRepeatForever:create(CCSequence:createWithTwoActions(motion, motion:reverse()))) root:runAction(action1) @@ -106,7 +106,7 @@ local function MotionStreakTest2() streak = CCMotionStreak:create(3, 3, 64, Color3B(255, 255, 255), s_streak) layer:addChild(streak) - streak:setPosition(CCPointMake(s.width / 2, s.height / 2)) + streak:setPosition(CCPoint(s.width / 2, s.height / 2)) local function onTouchMoved(x, y) if firstTick == true then @@ -114,7 +114,7 @@ local function MotionStreakTest2() return end - streak:setPosition(ccp(x, y)) + streak:setPosition(CCPoint(x, y)) end local function onTouch(eventType, x, y) @@ -149,7 +149,7 @@ local function Issue1358_update(dt) end fAngle = fAngle + 1.0 streak:setPosition( - ccp(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) + CCPoint(center.x + math.cos(fAngle / 180 * math.pi) * fRadius, center.y + math.sin(fAngle/ 180 * math.pi) * fRadius)) end local function Issue1358_onEnterOrExit(tag) @@ -166,7 +166,7 @@ local function Issue1358() streak = CCMotionStreak:create(2.0, 1.0, 50.0, Color3B(255, 255, 0), "Images/Icon.png") layer:addChild(streak) - center = ccp(s.width / 2, s.height / 2) + center = CCPoint(s.width / 2, s.height / 2) fRadius = s.width / 3 fAngle = 0 diff --git a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua index 98403dec40..22d7f28c87 100644 --- a/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/NodeTest/NodeTest.lua @@ -3,8 +3,8 @@ local kTagSprite2 = 2 local kTagSprite3 = 3 local kTagSlider = 4 -local s = CCDirector:sharedDirector():getWinSize() -local scheduler = CCDirector:sharedDirector():getScheduler() +local s = CCDirector:getInstance():getWinSize() +local scheduler = CCDirector:getInstance():getScheduler() local function getBaseLayer() local layer = CCLayer:create() @@ -23,46 +23,46 @@ local function CameraCenterTest() -- LEFT-TOP local sprite = CCSprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPointMake(s.width / 5 * 1, s.height / 5 * 1)) + sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 1)) sprite:setColor(Color3B(255, 0, 0)) - sprite:setTextureRect(CCRectMake(0, 0, 120, 50)) + sprite:setTextureRect(CCRect(0, 0, 120, 50)) local orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) - -- [sprite setAnchorPoint: CCPointMake(0,1)) + -- [sprite setAnchorPoint: CCPoint(0,1)) -- LEFT-BOTTOM sprite = CCSprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPointMake(s.width / 5 * 1, s.height / 5 * 4)) + sprite:setPosition(CCPoint(s.width / 5 * 1, s.height / 5 * 4)) sprite:setColor(Color3B(0, 0, 255)) - sprite:setTextureRect(CCRectMake(0, 0, 120, 50)) + sprite:setTextureRect(CCRect(0, 0, 120, 50)) orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) -- RIGHT-TOP sprite = CCSprite:create("Images/white-512x512.png") layer:addChild(sprite, 0) - sprite:setPosition(CCPointMake(s.width / 5 * 4, s.height / 5 * 1)) + sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 1)) sprite:setColor(Color3B(255, 255, 0)) - sprite:setTextureRect(CCRectMake(0, 0, 120, 50)) + sprite:setTextureRect(CCRect(0, 0, 120, 50)) orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) -- RIGHT-BOTTOM sprite = CCSprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPointMake(s.width / 5 * 4, s.height / 5 * 4)) + sprite:setPosition(CCPoint(s.width / 5 * 4, s.height / 5 * 4)) sprite:setColor(Color3B(0, 255, 0)) - sprite:setTextureRect(CCRectMake(0, 0, 120, 50)) + sprite:setTextureRect(CCRect(0, 0, 120, 50)) orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) -- CENTER sprite = CCSprite:create("Images/white-512x512.png") layer:addChild(sprite, 0, 40) - sprite:setPosition(CCPointMake(s.width / 2, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 2, s.height / 2)) sprite:setColor(Color3B(255, 255, 255)) - sprite:setTextureRect(CCRectMake(0, 0, 120, 50)) + sprite:setTextureRect(CCRect(0, 0, 120, 50)) orbit = CCOrbitCamera:create(10, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) @@ -82,8 +82,8 @@ local function Test2() local sp3 = CCSprite:create(s_pPathSister1) local sp4 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPointMake(100, s.height /2)) - sp2:setPosition(CCPointMake(380, s.height /2)) + sp1:setPosition(CCPoint(100, s.height /2)) + sp2:setPosition(CCPoint(380, s.height /2)) layer:addChild(sp1) layer:addChild(sp2) @@ -107,7 +107,7 @@ local function Test2() array2:addObject(a2:reverse()) local action2 = CCRepeatForever:create(CCSequence:create(array2)) - sp2:setAnchorPoint(CCPointMake(0,0)) + sp2:setAnchorPoint(CCPoint(0,0)) sp1:runAction(action1) sp2:runAction(action2) @@ -149,8 +149,8 @@ local function Test4() local sp1 = CCSprite:create(s_pPathSister1) local sp2 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPointMake(100, 160)) - sp2:setPosition(CCPointMake(380, 160)) + sp1:setPosition(CCPoint(100, 160)) + sp2:setPosition(CCPoint(380, 160)) Test4_layer:addChild(sp1, 0, 2) Test4_layer:addChild(sp2, 0, 3) @@ -198,8 +198,8 @@ local function Test5() local sp1 = CCSprite:create(s_pPathSister1) local sp2 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPointMake(100, 160)) - sp2:setPosition(CCPointMake(380, 160)) + sp1:setPosition(CCPoint(100, 160)) + sp2:setPosition(CCPoint(380, 160)) local rot = CCRotateBy:create(2, 360) local rot_back = rot:reverse() @@ -264,8 +264,8 @@ local function Test6() local sp2 = CCSprite:create(s_pPathSister2) local sp21 = CCSprite:create(s_pPathSister2) - sp1:setPosition(CCPointMake(100, 160)) - sp2:setPosition(CCPointMake(380, 160)) + sp1:setPosition(CCPoint(100, 160)) + sp2:setPosition(CCPoint(380, 160)) local rot = CCRotateBy:create(2, 360) local rot_back = rot:reverse() @@ -308,11 +308,11 @@ local function shouldNotCrash(dt) -- if the node has timers, it crashes local explosion = CCParticleSun:create() - explosion:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/fire.png")) + explosion:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) explosion:setPosition(s.width / 2, s.height / 2) - StressTest1_layer:setAnchorPoint(ccp(0, 0)) + StressTest1_layer:setAnchorPoint(CCPoint(0, 0)) local callFunc = CCCallFunc:create(removeMe) StressTest1_layer:runAction(CCSequence:createWithTwoActions(CCRotateBy:create(2, 360), callFunc)) @@ -333,7 +333,7 @@ local function StressTest1() sp1 = CCSprite:create(s_pPathSister1) StressTest1_layer:addChild(sp1, 0, kTagSprite1) - sp1:setPosition(CCPointMake(s.width / 2, s.height / 2)) + sp1:setPosition(CCPoint(s.width / 2, s.height / 2)) StressTest1_layer:registerScriptHandler(StressTest1_onEnterOrExit) @@ -368,17 +368,17 @@ local function StressTest2() sublayer = CCLayer:create() local sp1 = CCSprite:create(s_pPathSister1) - sp1:setPosition(CCPointMake(80, s.height / 2)) + sp1:setPosition(CCPoint(80, s.height / 2)) - local move = CCMoveBy:create(3, CCPointMake(350, 0)) - local move_ease_inout3 = CCEaseInOut:create(CCMoveBy:create(3, CCPointMake(350, 0)), 2.0) + local move = CCMoveBy:create(3, CCPoint(350, 0)) + local move_ease_inout3 = CCEaseInOut:create(CCMoveBy:create(3, CCPoint(350, 0)), 2.0) local move_ease_inout_back3 = move_ease_inout3:reverse() local seq3 = CCSequence:createWithTwoActions(move_ease_inout3, move_ease_inout_back3) sp1:runAction(CCRepeatForever:create(seq3)) sublayer:addChild(sp1, 1) local fire = CCParticleFire:create() - fire:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/fire.png")) + fire:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) fire = tolua.cast(fire, "CCNode") fire:setPosition(80, s.height / 2 - 50) @@ -406,21 +406,21 @@ local function NodeToWorld() local back = CCSprite:create(s_back3) layer:addChild(back, -10) - back:setAnchorPoint(CCPointMake(0, 0)) + back:setAnchorPoint(CCPoint(0, 0)) local backSize = back:getContentSize() local item = CCMenuItemImage:create(s_PlayNormal, s_PlaySelect) local menu = CCMenu:create() menu:addChild(item) menu:alignItemsVertically() - menu:setPosition(ccp(backSize.width / 2, backSize.height / 2)) + menu:setPosition(CCPoint(backSize.width / 2, backSize.height / 2)) back:addChild(menu) local rot = CCRotateBy:create(5, 360) local fe = CCRepeatForever:create(rot) item:runAction(fe) - local move = CCMoveBy:create(3, CCPointMake(200, 0)) + local move = CCMoveBy:create(3, CCPoint(200, 0)) local move_back = move:reverse() local seq = CCSequence:createWithTwoActions(move, move_back) local fe2 = CCRepeatForever:create(seq) @@ -435,9 +435,9 @@ end ----------------------------------- local function CameraOrbitTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection3D) + CCDirector:getInstance():setProjection(kCCDirectorProjection3D) elseif tag == "exit" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D) + CCDirector:getInstance():setProjection(kCCDirectorProjection2D) end end @@ -446,7 +446,7 @@ local function CameraOrbitTest() local p = CCSprite:create(s_back3) layer:addChild(p, 0) - p:setPosition(CCPointMake(s.width / 2, s.height / 2)) + p:setPosition(CCPoint(s.width / 2, s.height / 2)) p:setOpacity(128) -- LEFT @@ -454,7 +454,7 @@ local function CameraOrbitTest() local sprite = CCSprite:create(s_pPathGrossini) sprite:setScale(0.5) p:addChild(sprite, 0) - sprite:setPosition(CCPointMake(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() local orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 0, 0) sprite:runAction(CCRepeatForever:create(orbit)) @@ -463,7 +463,7 @@ local function CameraOrbitTest() sprite = CCSprite:create(s_pPathGrossini) sprite:setScale(1.0) p:addChild(sprite, 0) - sprite:setPosition(CCPointMake(s.width / 4 * 2, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 45, 0) sprite:runAction(CCRepeatForever:create(orbit)) @@ -471,7 +471,7 @@ local function CameraOrbitTest() sprite = CCSprite:create(s_pPathGrossini) sprite:setScale(2.0) p:addChild(sprite, 0) - sprite:setPosition(CCPointMake(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) local ss = sprite:getContentSize() orbit = CCOrbitCamera:create(2, 1, 0, 0, 360, 90, -45) sprite:runAction(CCRepeatForever:create(orbit)) @@ -507,10 +507,10 @@ end local function CameraZoomTest_onEnterOrExit(tag) if tag == "enter" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection3D) + CCDirector:getInstance():setProjection(kCCDirectorProjection3D) CameraZoomTest_entry = scheduler:scheduleScriptFunc(CameraZoomTest_update, 0.0, false) elseif tag == "exit" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D) + CCDirector:getInstance():setProjection(kCCDirectorProjection2D) scheduler:unscheduleScriptEntry(CameraZoomTest_entry) end end @@ -523,7 +523,7 @@ local function CameraZoomTest() -- LEFT local sprite = CCSprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0) - sprite:setPosition(ccp(s.width / 4 * 1, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 1, s.height / 2)) local cam = sprite:getCamera() cam:setEyeXYZ(0, 0, 415 / 2) cam:setCenterXYZ(0, 0, 0) @@ -531,12 +531,12 @@ local function CameraZoomTest() -- CENTER sprite = CCSprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 40) - sprite:setPosition(ccp(s.width / 4 * 2, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 2, s.height / 2)) -- RIGHT sprite = CCSprite:create(s_pPathGrossini) CameraZoomTest_layer:addChild(sprite, 0, 20) - sprite:setPosition(ccp(s.width / 4 * 3, s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * 3, s.height / 2)) CameraZoomTest_layer:scheduleUpdateWithPriorityLua(CameraZoomTest_update, 0) CameraZoomTest_layer:registerScriptHandler(CameraZoomTest_onEnterOrExit) @@ -557,7 +557,7 @@ local function ConvertToNode() local action = CCRepeatForever:create(rotate) for i = 0, 2 do local sprite = CCSprite:create("Images/grossini.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -565,11 +565,11 @@ local function ConvertToNode() ConvertToNode_layer:addChild(point, 10, 100 + i) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(ccp(1,1)) + sprite:setAnchorPoint(CCPoint(1,1)) end point:setPosition(sprite:getPosition()) @@ -583,8 +583,8 @@ local function ConvertToNode() for i = 0, 2 do local node = ConvertToNode_layer:getChildByTag(100 + i) local p1, p2 - p1 = node:convertToNodeSpaceAR(ccp(x, y)) - p2 = node:convertToNodeSpace(ccp(x, y)) + p1 = node:convertToNodeSpaceAR(CCPoint(x, y)) + p2 = node:convertToNodeSpace(CCPoint(x, y)) cclog("AR: x=" .. p1.x .. ", y=" .. p1.y .. " -- Not AR: x=" .. p2.x .. ", y=" .. p2.y) end @@ -618,7 +618,7 @@ local function NodeOpaqueTest() blendFunc.src = GL_ONE blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA background:setBlendFunc(blendFunc) - background:setAnchorPoint(ccp(0, 0)) + background:setAnchorPoint(CCPoint(0, 0)) layer:addChild(background) end @@ -639,7 +639,7 @@ local function NodeNonOpaqueTest() blendFunc.src = GL_ONE blendFunc.dst = GL_ZERO background:setBlendFunc(blendFunc) - background:setAnchorPoint(ccp(0, 0)) + background:setAnchorPoint(CCPoint(0, 0)) layer:addChild(background) end Helper.titleLabel:setString("Node Non Opaque Test") diff --git a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua index 45d5dd1be7..460fac980e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/OpenGLTest/OpenGLTest.lua @@ -8,7 +8,7 @@ local function OpenGLTestMainLayer() local curCase = 0 local accum = 0 local labelBMFont = nil - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local curLayer = nil local schedulEntry = nil local function OrderCallbackMenu() @@ -31,7 +31,7 @@ local function OpenGLTestMainLayer() end local ordercallbackmenu = CCMenu:create() - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) ordercallbackmenu:addChild(item1,kItemTagBasic) @@ -42,11 +42,11 @@ local function OpenGLTestMainLayer() ordercallbackmenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - ordercallbackmenu:setPosition(ccp(0, 0)) + ordercallbackmenu:setPosition(CCPoint(0, 0)) return ordercallbackmenu end @@ -127,12 +127,12 @@ local function OpenGLTestMainLayer() --Title local lableTitle = CCLabelTTF:create(GetTitle(), "Arial", 40) layer:addChild(lableTitle, 15) - lableTitle:setPosition(ccp(size.width/2, size.height-32)) + lableTitle:setPosition(CCPoint(size.width/2, size.height-32)) lableTitle:setColor(Color3B(255,255,40)) --SubTitle local subLabelTitle = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) layer:addChild(subLabelTitle, 15) - subLabelTitle:setPosition(ccp(size.width/2, size.height-80)) + subLabelTitle:setPosition(CCPoint(size.width/2, size.height-80)) end local function updateRetroEffect(fTime) @@ -192,8 +192,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -254,8 +254,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -316,8 +316,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -378,8 +378,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -440,8 +440,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -502,8 +502,8 @@ local function OpenGLTestMainLayer() local program = shader:getProgram() local glNode = gl.glNodeCreate() - glNode:setContentSize(CCSizeMake(256,256)) - glNode:setAnchorPoint(ccp(0.5, 0.5)) + glNode:setContentSize(CCSize(256,256)) + glNode:setAnchorPoint(CCPoint(0.5, 0.5)) uniformCenter = gl.getUniformLocation(program,"center") uniformResolution = gl.getUniformLocation( program, "resolution") glNode:setShaderProgram(shader) @@ -554,7 +554,7 @@ local function OpenGLTestMainLayer() glGetActiveLayer:addChild(sprite) local glNode = gl.glNodeCreate() glGetActiveLayer:addChild(glNode,-10) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() local function getCurrentResult() local var = {} @@ -602,8 +602,8 @@ local function OpenGLTestMainLayer() local glNode = gl.glNodeCreate() texImage2dLayer:addChild(glNode, 10) glNode:setPosition(size.width/2, size.height/2) - glNode:setContentSize(CCSizeMake(128,128)) - glNode:setAnchorPoint(ccp(0.5,0.5)) + glNode:setContentSize(CCSize(128,128)) + glNode:setAnchorPoint(CCPoint(0.5,0.5)) local shaderCache = CCShaderCache:getInstance() local shader = shaderCache:getProgram("ShaderPositionTexture") local function initGL() @@ -717,7 +717,7 @@ local function OpenGLTestMainLayer() readPixelsLayer:addChild(green,12) readPixelsLayer:addChild(red,13) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() local function getCurrentResult() local x = size.width @@ -782,7 +782,7 @@ local function OpenGLTestMainLayer() local glNode = gl.glNodeCreate() clearLayer:addChild(glNode,10) --gl.init() - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() local function clearDraw() gl.clear(gl.COLOR_BUFFER_BIT) @@ -1150,7 +1150,7 @@ local function OpenGLTestMainLayer() local curScene = CCScene:create() if nil ~= curScene then if nil ~= curLayer then - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if nil ~= schedulEntry then scheduler:unscheduleScriptEntry(schedulEntry) end @@ -1160,7 +1160,7 @@ local function OpenGLTestMainLayer() curScene:addChild(curLayer) curLayer:addChild(OrderCallbackMenu(),15) curScene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(curScene) + CCDirector:getInstance():replaceScene(curScene) end end end diff --git a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua index 1ed0bb022e..df34149294 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParallaxTest/ParallaxTest.lua @@ -24,7 +24,7 @@ local function Parallax1() -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( ccp(0,0) ) + cocosImage:setAnchorPoint( CCPoint(0,0) ) -- Middle layer: a Tile map atlas @@ -32,7 +32,7 @@ local function Parallax1() tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( ccp(0, 0) ) + tilemap:setAnchorPoint( CCPoint(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() @@ -43,7 +43,7 @@ local function Parallax1() -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( ccp(0,0) ) + background:setAnchorPoint( CCPoint(0,0) ) -- create a void node, a parent node @@ -52,21 +52,21 @@ local function Parallax1() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, ccp(0.4,0.5), ccp(0,0)) + voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0,0)) -- tiles are moved at a ratio of 2.2x, 1.0y - voidNode:addChild(tilemap, 1, ccp(2.2,1.0), ccp(0,-200) ) + voidNode:addChild(tilemap, 1, CCPoint(2.2,1.0), CCPoint(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild(cocosImage, 2, ccp(3.0,2.5), ccp(200,800) ) + voidNode:addChild(cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,800) ) -- now create some actions that will move the 'void' node -- and the children of the 'void' node will move at different -- speed, thus, simulation the 3D environment - local goUp = CCMoveBy:create(4, ccp(0,-500) ) + local goUp = CCMoveBy:create(4, CCPoint(0,-500) ) local goDown = goUp:reverse() - local go = CCMoveBy:create(8, ccp(-1000,0) ) + local go = CCMoveBy:create(8, CCPoint(-1000,0) ) local goBack = go:reverse() local arr = CCArray:create() arr:addObject(goUp) @@ -95,7 +95,7 @@ local function Parallax2() -- scale the image (optional) cocosImage:setScale( 2.5 ) -- change the transform anchor point to 0,0 (optional) - cocosImage:setAnchorPoint( ccp(0,0) ) + cocosImage:setAnchorPoint( CCPoint(0,0) ) -- Middle layer: a Tile map atlas @@ -103,7 +103,7 @@ local function Parallax2() tilemap:releaseMap() -- change the transform anchor to 0,0 (optional) - tilemap:setAnchorPoint( ccp(0, 0) ) + tilemap:setAnchorPoint( CCPoint(0, 0) ) -- Anti Aliased images tilemap:getTexture():setAntiAliasTexParameters() @@ -114,7 +114,7 @@ local function Parallax2() -- scale the image (optional) background:setScale( 1.5 ) -- change the transform anchor point (optional) - background:setAnchorPoint( ccp(0,0) ) + background:setAnchorPoint( CCPoint(0,0) ) -- create a void node, a parent node @@ -123,13 +123,13 @@ local function Parallax2() -- NOW add the 3 layers to the 'void' node -- background image is moved at a ratio of 0.4x, 0.5y - voidNode:addChild(background, -1, ccp(0.4,0.5), ccp(0, 0)) + voidNode:addChild(background, -1, CCPoint(0.4,0.5), CCPoint(0, 0)) -- tiles are moved at a ratio of 1.0, 1.0y - voidNode:addChild(tilemap, 1, ccp(1.0,1.0), ccp(0,-200) ) + voidNode:addChild(tilemap, 1, CCPoint(1.0,1.0), CCPoint(0,-200) ) -- top image is moved at a ratio of 3.0x, 2.5y - voidNode:addChild( cocosImage, 2, ccp(3.0,2.5), ccp(200,1000) ) + voidNode:addChild( cocosImage, 2, CCPoint(3.0,2.5), CCPoint(200,1000) ) ret:addChild(voidNode, 0, kTagNode) local prev = {x = 0, y = 0} local function onTouchEvent(eventType, x, y) @@ -144,7 +144,7 @@ local function Parallax2() local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( ccpAdd(ccp(newX, newY), ccp(diffX, diffY)) ) + node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) prev.x = x prev.y = y end @@ -157,7 +157,7 @@ end function ParallaxTestMain() cclog("ParallaxMain") Helper.index = 1 - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) local scene = CCScene:create() Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua index 4d113d7fd5..6f43f1fbef 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ParticleTest/ParticleTest.lua @@ -10,7 +10,7 @@ local titleLabel = nil local subtitleLabel = nil local baseLayer_entry = nil -local s = CCDirector:sharedDirector():getWinSize() +local s = CCDirector:getInstance():getWinSize() local function backAction() SceneIdx = SceneIdx - 1 @@ -38,7 +38,7 @@ local function backCallback(sender) scene:addChild(backAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function restartCallback(sender) @@ -47,7 +47,7 @@ local function restartCallback(sender) scene:addChild(restartAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function nextCallback(sender) @@ -56,7 +56,7 @@ local function nextCallback(sender) scene:addChild(nextAction()) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function toggleCallback(sender) @@ -85,7 +85,7 @@ local function update(dt) end local function baseLayer_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then baseLayer_entry = scheduler:scheduleScriptFunc(update, 0, false) elseif tag == "exit" then @@ -124,37 +124,37 @@ local function getBaseLayer() menu:addChild(item3) menu:addChild(item4) - menu:setPosition(CCPointMake(0, 0)) - item1:setPosition(CCPointMake(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(s.width/2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item4:setPosition(ccp(0, 100)) - item4:setAnchorPoint(ccp(0, 0)) + menu:setPosition(CCPoint(0, 0)) + item1:setPosition(CCPoint(s.width/2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(s.width/2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(s.width/2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item4:setPosition(CCPoint(0, 100)) + item4:setAnchorPoint(CCPoint(0, 0)) layer:addChild(menu, 100) labelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) layer:addChild(labelAtlas, 100) - labelAtlas:setPosition(ccp(s.width - 66, 50)) + labelAtlas:setPosition(CCPoint(s.width - 66, 50)) -- moving background background = CCSprite:create(s_back3) layer:addChild(background, 5) - background:setPosition(ccp(s.width / 2, s.height - 180)) + background:setPosition(CCPoint(s.width / 2, s.height - 180)) - local move = CCMoveBy:create(4, ccp(300, 0)) + local move = CCMoveBy:create(4, CCPoint(300, 0)) local move_back = move:reverse() local seq = CCSequence:createWithTwoActions(move, move_back) background:runAction(CCRepeatForever:create(seq)) local function onTouchEnded(x, y) - local pos = CCPointMake(0, 0) + local pos = CCPoint(0, 0) if background ~= nil then - pos = background:convertToWorldSpace(CCPointMake(0, 0)) + pos = background:convertToWorldSpace(CCPoint(0, 0)) end if emitter ~= nil then - local newPos = ccpSub(CCPointMake(x, y), pos) + local newPos = CCPoint.__sub(CCPoint(x, y), pos) emitter:setPosition(newPos.x, newPos.y) end end @@ -211,7 +211,7 @@ local function reorderParticles(dt) end local function ParticleReorder_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then ParticleReorder_entry = scheduler:scheduleScriptFunc(reorderParticles, 1.0, false) elseif tag == "exit" then @@ -257,9 +257,9 @@ local function ParticleReorder() neg = -1 end - emitter1:setPosition(ccp( s.width / 2 - 30, s.height / 2 + 60 * neg)) - emitter2:setPosition(ccp( s.width / 2, s.height / 2 + 60 * neg)) - emitter3:setPosition(ccp( s.width / 2 + 30, s.height / 2 + 60 * neg)) + emitter1:setPosition(CCPoint( s.width / 2 - 30, s.height / 2 + 60 * neg)) + emitter2:setPosition(CCPoint( s.width / 2, s.height / 2 + 60 * neg)) + emitter3:setPosition(CCPoint( s.width / 2 + 30, s.height / 2 + 60 * neg)) parent:addChild(emitter1, 0, 1) parent:addChild(emitter2, 0, 2) @@ -301,7 +301,7 @@ local function switchRender(dt) end local function ParticleBatchHybrid_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then ParticleBatchHybrid_entry = scheduler:scheduleScriptFunc(switchRender, 2.0, false) elseif tag == "exit" then @@ -352,9 +352,9 @@ local function ParticleBatchMultipleEmitters() local emitter3 = CCParticleSystemQuad:create("Particles/LavaFlow.plist") emitter3:setStartColor(Color4F(0,0,1,1)) - emitter1:setPosition(ccp(s.width / 1.25, s.height / 1.25)) - emitter2:setPosition(ccp(s.width / 2, s.height / 2)) - emitter3:setPosition(ccp(s.width / 4, s.height / 4)) + emitter1:setPosition(CCPoint(s.width / 1.25, s.height / 1.25)) + emitter2:setPosition(CCPoint(s.width / 2, s.height / 2)) + emitter3:setPosition(CCPoint(s.width / 4, s.height / 4)) local batch = CCParticleBatchNode:createWithTexture(emitter1:getTexture()) @@ -378,7 +378,7 @@ local function DemoFlower() emitter = CCParticleFlower:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_stars1)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -396,7 +396,7 @@ local function DemoGalaxy() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -414,7 +414,7 @@ local function DemoFirework() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_stars1)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) setEmitterPosition() @@ -432,7 +432,7 @@ local function DemoSpiral() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -450,7 +450,7 @@ local function DemoSun() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -468,7 +468,7 @@ local function DemoMeteor() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -486,7 +486,7 @@ local function DemoFire() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, 100) @@ -503,7 +503,7 @@ local function DemoSmoke() emitter = CCParticleSmoke:create() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) local pos_x, pos_y = emitter:getPosition() emitter:setPosition(pos_x, 100) @@ -524,7 +524,7 @@ local function DemoExplosion() -- emitter:retain() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_stars1)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) emitter:setAutoRemoveOnFinish(true) @@ -550,7 +550,7 @@ local function DemoSnow() emitter:setLifeVar(1) -- gravity - emitter:setGravity(CCPointMake(0, -10)) + emitter:setGravity(CCPoint(0, -10)) -- speed of particles emitter:setSpeed(130) @@ -568,7 +568,7 @@ local function DemoSnow() emitter:setEmissionRate(emitter:getTotalParticles() / emitter:getLife()) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_snow)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_snow)) setEmitterPosition() @@ -590,7 +590,7 @@ local function DemoRain() emitter:setPosition(pos_x, pos_y - 100) emitter:setLife(4) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) setEmitterPosition() @@ -610,11 +610,11 @@ local function DemoBigFlower() background:addChild(emitter, 10) ----emitter:release() -- win32 : use this line or remove this line and use autorelease() - emitter:setTexture( CCTextureCache:sharedTextureCache():addImage(s_stars1) ) + emitter:setTexture( CCTextureCache:getInstance():addImage(s_stars1) ) emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPointMake(0, 0)) + emitter:setGravity(CCPoint(0, 0)) -- angle emitter:setAngle(90) @@ -634,7 +634,7 @@ local function DemoBigFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(4) @@ -681,13 +681,13 @@ local function DemoRotFlower() background:addChild(emitter, 10) ----emitter:release() -- win32 : Remove this line - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_stars2)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars2)) -- duration emitter:setDuration(-1) -- gravity - emitter:setGravity(ccp(0, 0)) + emitter:setGravity(CCPoint(0, 0)) -- angle emitter:setAngle(90) @@ -707,7 +707,7 @@ local function DemoRotFlower() -- emitter position emitter:setPosition(160, 240) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(3) @@ -759,7 +759,7 @@ local function DemoModernArt() emitter:setDuration(-1) -- gravity - emitter:setGravity(CCPointMake(0,0)) + emitter:setGravity(CCPoint(0,0)) -- angle emitter:setAngle(0) @@ -779,7 +779,7 @@ local function DemoModernArt() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(2.0) @@ -801,7 +801,7 @@ local function DemoModernArt() emitter:setEndSizeVar(8.0) -- texture - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) -- additive emitter:setBlendAdditive(false) @@ -823,7 +823,7 @@ local function DemoRing() background:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_stars1)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_stars1)) emitter:setLifeVar(0) emitter:setLife(10) emitter:setSpeed(100) @@ -851,21 +851,21 @@ local function ParallaxParticle() local p1 = CCSprite:create(s_back3) local p2 = CCSprite:create(s_back3) - p:addChild(p1, 1, CCPointMake(0.5, 1), CCPointMake(0, 250)) - p:addChild(p2, 2, CCPointMake(1.5, 1), CCPointMake(0, 50)) + p:addChild(p1, 1, CCPoint(0.5, 1), CCPoint(0, 250)) + p:addChild(p2, 2, CCPoint(1.5, 1), CCPoint(0, 50)) emitter = CCParticleFlower:create() -- emitter:retain() - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + emitter:setTexture(CCTextureCache:getInstance():addImage(s_fire)) p1:addChild(emitter, 10) emitter:setPosition(250, 200) local par = CCParticleSun:create() p2:addChild(par, 10) - par:setTexture(CCTextureCache:sharedTextureCache():addImage(s_fire)) + par:setTexture(CCTextureCache:getInstance():addImage(s_fire)) - local move = CCMoveBy:create(4, CCPointMake(300,0)) + local move = CCMoveBy:create(4, CCPoint(300,0)) local move_back = move:reverse() local seq = CCSequence:createWithTwoActions(move, move_back) p:runAction(CCRepeatForever:create(seq)) @@ -909,7 +909,7 @@ local function RadiusMode1() emitter = CCParticleSystemQuad:new() emitter:initWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/stars-grayscale.png")) + emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration emitter:setDuration(kCCParticleDurationInfinity) @@ -934,7 +934,7 @@ local function RadiusMode1() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(5) @@ -980,7 +980,7 @@ local function RadiusMode2() emitter = CCParticleSystemQuad:new() emitter:initWithTotalParticles(200) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/stars-grayscale.png")) + emitter:setTexture(CCTextureCache:getInstance():addImage("Images/stars-grayscale.png")) -- duration emitter:setDuration(kCCParticleDurationInfinity) @@ -1004,7 +1004,7 @@ local function RadiusMode2() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(4) @@ -1050,7 +1050,7 @@ local function Issue704() emitter = CCParticleSystemQuad:new() emitter:initWithTotalParticles(100) layer:addChild(emitter, 10) - emitter:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/fire.png")) + emitter:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) -- duration emitter:setDuration(kCCParticleDurationInfinity) @@ -1075,7 +1075,7 @@ local function Issue704() -- emitter position emitter:setPosition(s.width / 2, s.height / 2) - emitter:setPosVar(ccp(0, 0)) + emitter:setPosVar(CCPoint(0, 0)) -- life of particles emitter:setLife(5) @@ -1122,12 +1122,12 @@ local function updateQuads(dt) update(dt) Issue870_index = math.mod(Issue870_index + 1, 4) - local rect = CCRectMake(Issue870_index * 32, 0, 32, 32) + local rect = CCRect(Issue870_index * 32, 0, 32, 32) emitter:setTextureWithRect(emitter:getTexture(), rect) end local function Issue870_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then Issue870_entry = scheduler:scheduleScriptFunc(updateQuads, 2.0, false) elseif tag == "exit" then @@ -1144,7 +1144,7 @@ local function Issue870() local system = CCParticleSystemQuad:new() system:initWithFile("Particles/SpinningPeas.plist") - system:setTextureWithRect(CCTextureCache:sharedTextureCache():addImage("Images/particles.png"), CCRectMake(0,0,32,32)) + system:setTextureWithRect(CCTextureCache:getInstance():addImage("Images/particles.png"), CCRect(0,0,32,32)) layer:addChild(system, 10) emitter = system @@ -1166,7 +1166,7 @@ local function MultipleParticleSystems() layer:removeChild(background, true) background = nil - CCTextureCache:sharedTextureCache():addImage("Images/particles.png") + CCTextureCache:getInstance():addImage("Images/particles.png") for i = 0, 4 do local particleSystem = CCParticleSystemQuad:create("Particles/SpinningPeas.plist") @@ -1239,7 +1239,7 @@ local function removeSystem(dt) end local function AddAndDeleteParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then AddAndDeleteParticleSystems_entry = scheduler:scheduleScriptFunc(removeSystem, 2.0, false) elseif tag == "exit" then @@ -1297,7 +1297,7 @@ local function reorderSystem(dt) end local function ReorderParticleSystems_onEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then ReorderParticleSystems_entry = scheduler:scheduleScriptFunc(reorderSystem, 2.0, false) elseif tag == "exit" then @@ -1344,7 +1344,7 @@ local function ReorderParticleSystems() particleSystem:setAngleVar(0) -- emitter position - particleSystem:setPosVar(ccp(0, 0)) + particleSystem:setPosVar(CCPoint(0, 0)) -- life of particles particleSystem:setLife(4) diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua index cb2281b10c..a2fba1bb9d 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceSpriteTest.lua @@ -3,13 +3,13 @@ local kBasicZOrder = 10 local kNodesIncrease = 250 local TEST_COUNT = 7 -local s = CCDirector:sharedDirector():getWinSize() +local s = CCDirector:getInstance():getWinSize() ----------------------------------- -- For test functions ----------------------------------- local function performanceActions(sprite) - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 local rot = CCRotateBy:create(period, 360.0 * math.random()) @@ -25,9 +25,9 @@ end local function performanceActions20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPointMake(-1000, -1000)) + sprite:setPosition(CCPoint(-1000, -1000)) end local period = 0.5 + math.mod(math.random(1, 99999999), 1000) / 500.0 @@ -42,29 +42,29 @@ local function performanceActions20(sprite) end local function performanceRotationScale(sprite) - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setRotation(math.random() * 360) sprite:setScale(math.random() * 2) end local function performancePosition(sprite) - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) end local function performanceout20(sprite) if math.random() < 0.2 then - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) else - sprite:setPosition(CCPointMake(-1000, -1000)) + sprite:setPosition(CCPoint(-1000, -1000)) end end local function performanceOut100(sprite) - sprite:setPosition(CCPointMake( -1000, -1000)) + sprite:setPosition(CCPoint( -1000, -1000)) end local function performanceScale(sprite) - sprite:setPosition(CCPointMake(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) + sprite:setPosition(CCPoint(math.mod(math.random(1, 99999999), s.width), math.mod(math.random(1, 99999999), s.height))) sprite:setScale(math.random() * 100 / 50) end @@ -80,7 +80,7 @@ local function initWithSubTest(nSubTest, p) parent = p batchNode = nil - local mgr = CCTextureCache:sharedTextureCache() + local mgr = CCTextureCache:getInstance() -- remove all texture mgr:removeTexture(mgr:addImage("Images/grossinis_sister1.png")) mgr:removeTexture(mgr:addImage("Images/grossini_dance_atlas.png")) @@ -128,10 +128,10 @@ local function createSpriteWithTag(tag) sprite = CCSprite:create("Images/grossinis_sister1.png") parent:addChild(sprite, -1, tag + 100) elseif subtestNumber == 2 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(0, 0, 52, 139)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 3 then - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(0, 0, 52, 139)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(0, 0, 52, 139)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 4 then local idx = math.floor((math.random() * 1400 / 100)) + 1 @@ -151,7 +151,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(x, y, 85, 121)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 6 then local y, x @@ -160,7 +160,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 5) x = x * 85 y = y * 121 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(x, y, 85, 121)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 85, 121)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 7 then local y, x @@ -177,7 +177,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(x, y, 32, 32)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) elseif subtestNumber == 9 then local y, x @@ -186,7 +186,7 @@ local function createSpriteWithTag(tag) x = math.mod(r, 8) x = x * 32 y = y * 32 - sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRectMake(x, y, 32, 32)) + sprite = CCSprite:createWithTexture(batchNode:getTexture(), CCRect(x, y, 32, 32)) batchNode:addChild(sprite, 0, tag + 100) end @@ -215,7 +215,7 @@ local maxCases = 7 local function showThisTest() local scene = CreateSpriteTestScene() - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function backCallback(sender) @@ -240,7 +240,7 @@ local function nextCallback(sender) end local function toPerformanceMainLayer(sender) - CCDirector:sharedDirector():replaceScene(PerformanceTest()) + CCDirector:getInstance():replaceScene(PerformanceTest()) end local function initWithLayer(layer, controlMenuVisible) @@ -251,7 +251,7 @@ local function initWithLayer(layer, controlMenuVisible) mainItem:setPosition(s.width - 50, 25) local menu = CCMenu:create() menu:addChild(mainItem) - menu:setPosition(CCPointMake(0, 0)) + menu:setPosition(CCPoint(0, 0)) if controlMenuVisible == true then local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) @@ -384,7 +384,7 @@ local function initWithMainTest(scene, asubtest, nNodes) end subMenu:alignItemsHorizontally() - subMenu:setPosition(CCPointMake(s.width / 2, 80)) + subMenu:setPosition(CCPoint(s.width / 2, 80)) scene:addChild(subMenu, 1) -- add title label diff --git a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua index 7de350d954..f0527c93ad 100644 --- a/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/PerformanceTest/PerformanceTest.lua @@ -13,7 +13,7 @@ local testsName = "PerformanceTouchesTest" } -local s = CCDirector:sharedDirector():getWinSize() +local s = CCDirector:getInstance():getWinSize() --Create toMainLayr MenuItem function CreatePerfomBasicLayerMenu(pMenu) @@ -23,14 +23,14 @@ function CreatePerfomBasicLayerMenu(pMenu) local function toMainLayer() local pScene = PerformanceTestMain() if pScene ~= nil then - CCDirector:sharedDirector():replaceScene(pScene) + CCDirector:getInstance():replaceScene(pScene) end end --Create BackMneu CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24) local pMenuItemFont = CCMenuItemFont:create("Back") - pMenuItemFont:setPosition(ccp(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) + pMenuItemFont:setPosition(CCPoint(VisibleRect:rightBottom().x - 50, VisibleRect:rightBottom().y + 25)) pMenuItemFont:registerScriptTapHandler(toMainLayer) pMenu:addChild(pMenuItemFont) end @@ -125,7 +125,7 @@ local function runNodeChildrenTest() ShowCurrentTest() end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) @@ -136,10 +136,10 @@ local function runNodeChildrenTest() pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:sharedDirector():getWinSize() - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = CCDirector:getInstance():getWinSize() + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -183,7 +183,7 @@ local function runNodeChildrenTest() local pSprites = CCArray:createWithCapacity(nTotalToAdd) local i = 0 for i = 0 , nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(0,0,32,32)) + local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) pSprites:addObject(pSprite) zs[i] = math.random(-1,1) * 50 end @@ -212,7 +212,7 @@ local function runNodeChildrenTest() -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0, nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(0,0,32,32)) + local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) pSprites:addObject(pSprite) end -- add them with random Z (very important!) @@ -240,7 +240,7 @@ local function runNodeChildrenTest() -- Don't include the sprite creation time as part of the profiling local i = 0 for i = 0,nTotalToAdd - 1 do - local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(0,0,32,32)) + local pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0,0,32,32)) pSprites:addObject(pSprite) end @@ -278,14 +278,14 @@ local function runNodeChildrenTest() end local function updateQuantityOfNodes() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() --increase nodes if( nCurrentQuantityOfNodes < nQuantityOfNodes ) then local i = 0 for i = 0,nQuantityOfNodes - nCurrentQuantityOfNodes - 1 do - local sprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(0, 0, 32, 32)) + local sprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 32, 32)) pBatchNode:addChild(sprite) - sprite:setPosition(ccp( math.random() * s.width, math.random() * s.height)) + sprite:setPosition(CCPoint( math.random() * s.width, math.random() * s.height)) if 0 ~= nCurCase then sprite:setVisible(false) end @@ -336,18 +336,18 @@ local function runNodeChildrenTest() end local function MainSceneInitWithQuantityOfNodes(nNodes) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() --Title local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) pNewscene:addChild(pLabel, 1) - pLabel:setPosition(ccp(s.width/2, s.height-32)) + pLabel:setPosition(CCPoint(s.width/2, s.height-32)) pLabel:setColor(Color3B(255,255,40)) if (nil ~= GetSubTitle()) and ("" ~= GetSubTitle()) then local pSubLabel = CCLabelTTF:create(GetSubTitle(), "Thonburi", 16) pNewscene:addChild(pSubLabel, 1) - pSubLabel:setPosition(ccp(s.width/2, s.height-80)) + pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) end nLastRenderedCount = 0 @@ -367,13 +367,13 @@ local function runNodeChildrenTest() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(ccp(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) pNewscene:addChild(pMenuAddOrSub,1) --InfoLayer local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(ccp(s.width/2, s.height/2-15)) + pInfoLabel:setPosition(CCPoint(s.width/2, s.height/2-15)) pNewscene:addChild(pInfoLabel, 1, NodeChildrenTestParam.kTagInfoLayer) --NodeChildrenMenuLayer @@ -381,7 +381,7 @@ local function runNodeChildrenTest() local pNodeChildrenMenuMenu = CCMenu:create() CreatePerfomBasicLayerMenu(pNodeChildrenMenuMenu) CreateBasicLayerMenuItem(pNodeChildrenMenuMenu,true,NodeChildrenTestParam.TEST_COUNT,nCurCase) - pNodeChildrenMenuMenu:setPosition(ccp(0, 0)) + pNodeChildrenMenuMenu:setPosition(CCPoint(0, 0)) pNodeChildrenMenuLayer:addChild(pNodeChildrenMenuMenu) pNewscene:addChild(pNodeChildrenMenuLayer) @@ -401,7 +401,7 @@ local function runNodeChildrenTest() MainSceneInitWithQuantityOfNodes(nQuantityOfNodes) -- pNewscene:registerScriptHandler(onNodeEvent) NodeChildrenScheduleUpdate() - CCDirector:sharedDirector():replaceScene(pNewscene) + CCDirector:getInstance():replaceScene(pNewscene) end end @@ -483,7 +483,7 @@ local function runParticleTest() ShowCurrentTest() end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) @@ -494,10 +494,10 @@ local function runParticleTest() pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:sharedDirector():getWinSize() - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = CCDirector:getInstance():getWinSize() + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -519,7 +519,7 @@ local function runParticleTest() end local function doTest() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local pParticleSystem = tolua.cast(pNewScene:getChildByTag(ParticleTestParam.kTagParticleSystem),"CCParticleSystem") if nil == pParticleSystem then return @@ -529,7 +529,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(ccp(0,-90)) + pParticleSystem:setGravity(CCPoint(0,-90)) --angle pParticleSystem:setAngle(90) @@ -544,8 +544,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(ccp(s.width/2, 100)) - pParticleSystem:setPosVar(ccp(s.width/2,0)) + pParticleSystem:setPosition(CCPoint(s.width/2, 100)) + pParticleSystem:setPosVar(CCPoint(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -577,7 +577,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(ccp(0,-90)) + pParticleSystem:setGravity(CCPoint(0,-90)) --angle pParticleSystem:setAngle(90) @@ -592,8 +592,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(ccp(s.width/2, 100)) - pParticleSystem:setPosVar(ccp(s.width/2,0)) + pParticleSystem:setPosition(CCPoint(s.width/2, 100)) + pParticleSystem:setPosVar(CCPoint(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -624,7 +624,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(ccp(0,-90)) + pParticleSystem:setGravity(CCPoint(0,-90)) --angle pParticleSystem:setAngle(90) @@ -639,8 +639,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(ccp(s.width/2, 100)) - pParticleSystem:setPosVar(ccp(s.width/2,0)) + pParticleSystem:setPosition(CCPoint(s.width/2, 100)) + pParticleSystem:setPosVar(CCPoint(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -671,7 +671,7 @@ local function runParticleTest() pParticleSystem:setDuration(-1) --gravity - pParticleSystem:setGravity(ccp(0,-90)) + pParticleSystem:setGravity(CCPoint(0,-90)) --angle pParticleSystem:setAngle(90) @@ -686,8 +686,8 @@ local function runParticleTest() pParticleSystem:setSpeedVar(50) -- emitter position - pParticleSystem:setPosition(ccp(s.width/2, 100)) - pParticleSystem:setPosVar(ccp(s.width/2,0)) + pParticleSystem:setPosition(CCPoint(s.width/2, 100)) + pParticleSystem:setPosVar(CCPoint(s.width/2,0)) -- life of particles pParticleSystem:setLife(2.0) @@ -733,8 +733,8 @@ local function runParticleTest() pNewScene:removeChildByTag(ParticleTestParam.kTagParticleSystem, true) --remove the "fire.png" from the TextureCache cache. - local pTexture = CCTextureCache:sharedTextureCache():addImage("Images/fire.png") - CCTextureCache:sharedTextureCache():removeTexture(pTexture) + local pTexture = CCTextureCache:getInstance():addImage("Images/fire.png") + CCTextureCache:getInstance():removeTexture(pTexture) local pParticleSystem = CCParticleSystemQuad:new() if 1 == nSubtestNumber then CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) @@ -755,7 +755,7 @@ local function runParticleTest() if nil ~= pParticleSystem then pParticleSystem:initWithTotalParticles(nQuantityParticles) - pParticleSystem:setTexture(CCTextureCache:sharedTextureCache():addImage("Images/fire.png")) + pParticleSystem:setTexture(CCTextureCache:getInstance():addImage("Images/fire.png")) end pNewScene:addChild(pParticleSystem, 0, ParticleTestParam.kTagParticleSystem) @@ -774,7 +774,7 @@ local function runParticleTest() local function ScheduleFuncion() local function OnEnterOrExit(tag) - local scheduler = CCDirector:sharedDirector():getScheduler() + local scheduler = CCDirector:getInstance():getScheduler() if tag == "enter" then ScheduleSelector = scheduler:scheduleScriptFunc(step,0,false) elseif tag == "exit" then @@ -806,7 +806,7 @@ local function runParticleTest() local function InitWithSubTest(nSubtest,nParticles) nSubtestNumber = nSubtest - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityParticles = nParticles @@ -824,25 +824,25 @@ local function runParticleTest() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(ccp(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(ccp(s.width/2, s.height - 90)) + pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, ParticleTestParam.kTagInfoLayer) --particles on stage local pLabelAtlas = CCLabelAtlas:create("0000", "fps_images.png", 12, 32, string.byte('.')) pNewScene:addChild(pLabelAtlas, 0, ParticleTestParam.kTagLabelAtlas) - pLabelAtlas:setPosition(ccp(s.width-66,50)) + pLabelAtlas:setPosition(CCPoint(s.width-66,50)) --ParticleTestMenuLayer local pParticleMenuLayer = CCLayer:create() local pParticleMenu = CCMenu:create() CreatePerfomBasicLayerMenu(pParticleMenu) CreateBasicLayerMenuItem(pParticleMenu,true,ParticleTestParam.TEST_COUNT,nCurCase) - pParticleMenu:setPosition(ccp(0, 0)) + pParticleMenu:setPosition(CCPoint(0, 0)) pParticleMenuLayer:addChild(pParticleMenu) pNewScene:addChild(pParticleMenuLayer) @@ -862,12 +862,12 @@ local function runParticleTest() end end pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(ccp(s.width/2, 80)) + pSubMenu:setPosition(CCPoint(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(ccp(s.width/2, s.height-32)) + pLabel:setPosition(CCPoint(s.width/2, s.height-32)) pLabel:setColor(Color3B(255,255,40)) UpdateQuantityLabel() @@ -877,11 +877,11 @@ local function runParticleTest() function ShowCurrentTest() if nil ~= pNewScene then - CCDirector:sharedDirector():getScheduler():unscheduleScriptEntry(ScheduleSelector) + CCDirector:getInstance():getScheduler():unscheduleScriptEntry(ScheduleSelector) end pNewScene = CCScene:create() InitWithSubTest(nSubtestNumber,nQuantityParticles) - CCDirector:sharedDirector():replaceScene(pNewScene) + CCDirector:getInstance():replaceScene(pNewScene) end @@ -971,7 +971,7 @@ local function runSpriteTest() ShowCurrentTest() end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) @@ -982,10 +982,10 @@ local function runSpriteTest() pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:sharedDirector():getWinSize() - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = CCDirector:getInstance():getWinSize() + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -1000,40 +1000,40 @@ local function runSpriteTest() end local function PerformancePosition(pSprite) - local size = CCDirector:sharedDirector():getWinSize() - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = CCDirector:getInstance():getWinSize() + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) end local function PerformanceScale(pSprite) - local size = CCDirector:sharedDirector():getWinSize() - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = CCDirector:getInstance():getWinSize() + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setScale(math.random() * 100 / 50) end local function PerformanceRotationScale(pSprite) - local size = CCDirector:sharedDirector():getWinSize() - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = CCDirector:getInstance():getWinSize() + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) pSprite:setRotation(math.random() * 360) pSprite:setScale(math.random() * 2) end local function PerformanceOut100(pSprite) - pSprite:setPosition(ccp( -1000, -1000)) + pSprite:setPosition(CCPoint( -1000, -1000)) end local function Performanceout20(pSprite) - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(ccp( -1000, -1000)) + pSprite:setPosition(CCPoint( -1000, -1000)) end end local function PerformanceActions(pSprite) - local size = CCDirector:sharedDirector():getWinSize() - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + local size = CCDirector:getInstance():getWinSize() + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) local fPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 local pRot = CCRotateBy:create(fPeriod, 360.0 * math.random() ) @@ -1054,12 +1054,12 @@ local function runSpriteTest() end local function PerformanceActions20(pSprite) - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() if math.random() < 0.2 then - pSprite:setPosition(ccp((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) + pSprite:setPosition(CCPoint((math.random(0,SpriteTestParam.kRandMax) % (size.width) ), (math.random(0,SpriteTestParam.kRandMax) % (size.height)))) else - pSprite:setPosition(ccp( -1000, -1000)) + pSprite:setPosition(CCPoint( -1000, -1000)) end local pPeriod = 0.5 + (math.random(0,SpriteTestParam.kRandMax) % 1000) / 500.0 @@ -1087,7 +1087,7 @@ local function runSpriteTest() pSprite = CCSprite:create("Images/grossinis_sister1.png") pNewScene:addChild(pSprite, 0, nTag+100) elseif 2 == nSubtestNumber or 3 == nSubtestNumber then - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(0, 0, 52, 139)) + pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(0, 0, 52, 139)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 4 == nSubtestNumber then local nIndex = math.floor((math.random() * 1400 / 100)) + 1 @@ -1104,7 +1104,7 @@ local function runSpriteTest() nX = nX * 85 nY = nY * 121 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(nX,nY,85,121)) + pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,85,121)) pBatchNode:addChild(pSprite, 0, nTag+100) elseif 7 == nSubtestNumber then local nX = 0 @@ -1127,7 +1127,7 @@ local function runSpriteTest() nX = nX * 32 nY = nY * 32 - pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRectMake(nX,nY,32,32)) + pSprite = CCSprite:createWithTexture(pBatchNode:getTexture(), CCRect(nX,nY,32,32)) pBatchNode:addChild(pSprite, 0, nTag+100) end CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) @@ -1215,7 +1215,7 @@ local function runSpriteTest() *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each ]]-- --purge textures - local pMgr = CCTextureCache:sharedTextureCache() + local pMgr = CCTextureCache:getInstance() --[mgr removeAllTextures] pMgr:removeTexture(pMgr:addImage("Images/grossinis_sister1.png")) pMgr:removeTexture(pMgr:addImage("Images/grossini_dance_atlas.png")) @@ -1259,7 +1259,7 @@ local function runSpriteTest() nSubtestNumber = nSubtest --about create subset InitWithSubTest(nSubtest) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() nLastRenderedCount = 0 nQuantityNodes = 0 @@ -1277,12 +1277,12 @@ local function runSpriteTest() pMenuAddOrSub:addChild(pDecrease) pMenuAddOrSub:addChild(pIncrease) pMenuAddOrSub:alignItemsHorizontally() - pMenuAddOrSub:setPosition(ccp(s.width/2, s.height/2+15)) + pMenuAddOrSub:setPosition(CCPoint(s.width/2, s.height/2+15)) pNewScene:addChild(pMenuAddOrSub,1) local pInfoLabel = CCLabelTTF:create("0 nodes", "Marker Felt", 30) pInfoLabel:setColor(Color3B(0,200,20)) - pInfoLabel:setPosition(ccp(s.width/2, s.height - 90)) + pInfoLabel:setPosition(CCPoint(s.width/2, s.height - 90)) pNewScene:addChild(pInfoLabel, 1, SpriteTestParam.kTagInfoLayer) --SpriteTestMenuLayer @@ -1290,7 +1290,7 @@ local function runSpriteTest() local pSpriteMenu = CCMenu:create() CreatePerfomBasicLayerMenu(pSpriteMenu) CreateBasicLayerMenuItem(pSpriteMenu,true,SpriteTestParam.TEST_COUNT,nCurCase) - pSpriteMenu:setPosition(ccp(0, 0)) + pSpriteMenu:setPosition(CCPoint(0, 0)) pSpriteMenuLayer:addChild(pSpriteMenu) pNewScene:addChild(pSpriteMenuLayer,1,SpriteTestParam.kTagMenuLayer) @@ -1315,12 +1315,12 @@ local function runSpriteTest() pSubMenu:alignItemsHorizontally() - pSubMenu:setPosition(ccp(s.width/2, 80)) + pSubMenu:setPosition(CCPoint(s.width/2, 80)) pNewScene:addChild(pSubMenu, 2) local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) pNewScene:addChild(pLabel, 1) - pLabel:setPosition(ccp(s.width/2, s.height-32)) + pLabel:setPosition(CCPoint(s.width/2, s.height-32)) pLabel:setColor(Color3B(255,255,40)) while nQuantityNodes < nNodes do onIncrease() @@ -1330,7 +1330,7 @@ local function runSpriteTest() function ShowCurrentTest() pNewScene = CCScene:create() InitWithSpriteTest(nSubtestNumber,nQuantityNodes) - CCDirector:sharedDirector():replaceScene(pNewScene) + CCDirector:getInstance():replaceScene(pNewScene) end InitWithSpriteTest(1,SpriteTestParam.kInitNodes) @@ -1359,12 +1359,12 @@ local function runTextureTest() local nTexCurCase = 0 local pNewscene = CCScene:create() local pLayer = CCLayer:create() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local function PerformTestsPNG(strFileName) local time local pTexture = nil - local pCache = CCTextureCache:sharedTextureCache() + local pCache = CCTextureCache:getInstance() print("RGBA 8888") CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) pTexture = pCache:addImage(strFileName) @@ -1439,18 +1439,18 @@ local function runTextureTest() --Title local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(ccp(s.width/2, s.height-32)) + pLabel:setPosition(CCPoint(s.width/2, s.height-32)) pLabel:setColor(Color3B(255,255,40)) --Subtitle local pSubLabel = CCLabelTTF:create(GetSubtitle(), "Thonburi", 16) pLayer:addChild(pSubLabel, 1) - pSubLabel:setPosition(ccp(s.width/2, s.height-80)) + pSubLabel:setPosition(CCPoint(s.width/2, s.height-80)) --menu local pMenu = CCMenu:create() CreatePerfomBasicLayerMenu(pMenu) - pMenu:setPosition(ccp(0, 0)) + pMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pMenu) PerformTests() @@ -1481,7 +1481,7 @@ local function runTouchesTest() local nNumberOfTouchesC = 0 local fElapsedTime = 0.0 - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local pNewscene = CCScene:create() local pLayer = CCLayer:create() @@ -1518,7 +1518,7 @@ local function runTouchesTest() ShowCurrentTest() end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local item1 = CCMenuItemImage:create(s_pPathB1, s_pPathB2) item1:registerScriptTapHandler(backCallback) pMenu:addChild(item1,kItemTagBasic) @@ -1529,10 +1529,10 @@ local function runTouchesTest() pMenu:addChild(item3,kItemTagBasic) item3:registerScriptTapHandler(nextCallback) - local size = CCDirector:sharedDirector():getWinSize() - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + local size = CCDirector:getInstance():getWinSize() + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) end end end @@ -1609,19 +1609,19 @@ local function runTouchesTest() local pTouchesTestMenu = CCMenu:create() CreatePerfomBasicLayerMenu(pTouchesTestMenu) CreateBasicLayerMenuItem(pTouchesTestMenu,true,TouchesTestParam.TEST_COUNT,nCurCase) - pTouchesTestMenu:setPosition(ccp(0, 0)) + pTouchesTestMenu:setPosition(CCPoint(0, 0)) pLayer:addChild(pTouchesTestMenu) --Title local pLabel = CCLabelTTF:create(GetTitle(), "Arial", 40) pLayer:addChild(pLabel, 1) - pLabel:setPosition(ccp(s.width/2, s.height-32)) + pLabel:setPosition(CCPoint(s.width/2, s.height-32)) pLabel:setColor(Color3B(255,255,40)) pLayer:scheduleUpdateWithPriorityLua(update,0) pClassLabel = CCLabelBMFont:create("00.0", "fonts/arial16.fnt") - pClassLabel:setPosition(ccp(s.width/2, s.height/2)) + pClassLabel:setPosition(CCPoint(s.width/2, s.height/2)) pLayer:addChild(pClassLabel) fElapsedTime = 0.0 @@ -1645,7 +1645,7 @@ local function runTouchesTest() pLayer = CCLayer:create() InitLayer() pNewscene:addChild(pLayer) - CCDirector:sharedDirector():replaceScene(pNewscene) + CCDirector:getInstance():replaceScene(pNewscene) end end @@ -1676,7 +1676,7 @@ local function menuCallback(tag, pMenuItem) local nIdx = pMenuItem:getZOrder() - kItemTagBasic local PerformanceTestScene = CreatePerformancesTestScene(nIdx) if nil ~= PerformanceTestScene then - CCDirector:sharedDirector():replaceScene(PerformanceTestScene) + CCDirector:getInstance():replaceScene(PerformanceTestScene) end end @@ -1684,7 +1684,7 @@ local function PerformanceMainLayer() local layer = CCLayer:create() local menu = CCMenu:create() - menu:setPosition(CCPointMake(0, 0)) + menu:setPosition(CCPoint(0, 0)) CCMenuItemFont:setFontName("Arial") CCMenuItemFont:setFontSize(24) for i = 1, MAX_COUNT do diff --git a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua index 7afecc97b3..aa8686027f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RenderTextureTest/RenderTextureTest.lua @@ -7,7 +7,7 @@ local function RenderTextureSave() local ret = createTestLayer("Touch the screen", "Press 'Save Image' to create an snapshot of the render texture") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local m_pTarget = nil local m_pBrush = nil local m_pTarget = nil @@ -25,7 +25,7 @@ local function RenderTextureSave() local pImage = m_pTarget:newCCImage() - local tex = CCTextureCache:sharedTextureCache():addUIImage(pImage, png) + local tex = CCTextureCache:getInstance():addUIImage(pImage, png) pImage:release() @@ -33,7 +33,7 @@ local function RenderTextureSave() sprite:setScale(0.3) ret:addChild(sprite) - sprite:setPosition(ccp(40, 40)) + sprite:setPosition(CCPoint(40, 40)) sprite:setRotation(counter * 3) cclog("Image saved %s and %s", png, jpg) @@ -44,7 +44,7 @@ local function RenderTextureSave() if event == "exit" then m_pBrush:release() m_pTarget:release() - CCTextureCache:sharedTextureCache():removeUnusedTextures() + CCTextureCache:getInstance():removeUnusedTextures() end end @@ -53,7 +53,7 @@ local function RenderTextureSave() -- create a render texture, this is what we are going to draw into m_pTarget = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) m_pTarget:retain() - m_pTarget:setPosition(ccp(s.width / 2, s.height / 2)) + m_pTarget:setPosition(CCPoint(s.width / 2, s.height / 2)) -- note that the render texture is a CCNode, and contains a sprite of its texture for convience, -- so we can just parent it to the scene like any other CCNode @@ -76,15 +76,15 @@ local function RenderTextureSave() local diffX = x - prev.x local diffY = y - prev.y - local startP = ccp(x, y) - local endP = ccp(prev.x, prev.y) + local startP = CCPoint(x, y) + local endP = CCPoint(prev.x, prev.y) -- begin drawing to the render texture m_pTarget:begin() -- for extra points, we'll draw this smoothly from the last position and vary the sprite's -- scale/rotation/offset - local distance = ccpDistance(startP, endP) + local distance = startP:getDistance(endP) if distance > 1 then local d = distance local i = 0 @@ -92,7 +92,7 @@ local function RenderTextureSave() local difx = endP.x - startP.x local dify = endP.y - startP.y local delta = i / distance - m_pBrush:setPosition(ccp(startP.x + (difx * delta), startP.y + (dify * delta))) + m_pBrush:setPosition(CCPoint(startP.x + (difx * delta), startP.y + (dify * delta))) m_pBrush:setRotation(math.random(0, 359)) local r = math.random(0, 49) / 50.0 + 0.25 m_pBrush:setScale(r) @@ -126,7 +126,7 @@ local function RenderTextureSave() local menu = CCMenu:createWithArray(arr) ret:addChild(menu) menu:alignItemsVertically() - menu:setPosition(ccp(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) + menu:setPosition(CCPoint(VisibleRect:rightTop().x - 80, VisibleRect:rightTop().y - 30)) return ret end @@ -154,10 +154,10 @@ end -- addChild(background) -- local spr_premulti = CCSprite:create("Images/fire.png") --- spr_premulti:setPosition(ccp(16,48)) +-- spr_premulti:setPosition(CCPoint(16,48)) -- local spr_nonpremulti = CCSprite:create("Images/fire.png") --- spr_nonpremulti:setPosition(ccp(16,16)) +-- spr_nonpremulti:setPosition(CCPoint(16,16)) @@ -178,14 +178,14 @@ end -- spr_nonpremulti:visit() -- rend:end() --- local s = CCDirector:sharedDirector():getWinSize() +-- local s = CCDirector:getInstance():getWinSize() -- --/* A1: setup */ --- spr_premulti:setPosition(ccp(s.width/2-16, s.height/2+16)) +-- spr_premulti:setPosition(CCPoint(s.width/2-16, s.height/2+16)) -- --/* B1: setup */ --- spr_nonpremulti:setPosition(ccp(s.width/2-16, s.height/2-16)) +-- spr_nonpremulti:setPosition(CCPoint(s.width/2-16, s.height/2-16)) --- rend:setPosition(ccp(s.width/2+16, s.height/2)) +-- rend:setPosition(CCPoint(s.width/2+16, s.height/2)) -- addChild(spr_nonpremulti) -- addChild(spr_premulti) @@ -207,7 +207,7 @@ end -- local pLayer = nextTestCase() -- addChild(pLayer) --- CCDirector:sharedDirector():replaceScene(this) +-- CCDirector:getInstance():replaceScene(this) -- end -- --/** @@ -217,24 +217,24 @@ end -- local function RenderTextureZbuffer() -- this:setTouchEnabled(true) --- local size = CCDirector:sharedDirector():getWinSize() +-- local size = CCDirector:getInstance():getWinSize() -- local label = CCLabelTTF:create("vertexZ = 50", "Marker Felt", 64) --- label:setPosition(ccp(size.width / 2, size.height * 0.25)) +-- label:setPosition(CCPoint(size.width / 2, size.height * 0.25)) -- this:addChild(label) -- local label2 = CCLabelTTF:create("vertexZ = 0", "Marker Felt", 64) --- label2:setPosition(ccp(size.width / 2, size.height * 0.5)) +-- label2:setPosition(CCPoint(size.width / 2, size.height * 0.5)) -- this:addChild(label2) -- local label3 = CCLabelTTF:create("vertexZ = -50", "Marker Felt", 64) --- label3:setPosition(ccp(size.width / 2, size.height * 0.75)) +-- label3:setPosition(CCPoint(size.width / 2, size.height * 0.75)) -- this:addChild(label3) -- label:setVertexZ(50) -- label2:setVertexZ(0) -- label3:setVertexZ(-50) --- CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("Images/bugs/circle.plist") +-- CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("Images/bugs/circle.plist") -- mgr = CCSpriteBatchNode:create("Images/bugs/circle.png", 9) -- this:addChild(mgr) -- sp1 = CCSprite:createWithSpriteFrameName("circle.png") @@ -335,7 +335,7 @@ end -- return -- end --- texture:setAnchorPoint(ccp(0, 0)) +-- texture:setAnchorPoint(CCPoint(0, 0)) -- texture:begin() -- this:visit() @@ -344,7 +344,7 @@ end -- local sprite = CCSprite:createWithTexture(texture:getSprite():getTexture()) --- sprite:setPosition(ccp(256, 256)) +-- sprite:setPosition(CCPoint(256, 256)) -- sprite:setOpacity(182) -- sprite:setFlipY(1) -- this:addChild(sprite, 999999) @@ -359,10 +359,10 @@ end -- local function RenderTextureTestDepthStencil() --- local s = CCDirector:sharedDirector():getWinSize() +-- local s = CCDirector:getInstance():getWinSize() -- local sprite = CCSprite:create("Images/fire.png") --- sprite:setPosition(ccp(s.width * 0.25, 0)) +-- sprite:setPosition(CCPoint(s.width * 0.25, 0)) -- sprite:setScale(10) -- local rend = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, GL_DEPTH24_STENCIL8) @@ -377,7 +377,7 @@ end -- sprite:visit() -- --! move sprite half width and height, and draw only where not marked --- sprite:setPosition(ccpAdd(sprite:getPosition(), ccpMult(ccp(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) +-- sprite:setPosition(CCPoint.__add(sprite:getPosition(), CCPoint.__mul(CCPoint(sprite:getContentSize().width * sprite:getScale(), sprite:getContentSize().height * sprite:getScale()), 0.5))) -- glStencilFunc(GL_NOTEQUAL, 1, 0xFF) -- glColorMask(1, 1, 1, 1) -- sprite:visit() @@ -386,7 +386,7 @@ end -- glDisable(GL_STENCIL_TEST) --- rend:setPosition(ccp(s.width * 0.5, s.height * 0.5)) +-- rend:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) -- this:addChild(rend) -- end @@ -425,14 +425,14 @@ end -- -- sprite 2 -- sprite2 = CCSprite:create("Images/fire_rgba8888.pvr") --- local s = CCDirector:sharedDirector():getWinSize() +-- local s = CCDirector:getInstance():getWinSize() -- /* Create the render texture */ -- local renderTexture = CCRenderTexture:create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444) -- this:renderTexture = renderTexture --- renderTexture:setPosition(ccp(s.width/2, s.height/2)) --- -- [renderTexture setPosition:ccp(s.width, s.height)] +-- renderTexture:setPosition(CCPoint(s.width/2, s.height/2)) +-- -- [renderTexture setPosition:CCPoint(s.width, s.height)] -- -- renderTexture.scale = 2 -- /* add the sprites to the render texture */ @@ -453,7 +453,7 @@ end -- local menu = CCMenu:create(item, NULL) -- addChild(menu) --- menu:setPosition(ccp(s.width/2, s.height/2)) +-- menu:setPosition(CCPoint(s.width/2, s.height/2)) -- end -- local function touched(CCObject* sender) @@ -473,8 +473,8 @@ end -- static float time = 0 -- float r = 80 --- sprite1:setPosition(ccp(cosf(time * 2) * r, sinf(time * 2) * r)) --- sprite2:setPosition(ccp(sinf(time * 2) * r, cosf(time * 2) * r)) +-- sprite1:setPosition(CCPoint(cosf(time * 2) * r, sinf(time * 2) * r)) +-- sprite2:setPosition(CCPoint(sinf(time * 2) * r, cosf(time * 2) * r)) -- time += dt -- end @@ -512,7 +512,7 @@ end -- if (rt == NULL) --- local s = CCDirector:sharedDirector():getWinSize() +-- local s = CCDirector:getInstance():getWinSize() -- rt = new CCRenderTexture() -- rt:initWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888) -- end @@ -554,8 +554,8 @@ end -- setTouchEnabled(true) --- local s = CCDirector:sharedDirector():getWinSize() --- addNewSpriteWithCoords(ccp(s.width/2, s.height/2)) +-- local s = CCDirector:getInstance():getWinSize() +-- addNewSpriteWithCoords(CCPoint(s.width/2, s.height/2)) -- end -- local function SimpleSprite* SpriteRenderTextureBug:addNewSpriteWithCoords(const CCPoint& p) @@ -565,7 +565,7 @@ end -- int y = (idx/5) * 121 -- SpriteRenderTextureBug:SimpleSprite *sprite = SpriteRenderTextureBug:SimpleSprite:create("Images/grossini_dance_atlas.png", --- CCRectMake(x,y,85,121)) +-- CCRect(x,y,85,121)) -- addChild(sprite) -- sprite:setPosition(p) diff --git a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua index 7a25265412..1c43ed7d0c 100644 --- a/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/RotateWorldTest/RotateWorldTest.lua @@ -1,5 +1,5 @@ -local size = CCDirector:sharedDirector():getWinSize() +local size = CCDirector:getInstance():getWinSize() local function CreateSpriteLayer() local layer = CCLayer:create() @@ -16,9 +16,9 @@ local function CreateSpriteLayer() spriteSister1:setScale(1.5) spriteSister2:setScale(1.5) - sprite:setPosition(CCPointMake(x / 2, y / 2)) - spriteSister1:setPosition(CCPointMake(40, y / 2)) - spriteSister2:setPosition(CCPointMake(x - 40, y / 2)) + sprite:setPosition(CCPoint(x / 2, y / 2)) + spriteSister1:setPosition(CCPoint(40, y / 2)) + spriteSister2:setPosition(CCPoint(x - 40, y / 2)) layer:addChild(sprite) layer:addChild(spriteSister1) @@ -27,13 +27,13 @@ local function CreateSpriteLayer() local rot = CCRotateBy:create(16, -3600) sprite:runAction(rot) - local jump1 = CCJumpBy:create(4, CCPointMake(-400, 0), 100, 4) + local jump1 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) local jump2 = jump1:reverse() local rot1 = CCRotateBy:create(4, 360 * 2) local rot2 = rot1:reverse() - local jump3 = CCJumpBy:create(4, CCPointMake(-400, 0), 100, 4) + local jump3 = CCJumpBy:create(4, CCPoint(-400, 0), 100, 4) local jump4 = jump3:reverse() local rot3 = CCRotateBy:create(4, 360 * 2) local rot4 = rot3:reverse() @@ -74,20 +74,20 @@ local function CreateRotateWorldLayer() local white = CCLayerColor:create(Color4B(255,255,255,255)) blue:setScale(0.5) - blue:setPosition(CCPointMake(- x / 4, - y / 4)) + blue:setPosition(CCPoint(- x / 4, - y / 4)) blue:addChild(CreateSpriteLayer()) red:setScale(0.5) - red:setPosition(CCPointMake(x / 4, - y / 4)) + red:setPosition(CCPoint(x / 4, - y / 4)) green:setScale(0.5) - green:setPosition(CCPointMake(- x / 4, y / 4)) + green:setPosition(CCPoint(- x / 4, y / 4)) green:addChild(CreateTestLayer()) white:setScale(0.5) - white:setPosition(CCPointMake(x / 4, y / 4)) + white:setPosition(CCPoint(x / 4, y / 4)) white:ignoreAnchorPointForPosition(false) - white:setPosition(CCPointMake(x / 4 * 3, y / 4 * 3)) + white:setPosition(CCPoint(x / 4 * 3, y / 4 * 3)) layer:addChild(blue, -1) layer:addChild(white) diff --git a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua index 3258da52c4..0212a1a90f 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SceneTest/SceneTest.lua @@ -23,7 +23,7 @@ SceneTestLayer1 = function() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene( scene ) + CCDirector:getInstance():pushScene( scene ) end local function onPushSceneTran(tag, pSender) @@ -31,7 +31,7 @@ SceneTestLayer1 = function() local layer = SceneTestLayer2() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():pushScene( CCTransitionSlideInT:create(1, scene) ) + CCDirector:getInstance():pushScene( CCTransitionSlideInT:create(1, scene) ) end @@ -55,10 +55,10 @@ SceneTestLayer1 = function() ret:addChild( menu ) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local sprite = CCSprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( ccp(s.width-40, s.height/2) ) + sprite:setPosition( CCPoint(s.width-40, s.height/2) ) local rotate = CCRotateBy:create(2, 360) local repeatAction = CCRepeatForever:create(rotate) sprite:runAction(repeatAction) @@ -86,7 +86,7 @@ SceneTestLayer2 = function() local m_timeCounter = 0 local function onGoBack(tag, pSender) - CCDirector:sharedDirector():popScene() + CCDirector:getInstance():popScene() end local function onReplaceScene(tag, pSender) @@ -94,7 +94,7 @@ SceneTestLayer2 = function() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene( scene ) + CCDirector:getInstance():replaceScene( scene ) end @@ -103,7 +103,7 @@ SceneTestLayer2 = function() local layer = SceneTestLayer3() scene:addChild(layer, 0) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene( CCTransitionFlipX:create(2, scene) ) + CCDirector:getInstance():replaceScene( CCTransitionFlipX:create(2, scene) ) end local item1 = CCMenuItemFont:create( "replaceScene") @@ -121,10 +121,10 @@ SceneTestLayer2 = function() ret:addChild( menu ) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local sprite = CCSprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( ccp(s.width-40, s.height/2) ) + sprite:setPosition( CCPoint(s.width-40, s.height/2) ) local rotate = CCRotateBy:create(2, 360) local repeat_action = CCRepeatForever:create(rotate) sprite:runAction(repeat_action) @@ -140,20 +140,20 @@ end SceneTestLayer3 = function() local ret = CCLayerColor:create(Color4B(0,0,255,255)) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local function item0Clicked(tag, pSender) local newScene = CCScene:create() newScene:addChild(SceneTestLayer3()) - CCDirector:sharedDirector():pushScene(CCTransitionFade:create(0.5, newScene, Color3B(0,255,255))) + CCDirector:getInstance():pushScene(CCTransitionFade:create(0.5, newScene, Color3B(0,255,255))) end local function item1Clicked(tag, pSender) - CCDirector:sharedDirector():popScene() + CCDirector:getInstance():popScene() end local function item2Clicked(tag, pSender) - CCDirector:sharedDirector():popToRootScene() + CCDirector:getInstance():popToRootScene() end local item0 = CCMenuItemFont:create("Touch to pushScene (self)") @@ -174,7 +174,7 @@ SceneTestLayer3 = function() local sprite = CCSprite:create(s_pPathGrossini) ret:addChild(sprite) - sprite:setPosition( ccp(s.width/2, 40) ) + sprite:setPosition( CCPoint(s.width/2, 40) ) local rotate = CCRotateBy:create(2, 360) local repeatAction = CCRepeatForever:create(rotate) sprite:runAction(repeatAction) diff --git a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua index b749890d11..7ec8dd09a9 100644 --- a/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/SpriteTest/SpriteTest.lua @@ -1,4 +1,4 @@ -local size = CCDirector:sharedDirector():getWinSize() +local size = CCDirector:getInstance():getWinSize() local kTagTileMap = 1 local kTagSpriteBatchNode = 1 local kTagNode = 2 @@ -29,10 +29,10 @@ function Sprite1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(x,y,85,121) ) + local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( ccp(point.x, point.y) ) + sprite:setPosition( CCPoint(point.x, point.y) ) local action = nil local random = math.random() @@ -59,7 +59,7 @@ function Sprite1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - Sprite1.addNewSpriteWithCoords(Helper.currentLayer, ccp(x,y)) + Sprite1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) return true end end @@ -68,7 +68,7 @@ function Sprite1.create() cclog("sprite1") local layer = CCLayer:create() Helper.initWithLayer(layer) - Sprite1.addNewSpriteWithCoords(layer, ccp(size.width/2, size.height/2)) + Sprite1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(Sprite1.onTouch) @@ -89,10 +89,10 @@ function SpriteBatchNode1.addNewSpriteWithCoords(layer, point) local x = math.floor(math.mod(idx,5) * 85) local y = math.floor(idx / 5 * 121) - local sprite = CCSprite:createWithTexture(BatchNode:getTexture(), CCRectMake(x,y,85,121) ) + local sprite = CCSprite:createWithTexture(BatchNode:getTexture(), CCRect(x,y,85,121) ) layer:addChild( sprite ) - sprite:setPosition( ccp(point.x, point.y) ) + sprite:setPosition( CCPoint(point.x, point.y) ) local action = nil local random = math.random() @@ -119,7 +119,7 @@ function SpriteBatchNode1.onTouch(event, x, y) if event == "began" then return true elseif event == "ended" then - SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, ccp(x,y)) + SpriteBatchNode1.addNewSpriteWithCoords(Helper.currentLayer, CCPoint(x,y)) return true end end @@ -130,7 +130,7 @@ function SpriteBatchNode1.create() local BatchNode = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 50) layer:addChild(BatchNode, 0, kTagSpriteBatchNode) - SpriteBatchNode1.addNewSpriteWithCoords(layer, ccp(size.width/2, size.height/2)) + SpriteBatchNode1.addNewSpriteWithCoords(layer, CCPoint(size.width/2, size.height/2)) layer:setTouchEnabled(true) layer:registerScriptTouchHandler(SpriteBatchNode1.onTouch) @@ -148,25 +148,25 @@ SpriteColorOpacity.__index = SpriteColorOpacity SpriteColorOpacity.entry = nil function SpriteColorOpacity.setLayerSprite(layer) - local sprite1 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*0, 121*1, 85, 121)) - local sprite2 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*1, 121*1, 85, 121)) - local sprite3 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*2, 121*1, 85, 121)) - local sprite4 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*3, 121*1, 85, 121)) + local sprite1 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) + local sprite2 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) + local sprite3 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) + local sprite4 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) - local sprite5 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*0, 121*1, 85, 121)) - local sprite6 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*1, 121*1, 85, 121)) - local sprite7 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*2, 121*1, 85, 121)) - local sprite8 = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*3, 121*1, 85, 121)) + local sprite5 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*0, 121*1, 85, 121)) + local sprite6 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*1, 121*1, 85, 121)) + local sprite7 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*2, 121*1, 85, 121)) + local sprite8 = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*3, 121*1, 85, 121)) - local s = CCDirector:sharedDirector():getWinSize() - sprite1:setPosition( ccp( (s.width/5)*1, (s.height/3)*1) ) - sprite2:setPosition( ccp( (s.width/5)*2, (s.height/3)*1) ) - sprite3:setPosition( ccp( (s.width/5)*3, (s.height/3)*1) ) - sprite4:setPosition( ccp( (s.width/5)*4, (s.height/3)*1) ) - sprite5:setPosition( ccp( (s.width/5)*1, (s.height/3)*2) ) - sprite6:setPosition( ccp( (s.width/5)*2, (s.height/3)*2) ) - sprite7:setPosition( ccp( (s.width/5)*3, (s.height/3)*2) ) - sprite8:setPosition( ccp( (s.width/5)*4, (s.height/3)*2) ) + local s = CCDirector:getInstance():getWinSize() + sprite1:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*1) ) + sprite2:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*1) ) + sprite3:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*1) ) + sprite4:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*1) ) + sprite5:setPosition( CCPoint( (s.width/5)*1, (s.height/3)*2) ) + sprite6:setPosition( CCPoint( (s.width/5)*2, (s.height/3)*2) ) + sprite7:setPosition( CCPoint( (s.width/5)*3, (s.height/3)*2) ) + sprite8:setPosition( CCPoint( (s.width/5)*4, (s.height/3)*2) ) local action = CCFadeIn:create(2) local action_back = action:reverse() @@ -240,15 +240,15 @@ SpriteFrameTest.m_pSprite2 = nil SpriteFrameTest.m_nCounter = 0 function SpriteFrameTest.onEnter() - local s = CCDirector:sharedDirector():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local s = CCDirector:getInstance():getWinSize() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") cache:addSpriteFramesWithFile("animations/grossini_blue.plist", "animations/grossini_blue.png") SpriteFrameTest.m_pSprite1 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite1:setPosition( ccp( s.width/2-80, s.height/2) ) + SpriteFrameTest.m_pSprite1:setPosition( CCPoint( s.width/2-80, s.height/2) ) local spritebatch = CCSpriteBatchNode:create("animations/grossini.png") spritebatch:addChild(SpriteFrameTest.m_pSprite1) @@ -256,7 +256,7 @@ function SpriteFrameTest.onEnter() local animFrames = CCArray:createWithCapacity(15) for i = 1,14 do - local frame = cache:spriteFrameByName( string.format("grossini_dance_%02d.png", i) ) + local frame = cache:getSpriteFrameByName( string.format("grossini_dance_%02d.png", i) ) animFrames:addObject(frame) end @@ -267,17 +267,17 @@ function SpriteFrameTest.onEnter() SpriteFrameTest.m_pSprite1:setFlipY(false) SpriteFrameTest.m_pSprite2 = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - SpriteFrameTest.m_pSprite2:setPosition( ccp( s.width/2 + 80, s.height/2) ) + SpriteFrameTest.m_pSprite2:setPosition( CCPoint( s.width/2 + 80, s.height/2) ) Helper.currentLayer:addChild(SpriteFrameTest.m_pSprite2) local moreFrames = CCArray:createWithCapacity(20) for i = 1,14 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_gray_%02d.png",i)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_gray_%02d.png",i)) moreFrames:addObject(frame) end for i = 1,4 do - local frame = cache:spriteFrameByName(string.format("grossini_blue_%02d.png",i)) + local frame = cache:getSpriteFrameByName(string.format("grossini_blue_%02d.png",i)) moreFrames:addObject(frame) end @@ -295,7 +295,7 @@ function SpriteFrameTest.onEnter() end function SpriteFrameTest.onExit() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") cache:removeSpriteFramesFromFile("animations/grossini_blue.plist") @@ -360,13 +360,13 @@ local SpriteFrameAliasNameTest = {} SpriteFrameAliasNameTest.__index = SpriteFrameAliasNameTest function SpriteFrameAliasNameTest.onEnter() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini-aliases.plist", "animations/grossini-aliases.png") local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width * 0.5, s.height * 0.5)) + sprite:setPosition(CCPoint(s.width * 0.5, s.height * 0.5)) local spriteBatch = CCSpriteBatchNode:create("animations/grossini-aliases.png") cclog("spriteBatch = " .. tostring(tolua.isnull(spriteBatch))) @@ -376,7 +376,7 @@ function SpriteFrameAliasNameTest.onEnter() local animFrames = CCArray:createWithCapacity(15) for i = 1,14 do - local frame = cache:spriteFrameByName(string.format("dance_%02d", i)) + local frame = cache:getSpriteFrameByName(string.format("dance_%02d", i)) animFrames:addObject(frame) end @@ -386,7 +386,7 @@ function SpriteFrameAliasNameTest.onEnter() end function SpriteFrameAliasNameTest.onExit() - CCSpriteFrameCache:sharedSpriteFrameCache():removeSpriteFramesFromFile("animations/grossini-aliases.plist") + CCSpriteFrameCache:getInstance():removeSpriteFramesFromFile("animations/grossini-aliases.plist") end function SpriteFrameAliasNameTest.onEnterOrExit(tag) @@ -417,14 +417,14 @@ local SpriteAnchorPoint = {} SpriteAnchorPoint.__index = SpriteAnchorPoint function SpriteAnchorPoint.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local rotate = CCRotateBy:create(10, 360) local action = CCRepeatForever:create(rotate) for i = 0, 2 do - local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRectMake(85*i, 121*1, 85, 121) ) - sprite:setPosition( ccp( s.width/4*(i+1), s.height/2) ) + local sprite = CCSprite:create("Images/grossini_dance_atlas.png", CCRect(85*i, 121*1, 85, 121) ) + sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) local point = CCSprite:create("Images/r1.png") point:setScale( 0.25 ) @@ -432,11 +432,11 @@ function SpriteAnchorPoint.initLayer(layer) layer:addChild(point, 10) if i == 0 then - sprite:setAnchorPoint( ccp(0, 0) ) + sprite:setAnchorPoint( CCPoint(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( ccp(0.5, 0.5) ) + sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( ccp(1,1) ) + sprite:setAnchorPoint( CCPoint(1,1) ) end point:setPosition( sprite:getPosition() ) @@ -470,28 +470,28 @@ function SpriteBatchNodeAnchorPoint.initLayer(layer) local batch = CCSpriteBatchNode:create("Images/grossini_dance_atlas.png", 1) layer:addChild(batch, 0, kTagSpriteBatchNode) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local rotate = CCRotateBy:create(10, 360) local action = CCRepeatForever:create(rotate) for i=0,2 do - local sprite = CCSprite:createWithTexture(batch:getTexture(), CCRectMake(85*i, 121*1, 85, 121)) - sprite:setPosition( ccp( s.width/4*(i+1), s.height/2) ) + local sprite = CCSprite:createWithTexture(batch:getTexture(), CCRect(85*i, 121*1, 85, 121)) + sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) local point = CCSprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( ccp(0,0) ) + sprite:setAnchorPoint( CCPoint(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( ccp(0.5, 0.5) ) + sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( ccp(1,1) ) + sprite:setAnchorPoint( CCPoint(1,1) ) end - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) local copy = tolua.cast(action:clone(), "CCAction") sprite:runAction(copy) @@ -521,8 +521,8 @@ local SpriteOffsetAnchorRotation = {} SpriteOffsetAnchorRotation.__index = SpriteOffsetAnchorRotation function SpriteOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local s = CCDirector:getInstance():getWinSize() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -531,7 +531,7 @@ function SpriteOffsetAnchorRotation.initLayer(layer) -- Animation using Sprite batch -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp( s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint( s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") point:setScale( 0.25 ) @@ -539,19 +539,19 @@ function SpriteOffsetAnchorRotation.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( ccp(0, 0) ) + sprite:setAnchorPoint( CCPoint(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( ccp(0.5, 0.5) ) + sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( ccp(1,1) ) + sprite:setAnchorPoint( CCPoint(1,1) ) end - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) local animFrames = CCArray:createWithCapacity(14) for i = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) animFrames:addObject(frame) end @@ -567,7 +567,7 @@ end function SpriteOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -595,9 +595,9 @@ SpriteBatchNodeOffsetAnchorRotation.__index = SpriteBatchNodeOffsetAnchorRotatio function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -611,26 +611,26 @@ function SpriteBatchNodeOffsetAnchorRotation.initLayer(layer) -- Animation using Sprite BatchNode -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( ccp( s.width/4*(i+1), s.height/2)) + sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") point:setScale( 0.25 ) - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint( ccp(0,0) ) + sprite:setAnchorPoint( CCPoint(0,0) ) elseif i == 1 then - sprite:setAnchorPoint( ccp(0.5, 0.5) ) + sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( ccp(1,1) ) + sprite:setAnchorPoint( CCPoint(1,1) ) end - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) local animFrames = CCArray:createWithCapacity(14) for k = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png",(k+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(k+1))) animFrames:addObject(frame) end @@ -645,7 +645,7 @@ end function SpriteBatchNodeOffsetAnchorRotation.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -672,9 +672,9 @@ local SpriteOffsetAnchorScale = {} SpriteOffsetAnchorScale.__index = SpriteOffsetAnchorScale function SpriteOffsetAnchorScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -683,7 +683,7 @@ function SpriteOffsetAnchorScale.initLayer(layer) -- Animation using Sprite BatchNode -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition( ccp( s.width/4*(i+1), s.height/2) ) + sprite:setPosition( CCPoint( s.width/4*(i+1), s.height/2) ) local point = CCSprite:create("Images/r1.png") point:setScale( 0.25 ) @@ -691,19 +691,19 @@ function SpriteOffsetAnchorScale.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint( ccp(0, 0) ) + sprite:setAnchorPoint( CCPoint(0, 0) ) elseif i == 1 then - sprite:setAnchorPoint( ccp(0.5, 0.5) ) + sprite:setAnchorPoint( CCPoint(0.5, 0.5) ) elseif i == 2 then - sprite:setAnchorPoint( ccp(1,1) ) + sprite:setAnchorPoint( CCPoint(1,1) ) end - point:setPosition( ccp(sprite:getPosition()) ) + point:setPosition( CCPoint(sprite:getPosition()) ) local animFrames = CCArray:createWithCapacity(14) for i = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png",(i+1))) animFrames:addObject(frame) end @@ -723,7 +723,7 @@ end function SpriteOffsetAnchorScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -749,9 +749,9 @@ end local SpriteBatchNodeOffsetAnchorScale = {} function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -761,7 +761,7 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) for i = 0,2 do -- Animation using Sprite BatchNode local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -769,11 +769,11 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(CCPointMake(0,0)) + sprite:setAnchorPoint(CCPoint(0,0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) @@ -782,7 +782,7 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) local str for k = 0, 13 do str = string.format("grossini_dance_%02d.png", (k+1)) - local frame = cache:spriteFrameByName(str) + local frame = cache:getSpriteFrameByName(str) animFrames:addObject(frame) end @@ -801,7 +801,7 @@ function SpriteBatchNodeOffsetAnchorScale.initLayer(layer) end function SpriteBatchNodeOffsetAnchorScale.onExit() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -834,9 +834,9 @@ SpriteOffsetAnchorSkew.__index = SpriteOffsetAnchorSkew function SpriteOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -845,7 +845,7 @@ function SpriteOffsetAnchorSkew.initLayer(layer) -- Animation using Sprite batch -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -853,18 +853,18 @@ function SpriteOffsetAnchorSkew.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) animFrames:addObject(frame) end @@ -892,7 +892,7 @@ end function SpriteOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -917,9 +917,9 @@ SpriteOffsetAnchorRotationalSkew.__index = SpriteOffsetAnchorRotationalSkew function SpriteOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -928,27 +928,27 @@ function SpriteOffsetAnchorRotationalSkew.initLayer(layer) -- Animation using Sprite batch -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(ccp(0,0)) + sprite:setAnchorPoint(CCPoint(0,0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(ccp(1,1)) + sprite:setAnchorPoint(CCPoint(1,1)) end - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) local animFrames = CCArray:create() for i = 0,13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", (i+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (i+1))) animFrames:addObject(frame) end local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) @@ -974,7 +974,7 @@ end function SpriteOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1001,9 +1001,9 @@ SpriteBatchNodeOffsetAnchorSkew.__index = SpriteBatchNodeOffsetAnchorSkew function SpriteBatchNodeOffsetAnchorSkew.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -1015,26 +1015,26 @@ function SpriteBatchNodeOffsetAnchorSkew.initLayer(layer) -- Animation using Sprite batch -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j + 1)) animFrames:addObject(frame) end @@ -1062,7 +1062,7 @@ end function SpriteBatchNodeOffsetAnchorSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1088,9 +1088,9 @@ SpriteBatchNodeOffsetAnchorRotationalSkew.__index = SpriteBatchNodeOffsetAnchorR function SpriteBatchNodeOffsetAnchorRotationalSkew.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -1102,27 +1102,27 @@ function SpriteBatchNodeOffsetAnchorRotationalSkew.initLayer(layer) -- Animation using Sprite batch -- local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(ccp(0,0)) + sprite:setAnchorPoint(CCPoint(0,0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) elseif i == 2 then - sprite:setAnchorPoint(ccp(1,1)) + sprite:setAnchorPoint(CCPoint(1,1)) end - point:setPosition(ccp(sprite:getPosition())) + point:setPosition(CCPoint(sprite:getPosition())) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) animFrames:addObject(frame) end @@ -1151,7 +1151,7 @@ end -- remove resources function SpriteBatchNodeOffsetAnchorRotationalSkew.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1175,16 +1175,16 @@ end local SpriteOffsetAnchorSkewScale = {} function SpriteOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -1192,18 +1192,18 @@ function SpriteOffsetAnchorSkewScale.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(ccp(0,0)) + sprite:setAnchorPoint(CCPoint(0,0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) animFrames:addObject(frame) end @@ -1238,7 +1238,7 @@ end function SpriteOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1261,16 +1261,16 @@ end local SpriteOffsetAnchorRotationalSkewScale = {} function SpriteOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") @@ -1279,18 +1279,18 @@ function SpriteOffsetAnchorRotationalSkewScale.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) animFrames:addObject(frame) end local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) @@ -1324,7 +1324,7 @@ end function SpriteOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1347,9 +1347,9 @@ end local SpriteBatchNodeOffsetAnchorSkewScale = {} function SpriteBatchNodeOffsetAnchorSkewScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -1360,7 +1360,7 @@ function SpriteBatchNodeOffsetAnchorSkewScale.initLayer(layer) -- Animation using Sprite batch local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -1368,18 +1368,18 @@ function SpriteBatchNodeOffsetAnchorSkewScale.initLayer(layer) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", (j+1))) animFrames:addObject(frame) end @@ -1413,7 +1413,7 @@ end function SpriteBatchNodeOffsetAnchorSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1435,9 +1435,9 @@ end -- local SpriteBatchNodeOffsetAnchorRotationalSkewScale = {} function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") @@ -1447,7 +1447,7 @@ function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) for i = 0, 2 do -- Animation using Sprite batch local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width/4*(i+1), s.height/2)) + sprite:setPosition(CCPoint(s.width/4*(i+1), s.height/2)) local point = CCSprite:create("Images/r1.png") @@ -1457,18 +1457,18 @@ function SpriteBatchNodeOffsetAnchorRotationalSkewScale.initLayer(layer) layer:addChild(point, 200) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) animFrames:addObject(frame) end local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.3) @@ -1500,7 +1500,7 @@ end function SpriteBatchNodeOffsetAnchorRotationalSkewScale.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end @@ -1522,16 +1522,16 @@ end -- local SpriteOffsetAnchorFlip = {} function SpriteOffsetAnchorFlip.initLayer(layer) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:addSpriteFramesWithFile("animations/grossini.plist") cache:addSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray.png") for i = 0, 2 do -- Animation using Sprite batch local sprite = CCSprite:createWithSpriteFrameName("grossini_dance_01.png") - sprite:setPosition(ccp(s.width / 4 * (i + 1), s.height / 2)) + sprite:setPosition(CCPoint(s.width / 4 * (i + 1), s.height / 2)) local point = CCSprite:create("Images/r1.png") point:setScale(0.25) @@ -1539,18 +1539,18 @@ function SpriteOffsetAnchorFlip.initLayer(layer) layer:addChild(point, 1) if i == 0 then - sprite:setAnchorPoint(ccp(0, 0)) + sprite:setAnchorPoint(CCPoint(0, 0)) elseif i == 1 then - sprite:setAnchorPoint(ccp(0.5, 0.5)) + sprite:setAnchorPoint(CCPoint(0.5, 0.5)) else - sprite:setAnchorPoint(ccp(1, 1)) + sprite:setAnchorPoint(CCPoint(1, 1)) end point:setPosition(sprite:getPosition()) local animFrames = CCArray:create() for j = 0, 13 do - local frame = cache:spriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) + local frame = cache:getSpriteFrameByName(string.format("grossini_dance_%02d.png", j+1)) animFrames:addObject(frame) end @@ -1576,7 +1576,7 @@ end function SpriteOffsetAnchorFlip.eventHandler(tag) if tag == "exit" then - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("animations/grossini.plist") cache:removeSpriteFramesFromFile("animations/grossini_gray.plist") end diff --git a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua index b3f2602527..4258077f62 100644 --- a/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/Texture2dTest/Texture2dTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:sharedDirector():getScheduler() +local scheduler = CCDirector:getInstance():getScheduler() local kTagLabel = 1 local kTagSprite1 = 2 local kTagSprite2 = 3 @@ -7,10 +7,10 @@ local originCreateLayer = createTestLayer local function createTestLayer(title, subtitle) local ret = originCreateLayer(title, subtitle) Helper.titleLabel:setTag(kTagLabel) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() local col = CCLayerColor:create(Color4B(128,128,128,255)) ret:addChild(col, -10) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end -------------------------------------------------------------------- @@ -21,12 +21,12 @@ end local function TextureTIFF() local ret = createTestLayer("TIFF Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image.tiff") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -38,12 +38,12 @@ end local function TexturePNG() local ret = createTestLayer("PNG Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image.png") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -54,12 +54,12 @@ end -------------------------------------------------------------------- local function TextureJPEG() local ret = createTestLayer("JPEG Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image.jpeg") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -70,12 +70,12 @@ end -------------------------------------------------------------------- local function TextureWEBP() local ret = createTestLayer("WEBP Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image.webp") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -87,9 +87,9 @@ end local function TextureMipMap() local ret = createTestLayer("Texture Mipmap", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local texture0 = CCTextureCache:sharedTextureCache():addImage( + local texture0 = CCTextureCache:getInstance():addImage( "Images/grossini_dance_atlas.png") texture0:generateMipmap() local texParams = ccTexParams() @@ -99,17 +99,17 @@ local function TextureMipMap() texParams.wrapT = GL_CLAMP_TO_EDGE texture0:setTexParameters(texParams) - local texture1 = CCTextureCache:sharedTextureCache():addImage( + local texture1 = CCTextureCache:getInstance():addImage( "Images/grossini_dance_atlas_nomipmap.png") local img0 = CCSprite:createWithTexture(texture0) - img0:setTextureRect(CCRectMake(85, 121, 85, 121)) - img0:setPosition(ccp( s.width/3.0, s.height/2.0)) + img0:setTextureRect(CCRect(85, 121, 85, 121)) + img0:setPosition(CCPoint( s.width/3.0, s.height/2.0)) ret:addChild(img0) local img1 = CCSprite:createWithTexture(texture1) - img1:setTextureRect(CCRectMake(85, 121, 85, 121)) - img1:setPosition(ccp( 2*s.width/3.0, s.height/2.0)) + img1:setTextureRect(CCRect(85, 121, 85, 121)) + img1:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) ret:addChild(img1) local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) @@ -127,7 +127,7 @@ local function TextureMipMap() arr:addObject(scale2) arr:addObject(sc_back2) img1:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -140,11 +140,11 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap() local ret = createTestLayer("PVRTC MipMap Test", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local imgMipMap = CCSprite:create("Images/logo-mipmap.pvr") if imgMipMap ~= nil then - imgMipMap:setPosition(ccp( s.width/2.0-100, s.height/2.0)) + imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering @@ -160,7 +160,7 @@ local function TexturePVRMipMap() local img = CCSprite:create("Images/logo-nomipmap.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0+100, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) ret:addChild(img) local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) @@ -180,7 +180,7 @@ local function TexturePVRMipMap() img:runAction(CCRepeatForever:create(CCSequence:create(arr))) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -192,10 +192,10 @@ end -------------------------------------------------------------------- local function TexturePVRMipMap2() local ret = createTestLayer("PVR MipMap Test #2", "Left image uses mipmap. Right image doesn't") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local imgMipMap = CCSprite:create("Images/test_image_rgba4444_mipmap.pvr") - imgMipMap:setPosition(ccp( s.width/2.0-100, s.height/2.0)) + imgMipMap:setPosition(CCPoint( s.width/2.0-100, s.height/2.0)) ret:addChild(imgMipMap) -- support mipmap filtering @@ -208,7 +208,7 @@ local function TexturePVRMipMap2() imgMipMap:getTexture():setTexParameters(texParams) local img = CCSprite:create("Images/test_image.png") - img:setPosition(ccp( s.width/2.0+100, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0+100, s.height/2.0)) ret:addChild(img) local scale1 = CCEaseOut:create(CCScaleBy:create(4, 0.01), 3) @@ -227,7 +227,7 @@ local function TexturePVRMipMap2() arr:addObject(sc_back2) img:runAction(CCRepeatForever:create(CCSequence:create(arr))) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -241,16 +241,16 @@ end local function TexturePVR2BPP() local ret = createTestLayer("PVR TC 2bpp Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtc2bpp.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -263,17 +263,17 @@ end -------------------------------------------------------------------- local function TexturePVR() local ret = createTestLayer("PVR TC 4bpp Test #2") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported.") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -287,17 +287,17 @@ end local function TexturePVR4BPP() local ret = createTestLayer("PVR TC 4bpp Test #3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtc4bpp.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported in cocos2d-mac") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -311,12 +311,12 @@ end local function TexturePVRRGBA8888() local ret = createTestLayer("PVR + RGBA 8888 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba8888.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -330,16 +330,16 @@ end local function TexturePVRBGRA8888() local ret = createTestLayer("PVR + BGRA 8888 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_bgra8888.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA8888 images are not supported") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -352,12 +352,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA5551() local ret = createTestLayer("PVR + RGBA 5551 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba5551.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -370,12 +370,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGBA4444() local ret = createTestLayer("PVR + RGBA 4444 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -389,12 +389,12 @@ end local function TexturePVRRGBA4444GZ() local ret = createTestLayer("PVR + RGBA 4444 + GZ Test", "This is a gzip PVR image") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba4444.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -408,12 +408,12 @@ end local function TexturePVRRGBA4444CCZ() local ret = createTestLayer("PVR + RGBA 4444 + CCZ Test", "This is a ccz PVR image") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba4444.pvr.ccz") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -426,12 +426,12 @@ end -------------------------------------------------------------------- local function TexturePVRRGB565() local ret = createTestLayer("PVR + RGB 565 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgb565.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -440,14 +440,14 @@ end -- http:--www.imgtec.com/powervr/insider/powervr-pvrtextool.asp local function TexturePVRRGB888() local ret = createTestLayer("PVR + RGB 888 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgb888.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -460,12 +460,12 @@ end -------------------------------------------------------------------- local function TexturePVRA8() local ret = createTestLayer("PVR + A8 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_a8.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -478,12 +478,12 @@ end -------------------------------------------------------------------- local function TexturePVRI8() local ret = createTestLayer("PVR + I8 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_i8.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -497,61 +497,61 @@ end -------------------------------------------------------------------- local function TexturePVRAI88() local ret = createTestLayer("PVR + AI88 Test") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_ai88.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR2BPPv3 local function TexturePVR2BPPv3() local ret = createTestLayer("PVR TC 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtc2bpp_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVRII2BPPv3 local function TexturePVRII2BPPv3() local ret = createTestLayer("PVR TC II 2bpp Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtcii2bpp_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end -- TexturePVR4BPPv3 local function TexturePVR4BPPv3() local ret = createTestLayer("PVR TC 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtc4bpp_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -563,17 +563,17 @@ end local function TexturePVRII4BPPv3() local ret = createTestLayer("PVR TC II 4bpp Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_pvrtcii4bpp_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("This test is not supported") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -581,16 +581,16 @@ end local function TexturePVRRGBA8888v3() local ret = createTestLayer("PVR + RGBA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba8888_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -599,18 +599,18 @@ local function TexturePVRBGRA8888v3() local ret = createTestLayer("PVR + BGRA 8888 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_bgra8888_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) else cclog("BGRA images are not supported") end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -618,15 +618,15 @@ end local function TexturePVRRGBA5551v3() local ret = createTestLayer("PVR + RGBA 5551 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba5551_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -634,16 +634,16 @@ end local function TexturePVRRGBA4444v3() local ret = createTestLayer("PVR + RGBA 4444 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgba4444_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -651,16 +651,16 @@ end local function TexturePVRRGB565v3() local ret = createTestLayer("PVR + RGB 565 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgb565_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -668,16 +668,16 @@ end local function TexturePVRRGB888v3() local ret = createTestLayer("PVR + RGB 888 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_rgb888_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -685,16 +685,16 @@ end local function TexturePVRA8v3() local ret = createTestLayer("PVR + A8 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_a8_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -702,16 +702,16 @@ end local function TexturePVRI8v3() local ret = createTestLayer("PVR + I8 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_i8_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -719,16 +719,16 @@ end local function TexturePVRAI88v3() local ret = createTestLayer("PVR + AI88 Test", "Testing PVR File Format v3") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image_ai88_v3.pvr") if img ~= nil then - img:setPosition(ccp(s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint(s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -742,11 +742,11 @@ end local function TexturePVRBadEncoding() local ret = createTestLayer("PVR Unsupported encoding", "You should not see any image") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/test_image-bad_encoding.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) end return ret @@ -760,12 +760,12 @@ end local function TexturePVRNonSquare() local ret = createTestLayer("PVR + Non square texture", "Loading a 128x256 texture") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/grossini_128x256_mipmap.pvr") - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -777,14 +777,14 @@ end local function TexturePVRNPOT4444() local ret = createTestLayer("PVR RGBA4 + NPOT texture", "Loading a 81x121 RGBA4444 texture.") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/grossini_pvr_rgba4444.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -796,14 +796,14 @@ end local function TexturePVRNPOT8888() local ret = createTestLayer("PVR RGBA8 + NPOT texture", "Loading a 81x121 RGBA8888 texture.") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local img = CCSprite:create("Images/grossini_pvr_rgba8888.pvr") if img ~= nil then - img:setPosition(ccp( s.width/2.0, s.height/2.0)) + img:setPosition(CCPoint( s.width/2.0, s.height/2.0)) ret:addChild(img) end - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -815,7 +815,7 @@ end local function TextureAlias() local ret = createTestLayer("AntiAlias / Alias textures", "Left image is antialiased. Right image is aliases") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() -- -- Sprite 1: GL_LINEAR @@ -823,7 +823,7 @@ local function TextureAlias() -- Default filter is GL_LINEAR local sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(ccp( s.width/3.0, s.height/2.0)) + sprite:setPosition(CCPoint( s.width/3.0, s.height/2.0)) ret:addChild(sprite) -- this is the default filterting @@ -834,7 +834,7 @@ local function TextureAlias() -- local sprite2 = CCSprite:create("Images/grossinis_sister2.png") - sprite2:setPosition(ccp( 2*s.width/3.0, s.height/2.0)) + sprite2:setPosition(CCPoint( 2*s.width/3.0, s.height/2.0)) ret:addChild(sprite2) -- Use Nearest in this one @@ -851,7 +851,7 @@ local function TextureAlias() sprite2:runAction(scaleforever) sprite:runAction(scaleToo) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -874,7 +874,7 @@ local function TexturePixelFormat() local label = tolua.cast(ret:getChildByTag(kTagLabel), "CCLabelTTF") label:setColor(Color3B(16,16,255)) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local background = CCLayerColor:create(Color4B(128,128,128,255), s.width, s.height) ret:addChild(background, -1) @@ -882,56 +882,56 @@ local function TexturePixelFormat() -- RGBA 8888 image (32-bit) CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) local sprite1 = CCSprite:create("Images/test-rgba1.png") - sprite1:setPosition(ccp(1*s.width/7, s.height/2+32)) + sprite1:setPosition(CCPoint(1*s.width/7, s.height/2+32)) ret:addChild(sprite1, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite1:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite1:getTexture()) -- RGBA 4444 image (16-bit) CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444) local sprite2 = CCSprite:create("Images/test-rgba1.png") - sprite2:setPosition(ccp(2*s.width/7, s.height/2-32)) + sprite2:setPosition(CCPoint(2*s.width/7, s.height/2-32)) ret:addChild(sprite2, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite2:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite2:getTexture()) -- RGB5A1 image (16-bit) CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1) local sprite3 = CCSprite:create("Images/test-rgba1.png") - sprite3:setPosition(ccp(3*s.width/7, s.height/2+32)) + sprite3:setPosition(CCPoint(3*s.width/7, s.height/2+32)) ret:addChild(sprite3, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite3:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite3:getTexture()) -- RGB888 image CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB888) local sprite4 = CCSprite:create("Images/test-rgba1.png") - sprite4:setPosition(ccp(4*s.width/7, s.height/2-32)) + sprite4:setPosition(CCPoint(4*s.width/7, s.height/2-32)) ret:addChild(sprite4, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite4:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite4:getTexture()) -- RGB565 image (16-bit) CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565) local sprite5 = CCSprite:create("Images/test-rgba1.png") - sprite5:setPosition(ccp(5*s.width/7, s.height/2+32)) + sprite5:setPosition(CCPoint(5*s.width/7, s.height/2+32)) ret:addChild(sprite5, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite5:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite5:getTexture()) -- A8 image (8-bit) CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8) local sprite6 = CCSprite:create("Images/test-rgba1.png") - sprite6:setPosition(ccp(6*s.width/7, s.height/2-32)) + sprite6:setPosition(CCPoint(6*s.width/7, s.height/2-32)) ret:addChild(sprite6, 0) -- remove texture from texture manager - CCTextureCache:sharedTextureCache():removeTexture(sprite6:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite6:getTexture()) local fadeout = CCFadeOut:create(2) local fadein = CCFadeIn:create(2) @@ -954,7 +954,7 @@ local function TexturePixelFormat() -- restore default CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_Default) - CCTextureCache:sharedTextureCache():dumpCachedTextureInfo() + CCTextureCache:getInstance():dumpCachedTextureInfo() return ret end @@ -972,7 +972,7 @@ local function TextureBlend() -- they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA local cloud = CCSprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 100+i) - cloud:setPosition(ccp(50+25*i, 80)) + cloud:setPosition(CCPoint(50+25*i, 80)) local blendFunc1 = BlendFunc() blendFunc1.src = GL_ONE blendFunc1.dst = GL_ONE_MINUS_SRC_ALPHA @@ -982,7 +982,7 @@ local function TextureBlend() -- they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA cloud = CCSprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(ccp(50+25*i, 160)) + cloud:setPosition(CCPoint(50+25*i, 160)) local blendFunc2 = BlendFunc() blendFunc2.src = GL_ONE_MINUS_DST_COLOR blendFunc2.dst = GL_ZERO @@ -992,7 +992,7 @@ local function TextureBlend() -- You can set any blend function to your sprites cloud = CCSprite:create("Images/test_blend.png") ret:addChild(cloud, i+1, 200+i) - cloud:setPosition(ccp(50+25*i, 320-80)) + cloud:setPosition(CCPoint(50+25*i, 320-80)) local blendFunc3 = BlendFunc() blendFunc3.src = GL_SRC_ALPHA blendFunc3.dst = GL_ONE @@ -1012,10 +1012,10 @@ local function TextureAsync() "Textures should load while an animation is being run") local m_nImageOffset = 0 - local size =CCDirector:sharedDirector():getWinSize() + local size =CCDirector:getInstance():getWinSize() local label = CCLabelTTF:create("Loading...", "Marker Felt", 32) - label:setPosition(ccp( size.width/2, size.height/2)) + label:setPosition(CCPoint( size.width/2, size.height/2)) ret:addChild(label, 10) local scale = CCScaleBy:create(0.3, 2) @@ -1028,7 +1028,7 @@ local function TextureAsync() local function imageLoaded(pObj) local tex = tolua.cast(pObj, "CCTexture2D") - local director = CCDirector:sharedDirector() + local director = CCDirector:getInstance() --CCASSERT( [NSThread currentThread] == [director runningThread], @"FAIL. Callback should be on cocos2d thread") @@ -1037,12 +1037,12 @@ local function TextureAsync() -- This test just creates a sprite based on the Texture local sprite = CCSprite:createWithTexture(tex) - sprite:setAnchorPoint(ccp(0,0)) + sprite:setAnchorPoint(CCPoint(0,0)) ret:addChild(sprite, -1) local size = director:getWinSize() local i = m_nImageOffset * 32 - sprite:setPosition(ccp( i % size.width, (i / size.width) * 32 )) + sprite:setPosition(CCPoint( i % size.width, (i / size.width) * 32 )) m_nImageOffset = m_nImageOffset + 1 cclog("Image loaded:...")-- %p", tex) @@ -1055,16 +1055,16 @@ local function TextureAsync() for j=0, 7 do local szSpriteName = string.format( "Images/sprites_test/sprite-%d-%d.png", i, j) - CCTextureCache:sharedTextureCache():addImageAsync( + CCTextureCache:getInstance():addImageAsync( szSpriteName, imageLoaded) end end - CCTextureCache:sharedTextureCache():addImageAsync("Images/background1.jpg", imageLoaded) - CCTextureCache:sharedTextureCache():addImageAsync("Images/background2.jpg", imageLoaded) - CCTextureCache:sharedTextureCache():addImageAsync("Images/background.png", imageLoaded) - CCTextureCache:sharedTextureCache():addImageAsync("Images/atlastest.png", imageLoaded) - CCTextureCache:sharedTextureCache():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) + CCTextureCache:getInstance():addImageAsync("Images/background1.jpg", imageLoaded) + CCTextureCache:getInstance():addImageAsync("Images/background2.jpg", imageLoaded) + CCTextureCache:getInstance():addImageAsync("Images/background.png", imageLoaded) + CCTextureCache:getInstance():addImageAsync("Images/atlastest.png", imageLoaded) + CCTextureCache:getInstance():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded) end local schedulerEntry = nil @@ -1073,7 +1073,7 @@ local function TextureAsync() schedulerEntry = scheduler:scheduleScriptFunc(loadImages, 1.0, false) elseif event == "exit" then scheduler:unscheduleScriptEntry(schedulerEntry) - CCTextureCache:sharedTextureCache():removeAllTextures() + CCTextureCache:getInstance():removeAllTextures() end end @@ -1089,13 +1089,13 @@ end local function TextureGlClamp() local ret = createTestLayer("Texture GL_CLAMP") - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRectMake(0,0,512,256)) + local sprite = CCSprite:create("Images/pattern1.png", CCRect(0,0,512,256)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(ccp(size.width/2,size.height/2)) + sprite:setPosition(CCPoint(size.width/2,size.height/2)) local texParams = ccTexParams() texParams.minFilter = GL_LINEAR texParams.magFilter = GL_LINEAR @@ -1115,7 +1115,7 @@ local function TextureGlClamp() sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:sharedTextureCache():removeUnusedTextures() + CCTextureCache:getInstance():removeUnusedTextures() end end @@ -1132,13 +1132,13 @@ end local function TextureGlRepeat() local ret = createTestLayer("Texture GL_REPEAT") - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() -- The .png image MUST be power of 2 in order to create a continue effect. -- eg: 32x64, 512x128, 256x1024, 64x64, etc.. - local sprite = CCSprite:create("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096)) + local sprite = CCSprite:create("Images/pattern1.png", CCRect(0, 0, 4096, 4096)) ret:addChild(sprite, -1, kTagSprite1) - sprite:setPosition(ccp(size.width/2,size.height/2)) + sprite:setPosition(CCPoint(size.width/2,size.height/2)) local texParams = ccTexParams() texParams.minFilter = GL_LINEAR @@ -1159,7 +1159,7 @@ local function TextureGlRepeat() sprite:runAction(seq) local function onNodeEvent(event) if event == "exit" then - CCTextureCache:sharedTextureCache():removeUnusedTextures() + CCTextureCache:getInstance():removeUnusedTextures() end end @@ -1217,20 +1217,20 @@ end local function TextureCache1() local ret = createTestLayer("CCTextureCache: remove", "4 images should appear: alias, antialias, alias, antilias") - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local sprite = nil sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(ccp(s.width/5*1, s.height/2)) + sprite:setPosition(CCPoint(s.width/5*1, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:sharedTextureCache():removeTexture(sprite:getTexture()) + CCTextureCache:getInstance():removeTexture(sprite:getTexture()) sprite = CCSprite:create("Images/grossinis_sister1.png") - sprite:setPosition(ccp(s.width/5*2, s.height/2)) + sprite:setPosition(CCPoint(s.width/5*2, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) @@ -1238,15 +1238,15 @@ local function TextureCache1() -- 2nd set of sprites sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(ccp(s.width/5*3, s.height/2)) + sprite:setPosition(CCPoint(s.width/5*3, s.height/2)) sprite:getTexture():setAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) - CCTextureCache:sharedTextureCache():removeTextureForKey("Images/grossinis_sister2.png") + CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister2.png") sprite = CCSprite:create("Images/grossinis_sister2.png") - sprite:setPosition(ccp(s.width/5*4, s.height/2)) + sprite:setPosition(CCPoint(s.width/5*4, s.height/2)) sprite:getTexture():setAntiAliasTexParameters() sprite:setScale(2) ret:addChild(sprite) @@ -1263,14 +1263,14 @@ local function TextureDrawAtPoint() local function draw() -- TextureDemo:draw() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - m_pTex1:drawAtPoint(ccp(s.width/2-50, s.height/2 - 50)) - m_pTex2F:drawAtPoint(ccp(s.width/2+50, s.height/2 - 50)) + m_pTex1:drawAtPoint(CCPoint(s.width/2-50, s.height/2 - 50)) + m_pTex2F:drawAtPoint(CCPoint(s.width/2+50, s.height/2 - 50)) end - m_pTex1 = CCTextureCache:sharedTextureCache():addImage("Images/grossinis_sister1.png") - m_pTex2F = CCTextureCache:sharedTextureCache():addImage("Images/grossinis_sister2.png") + m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") + m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1294,17 +1294,17 @@ local function TextureDrawInRect() local function draw() -- TextureDemo:draw() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - local rect1 = CCRectMake( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) - local rect2 = CCRectMake( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) + local rect1 = CCRect( s.width/2 - 80, 20, m_pTex1:getContentSize().width * 0.5, m_pTex1:getContentSize().height *2 ) + local rect2 = CCRect( s.width/2 + 80, s.height/2, m_pTex1:getContentSize().width * 2, m_pTex1:getContentSize().height * 0.5 ) m_pTex1:drawInRect(rect1) m_pTex2F:drawInRect(rect2) end - local m_pTex1 = CCTextureCache:sharedTextureCache():addImage("Images/grossinis_sister1.png") - local m_pTex2F = CCTextureCache:sharedTextureCache():addImage("Images/grossinis_sister2.png") + local m_pTex1 = CCTextureCache:getInstance():addImage("Images/grossinis_sister1.png") + local m_pTex2F = CCTextureCache:getInstance():addImage("Images/grossinis_sister2.png") m_pTex1:retain() m_pTex2F:retain() @@ -1337,7 +1337,7 @@ local function TextureMemoryAlloc() cclog("updateImage"..tag) m_pBackground:removeFromParentAndCleanup(true) end - CCTextureCache:sharedTextureCache():removeUnusedTextures() + CCTextureCache:getInstance():removeUnusedTextures() local file = "" if tag == 0 then @@ -1357,8 +1357,8 @@ local function TextureMemoryAlloc() m_pBackground:setVisible(false) - local s = CCDirector:sharedDirector():getWinSize() - m_pBackground:setPosition(ccp(s.width/2, s.height/2)) + local s = CCDirector:getInstance():getWinSize() + m_pBackground:setPosition(CCPoint(s.width/2, s.height/2)) end local item1 = CCMenuItemFont:create("PNG") @@ -1407,9 +1407,9 @@ local function TextureMemoryAlloc() menu2:alignItemsHorizontally() ret:addChild(menu2) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() - menu2:setPosition(ccp(s.width/2, s.height/4)) + menu2:setPosition(CCPoint(s.width/2, s.height/4)) return ret end @@ -1431,7 +1431,7 @@ local function TexturePVRv3Premult() sprite:runAction(repeatAction) end - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() local background = CCLayerColor:create(Color4B(128,128,128,255), size.width, size.height) ret:addChild(background, -1) @@ -1440,21 +1440,21 @@ local function TexturePVRv3Premult() -- PVR premultiplied local pvr1 = CCSprite:create("Images/grossinis_sister1-testalpha_premult.pvr") ret:addChild(pvr1, 0) - pvr1:setPosition(ccp(size.width/4*1, size.height/2)) + pvr1:setPosition(CCPoint(size.width/4*1, size.height/2)) transformSprite(pvr1) -- PVR non-premultiplied local pvr2 = CCSprite:create("Images/grossinis_sister1-testalpha_nopremult.pvr") ret:addChild(pvr2, 0) - pvr2:setPosition(ccp(size.width/4*2, size.height/2)) + pvr2:setPosition(CCPoint(size.width/4*2, size.height/2)) transformSprite(pvr2) -- PNG CCTexture2D:setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888) - CCTextureCache:sharedTextureCache():removeTextureForKey("Images/grossinis_sister1-testalpha.png") + CCTextureCache:getInstance():removeTextureForKey("Images/grossinis_sister1-testalpha.png") local png = CCSprite:create("Images/grossinis_sister1-testalpha.png") ret:addChild(png, 0) - png:setPosition(ccp(size.width/4*3, size.height/2)) + png:setPosition(CCPoint(size.width/4*3, size.height/2)) transformSprite(png) return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua index 3b634f5ef7..ce4d95e5ff 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TileMapTest/TileMapTest.lua @@ -1,5 +1,5 @@ -local size = CCDirector:sharedDirector():getWinSize() -local scheduler = CCDirector:sharedDirector():getScheduler() +local size = CCDirector:getInstance():getWinSize() +local scheduler = CCDirector:getInstance():getScheduler() local kTagTileMap = 1 @@ -25,7 +25,7 @@ local function createTileDemoLayer(title, subtitle) local diffX = x - prev.x local diffY = y - prev.y - node:setPosition( ccpAdd(ccp(newX, newY), ccp(diffX, diffY)) ) + node:setPosition( CCPoint.__add(CCPoint(newX, newY), CCPoint(diffX, diffY)) ) prev.x = x prev.y = y end @@ -55,7 +55,7 @@ local function TileMapTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( ccp(0, 0.5) ) + map:setAnchorPoint( CCPoint(0, 0.5) ) local scale = CCScaleBy:create(4, 0.8) local scaleBack = scale:reverse() @@ -101,7 +101,7 @@ local function TileMapEditTest() -- over all your tiles in every frame. It's very expensive -- for(int x=0 x < tilemap.tgaInfo:width x++) -- for(int y=0 y < tilemap.tgaInfo:height y++) - -- Color3B c =[tilemap tileAt:local Make(x,y)) + -- Color3B c =[tilemap getTileAt:local Make(x,y)) -- if( c.r != 0 ) -- --------cclog("%d,%d = %d", x,y,c.r) -- end @@ -109,7 +109,7 @@ local function TileMapEditTest() -- end -- NEW since v0.7 - local c = tilemap:tileAt(ccp(13,21)) + local c = tilemap:getTileAt(CCPoint(13,21)) c.r = c.r + 1 c.r = c.r % 50 @@ -117,7 +117,7 @@ local function TileMapEditTest() c.r=1 end -- NEW since v0.7 - tilemap:setTile(c, ccp(13,21) ) + tilemap:setTile(c, CCPoint(13,21) ) end local schedulerEntry = nil @@ -133,8 +133,8 @@ local function TileMapEditTest() layer:addChild(map, 0, kTagTileMap) - map:setAnchorPoint( ccp(0, 0) ) - map:setPosition( ccp(-20,-200) ) + map:setAnchorPoint( CCPoint(0, 0) ) + map:setPosition( CCPoint(-20,-200) ) return layer end @@ -189,9 +189,9 @@ local function TMXOrthoTest() local function onNodeEvent(event) if event == "enter" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection3D) + CCDirector:getInstance():setProjection(kCCDirectorProjection3D) elseif event == "exit" then - CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D) + CCDirector:getInstance():setProjection(kCCDirectorProjection2D) end end @@ -263,7 +263,7 @@ local function TMXOrthoTest3() end map:setScale(0.2) - map:setAnchorPoint( ccp(0.5, 0.5) ) + map:setAnchorPoint( CCPoint(0.5, 0.5) ) return layer end @@ -296,18 +296,18 @@ local function TMXOrthoTest4() child:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(ccp(0, 0)) + map:setAnchorPoint(CCPoint(0, 0)) - local layer = map:layerNamed("Layer 0") + local layer = map:getLayer("Layer 0") local s = layer:getLayerSize() - local sprite = layer:tileAt(ccp(0,0)) + local sprite = layer:getTileAt(CCPoint(0,0)) sprite:setScale(2) - sprite = layer:tileAt(ccp(s.width-1,0)) + sprite = layer:getTileAt(CCPoint(s.width-1,0)) sprite:setScale(2) - sprite = layer:tileAt(ccp(0,s.height-1)) + sprite = layer:getTileAt(CCPoint(0,s.height-1)) sprite:setScale(2) - sprite = layer:tileAt(ccp(s.width-1,s.height-1)) + sprite = layer:getTileAt(CCPoint(s.width-1,s.height-1)) sprite:setScale(2) local schedulerEntry = nil @@ -316,10 +316,10 @@ local function TMXOrthoTest4() scheduler:unscheduleScriptEntry(schedulerEntry) schedulerEntry = nil local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - local layer0 = map:layerNamed("Layer 0") + local layer0 = map:getLayer("Layer 0") local s = layer0:getLayerSize() - local sprite = layer0:tileAt( ccp(s.width-1,0) ) + local sprite = layer0:getTileAt( CCPoint(s.width-1,0) ) layer0:removeChild(sprite, true) end @@ -356,21 +356,21 @@ local function TMXReadWriteTest() cclog("ContentSize: %f, %f", s.width,s.height) - local layer = map:layerNamed("Layer 0") + local layer = map:getLayer("Layer 0") layer:getTexture():setAntiAliasTexParameters() map:setScale( 1 ) - local tile0 = layer:tileAt(ccp(1,63)) - local tile1 = layer:tileAt(ccp(2,63)) - local tile2 = layer:tileAt(ccp(3,62))--ccp(1,62)) - local tile3 = layer:tileAt(ccp(2,62)) - tile0:setAnchorPoint( ccp(0.5, 0.5) ) - tile1:setAnchorPoint( ccp(0.5, 0.5) ) - tile2:setAnchorPoint( ccp(0.5, 0.5) ) - tile3:setAnchorPoint( ccp(0.5, 0.5) ) + local tile0 = layer:getTileAt(CCPoint(1,63)) + local tile1 = layer:getTileAt(CCPoint(2,63)) + local tile2 = layer:getTileAt(CCPoint(3,62))--CCPoint(1,62)) + local tile3 = layer:getTileAt(CCPoint(2,62)) + tile0:setAnchorPoint( CCPoint(0.5, 0.5) ) + tile1:setAnchorPoint( CCPoint(0.5, 0.5) ) + tile2:setAnchorPoint( CCPoint(0.5, 0.5) ) + tile3:setAnchorPoint( CCPoint(0.5, 0.5) ) - local move = CCMoveBy:create(0.5, ccp(0,160)) + local move = CCMoveBy:create(0.5, CCPoint(0,160)) local rotate = CCRotateBy:create(2, 360) local scale = CCScaleBy:create(2, 5) local opacity = CCFadeOut:create(2) @@ -411,7 +411,7 @@ local function TMXReadWriteTest() tile3:runAction(seq3) - m_gid = layer:tileGIDAt(ccp(0,63)) + m_gid = layer:getTileGIDAt(CCPoint(0,63)) --------cclog("Tile GID at:(0,63) is: %d", m_gid) local updateColScheduler = nil local repainWithGIDScheduler = nil @@ -429,7 +429,7 @@ local function TMXReadWriteTest() local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:setTileGID(m_gid2, ccp(3, y)) + layer:setTileGID(m_gid2, CCPoint(3, y)) end m_gid2 = (m_gid2 + 1) % 80 @@ -444,8 +444,8 @@ local function TMXReadWriteTest() local x = 0 for x=0, s.width-1, 1 do local y = s.height-1 - local tmpgid = layer:tileGIDAt( ccp(x, y) ) - layer:setTileGID(tmpgid+1, ccp(x, y)) + local tmpgid = layer:getTileGIDAt( CCPoint(x, y) ) + layer:setTileGID(tmpgid+1, CCPoint(x, y)) end end @@ -457,7 +457,7 @@ local function TMXReadWriteTest() local s = layer:getLayerSize() local y = 0 for y=0, s.height-1, 1 do - layer:removeTileAt( ccp(5.0, y) ) + layer:removeTileAt( CCPoint(5.0, y) ) end end @@ -525,7 +525,7 @@ local function TMXIsoTest() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) + map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ) return ret end @@ -545,7 +545,7 @@ local function TMXIsoTest1() local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setAnchorPoint(ccp(0.5, 0.5)) + map:setAnchorPoint(CCPoint(0.5, 0.5)) return ret end @@ -568,7 +568,7 @@ local function TMXIsoTest2() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction( CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction( CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) return ret end @@ -591,7 +591,7 @@ local function TMXUncompressedTest() -- move map to the center of the screen local ms = map:getMapSize() local ts = map:getTileSize() - map:runAction(CCMoveTo:create(1.0, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) + map:runAction(CCMoveTo:create(1.0, CCPoint( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )) -- testing release map local pChildrenArray = map:getChildren() @@ -621,13 +621,13 @@ local function TMXTilesetTest() local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - local layer = map:layerNamed("Layer 0") + local layer = map:getLayer("Layer 0") layer:getTexture():setAntiAliasTexParameters() - layer = map:layerNamed("Layer 1") + layer = map:getLayer("Layer 1") layer:getTexture():setAntiAliasTexParameters() - layer = map:layerNamed("Layer 2") + layer = map:getLayer("Layer 2") layer:getTexture():setAntiAliasTexParameters() return ret end @@ -646,7 +646,7 @@ local function TMXOrthoObjectsTest() cclog("ContentSize: %f, %f", s.width,s.height) --------cclog("---: Iterating over all the group objets") - local group = map:objectGroupNamed("Object Group 1") + local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil @@ -671,7 +671,7 @@ end local function draw() local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") - local group = map:objectGroupNamed("Object Group 1") + local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil @@ -695,10 +695,10 @@ local function draw() glLineWidth(3) - ccDrawLine( ccp(x, y), ccp((x+width), y) ) - ccDrawLine( ccp((x+width), y), ccp((x+width), (y+height)) ) - ccDrawLine( ccp((x+width), (y+height)), ccp(x, (y+height)) ) - ccDrawLine( ccp(x, (y+height)), ccp(x, y) ) + ccDrawLine( CCPoint(x, y), CCPoint((x+width), y) ) + ccDrawLine( CCPoint((x+width), y), CCPoint((x+width), (y+height)) ) + ccDrawLine( CCPoint((x+width), (y+height)), CCPoint(x, (y+height)) ) + ccDrawLine( CCPoint(x, (y+height)), CCPoint(x, y) ) glLineWidth(1) end @@ -718,7 +718,7 @@ local function TMXIsoObjectsTest() local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - local group = map:objectGroupNamed("Object Group 1") + local group = map:getObjectGroup("Object Group 1") --UxMutableArray* objects = group:objects() local objects = group:getObjects() @@ -740,7 +740,7 @@ end local function draw() local map = tolua.cast(getChildByTag(kTagTileMap), "CCTMXTiledMap") - local group = map:objectGroupNamed("Object Group 1") + local group = map:getObjectGroup("Object Group 1") local objects = group:getObjects() local dict = nil @@ -764,10 +764,10 @@ local function draw() glLineWidth(3) - ccDrawLine( ccp(x,y), ccp(x+width,y) ) - ccDrawLine( ccp(x+width,y), ccp(x+width,y+height) ) - ccDrawLine( ccp(x+width,y+height), ccp(x,y+height) ) - ccDrawLine( ccp(x,y+height), ccp(x,y) ) + ccDrawLine( CCPoint(x,y), CCPoint(x+width,y) ) + ccDrawLine( CCPoint(x+width,y), CCPoint(x+width,y+height) ) + ccDrawLine( CCPoint(x+width,y+height), CCPoint(x,y+height) ) + ccDrawLine( CCPoint(x,y+height), CCPoint(x,y) ) glLineWidth(1) end @@ -787,13 +787,13 @@ local function TMXResizeTest() local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - local layer = map:layerNamed("Layer 0") + local layer = map:getLayer("Layer 0") local ls = layer:getLayerSize() local x = 0 local y = 0 for y = 0, ls.height-1, 1 do for x = 0, ls.width-1, 1 do - layer:setTileGID(1, ccp( x, y ) ) + layer:setTileGID(1, CCPoint( x, y ) ) end end return ret @@ -812,16 +812,16 @@ local function TMXIsoZorder() local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) - map:setPosition(ccp(-s.width/2,0)) + map:setPosition(CCPoint(-s.width/2,0)) m_tamara = CCSprite:create(s_pPathSister1) map:addChild(m_tamara, map:getChildren():count() ) m_tamara:retain() local mapWidth = map:getMapSize().width * map:getTileSize().width - m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(ccp( mapWidth/2,0))) - m_tamara:setAnchorPoint(ccp(0.5,0)) + m_tamara:setPosition(CC_POINT_PIXELS_TO_POINTS(CCPoint( mapWidth/2,0))) + m_tamara:setAnchorPoint(CCPoint(0.5,0)) - local move = CCMoveBy:create(10, ccp(300,250)) + local move = CCMoveBy:create(10, CCPoint(300,250)) local back = move:reverse() local arr = CCArray:create() arr:addObject(move) @@ -831,7 +831,7 @@ local function TMXIsoZorder() local function repositionSprite(dt) local x,y = m_tamara:getPosition() - local p = ccp(x, y) + local p = CCPoint(x, y) p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -880,10 +880,10 @@ local function TMXOrthoZorder() m_tamara = CCSprite:create(s_pPathSister1) map:addChild(m_tamara, map:getChildren():count()) m_tamara:retain() - m_tamara:setAnchorPoint(ccp(0.5,0)) + m_tamara:setAnchorPoint(CCPoint(0.5,0)) - local move = CCMoveBy:create(10, ccp(400,450)) + local move = CCMoveBy:create(10, CCPoint(400,450)) local back = move:reverse() local arr = CCArray:create() arr:addObject(move) @@ -893,7 +893,7 @@ local function TMXOrthoZorder() local function repositionSprite(dt) local x, y = m_tamara:getPosition() - local p = ccp(x, y) + local p = CCPoint(x, y) p = CC_POINT_POINTS_TO_PIXELS(p) local map = ret:getChildByTag(kTagTileMap) @@ -937,16 +937,16 @@ local function TMXIsoVertexZ() ret:addChild(map, 0, kTagTileMap) local s = map:getContentSize() - map:setPosition( ccp(-s.width/2,0) ) + map:setPosition( CCPoint(-s.width/2,0) ) cclog("ContentSize: %f, %f", s.width,s.height) -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you -- can use any CCSprite and it will work OK. - local layer = map:layerNamed("Trees") - m_tamara = layer:tileAt( ccp(29,29) ) + local layer = map:getLayer("Trees") + m_tamara = layer:getTileAt( CCPoint(29,29) ) m_tamara:retain() - local move = CCMoveBy:create(10, ccpMult( ccp(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) + local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ) local back = move:reverse() local arr = CCArray:create() arr:addObject(move) @@ -958,7 +958,7 @@ local function TMXIsoVertexZ() -- tile height is 64x32 -- map size: 30x30 local x, y = m_tamara:getPosition() - local p = ccp(x, y) + local p = CCPoint(x, y) p = CC_POINT_POINTS_TO_PIXELS(p) local newZ = -(p.y+32) /16 m_tamara:setVertexZ( newZ ) @@ -968,11 +968,11 @@ local function TMXIsoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D) + CCDirector:getInstance():setProjection(kCCDirectorProjection2D) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:sharedDirector():setProjection:kCCDirectorProjection3D) + -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) if m_tamara ~= nil then m_tamara:release() @@ -1001,12 +1001,12 @@ local function TMXOrthoVertexZ() -- because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you -- can use any CCSprite and it will work OK. - local layer = map:layerNamed("trees") - m_tamara = layer:tileAt(ccp(0,11)) + local layer = map:getLayer("trees") + m_tamara = layer:getTileAt(CCPoint(0,11)) cclog("vertexZ:"..m_tamara:getVertexZ()) m_tamara:retain() - local move = CCMoveBy:create(10, ccpMult( ccp(400,450), 1/CC_CONTENT_SCALE_FACTOR())) + local move = CCMoveBy:create(10, CCPoint.__mul( CCPoint(400,450), 1/CC_CONTENT_SCALE_FACTOR())) local back = move:reverse() local arr = CCArray:create() arr:addObject(move) @@ -1018,7 +1018,7 @@ local function TMXOrthoVertexZ() -- tile height is 101x81 -- map size: 12x12 local x, y = m_tamara:getPosition() - local p = ccp(x, y) + local p = CCPoint(x, y) p = CC_POINT_POINTS_TO_PIXELS(p) m_tamara:setVertexZ( -( (p.y+81) /81) ) end @@ -1027,11 +1027,11 @@ local function TMXOrthoVertexZ() local function onNodeEvent(event) if event == "enter" then -- TIP: 2d projection should be used - CCDirector:sharedDirector():setProjection(kCCDirectorProjection2D) + CCDirector:getInstance():setProjection(kCCDirectorProjection2D) schedulerEntry = scheduler:scheduleScriptFunc(repositionSprite, 0, false) elseif event == "exit" then -- At exit use any other projection. - -- CCDirector:sharedDirector():setProjection:kCCDirectorProjection3D) + -- CCDirector:getInstance():setProjection:kCCDirectorProjection3D) if m_tamara ~= nil then m_tamara:release() end @@ -1052,7 +1052,7 @@ local function TMXIsoMoveLayer() local map = CCTMXTiledMap:create("TileMaps/iso-test-movelayer.tmx") ret:addChild(map, 0, kTagTileMap) - map:setPosition(ccp(-700,-50)) + map:setPosition(CCPoint(-700,-50)) local s = map:getContentSize() cclog("ContentSize: %f, %f", s.width,s.height) @@ -1087,7 +1087,7 @@ local function TMXTilePropertyTest() ret:addChild(map ,0 ,kTagTileMap) local i = 0 for i=1, 20, 1 do - cclog("GID:%i, Properties:", i)--, map:propertiesForGID(i)) + cclog("GID:%i, Properties:", i)--, map:getPropertiesForGID(i)) end return ret end @@ -1142,12 +1142,12 @@ local function TMXOrthoFlipRunTimeTest() local function flipIt(dt) -- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "CCTMXTiledMap") - -- local layer = map:layerNamed("Layer 0") + -- local layer = map:getLayer("Layer 0") -- --blue diamond - -- local tileCoord = ccp(1,10) + -- local tileCoord = CCPoint(1,10) -- local flags = 0 - -- local GID = layer:tileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) + -- local GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical -- if( flags & kCCTMXTileVerticalFlag ) -- flags &= ~kCCTMXTileVerticalFlag @@ -1156,8 +1156,8 @@ local function TMXOrthoFlipRunTimeTest() -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = ccp(1,8) - -- GID = layer:tileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) + -- tileCoord = CCPoint(1,8) + -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Vertical -- if( flags & kCCTMXTileVerticalFlag ) -- flags &= ~kCCTMXTileVerticalFlag @@ -1166,8 +1166,8 @@ local function TMXOrthoFlipRunTimeTest() -- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags) - -- tileCoord = ccp(2,8) - -- GID = layer:tileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) + -- tileCoord = CCPoint(2,8) + -- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags) -- -- Horizontal -- if( flags & kCCTMXTileHorizontalFlag ) -- flags &= ~kCCTMXTileHorizontalFlag @@ -1198,7 +1198,7 @@ local function TMXOrthoFromXMLTest() local resources = "TileMaps" -- partial paths are OK as resource paths. local file = resources.."/orthogonal-test1.tmx" - local str = CCString:createWithContentsOfFile(CCFileUtils:sharedFileUtils():fullPathForFilename(file)):getCString() + local str = CCString:createWithContentsOfFile(CCFileUtils:getInstance():fullPathForFilename(file)):getCString() -- CCASSERT(str != NULL, "Unable to open file") if (str == nil) then cclog("Unable to open file") @@ -1248,9 +1248,9 @@ local function TMXBug987() pNode:getTexture():setAntiAliasTexParameters() end - map:setAnchorPoint(ccp(0, 0)) - local layer = map:layerNamed("Tile Layer 1") - layer:setTileGID(3, ccp(2,2)) + map:setAnchorPoint(CCPoint(0, 0)) + local layer = map:getLayer("Tile Layer 1") + layer:setTileGID(3, CCPoint(2,2)) return ret end @@ -1270,7 +1270,7 @@ end function TileMapTestMain() cclog("TileMapTestMain") Helper.index = 1 - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) local scene = CCScene:create() Helper.createFunctionTable = { diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua index b7e056f6d1..e970a286f0 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Ball.lua @@ -9,7 +9,7 @@ end) Ball.__index = Ball -Ball.m_velocity = ccp(0,0) +Ball.m_velocity = CCPoint(0,0) local M_PI = 3.1415926 @@ -19,23 +19,23 @@ function Ball:radius() end function Ball:move(delta) - local getPosition = ccp(self:getPosition()) - local position = ccpMult(self.m_velocity, delta) - self:setPosition( ccpAdd(getPosition, position) ); + local getPosition = CCPoint(self:getPosition()) + local position = CCPoint.__mul(self.m_velocity, delta) + self:setPosition( CCPoint.__add(getPosition, position) ); if (getPosition.x > VisibleRect:right().x - self:radius()) then - self:setPosition( ccp( VisibleRect:right().x - self:radius(), getPosition.y) ); + self:setPosition( CCPoint( VisibleRect:right().x - self:radius(), getPosition.y) ); self.m_velocity.x = self.m_velocity.x * -1; elseif (getPosition.x < VisibleRect:left().x + self:radius()) then - self:setPosition( ccp(VisibleRect:left().x + self:radius(), getPosition.y) ); + self:setPosition( CCPoint(VisibleRect:left().x + self:radius(), getPosition.y) ); self.m_velocity.x = self.m_velocity.x * -1; end end function Ball:collideWithPaddle(paddle) local paddleRect = paddle:rect() - local paddleGetPosition = ccp(paddle:getPosition()) - local selfGetPosition = ccp(self:getPosition()) + local paddleGetPosition = CCPoint(paddle:getPosition()) + local selfGetPosition = CCPoint(self:getPosition()) paddleRect.origin.x = paddleRect.origin.x + paddleGetPosition.x; paddleRect.origin.y = paddleRect.origin.y + paddleGetPosition.y; @@ -53,22 +53,22 @@ function Ball:collideWithPaddle(paddle) local angleOffset = 0.0; if (selfGetPosition.y > midY and selfGetPosition.y <= highY + self:radius()) then - self:setPosition( ccp(selfGetPosition.x, highY + self:radius()) ); + self:setPosition( CCPoint(selfGetPosition.x, highY + self:radius()) ); hit = true; angleOffset = M_PI / 2; elseif (selfGetPosition.y < midY and selfGetPosition.y >= lowY - self:radius()) then - self:setPosition( ccp(selfGetPosition.x, lowY - self:radius()) ); + self:setPosition( CCPoint(selfGetPosition.x, lowY - self:radius()) ); hit = true; angleOffset = -M_PI / 2; end if (hit) then - local hitAngle = ccpToAngle(ccpSub(paddleGetPosition, paddleGetPosition)) + angleOffset; + local hitAngle = (CCPoint.__sub(paddleGetPosition, paddleGetPosition)):getAngle() + angleOffset; - local scalarVelocity = ccpLength(self.m_velocity) * 1.05; - local velocityAngle = -ccpToAngle(self.m_velocity) + 0.5 * hitAngle; + local scalarVelocity = (self.m_velocity):getLength() * 1.05; + local velocityAngle = -(self.m_velocity):getAngle() + 0.5 * hitAngle; - self.m_velocity = ccpMult(ccpForAngle(velocityAngle), scalarVelocity); + self.m_velocity = CCPoint.__mul(CCPoint:forAngle(velocityAngle), scalarVelocity); end end diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua index afb3c90a60..ebbadec579 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/Paddle.lua @@ -15,14 +15,14 @@ Paddle.m_state = kPaddleStateGrabbed function Paddle:rect() local s = self:getTexture():getContentSize() - return CCRectMake(-s.width / 2, -s.height / 2, s.width, s.height) + return CCRect(-s.width / 2, -s.height / 2, s.width, s.height) end function Paddle:containsTouchLocation(x,y) - local position = ccp(self:getPosition()) + local position = CCPoint(self:getPosition()) local s = self:getTexture():getContentSize() - local touchRect = CCRectMake(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) - local b = touchRect:containsPoint(ccp(x,y)) + local touchRect = CCRect(-s.width / 2 + position.x, -s.height / 2 + position.y, s.width, s.height) + local b = touchRect:containsPoint(CCPoint(x,y)) return b end @@ -36,7 +36,7 @@ function Paddle:ccTouchBegan(x, y) end function Paddle:ccTouchMoved(x, y) - self:setPosition( ccp(x,y) ); + self:setPosition( CCPoint(x,y) ); end function Paddle:ccTouchEnded(x, y) diff --git a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua index 08c7bda61e..48b6de4098 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TouchesTest/TouchesTest.lua @@ -18,12 +18,12 @@ local layer = nil local function backCallback(sender) local scene = CCScene:create() scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function resetAndScoreBallForPlayer(player) - m_ballStartingVelocity = ccpMult(m_ballStartingVelocity, -1.1); + m_ballStartingVelocity = CCPoint.__mul(m_ballStartingVelocity, -1.1); m_ball:setVelocity( m_ballStartingVelocity ); m_ball:setPosition( VisibleRect:center() ); end @@ -39,7 +39,7 @@ local function doStep(delta) m_ball:collideWithPaddle( paddle ); end - local ballPosition = ccp(m_ball:getPosition()) + local ballPosition = CCPoint(m_ball:getPosition()) if (ballPosition.y > VisibleRect:top().y - kStatusBarHeight + m_ball:radius()) then resetAndScoreBallForPlayer( kLowPlayer ); elseif (ballPosition.y < VisibleRect:bottom().y-m_ball:radius()) then @@ -62,8 +62,8 @@ end local function CreateTouchesLayer() layer = CCLayer:create() - m_ballStartingVelocity = ccp(20.0, -100.0); - local mgr = CCTextureCache:sharedTextureCache() + m_ballStartingVelocity = CCPoint(20.0, -100.0); + local mgr = CCTextureCache:getInstance() local texture = mgr:addImage(s_Ball) m_ball = Ball.ballWithTexture(texture); @@ -72,24 +72,24 @@ local function CreateTouchesLayer() layer:addChild( m_ball ); m_ball:retain(); - local paddleTexture = CCTextureCache:sharedTextureCache():addImage(s_Paddle); + local paddleTexture = CCTextureCache:getInstance():addImage(s_Paddle); local paddlesM = {} local paddle = Paddle:paddleWithTexture(paddleTexture); - paddle:setPosition( ccp(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); + paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); + paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 15) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( ccp(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); + paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:bottom().y + 100) ); paddlesM[#paddlesM+1] = paddle paddle = Paddle:paddleWithTexture( paddleTexture ); - paddle:setPosition( ccp(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); + paddle:setPosition( CCPoint(VisibleRect:center().x, VisibleRect:top().y - kStatusBarHeight - 100) ); paddlesM[#paddlesM+1] = paddle m_paddles = paddlesM diff --git a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua index 0145d4843b..3f659a9fa2 100644 --- a/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/TransitionsTest/TransitionsTest.lua @@ -4,7 +4,7 @@ require "luaScript/TransitionsTest/TransitionsName" local SceneIdx = -1 local CurSceneNo = 2 local TRANSITION_DURATION = 1.2 -local s = CCDirector:sharedDirector():getWinSize() +local s = CCDirector:getInstance():getWinSize() local function switchSceneTypeNo() if CurSceneNo == 1 then @@ -38,17 +38,17 @@ end local function backCallback(sender) local scene = backAction() - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function restartCallback(sender) local scene = restartAction() - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end local function nextCallback(sender) local scene = nextAction() - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end ----------------------------- @@ -59,7 +59,7 @@ local function createLayer1() local x, y = s.width, s.height local bg1 = CCSprite:create(s_back1) - bg1:setPosition(CCPointMake(s.width / 2, s.height / 2)) + bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32) @@ -84,10 +84,10 @@ local function createLayer1() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPointMake(0, 0)) - item1:setPosition(CCPointMake(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(CCPoint(0, 0)) + item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -102,7 +102,7 @@ local function createLayer2() local x, y = s.width, s.height local bg1 = CCSprite:create(s_back2) - bg1:setPosition(CCPointMake(s.width / 2, s.height / 2)) + bg1:setPosition(CCPoint(s.width / 2, s.height / 2)) layer:addChild(bg1, -1) local titleLabel = CCLabelTTF:create(Transition_Name[SceneIdx], "Thonburi", 32 ) @@ -127,10 +127,10 @@ local function createLayer2() menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPointMake(0, 0)) - item1:setPosition(CCPointMake(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(s.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(CCPoint(0, 0)) + item1:setPosition(CCPoint(s.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(s.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(s.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) @@ -141,7 +141,7 @@ end -- Create Transition Test ----------------------------- local function createTransition(index, t, scene) - CCDirector:sharedDirector():setDepthTest(false) + CCDirector:getInstance():setDepthTest(false) if firstEnter == true then firstEnter = false @@ -165,10 +165,10 @@ local function createTransition(index, t, scene) elseif index == Transition_Table.CCTransitionCrossFade then scene = CCTransitionCrossFade:create(t, scene) elseif index == Transition_Table.TransitionPageForward then - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) scene = CCTransitionPageTurn:create(t, scene, false) elseif index == Transition_Table.TransitionPageBackward then - CCDirector:sharedDirector():setDepthTest(true) + CCDirector:getInstance():setDepthTest(true) scene = CCTransitionPageTurn:create(t, scene, true) elseif index == Transition_Table.CCTransitionFadeTR then scene = CCTransitionFadeTR:create(t, scene) diff --git a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua index 4d82f995cc..9a4ad1e713 100644 --- a/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/UserDefaultTest/UserDefaultTest.lua @@ -6,62 +6,62 @@ local function doTest() -- set default value - CCUserDefault:sharedUserDefault():setStringForKey("string", "value1") - CCUserDefault:sharedUserDefault():setIntegerForKey("integer", 10) - CCUserDefault:sharedUserDefault():setFloatForKey("float", 2.3) - CCUserDefault:sharedUserDefault():setDoubleForKey("double", 2.4) - CCUserDefault:sharedUserDefault():setBoolForKey("bool", true) + CCUserDefault:getInstance():setStringForKey("string", "value1") + CCUserDefault:getInstance():setIntegerForKey("integer", 10) + CCUserDefault:getInstance():setFloatForKey("float", 2.3) + CCUserDefault:getInstance():setDoubleForKey("double", 2.4) + CCUserDefault:getInstance():setBoolForKey("bool", true) -- print value - local ret = CCUserDefault:sharedUserDefault():getStringForKey("string") + local ret = CCUserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - local d = CCUserDefault:sharedUserDefault():getDoubleForKey("double") + local d = CCUserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - local i = CCUserDefault:sharedUserDefault():getIntegerForKey("integer") + local i = CCUserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - local f = CCUserDefault:sharedUserDefault():getFloatForKey("float") + local f = CCUserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - local b = CCUserDefault:sharedUserDefault():getBoolForKey("bool") + local b = CCUserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else cclog("bool is false") end - --CCUserDefault:sharedUserDefault():flush() + --CCUserDefault:getInstance():flush() cclog("********************** after change value ***********************") -- change the value - CCUserDefault:sharedUserDefault():setStringForKey("string", "value2") - CCUserDefault:sharedUserDefault():setIntegerForKey("integer", 11) - CCUserDefault:sharedUserDefault():setFloatForKey("float", 2.5) - CCUserDefault:sharedUserDefault():setDoubleForKey("double", 2.6) - CCUserDefault:sharedUserDefault():setBoolForKey("bool", false) + CCUserDefault:getInstance():setStringForKey("string", "value2") + CCUserDefault:getInstance():setIntegerForKey("integer", 11) + CCUserDefault:getInstance():setFloatForKey("float", 2.5) + CCUserDefault:getInstance():setDoubleForKey("double", 2.6) + CCUserDefault:getInstance():setBoolForKey("bool", false) - CCUserDefault:sharedUserDefault():flush() + CCUserDefault:getInstance():flush() -- print value - ret = CCUserDefault:sharedUserDefault():getStringForKey("string") + ret = CCUserDefault:getInstance():getStringForKey("string") cclog("string is %s", ret) - d = CCUserDefault:sharedUserDefault():getDoubleForKey("double") + d = CCUserDefault:getInstance():getDoubleForKey("double") cclog("double is %f", d) - i = CCUserDefault:sharedUserDefault():getIntegerForKey("integer") + i = CCUserDefault:getInstance():getIntegerForKey("integer") cclog("integer is %d", i) - f = CCUserDefault:sharedUserDefault():getFloatForKey("float") + f = CCUserDefault:getInstance():getFloatForKey("float") cclog("float is %f", f) - b = CCUserDefault:sharedUserDefault():getBoolForKey("bool") + b = CCUserDefault:getInstance():getBoolForKey("bool") if b == true then cclog("bool is true") else @@ -71,10 +71,10 @@ end function UserDefaultTestMain() local ret = CCScene:create() - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local label = CCLabelTTF:create("CCUserDefault test see log", "Arial", 28) ret:addChild(label, 0) - label:setPosition( ccp(s.width/2, s.height-50) ) + label:setPosition( CCPoint(s.width/2, s.height-50) ) doTest() return ret end diff --git a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua index 0c4f2c219c..2554843571 100644 --- a/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua +++ b/samples/Lua/TestLua/Resources/luaScript/VisibleRect.lua @@ -8,7 +8,7 @@ VisibleRect.s_visibleRect = CCRect:new() function VisibleRect:lazyInit() if (self.s_visibleRect.size.width == 0.0 and self.s_visibleRect.size.height == 0.0) then - local pEGLView = CCEGLView:sharedOpenGLView(); + local pEGLView = CCEGLView:getInstance(); self.s_visibleRect.origin = pEGLView:getVisibleOrigin(); self.s_visibleRect.size = pEGLView:getVisibleSize(); end @@ -16,42 +16,42 @@ end function VisibleRect:getVisibleRect() self:lazyInit(); - return CCRectMake(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y, self.s_visibleRect.size.width, self.s_visibleRect.size.height); + return CCRect(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y, self.s_visibleRect.size.width, self.s_visibleRect.size.height); end function VisibleRect:left() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); end function VisibleRect:right() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); end function VisibleRect:top() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); end function VisibleRect:bottom() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y); end function VisibleRect:center() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width/2, self.s_visibleRect.origin.y+self.s_visibleRect.size.height/2); end function VisibleRect:leftTop() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + return CCPoint(self.s_visibleRect.origin.x, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); end function VisibleRect:rightTop() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y+self.s_visibleRect.size.height); end function VisibleRect:leftBottom() @@ -61,5 +61,5 @@ end function VisibleRect:rightBottom() self:lazyInit(); - return ccp(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y); + return CCPoint(self.s_visibleRect.origin.x+self.s_visibleRect.size.width, self.s_visibleRect.origin.y); end diff --git a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua index 414be17b1d..e7b6b1710b 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ZwoptexTest/ZwoptexTest.lua @@ -1,4 +1,4 @@ -local scheduler = CCDirector:sharedDirector():getScheduler() +local scheduler = CCDirector:getInstance():getScheduler() -------------------------------------------------------------------- -- -- ZwoptexGenericTest @@ -9,33 +9,33 @@ local function ZwoptexGenericTest() "Coordinate Formats, Rotation, Trimming, flipX/Y") local spriteFrameIndex = 0 local counter = 0 - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local schedulerEntry = nil local schedulerFlipSpriteEntry = nil local sprite1 = nil local sprite2 = nil local function onEnter() - CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("zwoptex/grossini.plist") - CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile("zwoptex/grossini-generic.plist") + CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini.plist") + CCSpriteFrameCache:getInstance():addSpriteFramesWithFile("zwoptex/grossini-generic.plist") local layer1 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer1:setPosition(ccp(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + layer1:setPosition(CCPoint(s.width/2-80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer1) - sprite1 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName("grossini_dance_01.png")) - sprite1:setPosition(ccp( s.width/2-80, s.height/2)) + sprite1 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_01.png")) + sprite1:setPosition(CCPoint( s.width/2-80, s.height/2)) ret:addChild(sprite1) sprite1:setFlipX(false) sprite1:setFlipY(false) local layer2 = CCLayerColor:create(Color4B(255, 0, 0, 255), 85, 121) - layer2:setPosition(ccp(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) + layer2:setPosition(CCPoint(s.width/2+80 - (85.0 * 0.5), s.height/2 - (121.0 * 0.5))) ret:addChild(layer2) - sprite2 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName("grossini_dance_generic_01.png")) - sprite2:setPosition(ccp( s.width/2 + 80, s.height/2)) + sprite2 = CCSprite:createWithSpriteFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName("grossini_dance_generic_01.png")) + sprite2:setPosition(CCPoint( s.width/2 + 80, s.height/2)) ret:addChild(sprite2) sprite2:setFlipX(false) @@ -74,8 +74,8 @@ local function ZwoptexGenericTest() local str1 = string.format("grossini_dance_%02d.png", spriteFrameIndex) local str2 = string.format("grossini_dance_generic_%02d.png", spriteFrameIndex) - sprite1:setDisplayFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(str1)) - sprite2:setDisplayFrame(CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(str2)) + sprite1:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str1)) + sprite2:setDisplayFrame(CCSpriteFrameCache:getInstance():getSpriteFrameByName(str2)) end sprite1:retain() @@ -97,7 +97,7 @@ local function ZwoptexGenericTest() end sprite1:release() sprite2:release() - local cache = CCSpriteFrameCache:sharedSpriteFrameCache() + local cache = CCSpriteFrameCache:getInstance() cache:removeSpriteFramesFromFile("zwoptex/grossini.plist") cache:removeSpriteFramesFromFile("zwoptex/grossini-generic.plist") end diff --git a/samples/Lua/TestLua/Resources/luaScript/controller.lua b/samples/Lua/TestLua/Resources/luaScript/controller.lua index 146ff0c646..26a4954403 100644 --- a/samples/Lua/TestLua/Resources/luaScript/controller.lua +++ b/samples/Lua/TestLua/Resources/luaScript/controller.lua @@ -10,4 +10,4 @@ require "luaScript/mainMenu" -- run local scene = CCScene:create() scene:addChild(CreateTestMenu()) -CCDirector:sharedDirector():runWithScene(scene) +CCDirector:getInstance():runWithScene(scene) diff --git a/samples/Lua/TestLua/Resources/luaScript/helper.lua b/samples/Lua/TestLua/Resources/luaScript/helper.lua index 53afaab928..04b9bc9a47 100644 --- a/samples/Lua/TestLua/Resources/luaScript/helper.lua +++ b/samples/Lua/TestLua/Resources/luaScript/helper.lua @@ -1,14 +1,14 @@ CC_CONTENT_SCALE_FACTOR = function() - return CCDirector:sharedDirector():getContentScaleFactor() + return CCDirector:getInstance():getContentScaleFactor() end CC_POINT_PIXELS_TO_POINTS = function(pixels) - return ccp(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) + return CCPoint(pixels.x/CC_CONTENT_SCALE_FACTOR(), pixels.y/CC_CONTENT_SCALE_FACTOR()) end CC_POINT_POINTS_TO_PIXELS = function(points) - return ccp(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) + return CCPoint(points.x*CC_CONTENT_SCALE_FACTOR(), points.y*CC_CONTENT_SCALE_FACTOR()) end @@ -32,7 +32,7 @@ local function MainMenuCallback() local scene = CCScene:create() scene:addChild(CreateTestMenu()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end -- add the menu item for back to main menu @@ -41,7 +41,7 @@ function CreateBackMenuItem() local MenuItem = CCMenuItemLabel:create(label) MenuItem:registerScriptTapHandler(MainMenuCallback) - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local Menu = CCMenu:create() Menu:addChild(MenuItem) Menu:setPosition(0, 0) @@ -85,13 +85,13 @@ function Helper.newScene() scene:addChild(Helper.currentLayer) scene:addChild(CreateBackMenuItem()) - CCDirector:sharedDirector():replaceScene(scene) + CCDirector:getInstance():replaceScene(scene) end function Helper.initWithLayer(layer) Helper.currentLayer = layer - local size = CCDirector:sharedDirector():getWinSize() + local size = CCDirector:getInstance():getWinSize() Helper.titleLabel = CCLabelTTF:create("", "Arial", 28) layer:addChild(Helper.titleLabel, 1) Helper.titleLabel:setPosition(size.width / 2, size.height - 50) @@ -112,10 +112,10 @@ function Helper.initWithLayer(layer) menu:addChild(item1) menu:addChild(item2) menu:addChild(item3) - menu:setPosition(CCPointMake(0, 0)) - item1:setPosition(CCPointMake(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) - item2:setPosition(CCPointMake(size.width / 2, item2:getContentSize().height / 2)) - item3:setPosition(CCPointMake(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + menu:setPosition(CCPoint(0, 0)) + item1:setPosition(CCPoint(size.width / 2 - item2:getContentSize().width * 2, item2:getContentSize().height / 2)) + item2:setPosition(CCPoint(size.width / 2, item2:getContentSize().height / 2)) + item3:setPosition(CCPoint(size.width / 2 + item2:getContentSize().width * 2, item2:getContentSize().height / 2)) layer:addChild(menu, 1) local background = CCLayer:create() diff --git a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua index 105b3ce7ac..c0ba606bca 100644 --- a/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua +++ b/samples/Lua/TestLua/Resources/luaScript/mainMenu.lua @@ -96,7 +96,7 @@ local TESTS_COUNT = table.getn(_allTests) -- create scene local function CreateTestScene(nIdx) local scene = _allTests[nIdx].create_func() - CCDirector:sharedDirector():purgeCachedData() + CCDirector:getInstance():purgeCachedData() return scene end -- create menu @@ -104,7 +104,7 @@ function CreateTestMenu() local menuLayer = CCLayer:create() local function closeCallback() - CCDirector:sharedDirector():endToLua() + CCDirector:getInstance():endToLua() end local function menuCallback(tag) @@ -112,15 +112,15 @@ function CreateTestMenu() local Idx = tag - 10000 local testScene = CreateTestScene(Idx) if testScene then - CCDirector:sharedDirector():replaceScene(testScene) + CCDirector:getInstance():replaceScene(testScene) end end -- add close menu - local s = CCDirector:sharedDirector():getWinSize() + local s = CCDirector:getInstance():getWinSize() local CloseItem = CCMenuItemImage:create(s_pPathClose, s_pPathClose) CloseItem:registerScriptTapHandler(closeCallback) - CloseItem:setPosition(ccp(s.width - 30, s.height - 30)) + CloseItem:setPosition(CCPoint(s.width - 30, s.height - 30)) local CloseMenu = CCMenu:create() CloseMenu:setPosition(0, 0) @@ -138,11 +138,11 @@ function CreateTestMenu() testMenuItem:setEnabled(false) end testMenuItem:registerScriptTapHandler(menuCallback) - testMenuItem:setPosition(ccp(s.width / 2, (s.height - (index) * LINE_SPACE))) + testMenuItem:setPosition(CCPoint(s.width / 2, (s.height - (index) * LINE_SPACE))) MainMenu:addChild(testMenuItem, index + 10000, index + 10000) end - MainMenu:setContentSize(CCSizeMake(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) + MainMenu:setContentSize(CCSize(s.width, (TESTS_COUNT + 1) * (LINE_SPACE))) MainMenu:setPosition(CurPos.x, CurPos.y) menuLayer:addChild(MainMenu) @@ -157,7 +157,7 @@ function CreateTestMenu() local nMoveY = y - BeginPos.y local curPosx, curPosy = MainMenu:getPosition() local nextPosy = curPosy + nMoveY - local winSize = CCDirector:sharedDirector():getWinSize() + local winSize = CCDirector:getInstance():getWinSize() if nextPosy < 0 then MainMenu:setPosition(0, 0) return diff --git a/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp b/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp index e503aab97c..6833c086ca 100644 --- a/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp +++ b/samples/Lua/TestLua/proj.android/jni/testlua/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index cff6760a99..c1f7e7e611 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -39,9 +39,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/generated LOCAL_WHOLE_STATIC_LIBRARIES := spidermonkey_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_LDLIBS := -landroid LOCAL_LDLIBS += -llog @@ -49,6 +47,4 @@ LOCAL_LDLIBS += -llog include $(BUILD_STATIC_LIBRARY) $(call import-module,scripting/javascript/spidermonkey-android) -$(call import-module,cocos2dx) $(call import-module,extensions) -$(call import-module,external/chipmunk) diff --git a/scripting/javascript/bindings/ScriptingCore.cpp b/scripting/javascript/bindings/ScriptingCore.cpp index fd6b1fa55e..241bb2d33c 100644 --- a/scripting/javascript/bindings/ScriptingCore.cpp +++ b/scripting/javascript/bindings/ScriptingCore.cpp @@ -80,6 +80,16 @@ static std::map ports_sockets; // name ~> globals static std::map globals; + +static void ReportException(JSContext *cx) +{ + if (JS_IsExceptionPending(cx)) { + if (!JS_ReportPendingException(cx)) { + JS_ClearPendingException(cx); + } + } +} + static void executeJSFunctionFromReservedSpot(JSContext *cx, JSObject *obj, jsval &dataVal, jsval &retval) { @@ -487,7 +497,7 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c JS::CompileOptions options(cx); options.setUTF8(true).setFileAndLine(fullPath.c_str(), 1); - // a) check js file first + // a) check jsc file first std::string byteCodePath = RemoveFileExt(std::string(path)) + BYTE_CODE_FILE_EXT; unsigned long length = 0; void *data = futil->getFileData(byteCodePath.c_str(), @@ -499,6 +509,9 @@ JSBool ScriptingCore::runScript(const char *path, JSObject* global, JSContext* c // b) no jsc file, check js file if (!script) { + /* Clear any pending exception from previous failed decoding. */ + ReportException(cx); + #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) String* content = String::createWithContentsOfFile(path); if (content) { @@ -1804,9 +1817,9 @@ jsval FontDefinition_to_jsval(JSContext* cx, const FontDefinition& t) ok &= JS_DefineProperty(cx, tmp, "fontSize", int32_to_jsval(cx, t._fontSize), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "fontAlignmentH", int32_to_jsval(cx, t._alignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + ok &= JS_DefineProperty(cx, tmp, "fontAlignmentH", int32_to_jsval(cx, (int32_t)t._alignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); - ok &= JS_DefineProperty(cx, tmp, "fontAlignmentV", int32_to_jsval(cx, t._vertAlignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); + ok &= JS_DefineProperty(cx, tmp, "fontAlignmentV", int32_to_jsval(cx, (int32_t)t._vertAlignment), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); ok &= JS_DefineProperty(cx, tmp, "fontFillColor", cccolor3b_to_jsval(cx, t._fontFillColor), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); @@ -2232,8 +2245,8 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) // defaul values const char * defautlFontName = "Arial"; const int defaultFontSize = 32; - TextAlignment defaultTextAlignment = kTextAlignmentLeft; - VerticalTextAlignment defaultTextVAlignment = kVerticalTextAlignmentTop; + Label::HAlignment defaultTextAlignment = Label::HAlignment::LEFT; + Label::VAlignment defaultTextVAlignment = Label::VAlignment::TOP; // by default shadow and stroke are off out->_shadow._shadowEnabled = false; @@ -2278,7 +2291,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) JS_GetProperty(cx, jsobj, "fontAlignmentH", &jsr); double fontAlign = 0.0; JS_ValueToNumber(cx, jsr, &fontAlign); - out->_alignment = (TextAlignment)(int)fontAlign; + out->_alignment = (Label::HAlignment)(int)fontAlign; } else { @@ -2292,7 +2305,7 @@ JSBool jsval_to_FontDefinition( JSContext *cx, jsval vp, FontDefinition *out ) JS_GetProperty(cx, jsobj, "fontAlignmentV", &jsr); double fontAlign = 0.0; JS_ValueToNumber(cx, jsr, &fontAlign); - out->_vertAlignment = (VerticalTextAlignment)(int)fontAlign; + out->_vertAlignment = (Label::VAlignment)(int)fontAlign; } else { diff --git a/scripting/javascript/bindings/generated b/scripting/javascript/bindings/generated index 1f1832e138..395154e3b6 160000 --- a/scripting/javascript/bindings/generated +++ b/scripting/javascript/bindings/generated @@ -1 +1 @@ -Subproject commit 1f1832e138a639b764e23efb9b9752dc667d8d43 +Subproject commit 395154e3b6545f4b778d109fcefa25406a24f5d3 diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index a299746539..d8e2e29f20 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -22,14 +22,14 @@ static void removeSelector(std::string &str) { } } -SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, +SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; removeSelector(this->callBackProp); return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } -SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBControlSelector(Object * pTarget, +SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(Object * pTarget, const char * pSelectorName) { this->callBackProp = pSelectorName; @@ -273,7 +273,7 @@ JSBool js_cocos2dx_CCBReader_createSceneWithNodeGraphFromFile(JSContext *cx, uin JSBool js_CocosBuilder_create(JSContext *cx, uint32_t argc, jsval *vp) { - NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::sharedNodeLoaderLibrary(); + NodeLoaderLibrary * ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); ccNodeLoaderLibrary->registerNodeLoader("", JSLayerLoader::loader()); diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.h b/scripting/javascript/bindings/js_bindings_ccbreader.h index 77e77eb813..ff4b241619 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.h +++ b/scripting/javascript/bindings/js_bindings_ccbreader.h @@ -27,10 +27,10 @@ public: virtual ~CCBScriptCallbackProxy() {} CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(CCBScriptCallbackProxy, create); - virtual cocos2d::SEL_MenuHandler onResolveCCBMenuItemSelector(cocos2d::Object * pTarget, + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::Object * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBControlSelector(cocos2d::Object * pTarget, + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::Object * pTarget, const char * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::Object * pTarget, const char * pMemberVariableName, cocos2d::Node * pNode); diff --git a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj index 026ed86fac..e6fff0dc38 100644 --- a/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj +++ b/scripting/javascript/bindings/proj.win32/libJSBinding.vcxproj @@ -125,9 +125,9 @@ Level3 Disabled - WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;_LIB;DEBUG;COCOS2D_DEBUG=1;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) - 4068;4101;4800;4251;4996;4244;%(DisableSpecificWarnings) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true false
@@ -148,9 +148,9 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\sqlite3\libraries\win32\*.*" "$(O MaxSpeed true true - WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;%(PreprocessorDefinitions) + WIN32;_WINDOWS;NDEBUG;_LIB;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..;$(ProjectDir)..\..\spidermonkey-win32\include;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;$(ProjectDir)..\..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\extensions\LocalStorage;$(ProjectDir)..\..\..\..\extensions\network;%(AdditionalIncludeDirectories) - 4068;4101;4800;4251;4996;4244;%(DisableSpecificWarnings) + 4068;4101;4800;4251;4244;%(DisableSpecificWarnings) true
diff --git a/scripting/lua/cocos2dx_support/CCBProxy.cpp b/scripting/lua/cocos2dx_support/CCBProxy.cpp index 60fe9677b2..41eb542fa0 100644 --- a/scripting/lua/cocos2dx_support/CCBProxy.cpp +++ b/scripting/lua/cocos2dx_support/CCBProxy.cpp @@ -27,7 +27,7 @@ CCBReader* CCBProxy::createCCBReader() { - NodeLoaderLibrary *ccNodeLoaderLibrary = NodeLoaderLibrary::sharedNodeLoaderLibrary(); + NodeLoaderLibrary *ccNodeLoaderLibrary = NodeLoaderLibrary::getInstance(); ccNodeLoaderLibrary->registerNodeLoader("", CCBLayerLoader::loader()); diff --git a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 31541bd2fb..7e708e27c6 100644 --- a/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/scripting/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -7314b8a835d96e154da442ff16a7325c94edd276 \ No newline at end of file +fa9c4583d202c4fd4af5f97259eb3cac2bfbdec1 \ No newline at end of file diff --git a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp index 04c556bb4e..465275193f 100644 --- a/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp +++ b/scripting/lua/cocos2dx_support/LuaScriptHandlerMgr.cpp @@ -320,12 +320,13 @@ int tolua_Cocos2d_registerScriptTouchHandler00(lua_State* tolua_S) LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S,2,0)); bool isMultiTouches = ((bool) tolua_toboolean(tolua_S,3,false)); int priority = ((int) tolua_tonumber(tolua_S,4,0)); - //the fifth arg(swallowsTouches) is not set in Layer,default true, - ccTouchesMode touchesMode = kTouchesAllAtOnce; + bool swallowTouches = (bool)tolua_toboolean(tolua_S, 5, 0); + Touch::DispatchMode touchesMode = Touch::DispatchMode::ALL_AT_ONCE; if (!isMultiTouches) - touchesMode = kTouchesOneByOne; + touchesMode = Touch::DispatchMode::ONE_BY_ONE; self->setTouchMode(touchesMode); self->setTouchPriority(priority); + self->setSwallowsTouches(swallowTouches); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, ScriptHandlerMgr::kTouchesHandler); } return 0; diff --git a/scripting/lua/proj.win32/liblua.vcxproj b/scripting/lua/proj.win32/liblua.vcxproj index bd49613e75..244e64191c 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj +++ b/scripting/lua/proj.win32/liblua.vcxproj @@ -63,7 +63,7 @@ Disabled $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks MultiThreadedDebugDLL @@ -75,7 +75,7 @@ Level3 EditAndContinue - 4996;4800;4267;4251;4244;%(DisableSpecificWarnings) + 4800;4267;4251;4244;%(DisableSpecificWarnings) true @@ -95,7 +95,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" MaxSpeed true $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true @@ -106,7 +106,7 @@ xcopy /Y /Q "$(ProjectDir)..\luajit\win32\*.*" "$(OutDir)" Level3 ProgramDatabase - 4996;4800;4267;4251;4244;%(DisableSpecificWarnings) + 4800;4267;4251;4244;%(DisableSpecificWarnings) true diff --git a/scripting/lua/script/AudioEngine.lua b/scripting/lua/script/AudioEngine.lua index 599f21fcd2..07bcccfb3a 100644 --- a/scripting/lua/script/AudioEngine.lua +++ b/scripting/lua/script/AudioEngine.lua @@ -1,29 +1,29 @@ --Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects. local M = {} -local sharedEngine = SimpleAudioEngine:sharedEngine() +local audioEngineInstance = SimpleAudioEngine:getInstance() function M.stopAllEffects() - sharedEngine:stopAllEffects() + audioEngineInstance:stopAllEffects() end function M.getMusicVolume() - return sharedEngine:getBackgroundMusicVolume() + return audioEngineInstance:getBackgroundMusicVolume() end function M.isMusicPlaying() - return sharedEngine:isBackgroundMusicPlaying() + return audioEngineInstance:isBackgroundMusicPlaying() end function M.getEffectsVolume() - return sharedEngine:getEffectsVolume() + return audioEngineInstance:getEffectsVolume() end function M.setMusicVolume(volume) - sharedEngine:setBackgroundMusicVolume(volume) + audioEngineInstance:setBackgroundMusicVolume(volume) end function M.stopEffect(handle) - sharedEngine:stopEffect(handle) + audioEngineInstance:stopEffect(handle) end function M.stopMusic(isReleaseData) @@ -31,7 +31,7 @@ function M.stopMusic(isReleaseData) if nil ~= isReleaseData then releaseDataValue = isReleaseData end - sharedEngine:stopBackgroundMusic(releaseDataValue) + audioEngineInstance:stopBackgroundMusic(releaseDataValue) end function M.playMusic(filename, isLoop) @@ -39,19 +39,19 @@ function M.playMusic(filename, isLoop) if nil ~= isLoop then loopValue = isLoop end - sharedEngine:playBackgroundMusic(filename, loopValue) + audioEngineInstance:playBackgroundMusic(filename, loopValue) end function M.pauseAllEffects() - sharedEngine:pauseAllEffects() + audioEngineInstance:pauseAllEffects() end function M.preloadMusic(filename) - sharedEngine:preloadBackgroundMusic(filename) + audioEngineInstance:preloadBackgroundMusic(filename) end function M.resumeMusic() - sharedEngine:resumeBackgroundMusic() + audioEngineInstance:resumeBackgroundMusic() end function M.playEffect(filename, isLoop) @@ -59,43 +59,43 @@ function M.playEffect(filename, isLoop) if nil ~= isLoop then loopValue = isLoop end - return sharedEngine:playEffect(filename, loopValue) + return audioEngineInstance:playEffect(filename, loopValue) end function M.rewindMusic() - sharedEngine:rewindBackgroundMusic() + audioEngineInstance:rewindBackgroundMusic() end function M.willPlayMusic() - return sharedEngine:willPlayBackgroundMusic() + return audioEngineInstance:willPlayBackgroundMusic() end function M.unloadEffect(filename) - sharedEngine:unloadEffect(filename) + audioEngineInstance:unloadEffect(filename) end function M.preloadEffect(filename) - sharedEngine:preloadEffect(filename) + audioEngineInstance:preloadEffect(filename) end function M.setEffectsVolume(volume) - sharedEngine:setEffectsVolume(volume) + audioEngineInstance:setEffectsVolume(volume) end function M.pauseEffect(handle) - sharedEngine:pauseEffect(handle) + audioEngineInstance:pauseEffect(handle) end function M.resumeAllEffects(handle) - sharedEngine:resumeAllEffects() + audioEngineInstance:resumeAllEffects() end function M.pauseMusic() - sharedEngine:pauseBackgroundMusic() + audioEngineInstance:pauseBackgroundMusic() end function M.resumeEffect(handle) - sharedEngine:resumeEffect(handle) + audioEngineInstance:resumeEffect(handle) end local modename = "AudioEngine" diff --git a/scripting/lua/script/Deprecated.lua b/scripting/lua/script/Deprecated.lua index b9e326e025..e1d09a6de4 100644 --- a/scripting/lua/script/Deprecated.lua +++ b/scripting/lua/script/Deprecated.lua @@ -1,13 +1,9 @@ - +--tip local function deprecatedTip(old_name,new_name) print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********") end -local function addHandleOfControlEvent(self,func,controlEvent) - deprecatedTip("addHandleOfControlEvent","registerControlEventHandler") - self:registerControlEventHandler(func,controlEvent) -end -rawset(CCControl,"addHandleOfControlEvent",addHandleOfControlEvent) +--functions of _G will be deprecated begin local function ccpLineIntersect(a,b,c,d,s,t) deprecatedTip("ccpLineIntersect","CCPoint:isLineIntersect") return CCPoint:isLineIntersect(a,b,c,d,s,t) @@ -93,7 +89,6 @@ local function ccpRPerp(pt) end rawset(_G,"ccpRPerp",ccpRPerp) ---no test local function ccpProject(pt1,pt2) deprecatedTip("ccpProject","CCPoint:project") return pt1:project(pt2) @@ -137,8 +132,8 @@ end rawset(_G,"ccpDistance",ccpDistance) local function ccpNormalize(pt) - deprecatedTip("ccpNormalize","CCPoint:getDistance") - return pt:getDistance() + deprecatedTip("ccpNormalize","CCPoint:normalize") + return pt:normalize() end rawset(_G,"ccpNormalize",ccpNormalize) @@ -215,245 +210,566 @@ local function ccpIntersectPoint(pt1,pt2,pt3,pt4) end rawset(_G,"ccpIntersectPoint",ccpIntersectPoint) +local function ccc3(r,g,b) + deprecatedTip("ccc3(r,g,b)","ccColor3B(r,g,b)") + return ccColor3B(r,g,b) +end +rawset(_G,"ccc3",ccc3) -local function sharedOpenGLView() +local function ccc4(r,g,b,a) + deprecatedTip("ccc4(r,g,b,a)","Color4B(r,g,b,a)") + return Color4B(r,g,b,a) +end +rawset(_G,"ccc4",ccc4) + +local function ccc4FFromccc3B(color3B) + deprecatedTip("ccc4FFromccc3B(color3B)","Color4F(color3B.r / 255.0,color3B.g / 255.0,color3B.b / 255.0,1.0)") + return Color4F(color3B.r/255.0, color3B.g/255.0, color3B.b/255.0, 1.0) +end +rawset(_G,"ccc4FFromccc3B",ccc4FFromccc3B) + +local function ccc4f(r,g,b,a) + deprecatedTip("ccc4f(r,g,b,a)","Color4F(r,g,b,a)") + return Color4F(r,g,b,a) +end +rawset(_G,"ccc4f",ccc4f) + +local function ccc4FFromccc4B(color4B) + deprecatedTip("ccc4FFromccc4B(color4B)","Color4F(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0)") + return Color4F(color4B.r/255.0, color4B.g/255.0, color4B.b/255.0, color4B.a/255.0) +end +rawset(_G,"ccc4FFromccc4B",ccc4FFromccc4B) + +local function ccc4FEqual(a,b) + deprecatedTip("ccc4FEqual(a,b)","a:equals(b)") + return a:equals(b) +end +rawset(_G,"ccc4FEqual",ccc4FEqual) + +local function vertex2(x,y) + deprecatedTip("vertex2(x,y)","Vertex2F(x,y)") + return Vertex2F(x,y) +end +rawset(_G,"vertex2",vertex2) + +local function vertex3(x,y,z) + deprecatedTip("vertex3(x,y,z)","Vertex3F(x,y,z)") + return Vertex3F(x,y,z) +end +rawset(_G,"vertex3",vertex3) + +local function tex2(u,v) + deprecatedTip("tex2(u,v)","Tex2F(u,v)") + return Tex2F(u,v) +end +rawset(_G,"tex2",tex2) + +local function ccc4BFromccc4F(color4F) + deprecatedTip("ccc4BFromccc4F(color4F)","Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0)") + return Color4B(color4F.r * 255.0, color4F.g * 255.0, color4F.b * 255.0, color4B.a * 255.0) +end +rawset(_G,"ccc4BFromccc4F",ccc4BFromccc4F) + +local function ccColor3BDeprecated() + deprecatedTip("ccColor3B","Color3B") + return Color3B +end +_G["ccColor3B"] = ccColor3BDeprecated() + +local function ccColor4BDeprecated() + deprecatedTip("ccColor4B","Color4B") + return Color4B +end +_G["ccColor4B"] = ccColor4BDeprecated() + +local function ccColor4FDeprecated() + deprecatedTip("ccColor4F","Color4F") + return Color4F +end +_G["ccColor4F"] = ccColor4FDeprecated() + +local function ccVertex2FDeprecated() + deprecatedTip("ccVertex2F","Vertex2F") + return Vertex2F +end +_G["ccVertex2F"] = ccVertex2FDeprecated() + +local function ccVertex3FDeprecated() + deprecatedTip("ccVertex3F","Vertex3F") + return Vertex3F +end +_G["ccVertex3F"] = ccVertex3FDeprecated() + +local function ccTex2FDeprecated() + deprecatedTip("ccTex2F","Tex2F") + return Tex2F +end +_G["ccTex2F"] = ccTex2FDeprecated() + +local function ccPointSpriteDeprecated() + deprecatedTip("ccPointSprite","PointSprite") + return PointSprite +end +_G["ccPointSprite"] = ccPointSpriteDeprecated() + +local function ccQuad2Deprecated() + deprecatedTip("ccQuad2","Quad2") + return Quad2 +end +_G["ccQuad2"] = ccQuad2Deprecated() + +local function ccQuad3Deprecated() + deprecatedTip("ccQuad3","Quad3") + return Quad3 +end +_G["ccQuad3"] = ccQuad3Deprecated() + +local function ccV2FC4BT2FDeprecated() + deprecatedTip("ccV2F_C4B_T2F","V2F_C4B_T2F") + return V2F_C4B_T2F +end +_G["ccV2F_C4B_T2F"] = ccV2FC4BT2FDeprecated() + + +local function ccV2FC4FT2FDeprecated() + deprecatedTip("ccV2F_C4F_T2F","V2F_C4F_T2F") + return V2F_C4F_T2F +end +_G["ccV2F_C4F_T2F"] = ccV2FC4FT2FDeprecated() + +local function ccV3FC4BT2FDeprecated() + deprecatedTip("ccV3F_C4B_T2F","V3F_C4B_T2F") + return V3F_C4B_T2F +end +_G["ccV3F_C4B_T2F"] = ccV3FC4BT2FDeprecated() + +local function ccV2FC4BT2FQuadDeprecated() + deprecatedTip("ccV2F_C4B_T2F_Quad","V2F_C4B_T2F_Quad") + return V2F_C4B_T2F_Quad +end +_G["ccV2F_C4B_T2F_Quad"] = ccV2FC4BT2FQuadDeprecated() + +local function ccV3FC4BT2FQuadDeprecated() + deprecatedTip("ccV3F_C4B_T2F_Quad","V3F_C4B_T2F_Quad") + return V3F_C4B_T2F_Quad +end +_G["ccV3F_C4B_T2F_Quad"] = ccV3FC4BT2FQuadDeprecated() + +local function ccV2FC4FT2FQuadDeprecated() + deprecatedTip("ccV2F_C4F_T2F_Quad","V2F_C4F_T2F_Quad") + return V2F_C4F_T2F_Quad +end +_G["ccV2F_C4F_T2F_Quad"] = ccV2FC4FT2FQuadDeprecated() + +local function ccBlendFuncDeprecated() + deprecatedTip("ccBlendFunc","BlendFunc") + return BlendFunc +end +_G["ccBlendFunc"] = ccBlendFuncDeprecated() + +local function ccT2FQuadDeprecated() + deprecatedTip("ccT2F_Quad","T2F_Quad") + return T2F_Quad +end +_G["ccT2F_Quad"] = ccT2FQuadDeprecated() + +local function ccAnimationFrameDataDeprecated() + deprecatedTip("ccAnimationFrameData","AnimationFrameData") + return AnimationFrameData +end +_G["ccAnimationFrameData"] = ccAnimationFrameDataDeprecated() + +local function CCCallFuncNDeprecated( ) + deprecatedTip("CCCallFuncN","CCCallFunc") + return CCCallFunc +end +_G["CCCallFuncN"] = CCCallFuncNDeprecated() +--functions of _G will be deprecated end + + +--functions of CCControl will be deprecated end +local CCControlDeprecated = { } +function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent) + deprecatedTip("addHandleOfControlEvent","registerControlEventHandler") + print("come in addHandleOfControlEvent") + self:registerControlEventHandler(func,controlEvent) +end +rawset(CCControl,"addHandleOfControlEvent",CCControlDeprecated.addHandleOfControlEvent) +--functions of CCControl will be deprecated end + + +--functions of CCEGLView will be deprecated end +local CCEGLViewDeprecated = { } +function CCEGLViewDeprecated.sharedOpenGLView() deprecatedTip("CCEGLView:sharedOpenGLView","CCEGLView:getInstance") return CCEGLView:getInstance() end -rawset(CCEGLView,"sharedOpenGLView",sharedOpenGLView) +rawset(CCEGLView,"sharedOpenGLView",CCEGLViewDeprecated.sharedOpenGLView) +--functions of CCFileUtils will be deprecated end -local function sharedFileUtils() + +--functions of CCFileUtils will be deprecated end +local CCFileUtilsDeprecated = { } +function CCFileUtilsDeprecated.sharedFileUtils() deprecatedTip("CCFileUtils:sharedFileUtils","CCFileUtils:getInstance") return CCFileUtils:getInstance() end -rawset(CCFileUtils,"sharedFileUtils",sharedFileUtils) +rawset(CCFileUtils,"sharedFileUtils",CCFileUtilsDeprecated.sharedFileUtils) -local function purgeFileUtils() +function CCFileUtilsDeprecated.purgeFileUtils() deprecatedTip("CCFileUtils:purgeFileUtils","CCFileUtils:destroyInstance") return CCFileUtils:destroyInstance() end -rawset(CCFileUtils,"purgeFileUtils",purgeFileUtils) +rawset(CCFileUtils,"purgeFileUtils",CCFileUtilsDeprecated.purgeFileUtils) +--functions of CCFileUtils will be deprecated end -local function sharedApplication() + +--functions of CCApplication will be deprecated end +local CCApplicationDeprecated = { } +function CCApplicationDeprecated.sharedApplication() deprecatedTip("CCApplication:sharedApplication","CCApplication:getInstance") return CCApplication:getInstance() end -rawset(CCApplication,"sharedApplication",sharedApplication) +rawset(CCApplication,"sharedApplication",CCApplicationDeprecated.sharedApplication) +--functions of CCApplication will be deprecated end -local function sharedDirector() + +--functions of CCDirector will be deprecated end +local CCDirectorDeprecated = { } +function CCDirectorDeprecated.sharedDirector() deprecatedTip("CCDirector:sharedDirector","CCDirector:getInstance") return CCDirector:getInstance() end -rawset(CCDirector,"sharedDirector",sharedDirector) +rawset(CCDirector,"sharedDirector",CCDirectorDeprecated.sharedDirector) +--functions of CCDirector will be deprecated end -local function sharedUserDefault() + +--functions of CCUserDefault will be deprecated end +local CCUserDefaultDeprecated = { } +function CCUserDefaultDeprecated.sharedUserDefault() deprecatedTip("CCUserDefault:sharedUserDefault","CCUserDefault:getInstance") return CCUserDefault:getInstance() end -rawset(CCUserDefault,"sharedUserDefault",sharedUserDefault) +rawset(CCUserDefault,"sharedUserDefault",CCUserDefaultDeprecated.sharedUserDefault) -local function purgeSharedUserDefault() +function CCUserDefaultDeprecated.purgeSharedUserDefault() deprecatedTip("CCUserDefault:purgeSharedUserDefault","CCUserDefault:destroyInstance") return CCUserDefault:destroyInstance() end -rawset(CCUserDefault,"purgeSharedUserDefault",purgeSharedUserDefault) +rawset(CCUserDefault,"purgeSharedUserDefault",CCUserDefaultDeprecated.purgeSharedUserDefault) +--functions of CCUserDefault will be deprecated end -local function sharedNotificationCenter() +--functions of CCNotificationCenter will be deprecated end +local CCNotificationCenterDeprecated = { } +function CCNotificationCenterDeprecated.sharedNotificationCenter() deprecatedTip("CCNotificationCenter:sharedNotificationCenter","CCNotificationCenter:getInstance") return CCNotificationCenter:getInstance() end -rawset(CCNotificationCenter,"sharedNotificationCenter",sharedNotificationCenter) +rawset(CCNotificationCenter,"sharedNotificationCenter",CCNotificationCenterDeprecated.sharedNotificationCenter) -local function purgeNotificationCenter() +function CCNotificationCenterDeprecated.purgeNotificationCenter() deprecatedTip("CCNotificationCenter:purgeNotificationCenter","CCNotificationCenter:destroyInstance") return CCNotificationCenter:destroyInstance() end -rawset(CCNotificationCenter,"purgeNotificationCenter",purgeNotificationCenter) +rawset(CCNotificationCenter,"purgeNotificationCenter",CCNotificationCenterDeprecated.purgeNotificationCenter) +--functions of CCNotificationCenter will be deprecated end -local function sharedTextureCache() + +--functions of CCTextureCache will be deprecated begin +local CCTextureCacheDeprecated = { } +function CCTextureCacheDeprecated.sharedTextureCache() deprecatedTip("CCTextureCache:sharedTextureCache","CCTextureCache:getInstance") return CCTextureCache:getInstance() end -rawset(CCTextureCache,"sharedTextureCache",sharedTextureCache) +rawset(CCTextureCache,"sharedTextureCache",CCTextureCacheDeprecated.sharedTextureCache) -local function purgeSharedTextureCache() +function CCTextureCacheDeprecated.purgeSharedTextureCache() deprecatedTip("CCTextureCache:purgeSharedTextureCache","CCTextureCache:destroyInstance") return CCTextureCache:destroyInstance() end -rawset(CCTextureCache,"purgeSharedTextureCache",purgeSharedTextureCache) +rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) +--functions of CCTextureCache will be deprecated end -local function sharedSpriteFrameCache() - deprecatedTip("CCSpriteFrameCache:sharedSpriteFrameCache","CCSpriteFrameCache:getInstance") - return CCSpriteFrameCache:getInstance() -end -rawset(CCSpriteFrameCache,"sharedSpriteFrameCache",sharedSpriteFrameCache) -local function purgeSharedSpriteFrameCache() - deprecatedTip("CCSpriteFrameCache:purgeSharedSpriteFrameCache","CCSpriteFrameCache:destroyInstance") - return CCSpriteFrameCache:destroyInstance() -end -rawset(CCSpriteFrameCache,"purgeSharedSpriteFrameCache",purgeSharedSpriteFrameCache) - -local function vertex(self,pt) +--functions of CCGrid3DAction will be deprecated begin +local CCGrid3DActionDeprecated = { } +function CCGrid3DActionDeprecated.vertex(self,pt) deprecatedTip("vertex","CCGrid3DAction:getVertex") return self:getVertex(pt) end -rawset(CCGrid3DAction,"vertex",vertex) +rawset(CCGrid3DAction,"vertex",CCGrid3DActionDeprecated.vertex) -local function originalVertex(self,pt) +function CCGrid3DActionDeprecated.originalVertex(self,pt) deprecatedTip("originalVertex","CCGrid3DAction:getOriginalVertex") return self:getOriginalVertex(pt) end -rawset(CCGrid3DAction,"originalVertex",originalVertex) +rawset(CCGrid3DAction,"originalVertex",CCGrid3DActionDeprecated.originalVertex) +--functions of CCGrid3DAction will be deprecated end -local function tile(self,pt) + +--functions of CCTiledGrid3DAction will be deprecated begin +local CCTiledGrid3DActionDeprecated = { } +function CCTiledGrid3DActionDeprecated.tile(self,pt) deprecatedTip("tile","CCTiledGrid3DAction:getTile") return self:getTile(pt) end -rawset(CCTiledGrid3DAction,"tile",tile) +rawset(CCTiledGrid3DAction,"tile",CCTiledGrid3DActionDeprecated.tile) -local function originalTile(self,pt) +function CCTiledGrid3DActionDeprecated.originalTile(self,pt) deprecatedTip("originalTile","CCTiledGrid3DAction:getOriginalTile") return self:getOriginalTile(pt) end -rawset(CCTiledGrid3DAction,"originalTile",originalTile) +rawset(CCTiledGrid3DAction,"originalTile",CCTiledGrid3DActionDeprecated.originalTile) +--functions of CCTiledGrid3DAction will be deprecated end -local function sharedAnimationCache() + +--functions of CCAnimationCache will be deprecated begin +local CCAnimationCacheDeprecated = { } +function CCAnimationCacheDeprecated.sharedAnimationCache() deprecatedTip("CCAnimationCache:sharedAnimationCache","CCAnimationCache:getInstance") return CCAnimationCache:getInstance() end -rawset(CCAnimationCache,"sharedAnimationCache",sharedAnimationCache) +rawset(CCAnimationCache,"sharedAnimationCache",CCAnimationCacheDeprecated.sharedAnimationCache) -local function purgeSharedAnimationCache() +function CCAnimationCacheDeprecated.purgeSharedAnimationCache() deprecatedTip("CCAnimationCache:purgeSharedAnimationCache","CCAnimationCache:destroyInstance") return CCAnimationCache:destroyInstance() end -rawset(CCAnimationCache,"purgeSharedAnimationCache",purgeSharedAnimationCache) +rawset(CCAnimationCache,"purgeSharedAnimationCache",CCAnimationCacheDeprecated.purgeSharedAnimationCache) +--functions of CCAnimationCache will be deprecated end -local function boundingBox(self) + +--functions of CCNode will be deprecated begin +local CCNodeDeprecated = { } +function CCNodeDeprecated.boundingBox(self) deprecatedTip("CCNode:boundingBox","CCNode:getBoundingBox") return self:getBoundingBox() end -rawset(CCNode,"boundingBox",boundingBox) +rawset(CCNode,"boundingBox",CCNodeDeprecated.boundingBox) -local function numberOfRunningActions(self) +function CCNodeDeprecated.numberOfRunningActions(self) deprecatedTip("CCNode:numberOfRunningActions","CCNode:getNumberOfRunningActions") return self:getNumberOfRunningActions() end -rawset(CCNode,"numberOfRunningActions",numberOfRunningActions) +rawset(CCNode,"numberOfRunningActions",CCNodeDeprecated.numberOfRunningActions) +--functions of CCNode will be deprecated end -local function stringForFormat(self) + +--functions of CCTexture2D will be deprecated begin +local CCTexture2DDeprecated = { } +function CCTexture2DDeprecated.stringForFormat(self) deprecatedTip("Texture2D:stringForFormat","Texture2D:getStringForFormat") return self:getStringForFormat() end -rawset(CCTexture2D,"stringForFormat",stringForFormat) +rawset(CCTexture2D,"stringForFormat",CCTexture2DDeprecated.stringForFormat) -local function bitsPerPixelForFormat(self) +function CCTexture2DDeprecated.bitsPerPixelForFormat(self) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat() end -rawset(CCTexture2D,"bitsPerPixelForFormat",bitsPerPixelForFormat) +rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) -local function bitsPerPixelForFormat(self,pixelFormat) +function CCTexture2DDeprecated.bitsPerPixelForFormat(self,pixelFormat) deprecatedTip("Texture2D:bitsPerPixelForFormat","Texture2D:getBitsPerPixelForFormat") return self:getBitsPerPixelForFormat(pixelFormat) end -rawset(CCTexture2D,"bitsPerPixelForFormat",bitsPerPixelForFormat) +rawset(CCTexture2D,"bitsPerPixelForFormat",CCTexture2DDeprecated.bitsPerPixelForFormat) -local function defaultAlphaPixelFormat(self) +function CCTexture2DDeprecated.defaultAlphaPixelFormat(self) deprecatedTip("Texture2D:defaultAlphaPixelFormat","Texture2D:getDefaultAlphaPixelFormat") return self:getDefaultAlphaPixelFormat() end -rawset(CCTexture2D,"defaultAlphaPixelFormat",defaultAlphaPixelFormat) +rawset(CCTexture2D,"defaultAlphaPixelFormat",CCTexture2DDeprecated.defaultAlphaPixelFormat) +--functions of CCTexture2D will be deprecated end -local function spriteFrameByName(self,szName) + +--functions of CCSpriteFrameCache will be deprecated begin +local CCSpriteFrameCacheDeprecated = { } +function CCSpriteFrameCacheDeprecated.spriteFrameByName(self,szName) deprecatedTip("CCSpriteFrameCache:spriteFrameByName","CCSpriteFrameCache:getSpriteFrameByName") return self:getSpriteFrameByName(szName) end -rawset(CCSpriteFrameCache,"spriteFrameByName",spriteFrameByName) +rawset(CCSpriteFrameCache,"spriteFrameByName",CCSpriteFrameCacheDeprecated.spriteFrameByName) -local function timerWithScriptHandler(handler,seconds) +function CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache() + deprecatedTip("CCSpriteFrameCache:sharedSpriteFrameCache","CCSpriteFrameCache:getInstance") + return CCSpriteFrameCache:getInstance() +end +rawset(CCSpriteFrameCache,"sharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.sharedSpriteFrameCache) + +function CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache() + deprecatedTip("CCSpriteFrameCache:purgeSharedSpriteFrameCache","CCSpriteFrameCache:destroyInstance") + return CCSpriteFrameCache:destroyInstance() +end +rawset(CCSpriteFrameCache,"purgeSharedSpriteFrameCache",CCSpriteFrameCacheDeprecated.purgeSharedSpriteFrameCache) +--functions of CCSpriteFrameCache will be deprecated end + + +--functions of CCTimer will be deprecated begin +local CCTimerDeprecated = { } +function CCTimerDeprecated.timerWithScriptHandler(handler,seconds) deprecatedTip("CCTimer:timerWithScriptHandler","CCTimer:createWithScriptHandler") return CCTimer:createWithScriptHandler(handler,seconds) end -rawset(CCTimer,"timerWithScriptHandler",timerWithScriptHandler) +rawset(CCTimer,"timerWithScriptHandler",CCTimerDeprecated.timerWithScriptHandler) -local function numberOfRunningActionsInTarget(self,target) +function CCTimerDeprecated.numberOfRunningActionsInTarget(self,target) deprecatedTip("CCActionManager:numberOfRunningActionsInTarget","CCActionManager:getNumberOfRunningActionsInTarget") return self:getNumberOfRunningActionsInTarget(target) end -rawset(CCTimer,"numberOfRunningActionsInTarget",numberOfRunningActionsInTarget) +rawset(CCTimer,"numberOfRunningActionsInTarget",CCTimerDeprecated.numberOfRunningActionsInTarget) +--functions of CCTimer will be deprecated end -local function fontSize() + +--functions of CCMenuItemFont will be deprecated begin +local CCMenuItemFontDeprecated = { } +function CCMenuItemFontDeprecated.fontSize() deprecatedTip("CCMenuItemFont:fontSize","CCMenuItemFont:getFontSize") return CCMenuItemFont:getFontSize() end -rawset(CCMenuItemFont,"fontSize",fontSize) +rawset(CCMenuItemFont,"fontSize",CCMenuItemFontDeprecated.fontSize) -local function fontName() +function CCMenuItemFontDeprecated.fontName() deprecatedTip("CCMenuItemFont:fontName","CCMenuItemFont:getFontName") return CCMenuItemFont:getFontName() end -rawset(CCMenuItemFont,"fontName",fontName) +rawset(CCMenuItemFont,"fontName",CCMenuItemFontDeprecated.fontName) -local function fontSizeObj(self) +function CCMenuItemFontDeprecated.fontSizeObj(self) deprecatedTip("CCMenuItemFont:fontSizeObj","CCMenuItemFont:getFontSizeObj") return self:getFontSizeObj() end -rawset(CCMenuItemFont,"fontSizeObj",fontSizeObj) +rawset(CCMenuItemFont,"fontSizeObj",CCMenuItemFontDeprecated.fontSizeObj) -local function fontNameObj(self) +function CCMenuItemFontDeprecated.fontNameObj(self) deprecatedTip("CCMenuItemFont:fontNameObj","CCMenuItemFont:getFontNameObj") return self:getFontNameObj() end -rawset(CCMenuItemFont,"fontNameObj",fontNameObj) +rawset(CCMenuItemFont,"fontNameObj",CCMenuItemFontDeprecated.fontNameObj) +--functions of CCMenuItemFont will be deprecated end -local function selectedItem(self) + +--functions of CCMenuItemToggle will be deprecated begin +local CCMenuItemToggleDeprecated = { } +function CCMenuItemToggleDeprecated.selectedItem(self) deprecatedTip("CCMenuItemToggle:selectedItem","CCMenuItemToggle:getSelectedItem") return self:getSelectedItem() end -rawset(CCMenuItemToggle,"selectedItem",selectedItem) +rawset(CCMenuItemToggle,"selectedItem",CCMenuItemToggleDeprecated.selectedItem) +--functions of CCMenuItemToggle will be deprecated end -local function tileAt(self,pos) + +--functions of CCTileMapAtlas will be deprecated begin +local CCTileMapAtlasDeprecated = { } +function CCTileMapAtlasDeprecated.tileAt(self,pos) deprecatedTip("CCTileMapAtlas:tileAt","CCTileMapAtlas:getTileAt") return self:getTileAt(pos) end -rawset(CCTileMapAtlas,"tileAt",tileAt) +rawset(CCTileMapAtlas,"tileAt",CCTileMapAtlasDeprecated.tileAt) +--functions of CCTileMapAtlas will be deprecated end -local function tileAt(self,tileCoordinate) + +--functions of CCTMXLayer will be deprecated begin +local CCTMXLayerDeprecated = { } +function CCTMXLayerDeprecated.tileAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileAt","CCTMXLayer:getTileAt") return self:getTileAt(tileCoordinate) end -rawset(CCTMXLayer,"tileAt",tileAt) +rawset(CCTMXLayer,"tileAt",CCTMXLayerDeprecated.tileAt) -local function tileGIDAt(self,tileCoordinate) +function CCTMXLayerDeprecated.tileGIDAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:tileGIDAt","CCTMXLayer:getTileGIDAt") return self:getTileGIDAt(tileCoordinate) end -rawset(CCTMXLayer,"tileGIDAt",tileGIDAt) +rawset(CCTMXLayer,"tileGIDAt",CCTMXLayerDeprecated.tileGIDAt) -local function positionAt(self,tileCoordinate) +function CCTMXLayerDeprecated.positionAt(self,tileCoordinate) deprecatedTip("CCTMXLayer:positionAt","CCTMXLayer:getPositionAt") return self:getPositionAt(tileCoordinate) end -rawset(CCTMXLayer,"positionAt",positionAt) +rawset(CCTMXLayer,"positionAt",CCTMXLayerDeprecated.positionAt) -local function propertyNamed(self,propertyName) - deprecatedTip("CCTMXLayer:propertyNamed","CCTMXLayer:getPropertyNamed") - return self:getPropertyNamed(propertyName) +function CCTMXLayerDeprecated.propertyNamed(self,propertyName) + deprecatedTip("CCTMXLayer:propertyNamed","CCTMXLayer:getProperty") + return self:getProperty(propertyName) end -rawset(CCTMXLayer,"propertyNamed",propertyNamed) +rawset(CCTMXLayer,"propertyNamed",CCTMXLayerDeprecated.propertyNamed) +--functions of CCTMXLayer will be deprecated end -local function sharedEngine() + +--functions of SimpleAudioEngine will be deprecated begin +local SimpleAudioEngineDeprecated = { } +function SimpleAudioEngineDeprecated.sharedEngine() deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance") return SimpleAudioEngine:getInstance() end -rawset(SimpleAudioEngine,"sharedEngine",sharedEngine) +rawset(SimpleAudioEngine,"sharedEngine",SimpleAudioEngineDeprecated.sharedEngine) +--functions of SimpleAudioEngine will be deprecated end -local function sendBinaryMsg(self,table,size) - deprecatedTip("sendBinaryMsg","sendBinaryStringMsg") - local strMsg = string.char(unpack(table)) - return self:sendBinaryStringMsg(strMsg) + +--functions of CCTMXTiledMap will be deprecated begin +local CCTMXTiledMapDeprecated = { } +function CCTMXTiledMapDeprecated.layerNamed(self,layerName) + deprecatedTip("CCTMXTiledMap:layerNamed","CCTMXTiledMap:getLayer") + return self:getLayer(layerName) end -rawset(WebSocket,"sendBinaryMsg",sendBinaryMsg) +rawset(CCTMXTiledMap,"layerNamed", CCTMXTiledMapDeprecated.layerNamed) + +function CCTMXTiledMapDeprecated.propertyNamed(self,propertyName) + deprecatedTip("CCTMXTiledMap:propertyNamed","CCTMXTiledMap:getProperty") + return self:getProperty(propertyName) +end +rawset(CCTMXTiledMap,"propertyNamed", CCTMXTiledMapDeprecated.propertyNamed ) + +function CCTMXTiledMapDeprecated.propertiesForGID(self,GID) + deprecatedTip("CCTMXTiledMap:propertiesForGID","CCTMXTiledMap:getPropertiesForGID") + return self:getPropertiesForGID(GID) +end +rawset(CCTMXTiledMap,"propertiesForGID", CCTMXTiledMapDeprecated.propertiesForGID) + +function CCTMXTiledMapDeprecated.objectGroupNamed(self,groupName) + deprecatedTip("CCTMXTiledMap:objectGroupNamed","CCTMXTiledMap:getObjectGroup") + return self:getObjectGroup(groupName) +end +rawset(CCTMXTiledMap,"objectGroupNamed", CCTMXTiledMapDeprecated.objectGroupNamed) +--functions of CCTMXTiledMap will be deprecated end + + +--functions of CCTMXMapInfo will be deprecated begin +local CCTMXMapInfoDeprecated = { } +function CCTMXMapInfoDeprecated.getStoringCharacters(self) + deprecatedTip("CCTMXMapInfo:getStoringCharacters","CCTMXMapInfo:isStoringCharacters") + return self:isStoringCharacters() +end +rawset(CCTMXMapInfo,"getStoringCharacters", CCTMXMapInfoDeprecated.getStoringCharacters) + +function CCTMXMapInfoDeprecated.formatWithTMXFile(infoTable,tmxFile) + deprecatedTip("CCTMXMapInfo:formatWithTMXFile","CCTMXMapInfo:create") + return CCTMXMapInfo:create(tmxFile) +end +rawset(CCTMXMapInfo,"formatWithTMXFile", CCTMXMapInfoDeprecated.formatWithTMXFile) + +function CCTMXMapInfoDeprecated.formatWithXML(infoTable,tmxString,resourcePath) + deprecatedTip("CCTMXMapInfo:formatWithXML","TMXMapInfo:createWithXML") + return CCTMXMapInfo:createWithXML(tmxString,resourcePath) +end +rawset(CCTMXMapInfo,"formatWithXML", CCTMXMapInfoDeprecated.formatWithXML) +--functions of CCTMXMapInfo will be deprecated end + + +--functions of CCTMXObject will be deprecated begin +local CCTMXObjectGroupDeprecated = { } +function CCTMXObjectGroupDeprecated.propertyNamed(self,propertyName) + deprecatedTip("CCTMXObjectGroup:propertyNamed","CCTMXObjectGroup:getProperty") + return self:getProperty(propertyName) +end +rawset(CCTMXObjectGroup,"propertyNamed", CCTMXObjectGroupDeprecated.propertyNamed) + +function CCTMXObjectGroupDeprecated.objectNamed(self, objectName) + deprecatedTip("CCTMXObjectGroup:objectNamed","CCTMXObjectGroup:getObject") + return self:getObject(objectName) +end +rawset(CCTMXObjectGroup,"objectNamed", CCTMXObjectGroupDeprecated.objectNamed) +--functions of CCTMXObject will be deprecated end + diff --git a/scripting/lua/script/DrawPrimitives.lua b/scripting/lua/script/DrawPrimitives.lua index 5ee3b9ec46..1171947577 100644 --- a/scripting/lua/script/DrawPrimitives.lua +++ b/scripting/lua/script/DrawPrimitives.lua @@ -5,13 +5,13 @@ local dp_color = { 1.0, 1.0, 1.0, 1.0 } local dp_pointSizeLocation = -1 local dp_pointSize = 1.0 -local kShader_Position_uColor = "ShaderPosition_uColor" +local SHADER_NAME_POSITION_U_COLOR = "ShaderPosition_uColor" local targetPlatform = CCApplication:getInstance():getTargetPlatform() local function lazy_init() if not dp_initialized then - dp_shader = CCShaderCache:getInstance():getProgram(kShader_Position_uColor) + dp_shader = CCShaderCache:getInstance():getProgram(SHADER_NAME_POSITION_U_COLOR) --dp_shader:retain() if nil ~= dp_shader then dp_colorLocation = gl.getUniformLocation( dp_shader:getProgram(), "u_color") @@ -51,7 +51,7 @@ function ccDrawColor4f(r,g,b,a) end function ccPointSize(pointSize) - dp_pointSize = pointSize * CCDirector:sharedDirector():getContentScaleFactor() + dp_pointSize = pointSize * CCDirector:getInstance():getContentScaleFactor() end function ccDrawColor4B(r,g,b,a) diff --git a/template/android/.classpath b/template/android/.classpath deleted file mode 100644 index a4763d1eec..0000000000 --- a/template/android/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/template/android/.project b/template/android/.project deleted file mode 100644 index 828627b7aa..0000000000 --- a/template/android/.project +++ /dev/null @@ -1,133 +0,0 @@ - - - HelloCpp - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/Javah_jni_builder.launch - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - -C ${ProjDirPath} NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt -j2 - - - org.eclipse.cdt.make.core.buildCommand - ${ProjDirPath}/ANDROID_NDK/ndk-build - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - false - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - - - Classes - 2 - COCOS2DX/samples/Cpp/HelloCpp/Classes - - - cocos2dx - 2 - COCOS2DX/cocos2dx - - - extensions - 2 - COCOS2DX/extensions - - - scripting - 2 - COCOS2DX/scripting - - - diff --git a/template/android/Classes/AppDelegate.cpp b/template/android/Classes/AppDelegate.cpp deleted file mode 100644 index 3a4b020294..0000000000 --- a/template/android/Classes/AppDelegate.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "HelloWorldScene.h" - -USING_NS_CC; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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::getInstance()->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::getInstance()->resume(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} diff --git a/template/android/Classes/AppDelegate.h b/template/android/Classes/AppDelegate.h deleted file mode 100644 index b708f4bdca..0000000000 --- a/template/android/Classes/AppDelegate.h +++ /dev/null @@ -1,38 +0,0 @@ -#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(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/android/Classes/HelloWorldScene.cpp b/template/android/Classes/HelloWorldScene.cpp deleted file mode 100644 index a75e182bba..0000000000 --- a/template/android/Classes/HelloWorldScene.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "HelloWorldScene.h" -#include "SimpleAudioEngine.h" - -using namespace cocos2d; -using namespace CocosDenshion; - -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; - } - - ///////////////////////////// - // 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", - this, - menu_selector(HelloWorld::menuCloseCallback) ); - pCloseItem->setPosition( ccp(Director::getInstance()->getWinSize().width - 20, 20) ); - - // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); - pMenu->setPosition( PointZero ); - this->addChild(pMenu, 1); - - ///////////////////////////// - // 3. add your codes below... - - // add a label shows "Hello World" - // create and initialize a label - LabelTTF* pLabel = LabelTTF::create("Hello World", "Thonburi", 34); - - // ask director the window size - Size size = Director::getInstance()->getWinSize(); - - // position the label on the center of the screen - pLabel->setPosition( ccp(size.width / 2, size.height - 20) ); - - // add the label as a child to this layer - this->addChild(pLabel, 1); - - // add "HelloWorld" splash screen" - Sprite* pSprite = Sprite::create("HelloWorld.png"); - - // position the sprite on the center of the screen - pSprite->setPosition( ccp(size.width/2, size.height/2) ); - - // add the sprite as a child to this layer - this->addChild(pSprite, 0); - - return true; -} - -void HelloWorld::menuCloseCallback(Object* pSender) -{ - Director::getInstance()->end(); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif -} diff --git a/template/android/Classes/HelloWorldScene.h b/template/android/Classes/HelloWorldScene.h deleted file mode 100644 index fab5a9f173..0000000000 --- a/template/android/Classes/HelloWorldScene.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ - -#include "cocos2d.h" - -class HelloWorld : public cocos2d::Layer -{ -public: - // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); - - // there's no 'id' in cpp, so we recommand to return the exactly class pointer - static cocos2d::Scene* scene(); - - // a selector callback - void menuCloseCallback(Object* pSender); - - // implement the "static node()" method manually - CREATE_FUNC(HelloWorld); -}; - -#endif // __HELLOWORLD_SCENE_H__ diff --git a/template/android/build_native.sh b/template/android/build_native.sh deleted file mode 100644 index c9b49ce129..0000000000 --- a/template/android/build_native.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -PROJECT_PATH=${PWD} -APPNAME="__projectname__" -COCOS2DX_ROOT="__cocos2dxroot__" -NDK_ROOT="__ndkroot__" -DIR=$(cd `dirname $0`;pwd) -APP_ROOT=$(cd $DIR/..;pwd) - -# 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 - -# ... use paths relative to current directory -APP_ANDROID_ROOT="$DIR" - -#echo "NDK_ROOT = $NDK_ROOT" -#echo "COCOS2DX_ROOT = $COCOS2DX_ROOT" -#echo "APP_ROOT = $APP_ROOT" -#echo "APP_ANDROID_ROOT = $APP_ANDROID_ROOT" - -# 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 -cp -rf "$APP_ROOT"/Resources/* "$APP_ANDROID_ROOT"/assets - -# copy icons (if they exist) -file="$APP_ANDROID_ROOT"/assets/Icon-72.png -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/res/drawable-hdpi/icon.png -fi -file="$APP_ANDROID_ROOT"/assets/Icon-48.png -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/res/drawable-mdpi/icon.png -fi -file="$APP_ANDROID_ROOT"/assets/Icon-32.png -if [ -f "$file" ]; then - cp "$file" "$APP_ANDROID_ROOT"/res/drawable-ldpi/icon.png -fi - - -if [[ "$buildexternalsfromsource" ]]; then - echo "Building external dependencies from source" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source" -else - echo "Using prebuilt externals" - "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \ - "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt" -fi diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh deleted file mode 100644 index 9e4e3aa3df..0000000000 --- a/template/android/copy_files.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# check the args -# $1: root of cocos2dx $2: app path $3: pakcage path - -COCOS2DX_ROOT=$1 -APP_DIR=$2 -PACKAGE_PATH=$3 -USE_BOX2D=$4 -USE_CHIPMUNK=$5 -USE_LUA=$6 - -APP_NAME=`basename ${APP_DIR}` -HELLOWORLD_ROOT=$COCOS2DX_ROOT/samples/Cpp/HelloCpp -COCOSJAVALIB_ROOT=$COCOS2DX_ROOT/cocos2dx/platform/android/java - -# xxx.yyy.zzz -> xxx/yyy/zzz -convert_package_path_to_dir(){ - PACKAGE_PATH_DIR=`echo $1 | sed -e "s/\./\//g"` -} - -copy_cpp_h() { - mkdir $APP_DIR/Classes - cp $COCOS2DX_ROOT/template/android/Classes/* $APP_DIR/Classes -} - -# copy resources -copy_resouces() { - mkdir $APP_DIR/Resources - cp -rf $HELLOWORLD_ROOT/Resources/iphone/* $APP_DIR/Resources -} - -# from HelloWorld copy src and jni to APP_DIR -copy_src_and_jni() { - cp -rf $HELLOWORLD_ROOT/proj.android/{jni,src} $APP_DIR/proj.android - - # replace Android.mk - sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/proj.android/jni/Android.mk $USE_BOX2D $USE_CHIPMUNK $USE_LUA - - if [ $USE_LUA = "true" ]; then - # copy lua script - cp "$COCOS2DX_ROOT"/scripting/lua/script/* "$APP_DIR"/Resources - fi -} - -# copy build_native.sh and replace something -copy_build_native() { - # here should use # instead of /, why?? - sed "s#__cocos2dxroot__#$COCOS2DX_ROOT#;s#__ndkroot__#$NDK_ROOT#;s#__projectname__#$APP_NAME#" $COCOS2DX_ROOT/template/android/build_native.sh > $APP_DIR/proj.android/build_native.sh - chmod u+x $APP_DIR/proj.android/build_native.sh -} - -# copy debugger script and replace templated parameters -copy_ndkgdb() { - sed "s#__projectname__#$APP_NAME#;s#__packagename__#$PACKAGE_PATH#;s#__androidsdk__#$ANDROID_SDK_ROOT#;s#__ndkroot__#$NDK_ROOT#;s#__cocos2dxroot__#$COCOS2DX_ROOT#" $COCOS2DX_ROOT/template/android/ndkgdb.sh > $APP_DIR/proj.android/ndkgdb.sh - chmod u+x $APP_DIR/proj.android/ndkgdb.sh -} - -# copy .project and .classpath and replace project name -modify_project_classpath(){ - sed "s/HelloCpp/$APP_NAME/" $COCOS2DX_ROOT/template/android/.project > $APP_DIR/proj.android/.project - cp -f $COCOS2DX_ROOT/template/android/.classpath $APP_DIR/proj.android -} - -# replace AndroidManifext.xml and change the activity name -# use sed to replace the specified line -modify_androidmanifest(){ - sed "s/HelloCpp/$APP_NAME/;s/org\.cocos2dx\.hellocpp/$PACKAGE_PATH/" $HELLOWORLD_ROOT/proj.android/AndroidManifest.xml > $APP_DIR/proj.android/AndroidManifest.xml -} - -# modify HelloCpp.java -modify_applicationdemo() { - convert_package_path_to_dir $PACKAGE_PATH - - # rename APP_DIR/android/src/org/cocos2dx/hellocpp/HelloCpp.java to - # APP_DIR/android/src/org/cocos2dx/hellocpp/$APP_NAME.java, change hellocpp to game - sed "s/HelloCpp/$APP_NAME/;s/org\.cocos2dx\.hellocpp/$PACKAGE_PATH/;s/hellocpp/game/" $APP_DIR/proj.android/src/org/cocos2dx/hellocpp/HelloCpp.java > $APP_DIR/proj.android/src/$PACKAGE_PATH_DIR/$APP_NAME.java - rm -fr $APP_DIR/proj.android/src/org/cocos2dx/hellocpp -} - -modify_layout() { - rm -f $APP_DIR/proj.android/res/layout/main.xml -} - -# android.bat of android 4.0 don't create res/drawable-hdpi res/drawable-ldpi and res/drawable-mdpi. -# These work are done in ADT -copy_icon() { - if [ ! -d $APP_DIR/proj.android/res/drawable-hdpi ]; then - cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-hdpi $APP_DIR/proj.android/res - cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-ldpi $APP_DIR/proj.android/res - cp -r $HELLOWORLD_ROOT/proj.android/res/drawable-mdpi $APP_DIR/proj.android/res - fi -} - -copy_cpp_h -copy_resouces -copy_src_and_jni -copy_build_native -copy_ndkgdb -#modify_project_classpath -modify_androidmanifest -modify_applicationdemo -modify_layout -copy_icon diff --git a/template/android/gamemk.sh b/template/android/gamemk.sh deleted file mode 100644 index 1f5607e119..0000000000 --- a/template/android/gamemk.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -FILE=$1 -USE_BOX2D=$2 -USE_CHIPMUNK=$3 -USE_LUA=$4 - -LOCAL_STATIC_LIBRARIES="LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static" -MODULES_TO_CALL="\$(call import-module,CocosDenshion/android) \\ -\$(call import-module,cocos2dx) \\ -\$(call import-module,extensions)" - -LOCAL_SRC_FILES="LOCAL_SRC_FILES := hellocpp/main.cpp \\ - ../../Classes/AppDelegate.cpp \\ - ../../Classes/HelloWorldScene.cpp" - -if [ $USE_BOX2D = "true" ];then - LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" box2d_static" - MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,external/Box2D)" -fi - -if [ $USE_CHIPMUNK = "true" ]; then - LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" chipmunk_static" - MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,external/chipmunk)" -fi - -if [ $USE_LUA = "true" ]; then - LOCAL_STATIC_LIBRARIES=$LOCAL_STATIC_LIBRARIES" cocos_lua_static" - MODULES_TO_CALL=$MODULES_TO_CALL" \$(call import-module,scripting/lua/proj.android)" -fi - -cat > $FILE << EOF -LOCAL_PATH := \$(call my-dir) - -include \$(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -$LOCAL_SRC_FILES - -LOCAL_C_INCLUDES := \$(LOCAL_PATH)/../../Classes - -$LOCAL_STATIC_LIBRARIES - -include \$(BUILD_SHARED_LIBRARY) - -$MODULES_TO_CALL -EOF diff --git a/template/android/ndkgdb.sh b/template/android/ndkgdb.sh deleted file mode 100644 index d279dcafa9..0000000000 --- a/template/android/ndkgdb.sh +++ /dev/null @@ -1,30 +0,0 @@ -APPNAME="__projectname__" -APP_ANDROID_NAME="__packagename__" -ANDROID_SDK_ROOT="__androidsdk__" -NDK_ROOT="__ndkroot__" -COCOS2DX_ROOT="__cocos2dxroot__" - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -APP_ROOT="$DIR/.." -APP_ANDROID_ROOT="$COCOS2DX_ROOT/$APPNAME/proj.android" - -echo "NDK_ROOT = $NDK_ROOT" -echo "ANDROID_SDK_ROOT = $ANDROID_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 -"${ANDROID_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="${ANDROID_SDK_ROOT}"/platform-tools/adb \ - --verbose \ - --start \ - --force diff --git a/template/multi-platform-cpp/Classes/HelloWorldScene.cpp b/template/multi-platform-cpp/Classes/HelloWorldScene.cpp index 7dd5070eb7..b635359243 100644 --- a/template/multi-platform-cpp/Classes/HelloWorldScene.cpp +++ b/template/multi-platform-cpp/Classes/HelloWorldScene.cpp @@ -38,15 +38,14 @@ bool HelloWorld::init() MenuItemImage *pCloseItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback)); + CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); - pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 , + pCloseItem->setPosition(Point(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); + pMenu->setPosition(Point::ZERO); this->addChild(pMenu, 1); ///////////////////////////// @@ -58,7 +57,7 @@ bool HelloWorld::init() LabelTTF* pLabel = LabelTTF::create("Hello World", "Arial", 24); // position the label on the center of the screen - pLabel->setPosition(ccp(origin.x + visibleSize.width/2, + pLabel->setPosition(Point(origin.x + visibleSize.width/2, origin.y + visibleSize.height - pLabel->getContentSize().height)); // add the label as a child to this layer @@ -68,7 +67,7 @@ bool HelloWorld::init() Sprite* pSprite = Sprite::create("HelloWorld.png"); // position the sprite on the center of the screen - pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); + pSprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer this->addChild(pSprite, 0); diff --git a/template/multi-platform-cpp/proj.android/AndroidManifest.xml b/template/multi-platform-cpp/proj.android/AndroidManifest.xml index b4ecb3e78c..fc76c88e0b 100644 --- a/template/multi-platform-cpp/proj.android/AndroidManifest.xml +++ b/template/multi-platform-cpp/proj.android/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0"> - + reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-cpp/proj.android/project.properties b/template/multi-platform-cpp/proj.android/project.properties index d5f90ebab1..c483c9663c 100644 --- a/template/multi-platform-cpp/proj.android/project.properties +++ b/template/multi-platform-cpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-8 +target=android-10 android.library.reference.1=../../../cocos2dx/platform/android/java diff --git a/template/multi-platform-js/Classes/AppDelegate.cpp b/template/multi-platform-js/Classes/AppDelegate.cpp index bb3050a65c..ae91b478d4 100644 --- a/template/multi-platform-js/Classes/AppDelegate.cpp +++ b/template/multi-platform-js/Classes/AppDelegate.cpp @@ -23,7 +23,7 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - ScriptEngineManager::purgeSharedManager(); + ScriptEngineManager::destroyInstance(); } bool AppDelegate::applicationDidFinishLaunching() @@ -83,14 +83,14 @@ void handle_signal(int signal) { void AppDelegate::applicationDidEnterBackground() { Director::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); + SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); + SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); + SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); + SimpleAudioEngine::getInstance()->resumeAllEffects(); } diff --git a/template/multi-platform-js/proj.android/jni/Application.mk b/template/multi-platform-js/proj.android/jni/Application.mk index 8418b9b18c..4e46d23deb 100644 --- a/template/multi-platform-js/proj.android/jni/Application.mk +++ b/template/multi-platform-js/proj.android/jni/Application.mk @@ -1,4 +1,4 @@ APP_STL := gnustl_static APP_CPPFLAGS := -frtti -DCOCOS2D_JAVASCRIPT=1 -APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 +APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 NDK_TOOLCHAIN_VERSION=4.7 diff --git a/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp b/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp index 1f5171ccb1..5f73b61c4e 100644 --- a/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp +++ b/template/multi-platform-js/proj.android/jni/hellojavascript/main.cpp @@ -32,9 +32,9 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccGLInvalidateStateCache(); + GL::invalidateStateCache(); ShaderCache::getInstance()->reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj b/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj index 616ac78617..18d64274cf 100644 --- a/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj +++ b/template/multi-platform-js/proj.ios/HelloJavascript.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 1AF4C35A17865F7400122817 /* jsb_sys.js in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C34217865F1600122817 /* jsb_sys.js */; }; 1AF4C35B17865F7400122817 /* jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C34317865F1600122817 /* jsb.js */; }; 1AF4C35C17865F7400122817 /* main.debug.js in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C34417865F1600122817 /* main.debug.js */; }; + 466AF679179FC7EE002EE9BB /* jsb_deprecated.js in Resources */ = {isa = PBXBuildFile; fileRef = 466AF66C179FC7BE002EE9BB /* jsb_deprecated.js */; }; A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275431517C094001B78AA /* OpenGLES.framework */; }; A92275461517C094001B78AA /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; @@ -202,6 +203,7 @@ 1AF4C34217865F1600122817 /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_sys.js; path = ../../../scripting/javascript/bindings/js/jsb_sys.js; sourceTree = ""; }; 1AF4C34317865F1600122817 /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb.js; path = ../../../scripting/javascript/bindings/js/jsb.js; sourceTree = ""; }; 1AF4C34417865F1600122817 /* main.debug.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.debug.js; path = ../../../scripting/javascript/bindings/js/main.debug.js; sourceTree = ""; }; + 466AF66C179FC7BE002EE9BB /* jsb_deprecated.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_deprecated.js; path = ../../../scripting/javascript/bindings/js/jsb_deprecated.js; sourceTree = ""; }; A922753D1517C094001B78AA /* HelloJavascript.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloJavascript.app; sourceTree = BUILT_PRODUCTS_DIR; }; A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; A92275431517C094001B78AA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -290,6 +292,7 @@ 1AF4C33817865EF900122817 /* JS Common */ = { isa = PBXGroup; children = ( + 466AF66C179FC7BE002EE9BB /* jsb_deprecated.js */, 1AF4C33917865F1600122817 /* jsb_chipmunk_constants.js */, 1AF4C33A17865F1600122817 /* jsb_chipmunk.js */, 1AF4C33B17865F1600122817 /* jsb_cocos2d_constants.js */, @@ -531,6 +534,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 466AF679179FC7EE002EE9BB /* jsb_deprecated.js in Resources */, 1AF4C35117865F7400122817 /* jsb_chipmunk_constants.js in Resources */, 1AF4C35217865F7400122817 /* jsb_chipmunk.js in Resources */, 1AF4C35317865F7400122817 /* jsb_cocos2d_constants.js in Resources */, diff --git a/template/multi-platform-lua/Classes/AppDelegate.cpp b/template/multi-platform-lua/Classes/AppDelegate.cpp index da80ab1351..05fb3205e1 100644 --- a/template/multi-platform-lua/Classes/AppDelegate.cpp +++ b/template/multi-platform-lua/Classes/AppDelegate.cpp @@ -34,7 +34,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setAnimationInterval(1.0 / 60); // register lua engine - LuaEngine* pEngine = LuaEngine::defaultEngine(); + LuaEngine* pEngine = LuaEngine::getInstance(); ScriptEngineManager::getInstance()->setScriptEngine(pEngine); LuaStack *pStack = pEngine->getLuaStack(); @@ -57,7 +57,7 @@ void AppDelegate::applicationDidEnterBackground() { Director::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); + SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); } // this function will be called when the app is active again @@ -65,5 +65,5 @@ void AppDelegate::applicationWillEnterForeground() { Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); + SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); } diff --git a/template/multi-platform-lua/Resources/hello.lua b/template/multi-platform-lua/Resources/hello.lua index 942f7cd355..5bcbc1bda8 100644 --- a/template/multi-platform-lua/Resources/hello.lua +++ b/template/multi-platform-lua/Resources/hello.lua @@ -32,9 +32,9 @@ local function main() -- create dog animate local textureDog = CCTextureCache:getInstance():addImage("dog.png") - local rect = CCRectMake(0, 0, frameWidth, frameHeight) + local rect = CCRect(0, 0, frameWidth, frameHeight) local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) - rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) + rect = CCRect(frameWidth, 0, frameWidth, frameHeight) local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) local spriteDog = CCSprite:createWithSpriteFrame(frame0) @@ -87,7 +87,7 @@ local function main() end -- add crop - local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create("crop.png", CCRect(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); diff --git a/template/multi-platform-lua/proj.android/AndroidManifest.xml b/template/multi-platform-lua/proj.android/AndroidManifest.xml index 578c23647b..17aea441c2 100644 --- a/template/multi-platform-lua/proj.android/AndroidManifest.xml +++ b/template/multi-platform-lua/proj.android/AndroidManifest.xml @@ -4,7 +4,7 @@ android:versionCode="1" android:versionName="1.0"> - + reloadDefaultShaders(); - ccDrawInit(); + DrawPrimitives::init(); TextureCache::reloadAllTextures(); NotificationCenter::getInstance()->postNotification(EVNET_COME_TO_FOREGROUND, NULL); Director::getInstance()->setGLDefaultValues(); diff --git a/template/multi-platform-lua/proj.android/project.properties b/template/multi-platform-lua/proj.android/project.properties index d5f90ebab1..c483c9663c 100644 --- a/template/multi-platform-lua/proj.android/project.properties +++ b/template/multi-platform-lua/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-8 +target=android-10 android.library.reference.1=../../../cocos2dx/platform/android/java diff --git a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj index b07ff76b33..32008ad704 100644 --- a/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj +++ b/template/multi-platform-lua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -32,12 +32,9 @@ 1AF4C3F41786633E00122817 /* libcocos2dx-extensions iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3DD1786631700122817 /* libcocos2dx-extensions iOS.a */; }; 1AF4C3F51786633E00122817 /* libCocosDenshion iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3E31786631700122817 /* libCocosDenshion iOS.a */; }; 1AF4C3F61786633E00122817 /* libluabindings iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C3E71786631700122817 /* libluabindings iOS.a */; }; - 1AF4C3FD1786635F00122817 /* AudioEngine.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C3F81786635F00122817 /* AudioEngine.lua */; }; - 1AF4C3FE1786635F00122817 /* CCBReaderLoad.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C3F91786635F00122817 /* CCBReaderLoad.lua */; }; - 1AF4C3FF1786635F00122817 /* Cocos2dConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C3FA1786635F00122817 /* Cocos2dConstants.lua */; }; - 1AF4C4001786635F00122817 /* Opengl.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C3FB1786635F00122817 /* Opengl.lua */; }; - 1AF4C4011786635F00122817 /* OpenglConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1AF4C3FC1786635F00122817 /* OpenglConstants.lua */; }; 1AF4C403178663F200122817 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AF4C402178663F200122817 /* libz.dylib */; }; + 466AF68B179FCC03002EE9BB /* DrawPrimitives.lua in Resources */ = {isa = PBXBuildFile; fileRef = 466AF68A179FCC03002EE9BB /* DrawPrimitives.lua */; }; + 466AF68D179FCC09002EE9BB /* Deprecated.lua in Resources */ = {isa = PBXBuildFile; fileRef = 466AF68C179FCC09002EE9BB /* Deprecated.lua */; }; F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CC15EB7BE500256477 /* QuartzCore.framework */; }; F293B3CF15EB7BE500256477 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CE15EB7BE500256477 /* OpenGLES.framework */; }; F293B3D115EB7BE500256477 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3D015EB7BE500256477 /* OpenAL.framework */; }; @@ -211,12 +208,9 @@ 1AC3622E16D47C5C000847F2 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu2.png; path = ../Resources/menu2.png; sourceTree = ""; }; 1AF4C3B8178662A500122817 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = ../../../cocos2d_libs.xcodeproj; sourceTree = ""; }; - 1AF4C3F81786635F00122817 /* AudioEngine.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = AudioEngine.lua; path = ../../../scripting/lua/script/AudioEngine.lua; sourceTree = ""; }; - 1AF4C3F91786635F00122817 /* CCBReaderLoad.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CCBReaderLoad.lua; path = ../../../scripting/lua/script/CCBReaderLoad.lua; sourceTree = ""; }; - 1AF4C3FA1786635F00122817 /* Cocos2dConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Cocos2dConstants.lua; path = ../../../scripting/lua/script/Cocos2dConstants.lua; sourceTree = ""; }; - 1AF4C3FB1786635F00122817 /* Opengl.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Opengl.lua; path = ../../../scripting/lua/script/Opengl.lua; sourceTree = ""; }; - 1AF4C3FC1786635F00122817 /* OpenglConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = OpenglConstants.lua; path = ../../../scripting/lua/script/OpenglConstants.lua; sourceTree = ""; }; 1AF4C402178663F200122817 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 466AF68A179FCC03002EE9BB /* DrawPrimitives.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = DrawPrimitives.lua; path = ../../../scripting/lua/script/DrawPrimitives.lua; sourceTree = ""; }; + 466AF68C179FCC09002EE9BB /* Deprecated.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; name = Deprecated.lua; path = ../../../scripting/lua/script/Deprecated.lua; sourceTree = ""; }; F293B3C815EB7BE500256477 /* HelloLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloLua.app; sourceTree = BUILT_PRODUCTS_DIR; }; F293B3CC15EB7BE500256477 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; F293B3CE15EB7BE500256477 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; @@ -282,25 +276,14 @@ name = Products; sourceTree = ""; }; - 1AF4C3F71786634600122817 /* Lua Common */ = { - isa = PBXGroup; - children = ( - 1AF4C3F81786635F00122817 /* AudioEngine.lua */, - 1AF4C3F91786635F00122817 /* CCBReaderLoad.lua */, - 1AF4C3FA1786635F00122817 /* Cocos2dConstants.lua */, - 1AF4C3FB1786635F00122817 /* Opengl.lua */, - 1AF4C3FC1786635F00122817 /* OpenglConstants.lua */, - ); - name = "Lua Common"; - sourceTree = ""; - }; F293B3BD15EB7BE500256477 = { isa = PBXGroup; children = ( + 466AF68C179FCC09002EE9BB /* Deprecated.lua */, + 466AF68A179FCC03002EE9BB /* DrawPrimitives.lua */, 1AF4C3B91786631600122817 /* cocos2d_libs.xcodeproj */, F293BB7C15EB830F00256477 /* Classes */, F293B3CB15EB7BE500256477 /* Frameworks */, - 1AF4C3F71786634600122817 /* Lua Common */, F293B6E815EB807E00256477 /* Other Sources */, F293B3C915EB7BE500256477 /* Products */, F293BC4615EB859D00256477 /* Resources */, @@ -558,15 +541,12 @@ 1AC3623416D47C5C000847F2 /* farm.jpg in Resources */, 1AC3623516D47C5C000847F2 /* fonts in Resources */, 1AC3623616D47C5C000847F2 /* hello.lua in Resources */, + 466AF68B179FCC03002EE9BB /* DrawPrimitives.lua in Resources */, 1AC3623716D47C5C000847F2 /* hello2.lua in Resources */, 1AC3623816D47C5C000847F2 /* land.png in Resources */, 1AC3623916D47C5C000847F2 /* menu1.png in Resources */, + 466AF68D179FCC09002EE9BB /* Deprecated.lua in Resources */, 1AC3623A16D47C5C000847F2 /* menu2.png in Resources */, - 1AF4C3FD1786635F00122817 /* AudioEngine.lua in Resources */, - 1AF4C3FE1786635F00122817 /* CCBReaderLoad.lua in Resources */, - 1AF4C3FF1786635F00122817 /* Cocos2dConstants.lua in Resources */, - 1AF4C4001786635F00122817 /* Opengl.lua in Resources */, - 1AF4C4011786635F00122817 /* OpenglConstants.lua in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -717,6 +697,7 @@ "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios\"", "\"$(SRCROOT)/../../../cocos2dx/platform/ios/Simulation\"", "\"$(SRCROOT)/../../../extensions\"", + "\"$(SRCROOT)/../../../external/libwebsockets/ios/include\"", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; @@ -765,6 +746,7 @@ "\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios\"", "\"$(SRCROOT)/../../../cocos2dx/platform/ios/Simulation\"", "\"$(SRCROOT)/../../../extensions\"", + "\"$(SRCROOT)/../../../external/libwebsockets/ios/include\"", ); INFOPLIST_FILE = Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 5.0; diff --git a/template/xcode4/base_ios.xctemplate/Resources/HelloWorld.png.REMOVED.git-id b/template/xcode4/base_ios.xctemplate/Resources/HelloWorld.png.REMOVED.git-id deleted file mode 100644 index f02d84fd8f..0000000000 --- a/template/xcode4/base_ios.xctemplate/Resources/HelloWorld.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -5fe89fb5bd58cedf13b0363f97b20e3ea7ff255d \ No newline at end of file diff --git a/template/xcode4/base_ios.xctemplate/Resources/iTunesArtwork b/template/xcode4/base_ios.xctemplate/Resources/iTunesArtwork deleted file mode 100644 index b1cc056ba5..0000000000 Binary files a/template/xcode4/base_ios.xctemplate/Resources/iTunesArtwork and /dev/null differ diff --git a/template/xcode4/base_ios.xctemplate/ios/AppController.h b/template/xcode4/base_ios.xctemplate/ios/AppController.h deleted file mode 100644 index 4f51fc6229..0000000000 --- a/template/xcode4/base_ios.xctemplate/ios/AppController.h +++ /dev/null @@ -1,20 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -@class RootViewController; - -@interface AppController : NSObject { - UIWindow *window; - RootViewController *viewController; -} - -@property (nonatomic, retain) UIWindow *window; -@property (nonatomic, retain) RootViewController *viewController; - -@end - diff --git a/template/xcode4/base_ios.xctemplate/ios/AppController.mm b/template/xcode4/base_ios.xctemplate/ios/AppController.mm deleted file mode 100644 index 696a810b73..0000000000 --- a/template/xcode4/base_ios.xctemplate/ios/AppController.mm +++ /dev/null @@ -1,122 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.mm -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#import -#import "AppController.h" -#import "cocos2d.h" -#import "EAGLView.h" -#import "AppDelegate.h" - -#import "RootViewController.h" - -@implementation AppController - -@synthesize window; -@synthesize viewController; - -#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::getInstance()->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::getInstance()->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::getInstance()->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::getInstance()->applicationDidEnterBackground(); -} - -- (void)applicationWillEnterForeground:(UIApplication *)application { - /* - Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. - */ - cocos2d::Application::getInstance()->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. - */ - cocos2d::Director::getInstance()->purgeCachedData(); -} - - -- (void)dealloc { - [super dealloc]; -} - - -@end - diff --git a/template/xcode4/base_ios.xctemplate/ios/RootViewController.h b/template/xcode4/base_ios.xctemplate/ios/RootViewController.h deleted file mode 100644 index 5009e46b9d..0000000000 --- a/template/xcode4/base_ios.xctemplate/ios/RootViewController.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import - - -@interface RootViewController : UIViewController { - -} - -@end diff --git a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm b/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm deleted file mode 100644 index ae0bf611c2..0000000000 --- a/template/xcode4/base_ios.xctemplate/ios/RootViewController.mm +++ /dev/null @@ -1,73 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppController.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#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 UIInterfaceOrientationIsLandscape( interfaceOrientation ); -} - -// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead -- (NSUInteger) supportedInterfaceOrientations{ -#ifdef __IPHONE_6_0 - return UIInterfaceOrientationMaskLandscape; -#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 diff --git a/template/xcode4/base_ios.xctemplate/ios/main.m b/template/xcode4/base_ios.xctemplate/ios/main.m deleted file mode 100644 index 8edf7f409e..0000000000 --- a/template/xcode4/base_ios.xctemplate/ios/main.m +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.m -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#import - -int main(int argc, char *argv[]) { - - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - int retVal = UIApplicationMain(argc, argv, nil, @"AppController"); - [pool release]; - return retVal; -} diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp deleted file mode 100644 index 202290f37f..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "SimpleAudioEngine.h" -#include "HelloWorldScene.h" - -USING_NS_CC; -using namespace CocosDenshion; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); -} diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h deleted file mode 100644 index 05b0431708..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "CCApplication.h" - -/** -@brief The cocos2d Application. - -The reason to implement with private inheritance is to hide some interface details of 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 is called when the application enters the background - @param the pointer of the application instance - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function is called when the application enters the foreground - @param the pointer of the application instance - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp deleted file mode 100644 index a75e182bba..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "HelloWorldScene.h" -#include "SimpleAudioEngine.h" - -using namespace cocos2d; -using namespace CocosDenshion; - -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; - } - - ///////////////////////////// - // 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", - this, - menu_selector(HelloWorld::menuCloseCallback) ); - pCloseItem->setPosition( ccp(Director::getInstance()->getWinSize().width - 20, 20) ); - - // create menu, it's an autorelease object - Menu* pMenu = Menu::create(pCloseItem, NULL); - pMenu->setPosition( PointZero ); - this->addChild(pMenu, 1); - - ///////////////////////////// - // 3. add your codes below... - - // add a label shows "Hello World" - // create and initialize a label - LabelTTF* pLabel = LabelTTF::create("Hello World", "Thonburi", 34); - - // ask director the window size - Size size = Director::getInstance()->getWinSize(); - - // position the label on the center of the screen - pLabel->setPosition( ccp(size.width / 2, size.height - 20) ); - - // add the label as a child to this layer - this->addChild(pLabel, 1); - - // add "HelloWorld" splash screen" - Sprite* pSprite = Sprite::create("HelloWorld.png"); - - // position the sprite on the center of the screen - pSprite->setPosition( ccp(size.width/2, size.height/2) ); - - // add the sprite as a child to this layer - this->addChild(pSprite, 0); - - return true; -} - -void HelloWorld::menuCloseCallback(Object* pSender) -{ - Director::getInstance()->end(); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif -} diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h deleted file mode 100644 index 23bd643b38..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ - -#include "cocos2d.h" - -class HelloWorld : public cocos2d::Layer -{ -public: - // Method 'init' in cocos2d-x returns bool, instead of 'id' in cocos2d-iphone (an object pointer) - virtual bool init(); - - // there's no 'id' in cpp, so we recommend to return the class instance pointer - static cocos2d::Scene* scene(); - - // a selector callback - void menuCloseCallback(Object* pSender); - - // preprocessor macro for "static create()" constructor ( node() deprecated ) - CREATE_FUNC(HelloWorld); -}; - -#endif // __HELLOWORLD_SCENE_H__ diff --git a/template/xcode4/cocos2dx.xctemplate/Prefix.pch b/template/xcode4/cocos2dx.xctemplate/Prefix.pch deleted file mode 100644 index aa3260079c..0000000000 --- a/template/xcode4/cocos2dx.xctemplate/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/template/xcode4/cocos2dx.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx.xctemplate/TemplateIcon.icns deleted file mode 100644 index 0d9fef54cb..0000000000 Binary files a/template/xcode4/cocos2dx.xctemplate/TemplateIcon.icns and /dev/null differ diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp deleted file mode 100644 index 202290f37f..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "SimpleAudioEngine.h" -#include "HelloWorldScene.h" - -USING_NS_CC; -using namespace CocosDenshion; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); -} diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.h deleted file mode 100644 index 95225d3fd1..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#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(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp deleted file mode 100644 index 3afa164a8f..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// -// HelloWorldScene.cpp -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#include "HelloWorldScene.h" -#include "SimpleAudioEngine.h" - -using namespace cocos2d; -using namespace CocosDenshion; - -#define PTM_RATIO 32 - -enum { - kTagParentNode = 1, -}; - -PhysicsSprite::PhysicsSprite() -: _body(NULL) -{ - -} - -void PhysicsSprite::setPhysicsBody(b2Body * body) -{ - _body = body; -} - -// this method will only get called if the sprite is batched. -// return YES if the physics values (angles, position ) changed -// If you return NO, then nodeToParentTransform won't be called. -bool PhysicsSprite::isDirty(void) -{ - return true; -} - -// returns the transform matrix according the Chipmunk Body values -AffineTransform PhysicsSprite::nodeToParentTransform(void) -{ - b2Vec2 pos = _body->GetPosition(); - - float x = pos.x * PTM_RATIO; - float y = pos.y * PTM_RATIO; - - if ( isIgnoreAnchorPointForPosition() ) { - x += _anchorPointInPoints.x; - y += _anchorPointInPoints.y; - } - - // Make matrix - float radians = _body->GetAngle(); - float c = cosf(radians); - float s = sinf(radians); - - if( ! _anchorPointInPoints.equals(PointZero) ){ - x += c*-_anchorPointInPoints.x + -s*-_anchorPointInPoints.y; - y += s*-_anchorPointInPoints.x + c*-_anchorPointInPoints.y; - } - - // Rot, Translate Matrix - _transform = AffineTransformMake( c, s, - -s, c, - x, y ); - - return _transform; -} - -HelloWorld::HelloWorld() -{ - setTouchEnabled( true ); - setAccelerometerEnabled( true ); - - Size s = Director::getInstance()->getWinSize(); - // init physics - this->initPhysics(); - - SpriteBatchNode *parent = SpriteBatchNode::create("blocks.png", 100); - _spriteTexture = parent->getTexture(); - - addChild(parent, 0, kTagParentNode); - - - addNewSpriteAtPosition(ccp(s.width/2, s.height/2)); - - LabelTTF *label = LabelTTF::create("Tap screen", "Marker Felt", 32); - addChild(label, 0); - label->setColor(ccc3(0,0,255)); - label->setPosition(ccp( s.width/2, s.height-50)); - - scheduleUpdate(); -} - -HelloWorld::~HelloWorld() -{ - delete world; - world = NULL; - - //delete _debugDraw; -} - -void HelloWorld::initPhysics() -{ - - Size s = Director::getInstance()->getWinSize(); - - b2Vec2 gravity; - gravity.Set(0.0f, -10.0f); - world = new b2World(gravity); - - // Do we want to let bodies sleep? - world->SetAllowSleeping(true); - - world->SetContinuousPhysics(true); - -// _debugDraw = new GLESDebugDraw( PTM_RATIO ); -// world->SetDebugDraw(_debugDraw); - - uint32 flags = 0; - flags += b2Draw::e_shapeBit; - // flags += b2Draw::e_jointBit; - // flags += b2Draw::e_aabbBit; - // flags += b2Draw::e_pairBit; - // flags += b2Draw::e_centerOfMassBit; - //_debugDraw->SetFlags(flags); - - - // Define the ground body. - b2BodyDef groundBodyDef; - groundBodyDef.position.Set(0, 0); // bottom-left corner - - // Call the body factory which allocates memory for the ground body - // from a pool and creates the ground box shape (also from a pool). - // The body is also added to the world. - b2Body* groundBody = world->CreateBody(&groundBodyDef); - - // Define the ground box shape. - b2EdgeShape groundBox; - - // bottom - - groundBox.Set(b2Vec2(0,0), b2Vec2(s.width/PTM_RATIO,0)); - groundBody->CreateFixture(&groundBox,0); - - // top - groundBox.Set(b2Vec2(0,s.height/PTM_RATIO), b2Vec2(s.width/PTM_RATIO,s.height/PTM_RATIO)); - groundBody->CreateFixture(&groundBox,0); - - // left - groundBox.Set(b2Vec2(0,s.height/PTM_RATIO), b2Vec2(0,0)); - groundBody->CreateFixture(&groundBox,0); - - // right - groundBox.Set(b2Vec2(s.width/PTM_RATIO,s.height/PTM_RATIO), b2Vec2(s.width/PTM_RATIO,0)); - groundBody->CreateFixture(&groundBox,0); -} - -void HelloWorld::draw() -{ - // - // IMPORTANT: - // This is only for debug purposes - // It is recommend to disable it - // - Layer::draw(); - - ccGLEnableVertexAttribs( kVertexAttribFlag_Position ); - - kmGLPushMatrix(); - - world->DrawDebugData(); - - kmGLPopMatrix(); -} - -void HelloWorld::addNewSpriteAtPosition(Point p) -{ - CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); - Node* parent = getChildByTag(kTagParentNode); - - //We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is - //just randomly picking one of the images - int idx = (CCRANDOM_0_1() > .5 ? 0:1); - int idy = (CCRANDOM_0_1() > .5 ? 0:1); - PhysicsSprite *sprite = new PhysicsSprite(); - sprite->initWithTexture(_spriteTexture, CCRectMake(32 * idx,32 * idy,32,32)); - sprite->autorelease(); - - parent->addChild(sprite); - - sprite->setPosition( CCPointMake( p.x, p.y) ); - - // Define the dynamic body. - //Set up a 1m squared box in the physics world - b2BodyDef bodyDef; - bodyDef.type = b2_dynamicBody; - bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO); - - b2Body *body = world->CreateBody(&bodyDef); - - // Define another box shape for our dynamic body. - b2PolygonShape dynamicBox; - dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box - - // Define the dynamic body fixture. - b2FixtureDef fixtureDef; - fixtureDef.shape = &dynamicBox; - fixtureDef.density = 1.0f; - fixtureDef.friction = 0.3f; - body->CreateFixture(&fixtureDef); - - sprite->setPhysicsBody(body); -} - - -void HelloWorld::update(float dt) -{ - //It is recommended that a fixed time step is used with Box2D for stability - //of the simulation, however, we are using a variable time step here. - //You need to make an informed choice, the following URL is useful - //http://gafferongames.com/game-physics/fix-your-timestep/ - - int velocityIterations = 8; - int positionIterations = 1; - - // Instruct the world to perform a single step of simulation. It is - // generally best to keep the time step and iterations fixed. - world->Step(dt, velocityIterations, positionIterations); - - //Iterate over the bodies in the physics world - for (b2Body* b = world->GetBodyList(); b; b = b->GetNext()) - { - if (b->GetUserData() != NULL) { - //Synchronize the AtlasSprites position and rotation with the corresponding body - Sprite* myActor = (Sprite*)b->GetUserData(); - myActor->setPosition( CCPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO) ); - myActor->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()) ); - } - } -} - -void HelloWorld::ccTouchesEnded(Set* touches, Event* event) -{ - //Add a new body/atlas sprite at the touched location - SetIterator it; - Touch* touch; - - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (Touch*)(*it); - - if(!touch) - break; - - Point location = touch->getLocationInView(); - - location = Director::getInstance()->convertToGL(location); - - addNewSpriteAtPosition( location ); - } -} - -Scene* HelloWorld::scene() -{ - // 'scene' is an autorelease object - Scene *scene = Scene::create(); - - // add layer as a child to scene - Layer* layer = new HelloWorld(); - scene->addChild(layer); - layer->release(); - - return scene; -} diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h deleted file mode 100644 index e648e37bfa..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// HelloWorldScene.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// -#ifndef __HELLO_WORLD_H__ -#define __HELLO_WORLD_H__ - -// When you import this file, you import all the cocos2d classes -#include "cocos2d.h" -#include "Box2D.h" - -class PhysicsSprite : public cocos2d::Sprite -{ -public: - PhysicsSprite(); - void setPhysicsBody(b2Body * body); - virtual bool isDirty(void); - virtual cocos2d::AffineTransform nodeToParentTransform(void); -private: - b2Body* _body; // strong ref -}; - -class HelloWorld : public cocos2d::Layer { -public: - ~HelloWorld(); - HelloWorld(); - - // returns a Scene that contains the HelloWorld as the only child - static cocos2d::Scene* scene(); - - void initPhysics(); - // adds a new sprite at a given coordinate - void addNewSpriteAtPosition(cocos2d::Point p); - - virtual void draw(); - virtual void ccTouchesEnded(cocos2d::Set* touches, cocos2d::Event* event); - void update(float dt); - -private: - b2World* world; - cocos2d::Texture2D* _spriteTexture; // weak ref -}; - -#endif // __HELLO_WORLD_H__ diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_box2d.xctemplate/Prefix.pch deleted file mode 100644 index aa3260079c..0000000000 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_box2d.xctemplate/TemplateIcon.icns deleted file mode 100644 index 0d9fef54cb..0000000000 Binary files a/template/xcode4/cocos2dx_box2d.xctemplate/TemplateIcon.icns and /dev/null differ diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp deleted file mode 100644 index 202290f37f..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.cpp -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "SimpleAudioEngine.h" -#include "HelloWorldScene.h" - -USING_NS_CC; -using namespace CocosDenshion; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); -} diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.h deleted file mode 100644 index 788cdf920a..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// ___PROJECTNAMEASIDENTIFIER___AppDelegate.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#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(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp deleted file mode 100644 index e0d8419f21..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp +++ /dev/null @@ -1,271 +0,0 @@ -// -// HelloWorldScene.cpp -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - - -#include "HelloWorldScene.h" -#include "SimpleAudioEngine.h" - -using namespace cocos2d; -using namespace CocosDenshion; - -enum { - kTagParentNode = 1, -}; - -// callback to remove Shapes from the Space -void removeShape( cpBody *body, cpShape *shape, void *data ) -{ - cpShapeFree( shape ); -} - -ChipmunkPhysicsSprite::ChipmunkPhysicsSprite() -: _body(NULL) -{ - -} - -ChipmunkPhysicsSprite::~ChipmunkPhysicsSprite() -{ - cpBodyEachShape(_body, removeShape, NULL); - cpBodyFree( _body ); -} - -void ChipmunkPhysicsSprite::setPhysicsBody(cpBody * body) -{ - _body = body; -} - -// this method will only get called if the sprite is batched. -// return YES if the physics values (angles, position ) changed -// If you return NO, then nodeToParentTransform won't be called. -bool ChipmunkPhysicsSprite::isDirty(void) -{ - return true; -} - -AffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) -{ - float x = _body->p.x; - float y = _body->p.y; - - if ( isIgnoreAnchorPointForPosition() ) { - x += _anchorPointInPoints.x; - y += _anchorPointInPoints.y; - } - - // Make matrix - float c = _body->rot.x; - float s = _body->rot.y; - - if( ! _anchorPointInPoints.equals(PointZero) ){ - x += c*-_anchorPointInPoints.x + -s*-_anchorPointInPoints.y; - y += s*-_anchorPointInPoints.x + c*-_anchorPointInPoints.y; - } - - // Rot, Translate Matrix - _transform = AffineTransformMake( c, s, - -s, c, - x, y ); - - return _transform; -} - -HelloWorld::HelloWorld() -{ -} - -HelloWorld::~HelloWorld() -{ - // manually Free rogue shapes - for( int i=0;i<4;i++) { - cpShapeFree( _walls[i] ); - } - - cpSpaceFree( _space ); - -} - -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; -} - -bool HelloWorld::init() -{ - if (!Layer::init()) - { - return false; - } - - // enable events - setTouchEnabled(true); - setAccelerometerEnabled(true); - - Size s = Director::getInstance()->getWinSize(); - - // title - LabelTTF *label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36); - label->setPosition(ccp( s.width / 2, s.height - 30)); - this->addChild(label, -1); - - // init physics - initPhysics(); - -#if 1 - // Use batch node. Faster - SpriteBatchNode *parent = SpriteBatchNode::create("grossini_dance_atlas.png", 100); - _spriteTexture = parent->getTexture(); -#else - // doesn't use batch node. Slower - _spriteTexture = TextureCache::getInstance():addImage("grossini_dance_atlas.png"); - Node *parent = Node::node(); -#endif - addChild(parent, 0, kTagParentNode); - - addNewSpriteAtPosition(ccp(200,200)); - - scheduleUpdate(); - - return true; -} - - -void HelloWorld::initPhysics() -{ - Size s = Director::getInstance()->getWinSize(); - - // init chipmunk - cpInitChipmunk(); - - _space = cpSpaceNew(); - - _space->gravity = cpv(0, -100); - - // - // rogue shapes - // We have to free them manually - // - // bottom - _walls[0] = cpSegmentShapeNew( _space->staticBody, cpv(0,0), cpv(s.width,0), 0.0f); - - // top - _walls[1] = cpSegmentShapeNew( _space->staticBody, cpv(0,s.height), cpv(s.width,s.height), 0.0f); - - // left - _walls[2] = cpSegmentShapeNew( _space->staticBody, cpv(0,0), cpv(0,s.height), 0.0f); - - // right - _walls[3] = cpSegmentShapeNew( _space->staticBody, cpv(s.width,0), cpv(s.width,s.height), 0.0f); - - for( int i=0;i<4;i++) { - _walls[i]->e = 1.0f; - _walls[i]->u = 1.0f; - cpSpaceAddStaticShape(_space, _walls[i] ); - } -} - -void HelloWorld::update(float delta) -{ - // Should use a fixed size step based on the animation interval. - int steps = 2; - float dt = Director::getInstance()->getAnimationInterval()/(float)steps; - - for(int i=0; iinitWithTexture(_spriteTexture, CCRectMake(posx, posy, 85, 121)); - sprite->autorelease(); - - parent->addChild(sprite); - - sprite->setPosition(pos); - - int num = 4; - cpVect verts[] = { - cpv(-24,-54), - cpv(-24, 54), - cpv( 24, 54), - cpv( 24,-54), - }; - - cpBody *body = cpBodyNew(1.0f, cpMomentForPoly(1.0f, num, verts, cpvzero)); - - body->p = cpv(pos.x, pos.y); - cpSpaceAddBody(_space, body); - - cpShape* shape = cpPolyShapeNew(body, num, verts, cpvzero); - shape->e = 0.5f; shape->u = 0.5f; - cpSpaceAddShape(_space, shape); - - sprite->setPhysicsBody(body); -} - -void HelloWorld::ccTouchesEnded(Set* touches, Event* event) -{ - //Add a new body/atlas sprite at the touched location - SetIterator it; - Touch* touch; - - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (Touch*)(*it); - - if(!touch) - break; - - Point location = touch->getLocationInView(); - - location = Director::getInstance()->convertToGL(location); - - addNewSpriteAtPosition( location ); - } -} - -void HelloWorld::didAccelerate(Acceleration* pAccelerationValue) -{ - static float prevX=0, prevY=0; - -#define kFilterFactor 0.05f - - float accelX = (float) pAccelerationValue->x * kFilterFactor + (1- kFilterFactor)*prevX; - float accelY = (float) pAccelerationValue->y * kFilterFactor + (1- kFilterFactor)*prevY; - - prevX = accelX; - prevY = accelY; - - Point v = ccp( accelX, accelY); - v = ccpMult(v, 200); - _space->gravity = cpv(v.x, v.y); -} - - diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h deleted file mode 100644 index 10c6792925..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// HelloWorldScene.h -// ___PROJECTNAME___ -// -// Created by ___FULLUSERNAME___ on ___DATE___. -// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. -// - -#ifndef __HELLOW_WORLD_H__ -#define __HELLOW_WORLD_H__ - -#include "cocos2d.h" - -// include Chipmunk headers -#include "chipmunk.h" - -class ChipmunkPhysicsSprite : public cocos2d::Sprite -{ -public: - ChipmunkPhysicsSprite(); - virtual ~ChipmunkPhysicsSprite(); - void setPhysicsBody(cpBody* body); - virtual bool isDirty(void); - virtual cocos2d::AffineTransform nodeToParentTransform(void); -private: - cpBody* _body; // strong ref -}; - -// HelloWorld Layer -class HelloWorld : public cocos2d::Layer { -public: - HelloWorld(); - ~HelloWorld(); - bool init(); - static cocos2d::Scene* scene(); - CREATE_FUNC(HelloWorld); - - void initPhysics(); - void addNewSpriteAtPosition(cocos2d::Point p); - void update(float dt); - virtual void ccTouchesEnded(cocos2d::Set* touches, cocos2d::Event* event); - virtual void didAccelerate(cocos2d::Acceleration* pAccelerationValue); - -private: - cocos2d::Texture2D* _spriteTexture; // weak ref - cpSpace* _space; // strong ref - cpShape* _walls[4]; - -}; - -#endif // __HELLOW_WORLD_H__ diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_chipmunk.xctemplate/Prefix.pch deleted file mode 100644 index aa3260079c..0000000000 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_chipmunk.xctemplate/TemplateIcon.icns deleted file mode 100644 index 0d9fef54cb..0000000000 Binary files a/template/xcode4/cocos2dx_chipmunk.xctemplate/TemplateIcon.icns and /dev/null differ diff --git a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp deleted file mode 100644 index 635b3bef31..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "SimpleAudioEngine.h" -#include "ScriptingCore.h" -#include "jsb_cocos2dx_auto.hpp" -#include "jsb_cocos2dx_extension_auto.hpp" -#include "jsb_cocos2dx_extension_manual.h" -#include "cocos2d_specifics.hpp" -#include "js_bindings_chipmunk_registration.h" -#include "js_bindings_ccbreader.h" -#include "js_bindings_system_registration.h" -#include "jsb_opengl_registration.h" -#include "XMLHTTPRequest.h" - -USING_NS_CC; -using namespace CocosDenshion; - -AppDelegate::AppDelegate() -{ -} - -AppDelegate::~AppDelegate() -{ - // SimpleAudioEngine::end(); -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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); - - ScriptingCore* sc = ScriptingCore::getInstance(); - sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); - sc->addRegisterCallback(register_cocos2dx_js_extensions); - sc->addRegisterCallback(register_all_cocos2dx_extension_manual); - sc->addRegisterCallback(register_CCBuilderReader); - sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(jsb_register_system); - sc->addRegisterCallback(JSB_register_opengl); - sc->addRegisterCallback(MinXmlHttpRequest::_js_register); - - sc->start(); - - ScriptEngineProtocol *pEngine = ScriptingCore::getInstance(); - ScriptEngineManager::getInstance()->setScriptEngine(pEngine); - ScriptingCore::getInstance()->runScript("hello.js"); - - return true; -} - -void handle_signal(int signal) { - static int internal_state = 0; - ScriptingCore* sc = ScriptingCore::getInstance(); - // should start everything back - Director* director = Director::getInstance(); - if (director->getRunningScene()) { - director->popToRootScene(); - } else { - PoolManager::sharedPoolManager()->finalize(); - if (internal_state == 0) { - //sc->dumpRoot(NULL, 0, NULL); - sc->start(); - internal_state = 1; - } else { - sc->runScript("hello.js"); - internal_state = 0; - } - } -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - Director::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); -} diff --git a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.h deleted file mode 100644 index 244d2da335..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Classes/AppDelegate.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// GCTestAppDelegate.h -// GCTest -// -// Created by Rohan Kuruvilla on 06/08/2012. -// Copyright __MyCompanyName__ 2012. All rights reserved. -// - -#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(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/xcode4/cocos2dx_js.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_js.xctemplate/Prefix.pch deleted file mode 100644 index aa3260079c..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id deleted file mode 100644 index 18b9c22de9..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -f06c047dd32b61f12ad51e981afe518364512be6 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id deleted file mode 100644 index 717ceb89a1..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4b7c1e97acefff48ae3652f023e708245992f553 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id deleted file mode 100644 index fb1884455b..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ae62d7b07ac3e7579ed7d6a2e1f903719e45c6d9 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id deleted file mode 100644 index 5067e00b74..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -12db20c3124e1bd864312257eb8cefe95d2ee349 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id deleted file mode 100644 index 8ddebffce2..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e71140c1535f16b49980f3ea0cf7d3a29a8a9788 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id deleted file mode 100644 index 15f23ffc85..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -dc235c169030151e337ecbfa1fc6302fc909e500 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id deleted file mode 100644 index 2549ab6362..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -9e95a02e6eb2944fea12a49eb3f2c6fe7505a3ce \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id deleted file mode 100644 index 83954562c0..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -1423c81273926b3da9fb1cb36c9b710d3f14ee0e \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/debugger.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/debugger.js deleted file mode 100644 index 394864a923..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/debugger.js +++ /dev/null @@ -1,208 +0,0 @@ -// first attempt at the debugger - -var g = newGlobal("debug-global"); -var dbg = Debugger(g); - -var breakpointHandler = { - hit: function (frame) { - var script = frame.script; - _socketWrite(dbg.socket, "entering breakpoint: \n"); - _socketWrite(dbg.socket, " " + script.url + ":" + script.getOffsetLine(frame.offset) + "\n"); - beginDebug(frame, frame.script); - } -}; - -/** - let offsets = script.getLineOffsets(aLocation.line); - let codeFound = false; - for (let i = 0; i < offsets.length; i++) { - script.setBreakpoint(offsets[i], bpActor); - codeFound = true; - } - - let actualLocation; - if (offsets.length == 0) { - // No code at that line in any script, skipping forward. - let lines = script.getAllOffsets(); - let oldLine = aLocation.line; - for (let line = oldLine; line < lines.length; ++line) { - if (lines[line]) { - for (let i = 0; i < lines[line].length; i++) { - script.setBreakpoint(lines[line][i], bpActor); - codeFound = true; - } - actualLocation = { - url: aLocation.url, - line: line, - column: aLocation.column - }; - bpActor.location = actualLocation; - // Update the cache as well. - scriptBreakpoints[line] = scriptBreakpoints[oldLine]; - scriptBreakpoints[line].line = line; - delete scriptBreakpoints[oldLine]; - break; - } - } - } -*/ - -var beginDebug = function (frame, script) { - log(">> debugging js... listening on port 1337"); - var stop = false; - var offsets = 0; - var processInput = function (str, socket) { - var md = str.match(/^break current:(\d+)/); - if (!frame && md) { - var codeFound = false, i; - offsets = script.getLineOffsets(parseInt(md[1], 10)); - _socketWrite(socket, "offsets: " + JSON.stringify(offsets) + "\n"); - for (i=0; i < offsets.lenth; i++) { - script.setBreakpoint(offsets[i], breakpointHandler); - codeFound = true; - } - if (offsets.length === 0) { - var lines = script.getAllOffsets(); - var oldLine = parseInt(md[1], 10); - for (var line = oldLine; line < lines.length; ++line) { - if (lines[line]) { - for (i=0; i < lines[line].length; i++) { - script.setBreakpoint(lines[line][i], breakpointHandler); - codeFound = true; - } - break; - } - } - } - if (!codeFound) { - _socketWrite(socket, "invalid offset: " + offsets.join(",") + "\n"); - } else { - _socketWrite(socket, "socket set at line " + md[1] + " for current file\n"); - } - return; - } - md = str.match(/^b(reak)?\s+([^:]+):(\d+)/); - if (md) { - script = _getScript(md[2]); - if (script) { - offsets = script.getLineOffset(parseInt(md[3], 10)); - script.setBreakpoint(offsets[0], breakpointHandler); - _socketWrite(socket, "breakpoint set for line " + md[3] + " of script " + md[2] + "\n"); - } else { - _socketWrite(socket, "no script with that name" + "\n"); - } - return; - } - md = str.match(/^c(ontinue)?/); - if (md) { - stop = true; - return; - } - md = str.match(/^eval\s+(.+)/); - if (md && frame) { - var res = frame['eval'](md[1]), - k; - if (res['return']) { - var r = res['return']; - _socketWrite(socket, "* " + (typeof r) + "\n"); - if (typeof r == "string") { - _socketWrite(socket, "~> " + r + "\n"); - } else { - var props = r.getOwnPropertyNames(); - for (k in props) { - var desc = r.getOwnPropertyDescriptor(props[k]); - _socketWrite(socket, "~> " + props[k] + " = "); - if (desc.value) { - _socketWrite(socket, "" + desc.value); - } else if (desc.get) { - _socketWrite(socket, "" + desc.get()); - } else { - _socketWrite(socket, "undefined (no value or getter)"); - } - _socketWrite(socket, "\n"); - } - } - } else if (res['throw']) { - _socketWrite(socket, "!! got exception: " + res['throw'].message + "\n"); - } else { - _socketWrite(socket, "!!! invalid return for eval" + "\n"); - for (k in res) { - _socketWrite(socket, "* " + k + ": " + res[k] + "\n"); - } - } - return; - } else if (md) { - _socketWrite(socket, "! no frame to eval in\n"); - return; - } - md = str.match(/^line/); - if (md && frame) { - _socketWrite(socket, "current line: " + script.getOffsetLine(frame.offset) + "\n"); - return; - } else if (md) { - _socketWrite(socket, "no line, probably entering script\n"); - return; - } - md = str.match(/^bt/); - if (md && frame) { - var cur = frame, - stack = [cur.script.url + ":" + cur.script.getOffsetLine(cur.offset)]; - while ((cur = cur.older)) { - stack.push(cur.script.url + ":" + cur.script.getOffsetLine(cur.offset)); - } - _socketWrite(socket, stack.join("\n") + "\n"); - return; - } else if (md) { - _socketWrite(socket, "no valid frame\n"); - return; - } - _socketWrite("! invalid command" + "\n"); - }; - - _socketOpen(1337, function (socket) { - _socketWrite(socket, "entering debugger for file " + script.url + "\n"); - _socketWrite(socket, ">> "); - // set the client socket - dbg.socket = socket; - var str; - while (!stop && (str = _socketRead(socket))) { - processInput(str, socket); - if (!stop) - _socketWrite(socket, ">> "); - else { - _socketWrite(socket, "continuing execution\n"); - } - } - }); -}; - -dbg.onNewScript = function (script) { - // skip if the url is this script - var last = script.url.split("/").pop(); - if (last != "debugger.js" && script.url != "debugger eval code") { - log("on new script: " + script.url + "; will enter debugger"); - beginDebug(null, script); - } -}; - -dbg.onDebuggerStatement = function (frame) { - log("!! on debugger"); - beginDebug(frame, frame.script); -}; - -dbg.onError = function (frame, report) { - if (dbg.socket && report) { - _socketWrite(dbg.socket, "!! exception @ " + report.file + ":" + report.line); - } - log("!! exception"); - beginDebug(frame, frame.script); -}; - -function startDebugger(files, startFunc) { - for (var i in files) { - g['eval']("require('" + files[i] + "');"); - } - if (startFunc) { - g['eval'](startFunc); - } -} diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js deleted file mode 100644 index f1c911fc31..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js +++ /dev/null @@ -1,155 +0,0 @@ -require("jsb.js"); - -try { - - director = cc.Director.getInstance(); - winSize = director.getWinSize(); - centerPos = cc.p( winSize.width/2, winSize.height/2 ); - - // - // Main Menu - // - - // 'MenuLayerController' class is instantiated by CocosBuilder Reader - var MenuLayerController = function () { - }; - - // callback triggered by CCB Reader once the instance is created - MenuLayerController.prototype.onDidLoadFromCCB = function () { - // Spin the 'o' in the title - var o = this.titleLabel.getChildByTag(8); - - var a_delay = cc.DelayTime.create(6); - var a_tint = cc.TintTo.create(0.5, 0, 255, 0); - var a_rotate = cc.RotateBy.create(4, 360); - var a_rep = cc.Repeat.create(a_rotate, 1000); - var a_seq = cc.Sequence.create(a_delay, a_tint, a_delay.copy(), a_rep); - o.runAction(a_seq); - }; - - // callbacks for the menu, defined in the editor - MenuLayerController.prototype.onPlay = function () { - director.replaceScene( cc.TransitionFade.create(1, game.getPlayScene()) ); - }; - - MenuLayerController.prototype.onOptions = function () { - director.replaceScene( cc.TransitionFade.create(1, game.getOptionsScene()) ); - }; - - MenuLayerController.prototype.onAbout = function () { - director.replaceScene( cc.TransitionZoomFlipY.create(1, game.getAboutScene()) ); - }; - - var AboutLayerController = function() {} - - AboutLayerController.prototype.onDidLoadFromCCB = function () { - var back = cc.MenuItemFont.create("Back", this.onBack, this); - back.setColor(cc.BLACK); - var menu = cc.Menu.create(back); - this.rootNode.addChild(menu); - menu.zOrder = 100; - menu.alignItemsVertically(); - menu.setPosition(winSize.width - 50, 50); - }; - - AboutLayerController.prototype.onBack = function () { - director.replaceScene( cc.TransitionFade.create(1, game.getMainMenuScene())); - }; - - var GameCreator = function() { - - var self = {}; - self.callbacks = {}; - - self.getPlayScene = function() { - - var scene = new cc.Scene(); - var layer = new cc.LayerGradient(); - - layer.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); - - var lab = "Houston we have liftoff!"; - var label = cc.LabelTTF.create(lab, "Arial", 28); - layer.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height / 2)); - - var back = cc.MenuItemFont.create("Back", self.callbacks.onBack, self.callbacks); - back.setColor( cc.BLACK ); - - var menu = cc.Menu.create( back ); - layer.addChild( menu ); - menu.alignItemsVertically(); - menu.setPosition( cc.p( winSize.width - 50, 50) ); - - scene.addChild(layer); - - return scene; - }; - - self.getMainMenuScene = function() { - return cc.BuilderReader.loadAsScene("MainMenu.ccbi"); - }; - - self.getOptionsScene = function() { - - var l = cc.LayerGradient.create(); - l.init(cc.c4b(0, 0, 0, 255), cc.c4b(255, 255, 255, 255)); - - var scene = cc.Scene.create(); - - var label1 = cc.LabelBMFont.create("MUSIC ON", "konqa32.fnt" ); - var item1 = cc.MenuItemLabel.create(label1); - var label2 = cc.LabelBMFont.create("MUSIC OFF", "konqa32.fnt" ); - var item2 = cc.MenuItemLabel.create(label2); - var toggle = cc.MenuItemToggle.create( item1, item2 ); - - this.onMusicToggle = function( sender ) { - cc.log("OptionsScene onMusicToggle..."); - }; - - toggle.setCallback( this.onMusicToggle, this); - - var back = cc.MenuItemFont.create("Back", self.callbacks.onBack, self.callbacks); - var menu = cc.Menu.create( toggle, back ); - l.addChild( menu ); - menu.alignItemsVertically(); - menu.setPosition( centerPos ); - - scene.addChild(l); - - return scene; - }; - - - self.getAboutScene = function() { - - var scene = cc.Scene.create(); - var l = cc.Layer.create(); - var about = cc.BuilderReader.load("About.ccbi", l); - l.addChild( about ) - - scene.addChild( l ); - - return scene; - }; - - // Manual Callbacks - - self.callbacks.onBack = function( sender) { - director.replaceScene( cc.TransitionFlipX.create(1, self.getMainMenuScene()) ); - }; - - return self; - - }; - - var game = GameCreator(); - - __jsc__.garbageCollect(); - - // LOADING PLAY SCENE UNTILL CCBREADER IS FIXED - - director.runWithScene(game.getPlayScene()); - -} catch(e) {log(e);} - diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb.js deleted file mode 100644 index 5fabbaea88..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb.js +++ /dev/null @@ -1,10 +0,0 @@ -// -// Javascript Bindigns helper file -// - -// DO NOT ALTER THE ORDER -require('jsb_cocos2d.js'); -require('jsb_chipmunk.js'); -require('jsb_opengl.js'); -require('jsb_cocosbuilder.js'); -require('jsb_sys.js'); diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_chipmunk.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_chipmunk.js deleted file mode 100644 index ba8613f4c1..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_chipmunk.js +++ /dev/null @@ -1,328 +0,0 @@ -// -// Chipmunk defines -// - -var cp = cp || {}; - -cp.v = cc.p; -cp._v = cc._p; -cp.vzero = cp.v(0,0); - -// Vector: Compatibility with Chipmunk-JS -cp.v.add = cp.vadd; -cp.v.clamp = cp.vclamp; -cp.v.cross = cp.vcross; -cp.v.dist = cp.vdist; -cp.v.distsq = cp.vdistsq; -cp.v.dot = cp.vdot; -cp.v.eql = cp.veql; -cp.v.forangle = cp.vforangle; -cp.v.len = cp.vlength; -cp.v.lengthsq = cp.vlengthsq; -cp.v.lerp = cp.vlerp; -cp.v.lerpconst = cp.vlerpconst; -cp.v.mult = cp.vmult; -cp.v.near = cp.vnear; -cp.v.neg = cp.vneg; -cp.v.normalize = cp.vnormalize; -cp.v.normalize_safe = cp.vnormalize_safe; -cp.v.perp = cp.vperp; -cp.v.project = cp.vproject; -cp.v.rotate = cp.vrotate; -cp.v.rperp = cp.vrperp; -cp.v.slerp = cp.vslerp; -cp.v.slerpconst = cp.vslerpconst; -cp.v.sub = cp.vsub; -cp.v.toangle = cp.vtoangle; -cp.v.unrotate = cp.vunrotate; - -// XXX: renaming functions should be supported in JSB -cp.clamp01 = cp.fclamp01; - - -/// Initialize an offset box shaped polygon shape. -cp.BoxShape2 = function(body, box) -{ - var verts = [ - box.l, box.b, - box.l, box.t, - box.r, box.t, - box.r, box.b - ]; - - return new cp.PolyShape(body, verts, cp.vzero); -}; - -/// Initialize a box shaped polygon shape. -cp.BoxShape = function(body, width, height) -{ - var hw = width/2; - var hh = height/2; - - return cp.BoxShape2(body, new cp.BB(-hw, -hh, hw, hh)); -}; - - -/// Initialize an static body -cp.StaticBody = function() -{ - return new cp.Body(Infinity, Infinity); -}; - - -// "Bounding Box" compatibility with Chipmunk-JS -cp.BB = function(l, b, r, t) -{ - return {l:l, b:b, r:r, t:t}; -}; - -// helper function to create a BB -cp.bb = function(l, b, r, t) { - return new cp.BB(l, b, r, t); -}; - -// -// Some properties -// -// "handle" needed in some cases -Object.defineProperties(cp.Base.prototype, - { - "handle" : { - get : function(){ - return this.getHandle(); - }, - enumerable : true, - configurable : true - } - }); - -// Properties, for Chipmunk-JS compatibility -// Space properties -Object.defineProperties(cp.Space.prototype, - { - "gravity" : { - get : function(){ - return this.getGravity(); - }, - set : function(newValue){ - this.setGravity(newValue); - }, - enumerable : true, - configurable : true - }, - "iterations" : { - get : function(){ - return this.getIterations(); - }, - set : function(newValue){ - this.setIterations(newValue); - }, - enumerable : true, - configurable : true - }, - "damping" : { - get : function(){ - return this.getDamping(); - }, - set : function(newValue){ - this.setDamping(newValue); - }, - enumerable : true, - configurable : true - }, - "staticBody" : { - get : function(){ - return this.getStaticBody(); - }, - enumerable : true, - configurable : true - }, - "idleSpeedThreshold" : { - get : function(){ - return this.getIdleSpeedThreshold(); - }, - set : function(newValue){ - this.setIdleSpeedThreshold(newValue); - }, - enumerable : true, - configurable : true - }, - "sleepTimeThreshold": { - get : function(){ - return this.getSleepTimeThreshold(); - }, - set : function(newValue){ - this.setSleepTimeThreshold(newValue); - }, - enumerable : true, - configurable : true - }, - "collisionSlop": { - get : function(){ - return this.getCollisionSlop(); - }, - set : function(newValue){ - this.setCollisionSlop(newValue); - }, - enumerable : true, - configurable : true - }, - "collisionBias": { - get : function(){ - return this.getCollisionBias(); - }, - set : function(newValue){ - this.setCollisionBias(newValue); - }, - enumerable : true, - configurable : true - }, - "collisionPersistence": { - get : function(){ - return this.getCollisionPersistence(); - }, - set : function(newValue){ - this.setCollisionPersistence(newValue); - }, - enumerable : true, - configurable : true - }, - "enableContactGraph": { - get : function(){ - return this.getEnableContactGraph(); - }, - set : function(newValue){ - this.setEnableContactGraph(newValue); - }, - enumerable : true, - configurable : true - } - }); - -// Body properties -Object.defineProperties(cp.Body.prototype, - { - "a" : { - get : function(){ - return this.getAngle(); - }, - set : function(newValue){ - this.setAngle(newValue); - }, - enumerable : true, - configurable : true - }, - "w" : { - get : function(){ - return this.getAngVel(); - }, - set : function(newValue){ - this.setAngVel(newValue); - }, - enumerable : true, - configurable : true - }, - "p" : { - get : function(){ - return this.getPos(); - }, - set : function(newValue){ - this.setPos(newValue); - }, - enumerable : true, - configurable : true - }, - "v" : { - get : function(){ - return this.getVel(); - }, - set : function(newValue){ - this.setVel(newValue); - }, - enumerable : true, - configurable : true - }, - "i" : { - get : function(){ - return this.getMoment(); - }, - set : function(newValue){ - this.setMoment(newValue); - }, - enumerable : true, - configurable : true - } - - }); - -// Shape properties -Object.defineProperties(cp.Shape.prototype, - { - "body" : { - get : function(){ - return this.getBody(); - }, - set : function(newValue){ - this.setBody(newValue); - }, - enumerable : true, - configurable : true - }, - "group" : { - get : function(){ - return this.getGroup(); - }, - set : function(newValue){ - this.setGroup(newValue); - }, - enumerable : true, - configurable : true - }, - "collision_type" : { - get : function(){ - return this.getCollisionType(); - }, - enumerable : true, - configurable : true - } - }); - -// Constraint properties -Object.defineProperties(cp.Constraint.prototype, - { - "maxForce" : { - get : function(){ - return this.getMaxForce(); - }, - set : function(newValue){ - this.setMaxForce(newValue); - }, - enumerable : true, - configurable : true - } - }); - -// PinJoint properties -Object.defineProperties(cp.PinJoint.prototype, - { - "anchr1" : { - get : function(){ - return this.getAnchr1(); - }, - set : function(newValue){ - this.setAnchr1(newValue); - }, - enumerable : true, - configurable : true - }, - "anchr2" : { - get : function(){ - return this.getAnchr2(); - }, - set : function(newValue){ - this.setAnchr2(newValue); - }, - enumerable : true, - configurable : true - } - }); diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocos2d.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocos2d.js deleted file mode 100644 index f7f36de786..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocos2d.js +++ /dev/null @@ -1,528 +0,0 @@ -// -// cocos2d constants -// - -var cc = cc || {}; - -cc.DIRECTOR_PROJECTION_2D = 0; -cc.DIRECTOR_PROJECTION_3D = 1; - -cc.TEXTURE_PIXELFORMAT_RGBA8888 = 0; -cc.TEXTURE_PIXELFORMAT_RGB888 = 1; -cc.TEXTURE_PIXELFORMAT_RGB565 = 2; -cc.TEXTURE_PIXELFORMAT_A8 = 3; -cc.TEXTURE_PIXELFORMAT_I8 = 4; -cc.TEXTURE_PIXELFORMAT_AI88 = 5; -cc.TEXTURE_PIXELFORMAT_RGBA4444 = 6; -cc.TEXTURE_PIXELFORMAT_RGB5A1 = 7; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 8; -cc.TEXTURE_PIXELFORMAT_PVRTC4 = 9; -cc.TEXTURE_PIXELFORMAT_DEFAULT = cc.TEXTURE_PIXELFORMAT_RGBA8888; - -cc.TEXT_ALIGNMENT_LEFT = 0; -cc.TEXT_ALIGNMENT_CENTER = 1; -cc.TEXT_ALIGNMENT_RIGHT = 2; - -cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0; -cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1; -cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2; - -cc.IMAGE_FORMAT_JPEG = 0; -cc.IMAGE_FORMAT_PNG = 0; - -cc.PROGRESS_TIMER_TYPE_RADIAL = 0; -cc.PROGRESS_TIMER_TYPE_BAR = 1; - -cc.PARTICLE_TYPE_FREE = 0; -cc.PARTICLE_TYPE_RELATIVE = 1; -cc.PARTICLE_TYPE_GROUPED = 2; -cc.PARTICLE_DURATION_INFINITY = -1; -cc.PARTICLE_MODE_GRAVITY = 0; -cc.PARTICLE_MODE_RADIUS = 1; -cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE = -1; -cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS = -1; - -cc.TOUCH_ALL_AT_ONCE = 0; -cc.TOUCH_ONE_BY_ONE = 1; - -cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000; -cc.TMX_TILE_VERTICAL_FLAG = 0x40000000; -cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000; - -cc.TRANSITION_ORIENTATION_LEFT_OVER = 0; -cc.TRANSITION_ORIENTATION_RIGHT_OVER = 1; -cc.TRANSITION_ORIENTATION_UP_OVER = 0; -cc.TRANSITION_ORIENTATION_DOWN_OVER = 1; - -cc.RED = {r:255, g:0, b:0}; -cc.GREEN = {r:0, g:255, b:0}; -cc.BLUE = {r:0, g:0, b:255}; -cc.BLACK = {r:0, g:0, b:0}; -cc.WHITE = {r:255, g:255, b:255}; - -cc.POINT_ZERO = {x:0, y:0}; - -// XXX: This definition is different than cocos2d-html5 -// cc.REPEAT_FOREVER = - 1; -// We can't assign -1 to cc.REPEAT_FOREVER, since it will be a very big double value after -// converting it to double by JS_ValueToNumber on android. -// Then cast it to unsigned int, the value will be 0. The schedule will not be able to work. -// I don't know why this occurs only on android. -// So instead of passing -1 to it, I assign it with max value of unsigned int in c++. -cc.REPEAT_FOREVER = 0xffffffff; - -cc.MENU_STATE_WAITING = 0; -cc.MENU_STATE_TRACKING_TOUCH = 1; -cc.MENU_HANDLER_PRIORITY = -128; -cc.DEFAULT_PADDING = 5; - -// reusable objects -cc._reuse_p = [ {x:0, y:0}, {x:0,y:0}, {x:0,y:0}, {x:0,y:0} ]; -cc._reuse_p_index = 0; -cc._reuse_size = {width:0, height:0}; -cc._reuse_rect = {x:0, y:0, width:0, height:0}; -cc._reuse_color3b = {r:255, g:255, b:255 }; -cc._reuse_color4b = {r:255, g:255, b:255, a:255 }; -cc.log = cc.log || log; - -// -// Color 3B -// -cc.c3b = function( r, g, b ) -{ - return {r:r, g:g, b:b }; -}; -cc._c3b = function( r, g, b ) -{ - cc._reuse_color3b.r = r; - cc._reuse_color3b.g = g; - cc._reuse_color3b.b = b; - return cc._reuse_color3b; -}; - -// -// Color 4B -// -cc.c4b = function( r, g, b, a ) -{ - return {r:r, g:g, b:b, a:a }; -}; -cc._c4b = function( r, g, b, a ) -{ - cc._reuse_color4b.r = r; - cc._reuse_color4b.g = g; - cc._reuse_color4b.b = b; - cc._reuse_color4b.a = a; - return cc._reuse_color4b; -}; -// compatibility -cc.c4 = cc.c4b; -cc._c4 = cc._c4b; - -// -// Color 4F -// -cc.c4f = function( r, g, b, a ) -{ - return {r:r, g:g, b:b, a:a }; -}; - -// -// Point -// -cc.p = function( x, y ) -{ - return {x:x, y:y}; -}; -cc._p = function( x, y ) -{ - if( cc._reuse_p_index == cc._reuse_p.length ) - cc._reuse_p_index = 0; - - var p = cc._reuse_p[ cc._reuse_p_index]; - cc._reuse_p_index++; - p.x = x; - p.y = y; - return p; -}; - -cc.pointEqualToPoint = function (point1, point2) { - return ((point1.x == point2.x) && (point1.y == point2.y)); -}; - -// -// Grid -// -cc._g = function( x, y ) -{ - cc._reuse_grid.x = x; - cc._reuse_grid.y = y; - return cc._reuse_grid; -}; - -// -// Size -// -cc.size = function(w,h) -{ - return {width:w, height:h}; -}; -cc._size = function(w,h) -{ - cc._reuse_size.width = w; - cc._reuse_size.height = h; - return cc._reuse_size; -}; -cc.sizeEqualToSize = function (size1, size2) -{ - return ((size1.width == size2.width) && (size1.height == size2.height)); -}; - -// -// Rect -// -cc.rect = function(x,y,w,h) -{ - return {x:x, y:y, width:w, height:h}; -}; -cc._rect = function(x,y,w,h) -{ - cc._reuse_rect.x = x; - cc._reuse_rect.y = y; - cc._reuse_rect.width = w; - cc._reuse_rect.height = h; - return cc._reuse_rect; -}; -cc.rectEqualToRect = function (rect1, rect2) { - return ( rect1.x==rect2.x && rect1.y==rect2.y && rect1.width==rect2.width && rect1.height==rect2.height); -}; - -cc.rectContainsRect = function (rect1, rect2) { - if ((rect1.x >= rect2.x) || (rect1.y >= rect2.y) || - ( rect1.x + rect1.width <= rect2.x + rect2.width) || - ( rect1.y + rect1.height <= rect2.y + rect2.height)) - return false; - return true; -}; - -cc.rectGetMaxX = function (rect) { - return (rect.x + rect.width); -}; - -cc.rectGetMidX = function (rect) { - return (rect.x + rect.width / 2.0); -}; - -cc.rectGetMinX = function (rect) { - return rect.x; -}; - -cc.rectGetMaxY = function (rect) { - return(rect.y + rect.height); -}; - -cc.rectGetMidY = function (rect) { - return rect.y + rect.height / 2.0; -}; - -cc.rectGetMinY = function (rect) { - return rect.y; -}; - -cc.rectContainsPoint = function (rect, point) { - var ret = false; - if (point.x >= rect.x && point.x <= rect.x + rect.width && - point.y >= rect.y && point.y <= rect.y + rect.height) { - ret = true; - } - return ret; -}; - -cc.rectIntersectsRect = function( rectA, rectB ) -{ - var bool = ! ( rectA.x > rectB.x + rectB.width || - rectA.x + rectA.width < rectB.x || - rectA.y > rectB.y +rectB.height || - rectA.y + rectA.height < rectB.y ); - - return bool; -}; - -cc.rectUnion = function (rectA, rectB) { - var rect = cc.rect(0, 0, 0, 0); - rect.x = Math.min(rectA.x, rectB.x); - rect.y = Math.min(rectA.y, rectB.y); - rect.width = Math.max(rectA.x + rectA.width, rectB.x + rectB.width) - rect.x; - rect.height = Math.max(rectA.y + rectA.height, rectB.y + rectB.height) - rect.y; - return rect; -}; - -cc.rectIntersection = function (rectA, rectB) { - var intersection = cc.rect( - Math.max(rectA.x, rectB.x), - Math.max(rectA.y, rectB.y), - 0, 0); - - intersection.width = Math.min(rectA.x+rectA.width, rectB.x+rectB.width) - intersection.x; - intersection.height = Math.min(rectA.y+rectA.height, rectB.y+rectB.height) - intersection.y; - return intersection; -}; - -// -// Array: for cocos2d-html5 compatibility -// - -/** - * Returns index of first occurence of object, -1 if value not found. - * @function - * @param {Array} arr Source Array - * @param {*} findObj find object - * @return {Number} index of first occurence of value - */ -cc.ArrayGetIndexOfObject = function (arr, findObj) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == findObj) - return i; - } - return -1; -}; - -/** - * Returns a Boolean value that indicates whether value is present in the array. - * @function - * @param {Array} arr - * @param {*} findObj - * @return {Boolean} - */ -cc.ArrayContainsObject = function (arr, findObj) { - return cc.ArrayGetIndexOfObject(arr, findObj) != -1; -}; - -cc.ArrayRemoveObject = function (arr, delObj) { - for (var i = 0; i < arr.length; i++) { - if (arr[i] == delObj) { - arr.splice(i, 1); - } - } -}; - -// -// Helpers -// -cc.dump = function(obj) -{ - for( var i in obj ) - cc.log( i + " = " + obj[i] ); -}; - -// dump config info, but only in debug mode -cc.dumpConfig = function() -{ - cc.dump(sys); - cc.dump(sys.capabilities); -}; - -// -// Bindings Overrides -// -// MenuItemToggle -cc.MenuItemToggle.create = function( /* var args */) { - - var n = arguments.length; - - if (typeof arguments[n-2] === 'function' || typeof arguments[n-1] === 'function') { - var args = Array.prototype.slice.call(arguments); - var obj = null; - if( typeof arguments[n-2] === 'function' ) - obj = args.pop(); - - var func = args.pop(); - - // create it with arguments, - var item = cc.MenuItemToggle._create.apply(this, args); - - // then set the callback - if( obj !== null ) - item.setCallback(func, obj); - else - item.setCallback(func); - return item; - } else { - return cc.MenuItemToggle._create.apply(this, arguments); - } -}; - -// LabelAtlas -cc.LabelAtlas.create = function( a,b,c,d,e ) { - - var n = arguments.length; - - if ( n == 5) { - return cc.LabelAtlas._create(a,b,c,d,e.charCodeAt(0)); - } else { - return cc.LabelAtlas._create.apply(this, arguments); - } -}; - -cc.LayerMultiplex.create = cc.LayerMultiplex.createWithArray; - -// PhysicsDebugNode -cc.PhysicsDebugNode.create = function( space ) { - var s = space; - if( space.handle !== undefined ) - s = space.handle; - return cc.PhysicsDebugNode._create( s ); -}; -cc.PhysicsDebugNode.prototype.setSpace = function( space ) { - var s = space; - if( space.handle !== undefined ) - s = space.handle; - return this._setSpace( s ); -}; - -// PhysicsSprite -cc.PhysicsSprite.prototype.setBody = function( body ) { - var b = body; - if( body.handle !== undefined ) - b = body.handle; - return this._setCPBody( b ); -}; - - -/** - * Associates a base class with a native superclass - * @function - * @param {object} jsobj subclass - * @param {object} klass superclass - */ -cc.associateWithNative = function( jsobj, superclass_or_instance ) { - - try { - // Used when subclassing using the "extend" method - var native = new superclass_or_instance(); - __associateObjWithNative( jsobj, native ); - } catch(err) { - // Used when subclassing using the goog.inherits method - __associateObjWithNative( jsobj, superclass_or_instance ); - } -}; - -// -// JSB supports 2 official ways to create subclasses -// -// 1) Google "subclasses" borrowed from closure library -// This is the recommended way to do it -// -cc.inherits = function (childCtor, parentCtor) { - /** @constructor */ - function tempCtor() {}; - tempCtor.prototype = parentCtor.prototype; - childCtor.superClass_ = parentCtor.prototype; - childCtor.prototype = new tempCtor(); - childCtor.prototype.constructor = childCtor; - - // Copy "static" method, but doesn't generate subclasses. -// for( var i in parentCtor ) { -// childCtor[ i ] = parentCtor[ i ]; -// } -}; -cc.base = function(me, opt_methodName, var_args) { - var caller = arguments.callee.caller; - if (caller.superClass_) { - // This is a constructor. Call the superclass constructor. - ret = caller.superClass_.constructor.apply( me, Array.prototype.slice.call(arguments, 1)); - return ret; - } - - var args = Array.prototype.slice.call(arguments, 2); - var foundCaller = false; - for (var ctor = me.constructor; - ctor; ctor = ctor.superClass_ && ctor.superClass_.constructor) { - if (ctor.prototype[opt_methodName] === caller) { - foundCaller = true; - } else if (foundCaller) { - return ctor.prototype[opt_methodName].apply(me, args); - } - } - - // If we did not find the caller in the prototype chain, - // then one of two things happened: - // 1) The caller is an instance method. - // 2) This method was not called by the right caller. - if (me[opt_methodName] === caller) { - return me.constructor.prototype[opt_methodName].apply(me, args); - } else { - throw Error( - 'cc.base called from a method of one name ' + - 'to a method of a different name'); - } -}; - - -// -// 2) Using "extend" subclassing -// Simple JavaScript Inheritance By John Resig http://ejohn.org/ -// -cc.Class = function(){}; -cc.Class.extend = function (prop) { - var _super = this.prototype; - - // Instantiate a base class (but only create the instance, - // don't run the init constructor) - initializing = true; - var prototype = new this(); - initializing = false; - fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; - - // Copy the properties over onto the new prototype - for (var name in prop) { - // Check if we're overwriting an existing function - prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? - (function (name, fn) { - return function () { - var tmp = this._super; - - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; - - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; - - return ret; - }; - })(name, prop[name]) : - prop[name]; - } - - // The dummy class constructor - function Class() { - // All construction is actually done in the init method - if (!initializing && this.ctor) - this.ctor.apply(this, arguments); - } - - // Populate our constructed prototype object - Class.prototype = prototype; - - // Enforce the constructor to be what we expect - Class.prototype.constructor = Class; - - // And make this class extendable - Class.extend = arguments.callee; - - return Class; -}; - -cc.Node.prototype.ctor = function() {}; -cc.Node.extend = cc.Class.extend; -cc.Layer.extend = cc.Class.extend; -cc.LayerGradient.extend = cc.Class.extend; -cc.LayerColor.extend = cc.Class.extend; -cc.Sprite.extend = cc.Class.extend; -cc.MenuItemFont.extend = cc.Class.extend; -cc.Scene.extend = cc.Class.extend; -cc.DrawNode.extend = cc.Class.extend; diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocosbuilder.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocosbuilder.js deleted file mode 100644 index 93e111d1c0..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_cocosbuilder.js +++ /dev/null @@ -1,125 +0,0 @@ -// -// CocosBuilder definitions -// - -cc.BuilderReader = cc.BuilderReader || {}; -cc.BuilderReader._resourcePath = ""; - -var _ccbGlobalContext = this; - -cc.BuilderReader.setResourcePath = function (rootPath) { - cc.BuilderReader._resourcePath = rootPath; -}; - -cc.BuilderReader.load = function(file, owner, parentSize) -{ - // Load the node graph using the correct function - var reader = cc._Reader.create(); - reader.setCCBRootPath(cc.BuilderReader._resourcePath); - - var node; - - if (owner && parentSize) - { - node = reader.load(file, owner, parentSize); - } - else if (owner) - { - node = reader.load(file,owner); - } - else - { - node = reader.load(file); - } - - // Assign owner callbacks & member variables - if (owner) - { - // Callbacks - var ownerCallbackNames = reader.getOwnerCallbackNames(); - var ownerCallbackNodes = reader.getOwnerCallbackNodes(); - - for (var i = 0; i < ownerCallbackNames.length; i++) - { - var callbackName = ownerCallbackNames[i]; - var callbackNode = ownerCallbackNodes[i]; - - callbackNode.setCallback(owner[callbackName], owner); - } - - // Variables - var ownerOutletNames = reader.getOwnerOutletNames(); - var ownerOutletNodes = reader.getOwnerOutletNodes(); - - for (var i = 0; i < ownerOutletNames.length; i++) - { - var outletName = ownerOutletNames[i]; - var outletNode = ownerOutletNodes[i]; - - owner[outletName] = outletNode; - } - } - - var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers(); - var animationManagersForNodes = reader.getAnimationManagersForNodes(); - - // Attach animation managers to nodes and assign root node callbacks and member variables - for (var i = 0; i < nodesWithAnimationManagers.length; i++) - { - var innerNode = nodesWithAnimationManagers[i]; - var animationManager = animationManagersForNodes[i]; - - innerNode.animationManager = animationManager; - - var documentControllerName = animationManager.getDocumentControllerName(); - if (!documentControllerName) continue; - - // Create a document controller - var controller = new _ccbGlobalContext[documentControllerName](); - controller.controllerName = documentControllerName; - - innerNode.controller = controller; - controller.rootNode = innerNode; - - // Callbacks - var documentCallbackNames = animationManager.getDocumentCallbackNames(); - var documentCallbackNodes = animationManager.getDocumentCallbackNodes(); - - for (var j = 0; j < documentCallbackNames.length; j++) - { - var callbackName = documentCallbackNames[j]; - var callbackNode = documentCallbackNodes[j]; - - callbackNode.setCallback(controller[callbackName], controller); - } - - - // Variables - var documentOutletNames = animationManager.getDocumentOutletNames(); - var documentOutletNodes = animationManager.getDocumentOutletNodes(); - - for (var j = 0; j < documentOutletNames.length; j++) - { - var outletName = documentOutletNames[j]; - var outletNode = documentOutletNodes[j]; - - controller[outletName] = outletNode; - } - - if (typeof(controller.onDidLoadFromCCB) == "function") - { - controller.onDidLoadFromCCB(); - } - } - - return node; -}; - -cc.BuilderReader.loadAsScene = function(file, owner, parentSize) -{ - var node = cc.BuilderReader.load(file, owner, parentSize); - var scene = cc.Scene.create(); - scene.addChild( node ); - - return scene; -}; diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_debugger.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_debugger.js deleted file mode 100644 index 240fb7a93a..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_debugger.js +++ /dev/null @@ -1,191 +0,0 @@ -dbg = {}; - -// fallback for no cc -cc = {}; -cc.log = log; - -var breakpointHandler = { - hit: function (frame) { - var script = frame.script; - _lockVM(frame, frame.script); - } -}; - -var stepFunction = function (frame, script) { - if (dbg.breakLine > 0) { - var curLine = script.getOffsetLine(frame.offset); - if (curLine < dbg.breakLine) { - return; - } else { - _lockVM(frame, script); - // dbg.breakLine = 0; - // frame.onStep = undefined; - } - } else { - cc.log("invalid state onStep"); - } -}; - -dbg.breakLine = 0; - -var processInput = function (str, frame, script) { - str = str.replace(/\n$/, ""); - if (str.length === 0) { - return; - } - var md = str.match(/^b(reak)?\s+([^:]+):(\d+)/); - if (md) { - var scripts = dbg.scripts[md[2]], - tmpScript = null; - if (scripts) { - var breakLine = parseInt(md[3], 10), - off = -1; - for (var n=0; n < scripts.length; n++) { - offsets = scripts[n].getLineOffsets(breakLine); - if (offsets.length > 0) { - off = offsets[0]; - tmpScript = scripts[n]; - break; - } - } - if (off >= 0) { - tmpScript.setBreakpoint(off, breakpointHandler); - _bufferWrite("breakpoint set for line " + breakLine + " of script " + md[2] + "\n"); - } else { - _bufferWrite("no valid offsets at that line\n"); - } - } else { - _bufferWrite("no script named: " + md[2] + "\n"); - } - return; - } - md = str.match(/^scripts/); - if (md) { - cc.log("sending list of available scripts"); - _bufferWrite("scripts:\n" + Object.keys(dbg.scripts).join("\n") + "\n"); - return; - } - md = str.match(/^s(tep)?/); - if (md && frame) { - cc.log("will step"); - dbg.breakLine = script.getOffsetLine(frame.offset) + 1; - frame.onStep = function () { - stepFunction(frame, frame.script); - return undefined; - }; - stop = true; - _unlockVM(); - return; - } - md = str.match(/^c(ontinue)?/); - if (md) { - if (frame) { - frame.onStep = undefined; - dbg.breakLine = 0; - } - stop = true; - _unlockVM(); - return; - } - md = str.match(/^eval\s+(.+)/); - if (md && frame) { - var res = frame['eval'](md[1]), - k; - if (res['return']) { - var r = res['return']; - _bufferWrite("* " + (typeof r) + "\n"); - if (typeof r != "object") { - _bufferWrite("~> " + r + "\n"); - } else { - var props = r.getOwnPropertyNames(); - for (k in props) { - var desc = r.getOwnPropertyDescriptor(props[k]); - _bufferWrite("~> " + props[k] + " = "); - if (desc.value) { - _bufferWrite("" + desc.value); - } else if (desc.get) { - _bufferWrite("" + desc.get()); - } else { - _bufferWrite("undefined (no value or getter)"); - } - _bufferWrite("\n"); - } - } - } else if (res['throw']) { - _bufferWrite("!! got exception: " + res['throw'].message + "\n"); - } - return; - } else if (md) { - _bufferWrite("!! no frame to eval in\n"); - return; - } - md = str.match(/^line/); - if (md && frame) { - _bufferWrite("current line: " + script.getOffsetLine(frame.offset) + "\n"); - return; - } else if (md) { - _bufferWrite("no line, probably entering script\n"); - return; - } - md = str.match(/^bt/); - if (md && frame) { - var cur = frame, - stack = [cur.script.url + ":" + cur.script.getOffsetLine(cur.offset)]; - while ((cur = cur.older)) { - stack.push(cur.script.url + ":" + cur.script.getOffsetLine(cur.offset)); - } - _bufferWrite(stack.join("\n") + "\n"); - return; - } else if (md) { - _bufferWrite("no valid frame\n"); - return; - } - _bufferWrite("! invalid command: \"" + str + "\"\n"); -}; - -dbg.scripts = []; - -dbg.onNewScript = function (script) { - // skip if the url is this script - var last = script.url.split("/").pop(); - - var children = script.getChildScripts(), - arr = [script].concat(children); - /** - * just dumping all the offsets from the scripts - for (var i in arr) { - cc.log("script: " + arr[i].url); - for (var start=arr[i].startLine, j=start; j < start+arr[i].lineCount; j++) { - var offsets = arr[i].getLineOffsets(j); - cc.log(" off: " + offsets.join(",") + "; line: " + j); - } - } - */ - dbg.scripts[last] = arr; -}; - -dbg.onError = function (frame, report) { - if (dbg.socket && report) { - _socketWrite(dbg.socket, "!! exception @ " + report.file + ":" + report.line); - } - cc.log("!! exception"); -}; - -function _prepareDebugger(global) { - var tmp = new Debugger(global); - tmp.onNewScript = dbg.onNewScript; - tmp.onDebuggerStatement = dbg.onDebuggerStatement; - tmp.onError = dbg.onError; - dbg.dbg = tmp; -} - -function _startDebugger(global, files, startFunc) { - cc.log("starting with debugger enabled"); - for (var i in files) { - global['eval']("require('" + files[i] + "');"); - } - if (startFunc) { - global['eval'](startFunc); - } - // beginDebug(); -} diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_opengl.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_opengl.js deleted file mode 100644 index da7d6b7afd..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_opengl.js +++ /dev/null @@ -1,24 +0,0 @@ -// -// OpenGL defines -// - -var gl = gl || {}; - -gl.NEAREST = 0x2600; -gl.LINEAR = 0x2601; -gl.REPEAT = 0x2901; -gl.CLAMP_TO_EDGE = 0x812F; -gl.CLAMP_TO_BORDER = 0x812D; -gl.LINEAR_MIPMAP_NEAREST = 0x2701; -gl.NEAREST_MIPMAP_NEAREST = 0x2700; -gl.ZERO = 0; -gl.ONE = 1; -gl.SRC_COLOR = 0x0300; -gl.ONE_MINUS_SRC_COLOR = 0x0301; -gl.SRC_ALPHA = 0x0302; -gl.ONE_MINUS_SRC_ALPHA = 0x0303; -gl.DST_ALPHA = 0x0304; -gl.ONE_MINUS_DST_ALPHA = 0x0305; -gl.DST_COLOR = 0x0306; -gl.ONE_MINUS_DST_COLOR = 0x0307; -gl.SRC_ALPHA_SATURATE = 0x0308; diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_sys.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_sys.js deleted file mode 100644 index 086ef85ee5..0000000000 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/jsb_sys.js +++ /dev/null @@ -1,47 +0,0 @@ -// -// sys properties -// - -var sys = sys || {}; - -Object.defineProperties(sys, -{ - "capabilities" : { - get : function(){ - var capabilities = {"opengl":true}; - if( sys.platform == 'mobile' ) { - capabilities["accelerometer"] = true; - capabilities["touches"] = true; - } else { - // desktop - capabilities["keyboard"] = true; - capabilities["mouse"] = true; - } - return capabilities; - }, - enumerable : true, - configurable : true - }, - "os" : { - get : function(){ - return __getOS(); - }, - enumerable : true, - configurable : true - }, - "platform" : { - get : function(){ - return __getPlatform(); - }, - enumerable : true, - configurable : true - }, - "version" : { - get : function(){ - return __getVersion(); - }, - enumerable : true, - configurable : true - } - -}); diff --git a/template/xcode4/cocos2dx_js.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_js.xctemplate/TemplateIcon.icns deleted file mode 100644 index 0d9fef54cb..0000000000 Binary files a/template/xcode4/cocos2dx_js.xctemplate/TemplateIcon.icns and /dev/null differ diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp deleted file mode 100644 index 49a35b154c..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "cocos2d.h" -#include "AppDelegate.h" -#include "SimpleAudioEngine.h" -#include "script_support/CCScriptSupport.h" -#include "CCLuaEngine.h" - -USING_NS_CC; -using namespace CocosDenshion; - -AppDelegate::AppDelegate() -{ - // fixed me - //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF); -} - -AppDelegate::~AppDelegate() -{ - // end simple audio engine here, or it may crashed on win32 - SimpleAudioEngine::sharedEngine()->end(); - //CCScriptEngineManager::destroyInstance(); -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - Director *pDirector = Director::getInstance(); - pDirector->setOpenGLView(EGLView::getInstance()); - - // 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); - - // register lua engine - LuaEngine* pEngine = LuaEngine::defaultEngine(); - ScriptEngineManager::getInstance()->setScriptEngine(pEngine); - - std::string path = FileUtils::getInstance()->fullPathForFilename("hello.lua"); - pEngine->executeScriptFile(path.c_str()); - - 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::getInstance()->stopAnimation(); - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->pauseAllEffects(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - Director::getInstance()->startAnimation(); - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); - SimpleAudioEngine::sharedEngine()->resumeAllEffects(); -} diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.h b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.h deleted file mode 100644 index b708f4bdca..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.h +++ /dev/null @@ -1,38 +0,0 @@ -#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(); -}; - -#endif // _APP_DELEGATE_H_ - diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Prefix.pch b/template/xcode4/cocos2dx_lua.xctemplate/Prefix.pch deleted file mode 100644 index aa3260079c..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Prefix.pch +++ /dev/null @@ -1,8 +0,0 @@ -// -// Prefix header for all source files of the '___PROJECTNAME___' target in the '___PROJECTNAME___' project -// - -#ifdef __OBJC__ - #import - #import -#endif diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id b/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id deleted file mode 100644 index cfc16a8a4e..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/background.mp3.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -aec1c0a8c8068377fddca5ddd32084d8c3c3c419 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/farm.jpg.REMOVED.git-id b/template/xcode4/cocos2dx_lua.xctemplate/Resources/farm.jpg.REMOVED.git-id deleted file mode 100644 index 4609f3cf02..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/farm.jpg.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -d7290c34702d1c6bdb368acb060d93b42d5deff8 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua deleted file mode 100644 index 607a3b25de..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua +++ /dev/null @@ -1,203 +0,0 @@ - --- for CCLuaEngine traceback -function __G__TRACKBACK__(msg) - print("----------------------------------------") - print("LUA ERROR: " .. tostring(msg) .. "\n") - print(debug.traceback()) - print("----------------------------------------") -end - -local function main() - -- avoid memory leak - collectgarbage("setpause", 100) - collectgarbage("setstepmul", 5000) - - local cclog = function(...) - print(string.format(...)) - end - - require "hello2" - cclog("result is " .. myadd(3, 5)) - - --------------- - - local visibleSize = CCDirector:getInstance():getVisibleSize() - local origin = CCDirector:getInstance():getVisibleOrigin() - - -- add the moving dog - local function creatDog() - local frameWidth = 105 - local frameHeight = 95 - - -- create dog animate - local textureDog = CCTextureCache:getInstance():addImage("dog.png") - local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:createWithTexture(textureDog, rect) - rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:createWithTexture(textureDog, rect) - - local spriteDog = CCSprite:createWithSpriteFrame(frame0) - spriteDog.isPaused = false - spriteDog:setPosition(origin.x, origin.y + visibleSize.height / 4 * 3) - - local animFrames = CCArray:create() - - animFrames:addObject(frame0) - animFrames:addObject(frame1) - - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) - local animate = CCAnimate:create(animation); - spriteDog:runAction(CCRepeatForever:create(animate)) - - -- moving dog at every frame - local function tick() - if spriteDog.isPaused then return end - local x, y = spriteDog:getPosition() - if x > origin.x + visibleSize.width then - x = origin.x - else - x = x + 1 - end - - spriteDog:setPositionX(x) - end - - CCDirector:getInstance():getScheduler():scheduleScriptFunc(tick, 0, false) - - return spriteDog - end - - -- create farm - local function createLayerFarm() - local layerFarm = CCLayer:create() - - -- add in farm background - local bg = CCSprite:create("farm.jpg") - bg:setPosition(origin.x + visibleSize.width / 2 + 80, origin.y + visibleSize.height / 2) - layerFarm:addChild(bg) - - -- add land sprite - for i = 0, 3 do - for j = 0, 1 do - local spriteLand = CCSprite:create("land.png") - spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) - layerFarm:addChild(spriteLand) - end - end - - -- add crop - local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) - for i = 0, 3 do - for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); - spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) - layerFarm:addChild(spriteCrop) - end - end - - -- add moving dog - local spriteDog = creatDog() - layerFarm:addChild(spriteDog) - - -- handing touch events - local touchBeginPoint = nil - - local function onTouchBegan(x, y) - cclog("onTouchBegan: %0.2f, %0.2f", x, y) - touchBeginPoint = {x = x, y = y} - spriteDog.isPaused = true - -- CCTOUCHBEGAN event must return true - return true - end - - local function onTouchMoved(x, y) - cclog("onTouchMoved: %0.2f, %0.2f", x, y) - if touchBeginPoint then - local cx, cy = layerFarm:getPosition() - layerFarm:setPosition(cx + x - touchBeginPoint.x, - cy + y - touchBeginPoint.y) - touchBeginPoint = {x = x, y = y} - end - end - - local function onTouchEnded(x, y) - cclog("onTouchEnded: %0.2f, %0.2f", x, y) - touchBeginPoint = nil - spriteDog.isPaused = false - end - - local function onTouch(eventType, x, y) - if eventType == "began" then - return onTouchBegan(x, y) - elseif eventType == "moved" then - return onTouchMoved(x, y) - else - return onTouchEnded(x, y) - end - end - - layerFarm:registerScriptTouchHandler(onTouch) - layerFarm:setTouchEnabled(true) - - return layerFarm - end - - - -- create menu - local function createLayerMenu() - local layerMenu = CCLayer:create() - - local menuPopup, menuTools, effectID - - local function menuCallbackClosePopup() - -- stop test sound effect - SimpleAudioEngine:sharedEngine():stopEffect(effectID) - menuPopup:setVisible(false) - end - - local function menuCallbackOpenPopup() - -- loop test sound effect - local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - effectID = SimpleAudioEngine:sharedEngine():playEffect(effectPath) - menuPopup:setVisible(true) - end - - -- add a popup menu - local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") - menuPopupItem:setPosition(0, 0) - menuPopupItem:registerScriptTapHandler(menuCallbackClosePopup) - menuPopup = CCMenu:createWithItem(menuPopupItem) - menuPopup:setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2) - menuPopup:setVisible(false) - layerMenu:addChild(menuPopup) - - -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") - menuToolsItem:setPosition(0, 0) - menuToolsItem:registerScriptTapHandler(menuCallbackOpenPopup) - menuTools = CCMenu:createWithItem(menuToolsItem) - local itemWidth = menuToolsItem:getContentSize().width - local itemHeight = menuToolsItem:getContentSize().height - menuTools:setPosition(origin.x + itemWidth/2, origin.y + itemHeight/2) - layerMenu:addChild(menuTools) - - return layerMenu - end - - -- play background music, preload effect - - -- uncomment below for the BlackBerry version - -- local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.ogg") - local bgMusicPath = CCFileUtils:getInstance():fullPathForFilename("background.mp3") - SimpleAudioEngine:sharedEngine():playBackgroundMusic(bgMusicPath, true) - local effectPath = CCFileUtils:getInstance():fullPathForFilename("effect1.wav") - SimpleAudioEngine:sharedEngine():preloadEffect(effectPath) - - -- run - local sceneGame = CCScene:create() - sceneGame:addChild(createLayerFarm()) - sceneGame:addChild(createLayerMenu()) - CCDirector:getInstance():runWithScene(sceneGame) -end - -xpcall(main, __G__TRACKBACK__) diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello2.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello2.lua deleted file mode 100644 index 27158aa788..0000000000 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello2.lua +++ /dev/null @@ -1,3 +0,0 @@ -function myadd(x, y) - return x + y -end \ No newline at end of file diff --git a/template/xcode4/cocos2dx_lua.xctemplate/TemplateIcon.icns b/template/xcode4/cocos2dx_lua.xctemplate/TemplateIcon.icns deleted file mode 100644 index 0d9fef54cb..0000000000 Binary files a/template/xcode4/cocos2dx_lua.xctemplate/TemplateIcon.icns and /dev/null differ diff --git a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id deleted file mode 100644 index 50c226fc6c..0000000000 --- a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -4823a023cf264d8b8c7c2ac7934f21c30b776052 \ No newline at end of file diff --git a/tools/__init__.py b/tools/__init__.py new file mode 100755 index 0000000000..e69de29bb2 diff --git a/tools/bindings-generator b/tools/bindings-generator index 5fd67cb775..6c084a87f6 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 5fd67cb7750c0aa1da01e37e6ffe7d56b454032d +Subproject commit 6c084a87f667091088dfb46c3a8ef2b4cc84897b diff --git a/samples/Cpp/TestCpp/proj.emscripten/index.html b/tools/emscripten-template/index.html similarity index 95% rename from samples/Cpp/TestCpp/proj.emscripten/index.html rename to tools/emscripten-template/index.html index d1c4c339e0..c8ddb500e0 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/index.html +++ b/tools/emscripten-template/index.html @@ -3,7 +3,7 @@ - TestCpp + JS_APPLICATION