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

This commit is contained in:
samuele3hu 2014-03-27 11:21:20 +08:00
commit 6fbf1b4cdf
266 changed files with 2390 additions and 1267 deletions

View File

@ -793,6 +793,9 @@ Developers:
LoungeKatt LoungeKatt
Corrected a mistake of building android project in README.md Corrected a mistake of building android project in README.md
flashjay
Remove deprecated code in lua tests & template
Retired Core Developers: Retired Core Developers:
WenSheng Yang WenSheng Yang

View File

@ -1 +1 @@
7a4a3717b22578e2529226a4384ca423229137e7 2cf59ba2cf3781d24062b28a1f6305636615b464

View File

@ -1 +1 @@
ebeb897c2c3303710c06b9de3cb3d499f89fb78c bdcba92fe68d80bd996d1c61e15ea07397895549

View File

@ -159,6 +159,19 @@ Sequence* Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTime
return sequence; return sequence;
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Sequence* Sequence::variadicCreate(FiniteTimeAction *action1, ...)
{
va_list params;
va_start(params, action1);
Sequence *ret = Sequence::createWithVariableList(action1, params);
va_end(params);
return ret;
}
#else
Sequence* Sequence::create(FiniteTimeAction *action1, ...) Sequence* Sequence::create(FiniteTimeAction *action1, ...)
{ {
va_list params; va_list params;
@ -170,6 +183,7 @@ Sequence* Sequence::create(FiniteTimeAction *action1, ...)
return ret; return ret;
} }
#endif
Sequence* Sequence::createWithVariableList(FiniteTimeAction *action1, va_list args) Sequence* Sequence::createWithVariableList(FiniteTimeAction *action1, va_list args)
{ {
@ -532,6 +546,19 @@ RepeatForever *RepeatForever::reverse() const
// Spawn // Spawn
// //
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Spawn* Spawn::variadicCreate(FiniteTimeAction *action1, ...)
{
va_list params;
va_start(params, action1);
Spawn *ret = Spawn::createWithVariableList(action1, params);
va_end(params);
return ret;
}
#else
Spawn* Spawn::create(FiniteTimeAction *action1, ...) Spawn* Spawn::create(FiniteTimeAction *action1, ...)
{ {
va_list params; va_list params;
@ -543,6 +570,7 @@ Spawn* Spawn::create(FiniteTimeAction *action1, ...)
return ret; return ret;
} }
#endif
Spawn* Spawn::createWithVariableList(FiniteTimeAction *action1, va_list args) Spawn* Spawn::createWithVariableList(FiniteTimeAction *action1, va_list args)
{ {

View File

@ -93,7 +93,26 @@ class CC_DLL Sequence : public ActionInterval
{ {
public: public:
/** helper constructor to create an array of sequenceable actions */ /** helper constructor to create an array of sequenceable actions */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef FiniteTimeAction* M;
static Sequence* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
static Sequence* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); }
static Sequence* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static Sequence* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for variable argument lists longer than 10 items, use the other create functions or variadicCreate with NULL as the last argument
static Sequence* variadicCreate(FiniteTimeAction* item, ...);
#else
static Sequence* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION; static Sequence* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
#endif
/** helper constructor to create an array of sequenceable actions given an array /** helper constructor to create an array of sequenceable actions given an array
* @code * @code
* When this funtion bound to the js or lua,the input params changed * When this funtion bound to the js or lua,the input params changed
@ -248,7 +267,25 @@ public:
* in lua :local create(local object1,local object2, ...) * in lua :local create(local object1,local object2, ...)
* @endcode * @endcode
*/ */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef FiniteTimeAction* M;
static Spawn* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
static Spawn* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); }
static Spawn* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static Spawn* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for variable argument lists longer than 10 items, use the other create functions or createSpawn with NULL as the last argument
static Spawn* variadicCreate(FiniteTimeAction* item, ...);
#else
static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION; static Spawn* create(FiniteTimeAction *action1, ...) CC_REQUIRES_NULL_TERMINATION;
#endif
/** helper constructor to create an array of spawned actions */ /** helper constructor to create an array of spawned actions */
static Spawn* createWithVariableList(FiniteTimeAction *action1, va_list args); static Spawn* createWithVariableList(FiniteTimeAction *action1, va_list args);

View File

@ -67,7 +67,7 @@ public:
void setOwner(Node *pOwner); void setOwner(Node *pOwner);
Node* getOwner() const; Node* getOwner() const;
protected: protected:
Node *_owner; Node *_owner;
std::string _name; std::string _name;

View File

@ -61,7 +61,6 @@ bool ComponentContainer::add(Component *com)
if (_components == nullptr) if (_components == nullptr)
{ {
_components = new Map<std::string, Component*>(); _components = new Map<std::string, Component*>();
_owner->scheduleUpdate();
} }
Component *component = _components->at(com->getName()); Component *component = _components->at(com->getName());

View File

@ -963,6 +963,8 @@ CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetBlackBerry = Applic
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetNaCl = Application::Platform::OS_NACL; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetNaCl = Application::Platform::OS_NACL;
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetEmscripten = Application::Platform::OS_EMSCRIPTEN; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetEmscripten = Application::Platform::OS_EMSCRIPTEN;
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetTizen = Application::Platform::OS_TIZEN; CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetTizen = Application::Platform::OS_TIZEN;
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetWinRT = Application::Platform::OS_WINRT;
CC_DEPRECATED_ATTRIBUTE const Application::Platform kTargetWP8 = Application::Platform::OS_WP8;
CC_DEPRECATED_ATTRIBUTE typedef Application::Platform TargetPlatform; CC_DEPRECATED_ATTRIBUTE typedef Application::Platform TargetPlatform;
CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionExactFit = ResolutionPolicy::EXACT_FIT; CC_DEPRECATED_ATTRIBUTE const ResolutionPolicy kResolutionExactFit = ResolutionPolicy::EXACT_FIT;

View File

@ -45,6 +45,7 @@ THE SOFTWARE.
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "CCApplication.h" #include "CCApplication.h"
#include "CCFontFNT.h" #include "CCFontFNT.h"
#include "CCFontAtlasCache.h"
#include "CCActionManager.h" #include "CCActionManager.h"
#include "CCAnimationCache.h" #include "CCAnimationCache.h"
#include "CCTouch.h" #include "CCTouch.h"
@ -157,8 +158,10 @@ bool Director::init(void)
initTextureCache(); initTextureCache();
_renderer = new Renderer; _renderer = new Renderer;
_console = new Console;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
_console = new Console;
#endif
return true; return true;
} }
@ -182,7 +185,10 @@ Director::~Director(void)
delete _eventProjectionChanged; delete _eventProjectionChanged;
delete _renderer; delete _renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
delete _console; delete _console;
#endif
// clean auto release pool // clean auto release pool
PoolManager::destroyInstance(); PoolManager::destroyInstance();
@ -432,6 +438,12 @@ void Director::setProjection(Projection projection)
case Projection::_2D: case Projection::_2D:
kmGLMatrixMode(KM_GL_PROJECTION); kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity(); kmGLLoadIdentity();
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
if(getOpenGLView() != nullptr)
{
kmGLMultMatrix( getOpenGLView()->getOrientationMatrix());
}
#endif
kmMat4 orthoMatrix; kmMat4 orthoMatrix;
kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024); kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024);
kmGLMultMatrix(&orthoMatrix); kmGLMultMatrix(&orthoMatrix);
@ -447,7 +459,15 @@ void Director::setProjection(Projection projection)
kmGLMatrixMode(KM_GL_PROJECTION); kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity(); kmGLLoadIdentity();
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
//if needed, we need to add a rotation for Landscape orientations on Windows Phone 8 since it is always in Portrait Mode
GLView* view = getOpenGLView();
if(getOpenGLView() != nullptr)
{
kmGLMultMatrix(getOpenGLView()->getOrientationMatrix());
}
#endif
// issue #1334 // issue #1334
kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 10, zeye+size.height/2); kmMat4PerspectiveProjection(&matrixPerspective, 60, (GLfloat)size.width/size.height, 10, zeye+size.height/2);
// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500);
@ -485,10 +505,16 @@ void Director::setProjection(Projection projection)
void Director::purgeCachedData(void) void Director::purgeCachedData(void)
{ {
FontFNT::purgeCachedData(); FontFNT::purgeCachedData();
FontAtlasCache::purgeCachedData();
if (s_SharedDirector->getOpenGLView()) if (s_SharedDirector->getOpenGLView())
{ {
SpriteFrameCache::getInstance()->removeUnusedSpriteFrames(); SpriteFrameCache::getInstance()->removeUnusedSpriteFrames();
_textureCache->removeUnusedTextures(); _textureCache->removeUnusedTextures();
// Note: some tests such as ActionsTest are leaking refcounted textures
// There should be no test textures left in the cache
log("%s\n", _textureCache->getCachedTextureInfo().c_str());
} }
FileUtils::getInstance()->purgeCachedEntries(); FileUtils::getInstance()->purgeCachedEntries();
} }
@ -533,6 +559,11 @@ static void GLToClipTransform(kmMat4 *transformOut)
kmMat4 projection; kmMat4 projection;
kmGLGetMatrix(KM_GL_PROJECTION, &projection); kmGLGetMatrix(KM_GL_PROJECTION, &projection);
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
//if needed, we need to undo the rotation for Landscape orientation in order to get the correct positions
kmMat4Multiply(&projection, Director::getInstance()->getOpenGLView()->getReverseOrientationMatrix(), &projection);
#endif
kmMat4 modelview; kmMat4 modelview;
kmGLGetMatrix(KM_GL_MODELVIEW, &modelview); kmGLGetMatrix(KM_GL_MODELVIEW, &modelview);

View File

@ -59,7 +59,10 @@ class EventCustom;
class EventListenerCustom; class EventListenerCustom;
class TextureCache; class TextureCache;
class Renderer; class Renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
class Console; class Console;
#endif
/** /**
@brief Class that creates and handles the main Window and manages how @brief Class that creates and handles the main Window and manages how
@ -368,7 +371,9 @@ public:
/** Returns the Console /** Returns the Console
@since v3.0 @since v3.0
*/ */
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
Console* getConsole() const { return _console; } Console* getConsole() const { return _console; }
#endif
/* Gets delta time since last tick to main loop */ /* Gets delta time since last tick to main loop */
float getDeltaTime() const; float getDeltaTime() const;
@ -477,9 +482,11 @@ protected:
/* Renderer for the Director */ /* Renderer for the Director */
Renderer *_renderer; Renderer *_renderer;
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
/* Console for the director */ /* Console for the director */
Console *_console; Console *_console;
#endif
// GLViewProtocol will recreate stats labels to fit visible rect // GLViewProtocol will recreate stats labels to fit visible rect
friend class GLViewProtocol; friend class GLViewProtocol;
}; };

View File

@ -185,7 +185,9 @@ void FontAtlas::listenToForeground(EventCustom *event)
auto contentSize = Size(CacheTextureWidth,CacheTextureHeight); auto contentSize = Size(CacheTextureWidth,CacheTextureHeight);
auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8; auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize ); // this is a memory leak as the texture previously in _atlasTextures[_currentPage] is not deleted from OpenGL
// see CCTexture2D::initWithData for the temporary fix
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
} }
} }
#endif #endif
@ -257,8 +259,10 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
_currentPageOrigY += _commonLineHeight; _currentPageOrigY += _commonLineHeight;
_currentPageOrigX = 0; _currentPageOrigX = 0;
if(_currentPageOrigY + _commonLineHeight >= CacheTextureHeight) if(_currentPageOrigY + _commonLineHeight >= CacheTextureHeight)
{ {
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize ); // this is a memory leak as the texture previously in _atlasTextures[_currentPage] is not deleted from OpenGL
// see CCTexture2D::initWithData for the temporary fix
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
_currentPageOrigY = 0; _currentPageOrigY = 0;
memset(_currentPageData, 0, _currentPageDataSize); memset(_currentPageData, 0, _currentPageDataSize);
_currentPage++; _currentPage++;
@ -303,6 +307,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
if(existNewLetter) if(existNewLetter)
{ {
// this is a memory leak as the texture previously in _atlasTextures[_currentPage] is not deleted from OpenGL
// see CCTexture2D::initWithData for the temporary fix
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize ); _atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize, pixelFormat, CacheTextureWidth, CacheTextureHeight, contentSize );
} }
return true; return true;

View File

@ -26,15 +26,29 @@
#ifndef _FontFreetype_h_ #ifndef _FontFreetype_h_
#define _FontFreetype_h_ #define _FontFreetype_h_
#include "CCFont.h" #include "CCFont.h"
#include "CCData.h" #include "CCData.h"
#include <string> #include <string>
#include <ft2build.h> #include <ft2build.h>
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#define generic GenericFromFreeTypeLibrary
#define internal InternalFromFreeTypeLibrary
#endif
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_STROKER_H #include FT_STROKER_H
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#undef generic
#undef internal
#endif
NS_CC_BEGIN NS_CC_BEGIN
class CC_DLL FontFreeType : public Font class CC_DLL FontFreeType : public Font

View File

@ -37,6 +37,10 @@ THE SOFTWARE.
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"
#include "kazmath/kazmath.h" #include "kazmath/kazmath.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#include "CCPrecompiledShaders.h"
#endif
NS_CC_BEGIN NS_CC_BEGIN
typedef struct _hashUniformEntry typedef struct _hashUniformEntry
@ -116,6 +120,18 @@ GLProgram::~GLProgram()
bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray) bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
{ {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
GLboolean hasCompiler = false;
glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
_hasShaderCompiler = (hasCompiler == GL_TRUE);
if(!_hasShaderCompiler)
{
return initWithPrecompiledProgramByteArray(vShaderByteArray,fShaderByteArray);
}
#endif
_program = glCreateProgram(); _program = glCreateProgram();
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
@ -126,7 +142,8 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
if (!compileShader(&_vertShader, GL_VERTEX_SHADER, vShaderByteArray)) if (!compileShader(&_vertShader, GL_VERTEX_SHADER, vShaderByteArray))
{ {
CCLOG("cocos2d: ERROR: Failed to compile vertex shader"); CCLOG("cocos2d: ERROR: Failed to compile vertex shader");
} return false;
}
} }
// Create and compile fragment shader // Create and compile fragment shader
@ -135,6 +152,7 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
if (!compileShader(&_fragShader, GL_FRAGMENT_SHADER, fShaderByteArray)) if (!compileShader(&_fragShader, GL_FRAGMENT_SHADER, fShaderByteArray))
{ {
CCLOG("cocos2d: ERROR: Failed to compile fragment shader"); CCLOG("cocos2d: ERROR: Failed to compile fragment shader");
return false;
} }
} }
@ -152,9 +170,34 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
_shaderId = CCPrecompiledShaders::getInstance()->addShaders(vShaderByteArray, fShaderByteArray);
#endif
return true; return true;
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
{
bool haveProgram = false;
_program = glCreateProgram();
CHECK_GL_ERROR_DEBUG();
_vertShader = _fragShader = 0;
haveProgram = CCPrecompiledShaders::getInstance()->loadProgram(_program, vShaderByteArray, fShaderByteArray);
CHECK_GL_ERROR_DEBUG();
_hashForUniforms = NULL;
CHECK_GL_ERROR_DEBUG();
return haveProgram;
}
#endif
bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std::string &fShaderFilename) bool GLProgram::initWithFilenames(const std::string &vShaderFilename, const std::string &fShaderFilename)
{ {
auto fileUtils = FileUtils::getInstance(); auto fileUtils = FileUtils::getInstance();
@ -275,6 +318,15 @@ bool GLProgram::link()
{ {
CCASSERT(_program != 0, "Cannot link invalid program"); CCASSERT(_program != 0, "Cannot link invalid program");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
if(!_hasShaderCompiler)
{
// precompiled shader program is already linked
return true;
}
#endif
GLint status = GL_TRUE; GLint status = GL_TRUE;
glLinkProgram(_program); glLinkProgram(_program);
@ -291,7 +343,7 @@ bool GLProgram::link()
_vertShader = _fragShader = 0; _vertShader = _fragShader = 0;
#if COCOS2D_DEBUG #if DEBUG || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
glGetProgramiv(_program, GL_LINK_STATUS, &status); glGetProgramiv(_program, GL_LINK_STATUS, &status);
if (status == GL_FALSE) if (status == GL_FALSE)
@ -301,7 +353,14 @@ bool GLProgram::link()
_program = 0; _program = 0;
} }
#endif #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
if (status == GL_TRUE)
{
CCPrecompiledShaders::getInstance()->addProgram(_program, _shaderId);
}
#endif
return (status == GL_TRUE); return (status == GL_TRUE);
} }

View File

@ -126,7 +126,18 @@ public:
* @js initWithString * @js initWithString
* @lua initWithString * @lua initWithString
*/ */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
/** Initializes the CCGLProgram with precompiled shader program */
bool initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray);
#endif
/** Initializes the GLProgram with a vertex and fragment with bytes array
* @js initWithString
* @lua initWithString
*/
bool initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray); bool initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray);
/** Initializes the GLProgram with a vertex and fragment with contents of filenames /** Initializes the GLProgram with a vertex and fragment with contents of filenames
* @js init * @js init
* @lua init * @lua init
@ -266,6 +277,10 @@ private:
GLuint _fragShader; GLuint _fragShader;
GLint _uniforms[UNIFORM_MAX]; GLint _uniforms[UNIFORM_MAX];
struct _hashUniformEntry* _hashForUniforms; struct _hashUniformEntry* _hashForUniforms;
bool _hasShaderCompiler;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
std::string _shaderId;
#endif
struct flag_struct { struct flag_struct {
unsigned int usesTime:1; unsigned int usesTime:1;

View File

@ -334,6 +334,7 @@ void Label::reset()
Node::removeAllChildrenWithCleanup(true); Node::removeAllChildrenWithCleanup(true);
_textSprite = nullptr; _textSprite = nullptr;
_shadowNode = nullptr;
CC_SAFE_RELEASE_NULL(_reusedLetter); CC_SAFE_RELEASE_NULL(_reusedLetter);
@ -341,6 +342,7 @@ void Label::reset()
_textColorF = Color4F::WHITE; _textColorF = Color4F::WHITE;
setColor(Color3B::WHITE); setColor(Color3B::WHITE);
_shadowEnabled = false;
_clipEnabled = false; _clipEnabled = false;
} }
@ -349,7 +351,6 @@ void Label::updateShaderProgram()
switch (_currLabelEffect) switch (_currLabelEffect)
{ {
case cocos2d::LabelEffect::NORMAL: case cocos2d::LabelEffect::NORMAL:
case cocos2d::LabelEffect::SHADOW:
if (_useDistanceField) if (_useDistanceField)
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL)); setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL));
else if (_useA8Shader) else if (_useA8Shader)
@ -480,6 +481,13 @@ void Label::setFontDefinition(const FontDefinition& textDefinition)
_fontDefinition = textDefinition; _fontDefinition = textDefinition;
_fontName = textDefinition._fontName; _fontName = textDefinition._fontName;
_fontSize = textDefinition._fontSize; _fontSize = textDefinition._fontSize;
_shadowEnabled = textDefinition._shadow._shadowEnabled;
if (_shadowEnabled)
{
enableShadow(Color4B::BLACK,_fontDefinition._shadow._shadowOffset,_fontDefinition._shadow._shadowBlur);
}
_textColor = Color4B(_fontDefinition._fontFillColor); _textColor = Color4B(_fontDefinition._fontFillColor);
_textColorF.r = _textColor.r / 255.0f; _textColorF.r = _textColor.r / 255.0f;
_textColorF.g = _textColor.g / 255.0f; _textColorF.g = _textColor.g / 255.0f;
@ -834,24 +842,31 @@ void Label::enableOutline(const Color4B& outlineColor,int outlineSize /* = -1 */
void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const Size &offset /* = Size(2 ,-2)*/, int blurRadius /* = 0 */) void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const Size &offset /* = Size(2 ,-2)*/, int blurRadius /* = 0 */)
{ {
_shadowEnabled = true;
_fontDefinition._shadow._shadowEnabled = false;
_effectColor = shadowColor; _effectColor = shadowColor;
_effectColorF.r = _effectColor.r / 255.0f; _effectColorF.r = _effectColor.r / 255.0f;
_effectColorF.g = _effectColor.g / 255.0f; _effectColorF.g = _effectColor.g / 255.0f;
_effectColorF.b = _effectColor.b / 255.0f; _effectColorF.b = _effectColor.b / 255.0f;
_effectColorF.a = _effectColor.a / 255.0f; _effectColorF.a = _effectColor.a / 255.0f;
_shadowColor.r = _effectColor.r;
_shadowColor.g = _effectColor.g;
_shadowColor.b = _effectColor.b;
auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR(); auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
_shadowOffset.width = offset.width * contentScaleFactor; _shadowOffset.width = offset.width * contentScaleFactor;
_shadowOffset.height = offset.height * contentScaleFactor; _shadowOffset.height = offset.height * contentScaleFactor;
//todo:support blur for shadow //todo:support blur for shadow
_shadowBlurRadius = 0; _shadowBlurRadius = 0;
_currLabelEffect = LabelEffect::SHADOW;
_fontDefinition._shadow._shadowEnabled = true; if (_textSprite && _shadowNode)
_fontDefinition._shadow._shadowBlur = blurRadius; {
_fontDefinition._shadow._shadowOffset = _shadowOffset; _shadowNode->setColor(_shadowColor);
_fontDefinition._shadow._shadowOpacity = shadowColor.a / 255.0f; _shadowNode->setOpacity(_effectColorF.a * _displayedOpacity);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
_contentDirty = true; }
} }
void Label::disableEffect() void Label::disableEffect()
@ -864,6 +879,12 @@ void Label::disableEffect()
_currLabelEffect = LabelEffect::NORMAL; _currLabelEffect = LabelEffect::NORMAL;
updateShaderProgram(); updateShaderProgram();
_contentDirty = true; _contentDirty = true;
_shadowEnabled = false;
if (_shadowNode)
{
Node::removeChild(_shadowNode,true);
_shadowNode = nullptr;
}
} }
void Label::setFontScale(float fontScale) void Label::setFontScale(float fontScale)
@ -886,24 +907,25 @@ void Label::onDraw(const kmMat4& transform, bool transformUpdated)
GL::blendFunc( _blendFunc.src, _blendFunc.dst ); GL::blendFunc( _blendFunc.src, _blendFunc.dst );
bool trans = false; bool trans = false;
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
{
_shaderProgram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a);
}
else if(_currLabelEffect == LabelEffect::SHADOW && _shadowBlurRadius <= 0)
{
trans = true;
drawShadowWithoutBlur();
}
_shaderProgram->setUniformsForBuiltins(transform);
if (_currentLabelType == LabelType::TTF) if (_currentLabelType == LabelType::TTF)
{ {
_shaderProgram->setUniformLocationWith4f(_uniformTextColor, _shaderProgram->setUniformLocationWith4f(_uniformTextColor,
_textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a); _textColorF.r,_textColorF.g,_textColorF.b,_textColorF.a);
} }
if (_currLabelEffect == LabelEffect::OUTLINE || _currLabelEffect == LabelEffect::GLOW)
{
_shaderProgram->setUniformLocationWith4f(_uniformEffectColor,
_effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a);
}
else if(_shadowEnabled && _shadowBlurRadius <= 0)
{
trans = true;
kmGLPushMatrix();
drawShadowWithoutBlur();
}
_shaderProgram->setUniformsForBuiltins(transform);
for(const auto &child: _children) for(const auto &child: _children)
{ {
@ -932,19 +954,10 @@ void Label::drawShadowWithoutBlur()
Color3B oldColor = _realColor; Color3B oldColor = _realColor;
GLubyte oldOPacity = _displayedOpacity; GLubyte oldOPacity = _displayedOpacity;
if (_currentLabelType == LabelType::TTF) _displayedOpacity = _effectColorF.a * _displayedOpacity;
{ setColor(_shadowColor);
_shaderProgram->setUniformLocationWith4f(_uniformTextColor,
_effectColorF.r,_effectColorF.g,_effectColorF.b,_effectColorF.a);
}
else
{
_displayedOpacity = _effectColorF.a * _displayedOpacity;
setColor(Color3B(_effectColor));
}
_modelViewTransform = transform(_parentTransform); _modelViewTransform = transform(_parentTransform);
kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform); kmGLLoadMatrix(&_modelViewTransform);
_shaderProgram->setUniformsForBuiltins(_modelViewTransform); _shaderProgram->setUniformsForBuiltins(_modelViewTransform);
@ -961,11 +974,9 @@ void Label::drawShadowWithoutBlur()
_position.y -= _shadowOffset.height; _position.y -= _shadowOffset.height;
_transformDirty = _inverseDirty = true; _transformDirty = _inverseDirty = true;
if (_currentLabelType != LabelType::TTF) _displayedOpacity = oldOPacity;
{ setColor(oldColor);
_displayedOpacity = oldOPacity;
setColor(oldColor);
}
_modelViewTransform = transform(_parentTransform); _modelViewTransform = transform(_parentTransform);
kmGLLoadMatrix(&_modelViewTransform); kmGLLoadMatrix(&_modelViewTransform);
} }
@ -1010,6 +1021,11 @@ void Label::updateContent()
{ {
Node::removeChild(_textSprite,true); Node::removeChild(_textSprite,true);
_textSprite = nullptr; _textSprite = nullptr;
if (_shadowNode)
{
Node::removeChild(_shadowNode,true);
_shadowNode = nullptr;
}
} }
if (_fontAtlas) if (_fontAtlas)
{ {
@ -1040,6 +1056,40 @@ void Label::updateFont()
_fontDirty = false; _fontDirty = false;
} }
void Label::drawTextSprite(Renderer *renderer, bool parentTransformUpdated)
{
if (_fontDefinition._fontFillColor != _textColor)
{
Node::removeChild(_textSprite,true);
_textSprite = nullptr;
if (_shadowNode)
{
Node::removeChild(_shadowNode,true);
_shadowNode = nullptr;
}
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
createSpriteWithFontDefinition();
}
if (_shadowEnabled && _shadowNode == nullptr)
{
_shadowNode = Sprite::createWithTexture(_textSprite->getTexture());
_shadowNode->setAnchorPoint(Point::ANCHOR_BOTTOM_LEFT);
_shadowNode->setColor(_shadowColor);
_shadowNode->setOpacity(_effectColorF.a * _displayedOpacity);
_shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
Node::addChild(_shadowNode,0,Node::INVALID_TAG);
}
if (_shadowNode)
{
_shadowNode->visit(renderer, _modelViewTransform, parentTransformUpdated);
}
_textSprite->visit(renderer, _modelViewTransform, parentTransformUpdated);
}
void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated) void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{ {
if (! _visible || _originalUTF8String.empty()) if (! _visible || _originalUTF8String.empty())
@ -1055,7 +1105,7 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
updateContent(); updateContent();
} }
if (! _textSprite && _currLabelEffect == LabelEffect::SHADOW && _shadowBlurRadius <= 0) if (! _textSprite && _shadowEnabled && _shadowBlurRadius <= 0)
{ {
_parentTransform = parentTransform; _parentTransform = parentTransform;
draw(renderer, _modelViewTransform, true); draw(renderer, _modelViewTransform, true);
@ -1076,15 +1126,7 @@ void Label::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parent
if (_textSprite) if (_textSprite)
{ {
if (_fontDefinition._fontFillColor != _textColor) drawTextSprite(renderer,dirty);
{
Node::removeChild(_textSprite,true);
_fontDefinition._fontFillColor.r = _textColor.r;
_fontDefinition._fontFillColor.g = _textColor.g;
_fontDefinition._fontFillColor.b = _textColor.b;
createSpriteWithFontDefinition();
}
_textSprite->visit(renderer, _modelViewTransform, dirty);
} }
else else
{ {
@ -1228,6 +1270,10 @@ void Label::updateDisplayedColor(const Color3B& parentColor)
if (_textSprite) if (_textSprite)
{ {
_textSprite->updateDisplayedColor(_displayedColor); _textSprite->updateDisplayedColor(_displayedColor);
if (_shadowNode)
{
_shadowNode->updateDisplayedColor(_displayedColor);
}
} }
} }
@ -1239,6 +1285,10 @@ void Label::updateDisplayedOpacity(GLubyte parentOpacity)
if (_textSprite) if (_textSprite)
{ {
_textSprite->updateDisplayedOpacity(_displayedOpacity); _textSprite->updateDisplayedOpacity(_displayedOpacity);
if (_shadowNode)
{
_shadowNode->updateDisplayedOpacity(_displayedOpacity);
}
} }
} }

View File

@ -304,6 +304,8 @@ protected:
void drawShadowWithoutBlur(); void drawShadowWithoutBlur();
void drawTextSprite(Renderer *renderer, bool parentTransformUpdated);
void createSpriteWithFontDefinition(); void createSpriteWithFontDefinition();
void updateFont(); void updateFont();
@ -362,9 +364,12 @@ protected:
GLuint _uniformTextColor; GLuint _uniformTextColor;
CustomCommand _customCommand; CustomCommand _customCommand;
bool _shadowEnabled;
Size _shadowOffset; Size _shadowOffset;
int _shadowBlurRadius; int _shadowBlurRadius;
kmMat4 _parentTransform; kmMat4 _parentTransform;
Color3B _shadowColor;
Node* _shadowNode;
Color4B _textColor; Color4B _textColor;
Color4F _textColorF; Color4F _textColorF;

View File

@ -627,9 +627,25 @@ std::string LayerColor::getDescription() const
{ {
return StringUtils::format("<LayerColor | Tag = %d>", _tag); return StringUtils::format("<LayerColor | Tag = %d>", _tag);
} }
// //
// LayerGradient // LayerGradient
// //
LayerGradient::LayerGradient()
: _startColor(Color4B::BLACK)
, _endColor(Color4B::BLACK)
, _startOpacity(255)
, _endOpacity(255)
, _alongVector(Point(0, -1))
, _compressedInterpolation(true)
{
}
LayerGradient::~LayerGradient()
{
}
LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end) LayerGradient* LayerGradient::create(const Color4B& start, const Color4B& end)
{ {
LayerGradient * layer = new LayerGradient(); LayerGradient * layer = new LayerGradient();
@ -684,9 +700,9 @@ bool LayerGradient::initWithColor(const Color4B& start, const Color4B& end, cons
_endColor.g = end.g; _endColor.g = end.g;
_endColor.b = end.b; _endColor.b = end.b;
_endOpacity = end.a; _endOpacity = end.a;
_startOpacity = start.a; _startOpacity = start.a;
_alongVector = v; _alongVector = v;
_compressedInterpolation = true; _compressedInterpolation = true;
@ -852,7 +868,7 @@ LayerMultiplex * LayerMultiplex::create(Layer * layer, ...)
LayerMultiplex * LayerMultiplex::createWithLayer(Layer* layer) LayerMultiplex * LayerMultiplex::createWithLayer(Layer* layer)
{ {
return LayerMultiplex::create(layer, nullptr); return LayerMultiplex::create(layer, NULL);
} }
LayerMultiplex* LayerMultiplex::create() LayerMultiplex* LayerMultiplex::create()

View File

@ -343,19 +343,6 @@ public:
/** Creates a full-screen Layer with a gradient between start and end in the direction of v. */ /** Creates a full-screen Layer with a gradient between start and end in the direction of v. */
static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v); static LayerGradient* create(const Color4B& start, const Color4B& end, const Point& v);
virtual bool init();
/** Initializes the Layer with a gradient between start and end.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end);
/** Initializes the Layer with a gradient between start and end in the direction of v.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
/** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors
Default: true Default: true
@ -391,6 +378,23 @@ public:
const Point& getVector() const; const Point& getVector() const;
virtual std::string getDescription() const override; virtual std::string getDescription() const override;
CC_CONSTRUCTOR_ACCESS:
LayerGradient();
virtual ~LayerGradient();
virtual bool init();
/** Initializes the Layer with a gradient between start and end.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end);
/** Initializes the Layer with a gradient between start and end in the direction of v.
* @js init
* @lua init
*/
bool initWithColor(const Color4B& start, const Color4B& end, const Point& v);
protected: protected:
virtual void updateColor() override; virtual void updateColor() override;
@ -431,7 +435,25 @@ public:
* In lua:local create(...) * In lua:local create(...)
* @endcode * @endcode
*/ */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef Layer* M;
static LayerMultiplex* create(M m1, std::nullptr_t listEnd) { return createVariadic(m1, NULL); }
static LayerMultiplex* create(M m1, M m2, std::nullptr_t listEnd) { return createVariadic(m1, m2, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, m6, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, m6, m7, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static LayerMultiplex* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return createVariadic(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for variable argument lists longer than 10 items, use createWithArray or createVariadic with NULL as the last argument
static LayerMultiplex* createVariadic(Layer* item, ...) CC_REQUIRES_NULL_TERMINATION;
#else
static LayerMultiplex * create(Layer* layer, ... ); static LayerMultiplex * create(Layer* layer, ... );
#endif
/** /**
* lua script can not init with undetermined number of variables * lua script can not init with undetermined number of variables

View File

@ -53,11 +53,27 @@ Menu::~Menu()
CCLOGINFO("In the destructor of Menu. %p", this); CCLOGINFO("In the destructor of Menu. %p", this);
} }
Menu* Menu::create() Menu* Menu::create()
{ {
return Menu::create(nullptr, nullptr); return Menu::create(nullptr, nullptr);
} }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Menu * Menu::variadicCreate(MenuItem* item, ...)
{
va_list args;
va_start(args,item);
Menu *ret = Menu::createWithItems(item, args);
va_end(args);
return ret;
}
#else
Menu * Menu::create(MenuItem* item, ...) Menu * Menu::create(MenuItem* item, ...)
{ {
va_list args; va_list args;
@ -69,6 +85,8 @@ Menu * Menu::create(MenuItem* item, ...)
return ret; return ret;
} }
#endif
Menu* Menu::createWithArray(const Vector<MenuItem*>& arrayOfItems) Menu* Menu::createWithArray(const Vector<MenuItem*>& arrayOfItems)
{ {

View File

@ -60,9 +60,27 @@ public:
/** creates an empty Menu */ /** creates an empty Menu */
static Menu* create(); static Menu* create();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef MenuItem* M;
static Menu* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
static Menu* create(M m1, M m2, std::nullptr_t listEnd) { return variadicCreate(m1, m2, NULL); }
static Menu* create(M m1, M m2, M m3, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static Menu* create(M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return variadicCreate(m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument
static Menu* variadicCreate(MenuItem* item, ...);
#else
/** creates a Menu with MenuItem objects */ /** creates a Menu with MenuItem objects */
static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION; static Menu* create(MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
#endif
/** creates a Menu with a Array of MenuItem objects */ /** creates a Menu with a Array of MenuItem objects */
static Menu* createWithArray(const Vector<MenuItem*>& arrayOfItems); static Menu* createWithArray(const Vector<MenuItem*>& arrayOfItems);
@ -136,6 +154,9 @@ CC_CONSTRUCTOR_ACCESS:
bool initWithArray(const Vector<MenuItem*>& arrayOfItems); bool initWithArray(const Vector<MenuItem*>& arrayOfItems);
protected: protected:
/** whether or not the menu will receive events */ /** whether or not the menu will receive events */
bool _enabled; bool _enabled;

View File

@ -1458,7 +1458,7 @@ private:
CC_DISALLOW_COPY_AND_ASSIGN(Node); CC_DISALLOW_COPY_AND_ASSIGN(Node);
}; };
//#pragma mark - NodeRGBA // NodeRGBA
/** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol. /** NodeRGBA is a subclass of Node that implements the RGBAProtocol protocol.

View File

@ -125,6 +125,13 @@ emitter.startSpin = 0;
@endcode @endcode
*/ */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#ifdef RELATIVE
#undef RELATIVE
#endif
#endif
class CC_DLL ParticleSystem : public Node, public TextureProtocol class CC_DLL ParticleSystem : public Node, public TextureProtocol
{ {
public: public:

View File

@ -31,7 +31,7 @@ using namespace std;
NS_CC_BEGIN NS_CC_BEGIN
//#pragma mark - Profiling Categories // Profiling Categories
/* set to false the categories that you don't want to profile */ /* set to false the categories that you don't want to profile */
bool kProfilerCategorySprite = false; bool kProfilerCategorySprite = false;
bool kProfilerCategoryBatchSprite = false; bool kProfilerCategoryBatchSprite = false;

View File

@ -41,8 +41,8 @@ bool CC_DLL cc_assert_script_compatible(const char *msg)
NS_CC_BEGIN NS_CC_BEGIN
// #pragma mark - //
// #pragma mark ScriptHandlerEntry // // ScriptHandlerEntry
ScriptHandlerEntry* ScriptHandlerEntry::create(int handler) ScriptHandlerEntry* ScriptHandlerEntry::create(int handler)
{ {
@ -61,8 +61,8 @@ ScriptHandlerEntry::~ScriptHandlerEntry(void)
} }
} }
// #pragma mark - //
// #pragma mark SchedulerScriptHandlerEntry // // SchedulerScriptHandlerEntry
SchedulerScriptHandlerEntry* SchedulerScriptHandlerEntry::create(int handler, float interval, bool paused) SchedulerScriptHandlerEntry* SchedulerScriptHandlerEntry::create(int handler, float interval, bool paused)
{ {
@ -88,8 +88,8 @@ SchedulerScriptHandlerEntry::~SchedulerScriptHandlerEntry(void)
} }
// #pragma mark - //
// #pragma mark TouchScriptHandlerEntry // // TouchScriptHandlerEntry
TouchScriptHandlerEntry* TouchScriptHandlerEntry::create(int handler, TouchScriptHandlerEntry* TouchScriptHandlerEntry::create(int handler,
bool isMultiTouches, bool isMultiTouches,
@ -115,8 +115,8 @@ bool TouchScriptHandlerEntry::init(bool isMultiTouches, int priority, bool swall
return true; return true;
} }
// #pragma mark - //
// #pragma mark ScriptEngineManager // // ScriptEngineManager
static ScriptEngineManager* s_pSharedScriptEngineManager = nullptr; static ScriptEngineManager* s_pSharedScriptEngineManager = nullptr;

View File

@ -51,6 +51,8 @@ THE SOFTWARE.
NS_CC_BEGIN NS_CC_BEGIN
namespace { namespace {
typedef Texture2D::PixelFormatInfoMap::value_type PixelFormatInfoMapValue; typedef Texture2D::PixelFormatInfoMap::value_type PixelFormatInfoMapValue;
static const PixelFormatInfoMapValue TexturePixelFormatInfoTablesValue[] = static const PixelFormatInfoMapValue TexturePixelFormatInfoTablesValue[] =
@ -549,6 +551,15 @@ bool Texture2D::initWithData(const void *data, ssize_t dataLen, Texture2D::Pixel
bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh) bool Texture2D::initWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, PixelFormat pixelFormat, int pixelsWide, int pixelsHigh)
{ {
// cocos2d-x is currently calling this multiple times on the same Texture2D
// if the GL texture has already been created,it will be leaked in OpenGL
// For now, call deleteTexture if the texture already exists
if(_name)
{
GL::deleteTexture(_name);
_name = 0;
}
//the pixelFormat must be a certain value //the pixelFormat must be a certain value
CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!"); CCASSERT(pixelFormat != PixelFormat::NONE && pixelFormat != PixelFormat::AUTO, "the \"pixelFormat\" param must be a certain value!");
CCASSERT(pixelsWide>0 && pixelsHigh>0, "Invalid size"); CCASSERT(pixelsWide>0 && pixelsHigh>0, "Invalid size");
@ -1072,9 +1083,7 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
} }
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID) && (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)
bool requestUnsupported = textDefinition._shadow._shadowEnabled || textDefinition._stroke._strokeEnabled; CCASSERT(textDefinition._stroke._strokeEnabled == false, "Currently stroke only supported on iOS and Android!");
CCASSERT(requestUnsupported == false, "Currently shadow and stroke only supported on iOS and Android!");
#endif #endif
PixelFormat pixelFormat = g_defaultAlphaPixelFormat; PixelFormat pixelFormat = g_defaultAlphaPixelFormat;
@ -1088,6 +1097,9 @@ bool Texture2D::initWithString(const char *text, const FontDefinition& textDefin
textDef._fontSize *= contentScaleFactor; textDef._fontSize *= contentScaleFactor;
textDef._dimensions.width *= contentScaleFactor; textDef._dimensions.width *= contentScaleFactor;
textDef._dimensions.height *= contentScaleFactor; textDef._dimensions.height *= contentScaleFactor;
textDef._stroke._strokeSize *= contentScaleFactor;
textDef._shadow._shadowEnabled = false;
Data outData = Device::getTextureDataForText(text,textDef,align,imageWidth,imageHeight); Data outData = Device::getTextureDataForText(text,textDef,align,imageWidth,imageHeight);
if(outData.isNull()) if(outData.isNull())
return false; return false;

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCFileUtilsAndroid.h" #include "platform/android/CCFileUtilsAndroid.h"
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
// for import ssize_t on win32 platform // for import ssize_t on win32 platform
#include "CCStdC.h" #include "CCStdC.h"
#endif #endif

View File

@ -278,8 +278,8 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr)
arr->num -= back; arr->num -= back;
} }
// #pragma mark - //
// #pragma mark ccCArray for Values (c structures) // // ccCArray for Values (c structures)
/** Allocates and initializes a new C array with specified capacity */ /** Allocates and initializes a new C array with specified capacity */
ccCArray* ccCArrayNew(ssize_t capacity) ccCArray* ccCArrayNew(ssize_t capacity)

View File

@ -130,8 +130,8 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr);
matching instances in arr will be removed. */ matching instances in arr will be removed. */
void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr);
// #pragma mark - //
// #pragma mark ccCArray for Values (c structures) // // ccCArray for Values (c structures)
typedef struct _ccCArray { typedef struct _ccCArray {
ssize_t num, max; ssize_t num, max;

View File

@ -217,7 +217,7 @@ void bindVAO(GLuint vaoId)
} }
} }
//#pragma mark - GL Vertex Attrib functions // GL Vertex Attrib functions
void enableVertexAttribs( unsigned int flags ) void enableVertexAttribs( unsigned int flags )
{ {
@ -260,7 +260,7 @@ void enableVertexAttribs( unsigned int flags )
} }
} }
//#pragma mark - GL Uniforms functions // GL Uniforms functions
void setProjectionMatrixDirty( void ) void setProjectionMatrixDirty( void )
{ {

View File

@ -195,6 +195,22 @@ THE SOFTWARE.
#include "platform/linux/CCStdC.h" #include "platform/linux/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX #endif // CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
#include "platform/winrt/CCApplication.h"
#include "platform/winrt/CCGLView.h"
#include "platform/winrt/CCGL.h"
#include "platform/winrt/CCStdC.h"
#include "platform/winrt/CCPrecompiledShaders.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
#include "platform/winrt/CCApplication.h"
#include "platform/wp8/CCGLView.h"
#include "platform/winrt/CCGL.h"
#include "platform/winrt/CCStdC.h"
#include "platform/winrt/CCPrecompiledShaders.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WP8
// script_support // script_support
#include "CCScriptSupport.h" #include "CCScriptSupport.h"

View File

@ -52,7 +52,9 @@ public:
OS_BLACKBERRY, OS_BLACKBERRY,
OS_NACL, OS_NACL,
OS_EMSCRIPTEN, OS_EMSCRIPTEN,
OS_TIZEN OS_TIZEN,
OS_WINRT,
OS_WP8
}; };
/** /**

View File

@ -37,7 +37,7 @@ namespace {
static Touch* g_touches[EventTouch::MAX_TOUCHES] = { nullptr }; static Touch* g_touches[EventTouch::MAX_TOUCHES] = { nullptr };
static unsigned int g_indexBitsUsed = 0; static unsigned int g_indexBitsUsed = 0;
// System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0 // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0
static std::map<int, int> g_touchIdReorderMap; static std::map<intptr_t, int> g_touchIdReorderMap;
static int getUnUsedIndex() static int getUnUsedIndex()
{ {
@ -235,9 +235,9 @@ const std::string& GLViewProtocol::getViewName() const
return _viewName; return _viewName;
} }
void GLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesBegin(int num, intptr_t ids[], float xs[], float ys[])
{ {
int id = 0; intptr_t id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
int unusedIndex = 0; int unusedIndex = 0;
@ -285,9 +285,9 @@ void GLViewProtocol::handleTouchesBegin(int num, int ids[], float xs[], float ys
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void GLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesMove(int num, intptr_t ids[], float xs[], float ys[])
{ {
int id = 0; intptr_t id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
EventTouch touchEvent; EventTouch touchEvent;
@ -317,7 +317,7 @@ void GLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[
else else
{ {
// It is error, should return. // It is error, should return.
CCLOG("Moving touches with id: %d error", id); CCLOG("Moving touches with id: %ld error", id);
return; return;
} }
} }
@ -333,9 +333,9 @@ void GLViewProtocol::handleTouchesMove(int num, int ids[], float xs[], float ys[
dispatcher->dispatchEvent(&touchEvent); dispatcher->dispatchEvent(&touchEvent);
} }
void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[])
{ {
int id = 0; intptr_t id = 0;
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
EventTouch touchEvent; EventTouch touchEvent;
@ -370,7 +370,7 @@ void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,
} }
else else
{ {
CCLOG("Ending touches with id: %d error", id); CCLOG("Ending touches with id: %ld error", id);
return; return;
} }
@ -393,12 +393,12 @@ void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,
} }
} }
void GLViewProtocol::handleTouchesEnd(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesEnd(int num, intptr_t ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);
} }
void GLViewProtocol::handleTouchesCancel(int num, int ids[], float xs[], float ys[]) void GLViewProtocol::handleTouchesCancel(int num, intptr_t ids[], float xs[], float ys[])
{ {
handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys); handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);
} }

View File

@ -160,10 +160,10 @@ public:
const std::string& getViewName() const; const std::string& getViewName() const;
/** Touch events are handled by default; if you want to customize your handlers, please override these functions: */ /** Touch events are handled by default; if you want to customize your handlers, please override these functions: */
virtual void handleTouchesBegin(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesBegin(int num, intptr_t ids[], float xs[], float ys[]);
virtual void handleTouchesMove(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesMove(int num, intptr_t ids[], float xs[], float ys[]);
virtual void handleTouchesEnd(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesEnd(int num, intptr_t ids[], float xs[], float ys[]);
virtual void handleTouchesCancel(int num, int ids[], float xs[], float ys[]); virtual void handleTouchesCancel(int num, intptr_t ids[], float xs[], float ys[]);
/** /**
* Get the opengl view port rectangle. * Get the opengl view port rectangle.
@ -186,7 +186,7 @@ public:
protected: protected:
void updateDesignResolutionSize(); void updateDesignResolutionSize();
void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, int ids[], float xs[], float ys[]); void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[]);
// real screen size // real screen size
Size _screenSize; Size _screenSize;

View File

@ -46,7 +46,9 @@ extern "C"
#include "atitc.h" #include "atitc.h"
#include "TGAlib.h" #include "TGAlib.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) && (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
#include "decode.h" #include "decode.h"
#endif
#include "ccMacros.h" #include "ccMacros.h"
#include "CCCommon.h" #include "CCCommon.h"
@ -1832,7 +1834,11 @@ bool Image::initWithPVRData(const unsigned char * data, ssize_t dataLen)
bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen) bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen)
{ {
bool bRet = false; bool bRet = false;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
CCLOG("WEBP image format not supported on WinRT or WP8");
#else
do do
{ {
WebPDecoderConfig config; WebPDecoderConfig config;
@ -1862,9 +1868,11 @@ bool Image::initWithWebpData(const unsigned char * data, ssize_t dataLen)
bRet = true; bRet = true;
} while (0); } while (0);
#endif
return bRet; return bRet;
} }
bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti) bool Image::initWithRawData(const unsigned char * data, ssize_t dataLen, int width, int height, int bitsPerComponent, bool preMulti)
{ {
bool bRet = false; bool bRet = false;

View File

@ -36,8 +36,6 @@ import android.view.ViewGroup;
import android.util.Log; import android.util.Log;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import java.io.File;
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener { public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
// =========================================================== // ===========================================================
// Constants // Constants
@ -138,14 +136,14 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
// FrameLayout // FrameLayout
ViewGroup.LayoutParams framelayout_params = ViewGroup.LayoutParams framelayout_params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.FILL_PARENT); ViewGroup.LayoutParams.MATCH_PARENT);
FrameLayout framelayout = new FrameLayout(this); FrameLayout framelayout = new FrameLayout(this);
framelayout.setLayoutParams(framelayout_params); framelayout.setLayoutParams(framelayout_params);
// Cocos2dxEditText layout // Cocos2dxEditText layout
ViewGroup.LayoutParams edittext_layout_params = ViewGroup.LayoutParams edittext_layout_params =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT); ViewGroup.LayoutParams.WRAP_CONTENT);
Cocos2dxEditText edittext = new Cocos2dxEditText(this); Cocos2dxEditText edittext = new Cocos2dxEditText(this);
edittext.setLayoutParams(edittext_layout_params); edittext.setLayoutParams(edittext_layout_params);

View File

@ -39,7 +39,6 @@ import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.FloatMath;
import android.util.Log; import android.util.Log;
public class Cocos2dxBitmap { public class Cocos2dxBitmap {
@ -119,7 +118,7 @@ public class Cocos2dxBitmap {
*/ */
if(0 != width) if(0 != width)
{ {
final int firstWordWidth = (int) FloatMath.ceil(paint.measureText(string, 0,1)); final int firstWordWidth = (int) Math.ceil(paint.measureText(string, 0,1));
if ( firstWordWidth > width) if ( firstWordWidth > width)
{ {
Log.w("createTextBitmapShadowStroke warning:","the input width is less than the width of the pString's first word\n"); Log.w("createTextBitmapShadowStroke warning:","the input width is less than the width of the pString's first word\n");
@ -140,25 +139,6 @@ public class Cocos2dxBitmap {
float renderTextDeltaX = 0.0f; float renderTextDeltaX = 0.0f;
float renderTextDeltaY = 0.0f; float renderTextDeltaY = 0.0f;
if ( shadow ) {
int shadowColor = ((int)(255 * shadowOpacity) & 0xff) << 24;
paint.setShadowLayer(shadowBlur, shadowDX, shadowDY, shadowColor);
bitmapPaddingX = Math.abs(shadowDX);
bitmapPaddingY = Math.abs(shadowDY);
if ( shadowDX < 0.0 )
{
renderTextDeltaX = bitmapPaddingX;
}
if ( shadowDY < 0.0 )
{
renderTextDeltaY = bitmapPaddingY;
}
}
if (0 == textProperty.mMaxWidth || 0 == bitmapTotalHeight) if (0 == textProperty.mMaxWidth || 0 == bitmapTotalHeight)
{ {
Log.w("createTextBitmapShadowStroke warning:","textProperty MaxWidth is 0 or bitMapTotalHeight is 0\n"); Log.w("createTextBitmapShadowStroke warning:","textProperty MaxWidth is 0 or bitMapTotalHeight is 0\n");
@ -173,41 +153,44 @@ public class Cocos2dxBitmap {
/* Draw string. */ /* Draw string. */
final FontMetricsInt fontMetricsInt = paint.getFontMetricsInt(); final FontMetricsInt fontMetricsInt = paint.getFontMetricsInt();
int x = 0;
int y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment);
final String[] lines = textProperty.mLines;
for (final String line : lines) {
x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment);
canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paint);
y += textProperty.mHeightPerLine;
}
// draw again with stroke on if needed // draw again with stroke on if needed
if ( stroke ) { if ( stroke )
{
final Paint paintStroke = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment); final Paint paintStroke = Cocos2dxBitmap.newPaint(fontName, fontSize, horizontalAlignment);
paintStroke.setStyle(Paint.Style.STROKE); paintStroke.setStyle(Paint.Style.STROKE);
paintStroke.setStrokeWidth(strokeSize * 0.5f); paintStroke.setStrokeWidth(strokeSize);
paintStroke.setARGB(255, (int) (strokeR * 255), (int) (strokeG * 255), (int) (strokeB * 255)); paintStroke.setARGB(255, (int) (strokeR * 255), (int) (strokeG * 255), (int) (strokeB * 255));
x = 0; int x = 0;
y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment); int y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment);
final String[] lines2 = textProperty.mLines; final String[] lines2 = textProperty.mLines;
for (final String line : lines2) { for (final String line : lines2) {
x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment); x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment);
canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paintStroke); canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paintStroke);
canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paint);
y += textProperty.mHeightPerLine; y += textProperty.mHeightPerLine;
} }
} }
else
{
int x = 0;
int y = Cocos2dxBitmap.computeY(fontMetricsInt, height, textProperty.mTotalHeight, verticalAlignment);
final String[] lines = textProperty.mLines;
for (final String line : lines) {
x = Cocos2dxBitmap.computeX(line, textProperty.mMaxWidth, horizontalAlignment);
canvas.drawText(line, x + renderTextDeltaX, y + renderTextDeltaY, paint);
y += textProperty.mHeightPerLine;
}
}
Cocos2dxBitmap.initNativeObject(bitmap); Cocos2dxBitmap.initNativeObject(bitmap);
@ -269,7 +252,7 @@ public class Cocos2dxBitmap {
/* Compute the max width. */ /* Compute the max width. */
int temp = 0; int temp = 0;
for (final String line : lines) { for (final String line : lines) {
temp = (int) FloatMath.ceil(paint.measureText(line, 0, temp = (int) Math.ceil(paint.measureText(line, 0,
line.length())); line.length()));
if (temp > maxContentWidth) { if (temp > maxContentWidth) {
maxContentWidth = temp; maxContentWidth = temp;
@ -343,7 +326,7 @@ public class Cocos2dxBitmap {
* The width of line is exceed maxWidth, should divide it into * The width of line is exceed maxWidth, should divide it into
* two or more lines. * two or more lines.
*/ */
final int lineWidth = (int) FloatMath.ceil(paint final int lineWidth = (int) Math.ceil(paint
.measureText(line)); .measureText(line));
if (lineWidth > maxWidth) { if (lineWidth > maxWidth) {
strList.addAll(Cocos2dxBitmap.divideStringWithMaxWidth( strList.addAll(Cocos2dxBitmap.divideStringWithMaxWidth(
@ -391,7 +374,7 @@ public class Cocos2dxBitmap {
/* Break a String into String[] by the width & should wrap the word. */ /* Break a String into String[] by the width & should wrap the word. */
for (int i = 1; i <= charLength; ++i) { for (int i = 1; i <= charLength; ++i) {
tempWidth = (int) FloatMath.ceil(paint.measureText(string, start, tempWidth = (int) Math.ceil(paint.measureText(string, start,
i)); i));
if (tempWidth >= maxWidth) { if (tempWidth >= maxWidth) {
final int lastIndexOfSpace = string.substring(0, i) final int lastIndexOfSpace = string.substring(0, i)

View File

@ -157,7 +157,7 @@ public class Cocos2dxEditBoxDialog extends Dialog {
final LinearLayout layout = new LinearLayout(this.getContext()); final LinearLayout layout = new LinearLayout(this.getContext());
layout.setOrientation(LinearLayout.VERTICAL); layout.setOrientation(LinearLayout.VERTICAL);
final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
this.mTextViewTitle = new TextView(this.getContext()); this.mTextViewTitle = new TextView(this.getContext());
final LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); final LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
@ -166,7 +166,7 @@ public class Cocos2dxEditBoxDialog extends Dialog {
layout.addView(this.mTextViewTitle, textviewParams); layout.addView(this.mTextViewTitle, textviewParams);
this.mInputEditText = new EditText(this.getContext()); this.mInputEditText = new EditText(this.getContext());
final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editTextParams.leftMargin = editTextParams.rightMargin = this.convertDipsToPixels(10); editTextParams.leftMargin = editTextParams.rightMargin = this.convertDipsToPixels(10);
layout.addView(this.mInputEditText, editTextParams); layout.addView(this.mInputEditText, editTextParams);

View File

@ -24,7 +24,6 @@ THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
package org.cocos2dx.lib; package org.cocos2dx.lib;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;

View File

@ -195,7 +195,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) { switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown); final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown);
final float xPointerDown = pMotionEvent.getX(indexPointerDown); final float xPointerDown = pMotionEvent.getX(indexPointerDown);
final float yPointerDown = pMotionEvent.getY(indexPointerDown); final float yPointerDown = pMotionEvent.getY(indexPointerDown);
@ -232,7 +232,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
break; break;
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; final int indexPointUp = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int idPointerUp = pMotionEvent.getPointerId(indexPointUp); final int idPointerUp = pMotionEvent.getPointerId(indexPointUp);
final float xPointerUp = pMotionEvent.getX(indexPointUp); final float xPointerUp = pMotionEvent.getX(indexPointUp);
final float yPointerUp = pMotionEvent.getY(indexPointUp); final float yPointerUp = pMotionEvent.getY(indexPointUp);
@ -351,7 +351,7 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
final int actionCode = action & MotionEvent.ACTION_MASK; final int actionCode = action & MotionEvent.ACTION_MASK;
sb.append("event ACTION_").append(names[actionCode]); sb.append("event ACTION_").append(names[actionCode]);
if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) { if (actionCode == MotionEvent.ACTION_POINTER_DOWN || actionCode == MotionEvent.ACTION_POINTER_UP) {
sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_ID_SHIFT); sb.append("(pid ").append(action >> MotionEvent.ACTION_POINTER_INDEX_SHIFT);
sb.append(")"); sb.append(")");
} }
sb.append("["); sb.append("[");

View File

@ -30,9 +30,7 @@ import java.util.Locale;
import java.lang.Runnable; import java.lang.Runnable;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;

View File

@ -26,7 +26,6 @@ package org.cocos2dx.lib;
import android.content.Context; import android.content.Context;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;

View File

@ -523,7 +523,7 @@ void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int
_captured = true; _captured = true;
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX,_mouseY))) if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX,_mouseY)))
{ {
int id = 0; intptr_t id = 0;
this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY); this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);
} }
} }
@ -532,7 +532,7 @@ void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int
if (_captured) if (_captured)
{ {
_captured = false; _captured = false;
int id = 0; intptr_t id = 0;
this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY); this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY);
} }
} }
@ -575,7 +575,7 @@ void GLView::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
if (_captured) if (_captured)
{ {
int id = 0; intptr_t id = 0;
this->handleTouchesMove(1, &id, &_mouseX, &_mouseY); this->handleTouchesMove(1, &id, &_mouseX, &_mouseY);
} }

View File

@ -315,15 +315,9 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
shadowStrokePaddingY = ceilf(info->strokeSize); shadowStrokePaddingY = ceilf(info->strokeSize);
} }
if ( info->hasShadow )
{
shadowStrokePaddingX = std::max(shadowStrokePaddingX, (float)fabs(info->shadowOffset.width));
shadowStrokePaddingY = std::max(shadowStrokePaddingY, (float)fabs(info->shadowOffset.height));
}
// add the padding (this could be 0 if no shadow and no stroke) // add the padding (this could be 0 if no shadow and no stroke)
dim.width += shadowStrokePaddingX; dim.width += shadowStrokePaddingX*2;
dim.height += shadowStrokePaddingY; dim.height += shadowStrokePaddingY*2;
unsigned char* data = (unsigned char*)malloc(sizeof(unsigned char) * (int)(dim.width * dim.height * 4)); unsigned char* data = (unsigned char*)malloc(sizeof(unsigned char) * (int)(dim.width * dim.height * 4));
@ -356,84 +350,69 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
// measure text size with specified font and determine the rectangle to draw text in // measure text size with specified font and determine the rectangle to draw text in
unsigned uHoriFlag = (int)align & 0x0f; unsigned uHoriFlag = (int)align & 0x0f;
UITextAlignment testAlign = (UITextAlignment)((2 == uHoriFlag) ? UITextAlignmentRight NSTextAlignment nsAlign = (2 == uHoriFlag) ? NSTextAlignmentRight
: (3 == uHoriFlag) ? UITextAlignmentCenter : (3 == uHoriFlag) ? NSTextAlignmentCenter
: UITextAlignmentLeft); : NSTextAlignmentLeft;
// take care of stroke if needed
if ( info->hasStroke )
{
CGContextSetTextDrawingMode(context, kCGTextFillStroke);
CGContextSetRGBStrokeColor(context, info->strokeColorR, info->strokeColorG, info->strokeColorB, 1);
CGContextSetLineWidth(context, info->strokeSize);
}
// take care of shadow if needed
if ( info->hasShadow )
{
CGSize offset;
offset.height = info->shadowOffset.height;
offset.width = info->shadowOffset.width;
CGFloat shadowColorValues[] = {0, 0, 0, info->shadowOpacity};
CGColorRef shadowColor = CGColorCreate (colorSpace, shadowColorValues);
CGContextSetShadowWithColor(context, offset, info->shadowBlur, shadowColor);
CGColorRelease (shadowColor);
}
CGColorSpaceRelease(colorSpace); CGColorSpaceRelease(colorSpace);
// normal fonts
//if( [font isKindOfClass:[UIFont class] ] )
//{
// [str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:(UILineBreakMode)UILineBreakModeWordWrap alignment:align];
//}
//else // ZFont class
//{
// [FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:(UILineBreakMode)UILineBreakModeWordWrap
////alignment:align];
//}
// compute the rect used for rendering the text // compute the rect used for rendering the text
// based on wether shadows or stroke are enabled // based on wether shadows or stroke are enabled
float textOriginX = 0.0; float textOriginX = 0;
float textOrigingY = 0.0; float textOrigingY = startH;
float textWidth = dim.width - shadowStrokePaddingX; float textWidth = dim.width;
float textHeight = dim.height - shadowStrokePaddingY; float textHeight = dim.height;
if ( info->shadowOffset.width < 0 )
{
textOriginX = shadowStrokePaddingX;
}
else
{
textOriginX = 0.0;
}
if (info->shadowOffset.height > 0)
{
textOrigingY = startH;
}
else
{
textOrigingY = startH - shadowStrokePaddingY;
}
CGRect rect = CGRectMake(textOriginX, textOrigingY, textWidth, textHeight); CGRect rect = CGRectMake(textOriginX, textOrigingY, textWidth, textHeight);
CGContextBeginTransparencyLayerWithRect(context, rect, nullptr); CGContextSetShouldSubpixelQuantizeFonts(context, false);
// actually draw the text in the context
// XXX: ios7 casting
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:(NSTextAlignment)testAlign];
CGContextBeginTransparencyLayerWithRect(context, rect, NULL);
if ( info->hasStroke )
{
CGContextSetTextDrawingMode(context, kCGTextStroke);
if([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending)
{
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = nsAlign;
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
[str drawInRect:rect withAttributes:@{
NSFontAttributeName: font,
NSStrokeWidthAttributeName: [NSNumber numberWithFloat: info->strokeSize / size * 100 ],
NSForegroundColorAttributeName:[UIColor colorWithRed:info->tintColorR
green:info->tintColorG
blue:info->tintColorB
alpha:1.0f],
NSParagraphStyleAttributeName:paragraphStyle,
NSStrokeColorAttributeName: [UIColor colorWithRed:info->strokeColorR
green:info->strokeColorG
blue:info->strokeColorB
alpha:1.0f]
}
];
[paragraphStyle release];
}
else
{
CGContextSetRGBStrokeColor(context, info->strokeColorR, info->strokeColorG, info->strokeColorB, 1);
CGContextSetLineWidth(context, info->strokeSize);
//original code that was not working in iOS 7
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:nsAlign];
}
}
CGContextSetTextDrawingMode(context, kCGTextFill);
// actually draw the text in the context
[str drawInRect: rect withFont:font lineBreakMode:NSLineBreakByWordWrapping alignment:nsAlign];
CGContextEndTransparencyLayer(context); CGContextEndTransparencyLayer(context);
// pop the context // pop the context

View File

@ -408,7 +408,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
} }
auto glview = cocos2d::Director::getInstance()->getOpenGLView(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesBegin(i, (int*)ids, xs, ys); glview->handleTouchesBegin(i, (intptr_t*)ids, xs, ys);
} }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
@ -430,7 +430,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
} }
auto glview = cocos2d::Director::getInstance()->getOpenGLView(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesMove(i, (int*)ids, xs, ys); glview->handleTouchesMove(i, (intptr_t*)ids, xs, ys);
} }
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
@ -453,7 +453,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
} }
auto glview = cocos2d::Director::getInstance()->getOpenGLView(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesEnd(i, (int*)ids, xs, ys); glview->handleTouchesEnd(i, (intptr_t*)ids, xs, ys);
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
@ -476,7 +476,7 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
} }
auto glview = cocos2d::Director::getInstance()->getOpenGLView(); auto glview = cocos2d::Director::getInstance()->getOpenGLView();
glview->handleTouchesCancel(i, (int*)ids, xs, ys); glview->handleTouchesCancel(i, (intptr_t*)ids, xs, ys);
} }
#pragma mark - UIView - Responder #pragma mark - UIView - Responder

View File

@ -100,6 +100,7 @@ typedef enum {
BOOL backgroundMusic; BOOL backgroundMusic;
// whether background music is paused // whether background music is paused
BOOL paused; BOOL paused;
BOOL stopped;
@public @public
BOOL systemPaused;//Used for auto resign handling BOOL systemPaused;//Used for auto resign handling
NSTimeInterval systemPauseLocation;//Used for auto resign handling NSTimeInterval systemPauseLocation;//Used for auto resign handling

View File

@ -48,6 +48,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
mute = NO; mute = NO;
enabled_ = YES; enabled_ = YES;
paused = NO; paused = NO;
stopped = NO;
} }
return self; return self;
} }
@ -96,6 +97,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
if (enabled_) { if (enabled_) {
self->systemPaused = NO; self->systemPaused = NO;
self->paused = NO; self->paused = NO;
self->stopped = NO;
[audioSourcePlayer play]; [audioSourcePlayer play];
} else { } else {
CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled");
@ -104,6 +106,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
-(void) stop { -(void) stop {
self->paused = NO; self->paused = NO;
self->stopped = YES;
[audioSourcePlayer stop]; [audioSourcePlayer stop];
} }
@ -118,9 +121,11 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
} }
-(void) resume { -(void) resume {
self->paused = NO; if (!stopped) {
[audioSourcePlayer play]; self->paused = NO;
} [audioSourcePlayer play];
}
}
-(BOOL) isPlaying { -(BOOL) isPlaying {
if (state != kLAS_Init) { if (state != kLAS_Init) {

View File

@ -119,7 +119,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised";
-(void) resume { -(void) resume {
self->paused = NO; self->paused = NO;
[audioSourcePlayer play]; [audioSourcePlayer resume];
} }
-(BOOL) isPlaying { -(BOOL) isPlaying {

View File

@ -96,6 +96,7 @@ extern OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *o
- (BOOL)playAtTime:(NSTimeInterval) time; /* play a sound some time in the future. time should be greater than deviceCurrentTime. */ - (BOOL)playAtTime:(NSTimeInterval) time; /* play a sound some time in the future. time should be greater than deviceCurrentTime. */
- (void)pause; /* pauses playback, but remains ready to play. */ - (void)pause; /* pauses playback, but remains ready to play. */
- (void)stop; /* stops playback. no longer ready to play. */ - (void)stop; /* stops playback. no longer ready to play. */
- (BOOL) resume;
/* properties */ /* properties */

View File

@ -88,7 +88,13 @@ OSStatus AudioSessionGetProperty(UInt32 inID, UInt32 *ioDataSize, void *outData)
result = [_player resume]; result = [_player resume];
} }
return result; return result;
} }
- (BOOL) resume{
BOOL result = [_player resume];
return result;
}
-(void) pause { -(void) pause {
[_player pause]; [_player pause];

View File

@ -106,6 +106,8 @@ static bool isFloat( std::string myString ) {
return iss.eof() && !iss.fail(); return iss.eof() && !iss.fail();
} }
#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT && CC_TARGET_PLATFORM != CC_PLATFORM_WP8
// helper free functions // helper free functions
// dprintf() is not defined in Android // dprintf() is not defined in Android
@ -176,6 +178,7 @@ static void printFileUtils(int fd)
} }
sendPrompt(fd); sendPrompt(fd);
} }
#endif
#if defined(__MINGW32__) #if defined(__MINGW32__)
@ -210,20 +213,22 @@ static void _log(const char *format, va_list args)
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf); __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 #elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_WP8
WCHAR wszBuf[MAX_LOG_LENGTH] = {0}; WCHAR wszBuf[MAX_LOG_LENGTH] = {0};
MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf)); MultiByteToWideChar(CP_UTF8, 0, buf, -1, wszBuf, sizeof(wszBuf));
OutputDebugStringW(wszBuf); OutputDebugStringW(wszBuf);
WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE);
printf("%s", buf); printf("%s", buf);
#else #else
// Linux, Mac, iOS, etc // Linux, Mac, iOS, etc
fprintf(stdout, "cocos2d: %s", buf); fprintf(stdout, "cocos2d: %s", buf);
fflush(stdout); fflush(stdout);
#endif #endif
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
Director::getInstance()->getConsole()->log(buf); Director::getInstance()->getConsole()->log(buf);
#endif
} }
// XXX: Deprecated // XXX: Deprecated
@ -243,6 +248,8 @@ void log(const char * format, ...)
va_end(args); va_end(args);
} }
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
// //
// Console code // Console code
// //
@ -1081,4 +1088,7 @@ void Console::loop()
_running = false; _running = false;
} }
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) */
NS_CC_END NS_CC_END

View File

@ -68,6 +68,8 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
scheduler->performFunctionInCocosThread( ... ); scheduler->performFunctionInCocosThread( ... );
``` ```
*/ */
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
class CC_DLL Console class CC_DLL Console
{ {
public: public:
@ -137,11 +139,12 @@ protected:
std::mutex _DebugStringsMutex; std::mutex _DebugStringsMutex;
std::vector<std::string> _DebugStrings; std::vector<std::string> _DebugStrings;
int _touchId; intptr_t _touchId;
private: private:
CC_DISALLOW_COPY_AND_ASSIGN(Console); CC_DISALLOW_COPY_AND_ASSIGN(Console);
}; };
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) */
NS_CC_END NS_CC_END
#endif /* defined(__CCCONSOLE_H__) */ #endif /* defined(__CCCONSOLE_H__) */

View File

@ -48,6 +48,8 @@ Config of cocos2d-x project, per target platform.
#define CC_PLATFORM_EMSCRIPTEN 10 #define CC_PLATFORM_EMSCRIPTEN 10
#define CC_PLATFORM_TIZEN 11 #define CC_PLATFORM_TIZEN 11
#define CC_PLATFORM_QT5 12 #define CC_PLATFORM_QT5 12
#define CC_PLATFORM_WP8 13
#define CC_PLATFORM_WINRT 14
// Determine target platform by compile environment macro. // Determine target platform by compile environment macro.
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
@ -124,6 +126,19 @@ Config of cocos2d-x project, per target platform.
#define CC_TARGET_PLATFORM CC_PLATFORM_QT5 #define CC_TARGET_PLATFORM CC_PLATFORM_QT5
#endif #endif
// WinRT (Windows Store App)
#if defined(WINRT)
#undef CC_TARGET_PLATFORM
#define CC_TARGET_PLATFORM CC_PLATFORM_WINRT
#endif
// WP8 (Windows Phone 8 App)
#if defined(WP8)
#undef CC_TARGET_PLATFORM
#define CC_TARGET_PLATFORM CC_PLATFORM_WP8
#endif
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// post configure // post configure
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

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

View File

@ -128,7 +128,12 @@ public:
PERCENT, PERCENT,
MULTIPLY_RESOLUTION, MULTIPLY_RESOLUTION,
}; };
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
#ifdef ABSOLUTE
#undef ABSOLUTE
#endif
#endif
enum class SizeType enum class SizeType
{ {
ABSOLUTE, ABSOLUTE,

View File

@ -97,6 +97,15 @@ bool ComAudio::serialize(void* r)
CC_BREAK_IF(resType != 0); CC_BREAK_IF(resType != 0);
if (strcmp(className, "CCBackgroundAudio") == 0) if (strcmp(className, "CCBackgroundAudio") == 0)
{ {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// no MP3 support for CC_PLATFORM_WP8
std::string::size_type pos = filePath.find(".mp3");
if (pos == filePath.npos)
{
continue;
}
filePath.replace(pos, filePath.length(), ".wav");
#endif
preloadBackgroundMusic(filePath.c_str()); preloadBackgroundMusic(filePath.c_str());
bool loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false; bool loop = DICTOOL->getIntValue_json(*v, "loop") != 0? true:false;
setLoop(loop); setLoop(loop);

View File

@ -43,6 +43,10 @@ bool ComController::init()
void ComController::onEnter() void ComController::onEnter()
{ {
if (_owner != nullptr)
{
_owner->scheduleUpdate();
}
} }
void ComController::onExit() void ComController::onExit()

View File

@ -39,13 +39,17 @@ ComRender::ComRender(void)
ComRender::ComRender(cocos2d::Node *node, const char *comName) ComRender::ComRender(cocos2d::Node *node, const char *comName)
{ {
_render = node; if (node != nullptr)
{
_render = node;
_render->retain();
}
_name.assign(comName); _name.assign(comName);
} }
ComRender::~ComRender(void) ComRender::~ComRender(void)
{ {
_render = nullptr; CC_SAFE_RELEASE_NULL(_render);
} }
void ComRender::onEnter() void ComRender::onEnter()
@ -58,7 +62,10 @@ void ComRender::onEnter()
void ComRender::onExit() void ComRender::onExit()
{ {
_render = nullptr; if (_owner != nullptr)
{
_owner->removeChild(_render, true);
}
} }
cocos2d::Node* ComRender::getNode() cocos2d::Node* ComRender::getNode()
@ -68,7 +75,16 @@ cocos2d::Node* ComRender::getNode()
void ComRender::setNode(cocos2d::Node *node) void ComRender::setNode(cocos2d::Node *node)
{ {
_render = node; if (_render != nullptr)
{
_render->release();
_render = nullptr;
}
if (node != nullptr)
{
_render = node;
_render->retain();
}
} }
@ -111,15 +127,18 @@ bool ComRender::serialize(void* r)
if (strcmp(className, "CCSprite") == 0 && filePath.find(".png") != std::string::npos) if (strcmp(className, "CCSprite") == 0 && filePath.find(".png") != std::string::npos)
{ {
_render = Sprite::create(filePath.c_str()); _render = Sprite::create(filePath.c_str());
_render->retain();
} }
else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != std::string::npos) else if(strcmp(className, "CCTMXTiledMap") == 0 && filePath.find(".tmx") != std::string::npos)
{ {
_render = TMXTiledMap::create(filePath.c_str()); _render = TMXTiledMap::create(filePath.c_str());
_render->retain();
} }
else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != std::string::npos) else if(strcmp(className, "CCParticleSystemQuad") == 0 && filePath.find(".plist") != std::string::npos)
{ {
_render = ParticleSystemQuad::create(filePath.c_str()); _render = ParticleSystemQuad::create(filePath.c_str());
_render->setPosition(Point(0.0f, 0.0f)); _render->setPosition(Point(0.0f, 0.0f));
_render->retain();
} }
else if(strcmp(className, "CCArmature") == 0) else if(strcmp(className, "CCArmature") == 0)
{ {
@ -141,6 +160,7 @@ bool ComRender::serialize(void* r)
ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str()); ArmatureDataManager::getInstance()->addArmatureFileInfo(filePath.c_str());
Armature *pAr = Armature::create(name); Armature *pAr = Armature::create(name);
_render = pAr; _render = pAr;
_render->retain();
const char *actionName = DICTOOL->getStringValue_json(*v, "selectedactionname"); const char *actionName = DICTOOL->getStringValue_json(*v, "selectedactionname");
if (actionName != nullptr && pAr->getAnimation() != nullptr) if (actionName != nullptr && pAr->getAnimation() != nullptr)
{ {
@ -151,6 +171,7 @@ bool ComRender::serialize(void* r)
{ {
cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str()); cocos2d::ui::Widget* widget = GUIReader::getInstance()->widgetFromJsonFile(filePath.c_str());
_render = widget; _render = widget;
_render->retain();
} }
else else
{ {
@ -170,6 +191,7 @@ bool ComRender::serialize(void* r)
strPngFile.replace(pos, strPngFile.length(), ".png"); strPngFile.replace(pos, strPngFile.length(), ".png");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str()); SpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath.c_str(), strPngFile.c_str());
_render = Sprite::createWithSpriteFrameName(filePath.c_str()); _render = Sprite::createWithSpriteFrameName(filePath.c_str());
_render->retain();
} }
else else
{ {

View File

@ -37,6 +37,7 @@ SceneReader* SceneReader::s_sharedReader = nullptr;
SceneReader::SceneReader() SceneReader::SceneReader()
: _fnSelector(nullptr) : _fnSelector(nullptr)
, _node(nullptr) , _node(nullptr)
, _attachComponent(AttachComponentType::EMPTY_NODE)
{ {
ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComAttribute));
ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender)); ObjectFactory::getInstance()->registerType(CREATE_CLASS_COMPONENT_INFO(ComRender));
@ -53,12 +54,12 @@ const char* SceneReader::sceneReaderVersion()
return "1.0.0.0"; return "1.0.0.0";
} }
cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName) cocos2d::Node* SceneReader::createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent /*= AttachComponentType::EMPTY_NODE*/)
{ {
rapidjson::Document jsonDict; rapidjson::Document jsonDict;
do { do {
CC_BREAK_IF(!readJson(fileName, jsonDict)); CC_BREAK_IF(!readJson(fileName, jsonDict));
_node = createObject(jsonDict, nullptr); _node = createObject(jsonDict, nullptr, attachComponent);
TriggerMng::getInstance()->parse(jsonDict); TriggerMng::getInstance()->parse(jsonDict);
} while (0); } while (0);
@ -110,7 +111,7 @@ Node* SceneReader::nodeByTag(Node *parent, int tag)
} }
Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent) Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* parent, AttachComponentType attachComponent)
{ {
const char *className = DICTOOL->getStringValue_json(dict, "classname"); const char *className = DICTOOL->getStringValue_json(dict, "classname");
if(strcmp(className, "CCNode") == 0) if(strcmp(className, "CCNode") == 0)
@ -120,14 +121,9 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
{ {
gb = Node::create(); gb = Node::create();
} }
else
{
gb = Node::create();
parent->addChild(gb);
}
setPropertyFromJsonDict(dict, gb);
std::vector<Component*> vecComs;
ComRender *render = nullptr;
int count = DICTOOL->getArrayCount_json(dict, "components"); int count = DICTOOL->getArrayCount_json(dict, "components");
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
@ -138,23 +134,52 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
} }
const char *comName = DICTOOL->getStringValue_json(subDict, "classname"); const char *comName = DICTOOL->getStringValue_json(subDict, "classname");
Component *com = ObjectFactory::getInstance()->createComponent(comName); Component *com = ObjectFactory::getInstance()->createComponent(comName);
if (com != NULL) if (com != nullptr)
{ {
if (com->serialize((void*)(&subDict))) if (com->serialize((void*)(&subDict)))
{
gb->addComponent(com);
}
else
{ {
com = nullptr; ComRender *tRender = dynamic_cast<ComRender*>(com);
if (tRender == nullptr)
{
vecComs.push_back(com);
}
else
{
render = tRender;
}
} }
} }
if(_fnSelector != nullptr) if(_fnSelector != nullptr)
{ {
_fnSelector(com, (void*)(&subDict)); _fnSelector(com, (void*)(&subDict));
} }
} }
if (parent != nullptr)
{
if (render == nullptr || attachComponent == AttachComponentType::EMPTY_NODE)
{
gb = Node::create();
if (render != nullptr)
{
vecComs.push_back(render);
}
}
else
{
gb = render->getNode();
gb->retain();
render->setNode(nullptr);
}
parent->addChild(gb);
}
setPropertyFromJsonDict(dict, gb);
for (std::vector<Component*>::iterator iter = vecComs.begin(); iter != vecComs.end(); ++iter)
{
gb->addComponent(*iter);
}
int length = DICTOOL->getArrayCount_json(dict, "gameobjects"); int length = DICTOOL->getArrayCount_json(dict, "gameobjects");
for (int i = 0; i < length; ++i) for (int i = 0; i < length; ++i)
{ {
@ -163,7 +188,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
{ {
break; break;
} }
createObject(subDict, gb); createObject(subDict, gb, attachComponent);
} }
return gb; return gb;

View File

@ -30,9 +30,30 @@ THE SOFTWARE.
namespace cocostudio { namespace cocostudio {
class SceneReader class SceneReader
{ {
public: public:
enum class AttachComponentType
{
///parent: Empty Node
/// ComRender(Sprite, Armature, TMXTiledMap, ParticleSystemQuad, GUIComponent)
/// ComAttribute
/// ComAudio
/// ....
EMPTY_NODE,
///parent: ComRender(Sprite, Armature, TMXTiledMap, ParticleSystemQuad, GUIComponent)
/// ComAttribute
/// ComAudio
/// .....
RENDER_NODE,
/// Default AttachComponentType is _EmptyNode
DEFAULT = EMPTY_NODE,
};
static SceneReader* getInstance(); static SceneReader* getInstance();
/** /**
* @js purge * @js purge
@ -40,22 +61,23 @@ public:
*/ */
static void destroyInstance(); static void destroyInstance();
static const char* sceneReaderVersion(); static const char* sceneReaderVersion();
cocos2d::Node* createNodeWithSceneFile(const std::string &fileName); cocos2d::Node* createNodeWithSceneFile(const std::string &fileName, AttachComponentType attachComponent = AttachComponentType::EMPTY_NODE);
void setTarget(const std::function<void(cocos2d::Ref* obj, void* doc)>& selector); void setTarget(const std::function<void(cocos2d::Ref* obj, void* doc)>& selector);
cocos2d::Node* getNodeByTag(int nTag); cocos2d::Node* getNodeByTag(int nTag);
inline AttachComponentType getAttachComponentType(){return _attachComponent;}
private: private:
SceneReader(void); SceneReader(void);
virtual ~SceneReader(void); virtual ~SceneReader(void);
cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent); cocos2d::Node* createObject(const rapidjson::Value& dict, cocos2d::Node* parent, AttachComponentType attachComponent);
void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node); void setPropertyFromJsonDict(const rapidjson::Value& dict, cocos2d::Node *node);
bool readJson(const std::string &fileName, rapidjson::Document& doc); bool readJson(const std::string &fileName, rapidjson::Document& doc);
cocos2d::Node* nodeByTag(cocos2d::Node *parent, int tag); cocos2d::Node* nodeByTag(cocos2d::Node *parent, int tag);
private: private:
static SceneReader* s_sharedReader; static SceneReader* s_sharedReader;
std::function<void(cocos2d::Ref* obj, void* doc)> _fnSelector; std::function<void(cocos2d::Ref* obj, void* doc)> _fnSelector;
cocos2d::Node* _node; cocos2d::Node* _node;
AttachComponentType _attachComponent;
}; };

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ActionManagerEx -- @module ActionManagerEx
-- @extend Ref
-------------------------------- --------------------------------
-- overload function: playActionByName(char, char, cc.CallFunc) -- overload function: playActionByName(char, char, cc.CallFunc)

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ActionObject -- @module ActionObject
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#ActionObject] setCurrentTime -- @function [parent=#ActionObject] setCurrentTime

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module AnimationData -- @module AnimationData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#AnimationData] getMovement -- @function [parent=#AnimationData] getMovement

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module Armature -- @module Armature
-- @extend Node,BlendProtocol, -- @extend Node,BlendProtocol
-------------------------------- --------------------------------
-- @function [parent=#Armature] getBone -- @function [parent=#Armature] getBone

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ArmatureAnimation -- @module ArmatureAnimation
-- @extend ProcessBase
-------------------------------- --------------------------------
-- @function [parent=#ArmatureAnimation] getSpeedScale -- @function [parent=#ArmatureAnimation] getSpeedScale

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ArmatureData -- @module ArmatureData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#ArmatureData] addBoneData -- @function [parent=#ArmatureData] addBoneData

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ArmatureDataManager -- @module ArmatureDataManager
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#ArmatureDataManager] getAnimationDatas -- @function [parent=#ArmatureDataManager] getAnimationDatas

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module AtlasNode -- @module AtlasNode
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- @function [parent=#AtlasNode] updateAtlasValues -- @function [parent=#AtlasNode] updateAtlasValues

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module BaseData -- @module BaseData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#BaseData] getColor -- @function [parent=#BaseData] getColor

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module CCBAnimationManager -- @module CCBAnimationManager
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#CCBAnimationManager] moveAnimationsFromNode -- @function [parent=#CCBAnimationManager] moveAnimationsFromNode

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module CCBReader -- @module CCBReader
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#CCBReader] addOwnerOutletName -- @function [parent=#CCBReader] addOwnerOutletName

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module ComController -- @module ComController
-- @extend Component,InputDelegate, -- @extend Component,InputDelegate
-------------------------------- --------------------------------
-- @function [parent=#ComController] create -- @function [parent=#ComController] create

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module ContourData -- @module ContourData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#ContourData] init -- @function [parent=#ContourData] init

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module DisplayData -- @module DisplayData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#DisplayData] copy -- @function [parent=#DisplayData] copy

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module DisplayManager -- @module DisplayManager
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#DisplayManager] getDisplayRenderNode -- @function [parent=#DisplayManager] getDisplayRenderNode

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module EditBox -- @module EditBox
-- @extend ControlButton,IMEDelegate, -- @extend ControlButton,IMEDelegate
-------------------------------- --------------------------------
-- @function [parent=#EditBox] getText -- @function [parent=#EditBox] getText

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module GLView -- @module GLView
-- @extend GLViewProtocol,Ref, -- @extend GLViewProtocol,Ref
-------------------------------- --------------------------------
-- @function [parent=#GLView] createWithRect -- @function [parent=#GLView] createWithRect

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module GUIReader -- @module GUIReader
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#GUIReader] widgetFromJsonFile -- @function [parent=#GUIReader] widgetFromJsonFile

View File

@ -2,13 +2,6 @@
-------------------------------- --------------------------------
-- @module Helper -- @module Helper
--------------------------------
-- @function [parent=#Helper] seekActionWidgetByActionTag
-- @param self
-- @param #ccui.Widget widget
-- @param #int int
-- @return Widget#Widget ret (return value: ccui.Widget)
-------------------------------- --------------------------------
-- @function [parent=#Helper] seekWidgetByTag -- @function [parent=#Helper] seekWidgetByTag
-- @param self -- @param self
@ -17,10 +10,10 @@
-- @return Widget#Widget ret (return value: ccui.Widget) -- @return Widget#Widget ret (return value: ccui.Widget)
-------------------------------- --------------------------------
-- @function [parent=#Helper] seekWidgetByRelativeName -- @function [parent=#Helper] seekActionWidgetByActionTag
-- @param self -- @param self
-- @param #ccui.Widget widget -- @param #ccui.Widget widget
-- @param #char char -- @param #int int
-- @return Widget#Widget ret (return value: ccui.Widget) -- @return Widget#Widget ret (return value: ccui.Widget)
-------------------------------- --------------------------------

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module Label -- @module Label
-- @extend SpriteBatchNode,LabelProtocol, -- @extend SpriteBatchNode,LabelProtocol
-------------------------------- --------------------------------
-- @function [parent=#Label] isClipMarginEnabled -- @function [parent=#Label] isClipMarginEnabled

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module LabelAtlas -- @module LabelAtlas
-- @extend AtlasNode,LabelProtocol, -- @extend AtlasNode,LabelProtocol
-------------------------------- --------------------------------
-- @function [parent=#LabelAtlas] setString -- @function [parent=#LabelAtlas] setString

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module LabelBMFont -- @module LabelBMFont
-- @extend Node,LabelProtocol,BlendProtocol, -- @extend Node,LabelProtocol,BlendProtocol
-------------------------------- --------------------------------
-- @function [parent=#LabelBMFont] setLineBreakWithoutSpace -- @function [parent=#LabelBMFont] setLineBreakWithoutSpace

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module LabelTTF -- @module LabelTTF
-- @extend Node,LabelProtocol,BlendProtocol, -- @extend Node,LabelProtocol,BlendProtocol
-------------------------------- --------------------------------
-- @function [parent=#LabelTTF] enableShadow -- @function [parent=#LabelTTF] enableShadow

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module LayerColor -- @module LayerColor
-- @extend Layer,BlendProtocol, -- @extend Layer,BlendProtocol
-------------------------------- --------------------------------
-- @function [parent=#LayerColor] changeWidthAndHeight -- @function [parent=#LayerColor] changeWidthAndHeight

View File

@ -43,20 +43,6 @@
-- @param self -- @param self
-- @return point_table#point_table ret (return value: point_table) -- @return point_table#point_table ret (return value: point_table)
--------------------------------
-- overload function: initWithColor(color4B_table, color4B_table)
--
-- overload function: initWithColor()
--
-- overload function: initWithColor(color4B_table, color4B_table, point_table)
--
-- @function [parent=#LayerGradient] initWithColor
-- @param self
-- @param #color4B_table color4b
-- @param #color4B_table color4b
-- @param #point_table point
-- @return bool#bool ret (retunr value: bool)
-------------------------------- --------------------------------
-- @function [parent=#LayerGradient] setEndColor -- @function [parent=#LayerGradient] setEndColor
-- @param self -- @param self

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module LayoutParameter -- @module LayoutParameter
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#LayoutParameter] clone -- @function [parent=#LayoutParameter] clone

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module MotionStreak -- @module MotionStreak
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- @function [parent=#MotionStreak] reset -- @function [parent=#MotionStreak] reset

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module MovementBoneData -- @module MovementBoneData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#MovementBoneData] init -- @function [parent=#MovementBoneData] init

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module MovementData -- @module MovementData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#MovementData] getMovementBoneData -- @function [parent=#MovementData] getMovementBoneData

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module PageView -- @module PageView
-- @extend Layout,UIScrollInterface, -- @extend Layout,UIScrollInterface
-------------------------------- --------------------------------
-- @function [parent=#PageView] getCurPageIndex -- @function [parent=#PageView] getCurPageIndex

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module ParticleBatchNode -- @module ParticleBatchNode
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- @function [parent=#ParticleBatchNode] setTexture -- @function [parent=#ParticleBatchNode] setTexture

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module ParticleSystem -- @module ParticleSystem
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- @function [parent=#ParticleSystem] getStartSizeVar -- @function [parent=#ParticleSystem] getStartSizeVar

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module RichElement -- @module RichElement
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#RichElement] init -- @function [parent=#RichElement] init

View File

@ -11,8 +11,14 @@
-- @function [parent=#SceneReader] createNodeWithSceneFile -- @function [parent=#SceneReader] createNodeWithSceneFile
-- @param self -- @param self
-- @param #string str -- @param #string str
-- @param #ccs.SceneReader::AttachComponentType attachcomponenttype
-- @return Node#Node ret (return value: cc.Node) -- @return Node#Node ret (return value: cc.Node)
--------------------------------
-- @function [parent=#SceneReader] getAttachComponentType
-- @param self
-- @return SceneReader::AttachComponentType#SceneReader::AttachComponentType ret (return value: ccs.SceneReader::AttachComponentType)
-------------------------------- --------------------------------
-- @function [parent=#SceneReader] getNodeByTag -- @function [parent=#SceneReader] getNodeByTag
-- @param self -- @param self

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module ScrollView -- @module ScrollView
-- @extend Layout,UIScrollInterface, -- @extend Layout,UIScrollInterface
-------------------------------- --------------------------------
-- @function [parent=#ScrollView] scrollToTop -- @function [parent=#ScrollView] scrollToTop

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module Skeleton -- @module Skeleton
-- @extend Node,BlendProtocol, -- @extend Node,BlendProtocol
-------------------------------- --------------------------------
-- @function [parent=#Skeleton] setToSetupPose -- @function [parent=#Skeleton] setToSetupPose

View File

@ -111,6 +111,12 @@
-- @param self -- @param self
-- @return string#string ret (return value: string) -- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Slider] hitTest
-- @param self
-- @param #point_table point
-- @return bool#bool ret (return value: bool)
-------------------------------- --------------------------------
-- @function [parent=#Slider] getContentSize -- @function [parent=#Slider] getContentSize
-- @param self -- @param self

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module Sprite -- @module Sprite
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- overload function: setSpriteFrame(cc.SpriteFrame) -- overload function: setSpriteFrame(cc.SpriteFrame)

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module SpriteBatchNode -- @module SpriteBatchNode
-- @extend Node,TextureProtocol, -- @extend Node,TextureProtocol
-------------------------------- --------------------------------
-- @function [parent=#SpriteBatchNode] appendChild -- @function [parent=#SpriteBatchNode] appendChild

View File

@ -1,7 +1,7 @@
-------------------------------- --------------------------------
-- @module TableView -- @module TableView
-- @extend ScrollView,ScrollViewDelegate, -- @extend ScrollView,ScrollViewDelegate
-------------------------------- --------------------------------
-- @function [parent=#TableView] updateCellAtIndex -- @function [parent=#TableView] updateCellAtIndex

View File

@ -1,6 +1,7 @@
-------------------------------- --------------------------------
-- @module TextureData -- @module TextureData
-- @extend Ref
-------------------------------- --------------------------------
-- @function [parent=#TextureData] getContourData -- @function [parent=#TextureData] getContourData

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