mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop
Conflicts: plugin/samples/HelloSocial/proj.ios/HelloSocial.xcodeproj/project.pbxproj
This commit is contained in:
commit
e994321a61
2
AUTHORS
2
AUTHORS
|
@ -24,6 +24,7 @@ Developers:
|
|||
|
||||
carlomorgantinizynga
|
||||
CCLabelTTF supports for shadow and stroke
|
||||
Adding CCLabelTTF::createWithFontDefinition.
|
||||
|
||||
James Gregory (j4m3z0r, Zynga)
|
||||
Maintainer of Emscripten port.
|
||||
|
@ -183,6 +184,7 @@ Developers:
|
|||
Simpler, correct handling of spritesheet sources for CCScale9Sprite.
|
||||
Clean up linked libraries for android.
|
||||
JavaScript debugger improved and bugfixed.
|
||||
Fix flags for debugger server socket.
|
||||
|
||||
Nicolas Gramlich (nicolasgramlich, Zynga)
|
||||
fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
cocos2d-x-3.0alpha0-pre @Jul.24 2013
|
||||
[all platforms]
|
||||
Feature #XXXX: Add support for std::function<> in CCMemuItem and CCCallFunc
|
||||
|
||||
|
||||
cocos2d-2.1rc0-x-2.1.3 @May.01 2013
|
||||
[all platforms]
|
||||
Bug #1853: use SHELLOPTS instead of "-o igncr" for Android Eclipse project
|
||||
|
|
|
@ -289,7 +289,8 @@ bool initAudioPlayer(AudioPlayer* player, const char* filename)
|
|||
if(fp){
|
||||
SLDataLocator_URI loc_fd = {SL_DATALOCATOR_URI , (SLchar*)filename};
|
||||
SLDataFormat_MIME format_mime = {SL_DATAFORMAT_MIME, NULL, SL_CONTAINERTYPE_UNSPECIFIED};
|
||||
(player->audioSrc) = {&loc_fd, &format_mime};
|
||||
player->audioSrc.pLocator = &loc_fd;
|
||||
player->audioSrc.pFormat = &format_mime;
|
||||
return createAudioPlayerBySource(player);
|
||||
}
|
||||
LOGD("file not found! Stop preload file: %s", filename);
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1067387441" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
|
||||
<builder autoBuildTarget="all" buildPath="${workspace_loc:/cocosdenshion/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1261707379" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
|
||||
<tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -49,7 +49,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -57,14 +56,15 @@
|
|||
<listOptionValue builtIn="false" value="_DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="TIZEN"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.other.other.174888158" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
|
||||
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -79,7 +79,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -89,12 +88,11 @@
|
|||
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
</tool>
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
#include "CCStdC.h"
|
||||
#include "ccTypeInfo.h"
|
||||
#include "CCAction.h"
|
||||
|
||||
|
@ -213,7 +214,7 @@ public:
|
|||
: m_pSelectorTarget(NULL)
|
||||
, m_nScriptHandler(0)
|
||||
, m_pCallFunc(NULL)
|
||||
, _function(NULL)
|
||||
, _function(nullptr)
|
||||
{
|
||||
}
|
||||
virtual ~CCCallFunc();
|
||||
|
|
|
@ -103,7 +103,7 @@ CCNode::CCNode(void)
|
|||
|
||||
CCNode::~CCNode(void)
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing" );
|
||||
CCLOGINFO( "cocos2d: deallocing: %p", this );
|
||||
|
||||
unregisterScriptHandler();
|
||||
if (m_nUpdateScriptHandler)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CCData : public CCObject
|
||||
class CC_DLL CCData : public CCObject
|
||||
{
|
||||
public:
|
||||
CCData(unsigned char *pBytes, const unsigned long nSize);
|
||||
|
|
|
@ -30,7 +30,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "2.1rc0-x-2.1.3";
|
||||
return "3.0-alpha0-pre";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -142,7 +142,7 @@ CCBMFontConfiguration::CCBMFontConfiguration()
|
|||
|
||||
CCBMFontConfiguration::~CCBMFontConfiguration()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration" );
|
||||
CCLOGINFO( "cocos2d: deallocing CCBMFontConfiguration %p", this );
|
||||
this->purgeFontDefDictionary();
|
||||
this->purgeKerningDictionary();
|
||||
m_sAtlasName.clear();
|
||||
|
|
|
@ -96,6 +96,18 @@ CCLabelTTF* CCLabelTTF::create(const char *string, const char *fontName, float f
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCLabelTTF * CCLabelTTF::createWithFontDefinition(const char *string, ccFontDefinition &textDefinition)
|
||||
{
|
||||
CCLabelTTF *pRet = new CCLabelTTF();
|
||||
if(pRet && pRet->initWithStringAndTextDefinition(string, textDefinition))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
CC_SAFE_DELETE(pRet);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CCLabelTTF::init()
|
||||
{
|
||||
return this->initWithString("", "Helvetica", 12);
|
||||
|
@ -355,7 +367,7 @@ void CCLabelTTF::enableShadow(const CCSize &shadowOffset, float shadowOpacity, f
|
|||
}
|
||||
|
||||
#else
|
||||
CCAssert(false, "Currently only supported on iOS and Android!");
|
||||
CCLOGERROR("Currently only supported on iOS and Android!");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -374,7 +386,7 @@ void CCLabelTTF::disableShadow(bool updateTexture)
|
|||
}
|
||||
|
||||
#else
|
||||
CCAssert(false, "Currently only supported on iOS and Android!");
|
||||
CCLOGERROR("Currently only supported on iOS and Android!");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -408,7 +420,7 @@ void CCLabelTTF::enableStroke(const ccColor3B &strokeColor, float strokeSize, bo
|
|||
}
|
||||
|
||||
#else
|
||||
CCAssert(false, "Currently only supported on iOS and Android!");
|
||||
CCLOGERROR("Currently only supported on iOS and Android!");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -426,7 +438,7 @@ void CCLabelTTF::disableStroke(bool updateTexture)
|
|||
}
|
||||
|
||||
#else
|
||||
CCAssert(false, "Currently only supported on iOS and Android!");
|
||||
CCLOGERROR("Currently only supported on iOS and Android!");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -442,7 +454,7 @@ void CCLabelTTF::setFontFillColor(const ccColor3B &tintColor, bool updateTexture
|
|||
this->updateTexture();
|
||||
}
|
||||
#else
|
||||
CCAssert(false, "Currently only supported on iOS and Android!");
|
||||
CCLOGERROR("Currently only supported on iOS and Android!");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,10 @@ public:
|
|||
const CCSize& dimensions, CCTextAlignment hAlignment,
|
||||
CCVerticalTextAlignment vAlignment);
|
||||
|
||||
|
||||
/** Create a lable with string and a font definition*/
|
||||
static CCLabelTTF * createWithFontDefinition(const char *string, ccFontDefinition &textDefinition);
|
||||
|
||||
/** initializes the CCLabelTTF with a font name and font size */
|
||||
bool initWithString(const char *string, const char *fontName, float fontSize);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ const unsigned int kDisableTag = 0x3;
|
|||
|
||||
CCMenuItem* CCMenuItem::create()
|
||||
{
|
||||
return CCMenuItem::create((const ccMenuCallback&)NULL);
|
||||
return CCMenuItem::create((const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
|
@ -161,6 +161,7 @@ bool CCMenuItem::isSelected()
|
|||
return m_bSelected;
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
void CCMenuItem::setTarget(CCObject *target, SEL_MenuHandler selector)
|
||||
{
|
||||
_target = target;
|
||||
|
@ -227,7 +228,7 @@ CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, const ccMenuCallback& ca
|
|||
CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label)
|
||||
{
|
||||
CCMenuItemLabel *pRet = new CCMenuItemLabel();
|
||||
pRet->initWithLabel(label, (const ccMenuCallback&) NULL);
|
||||
pRet->initWithLabel(label, (const ccMenuCallback&) nullptr);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
@ -334,7 +335,7 @@ void CCMenuItemLabel::setEnabled(bool enabled)
|
|||
|
||||
CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap)
|
||||
{
|
||||
return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)NULL);
|
||||
return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, (const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
|
@ -427,11 +428,12 @@ CCMenuItemFont * CCMenuItemFont::create(const char *value, const ccMenuCallback&
|
|||
CCMenuItemFont * CCMenuItemFont::create(const char *value)
|
||||
{
|
||||
CCMenuItemFont *pRet = new CCMenuItemFont();
|
||||
pRet->initWithString(value, (const ccMenuCallback&)NULL);
|
||||
pRet->initWithString(value, (const ccMenuCallback&)nullptr);
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_MenuHandler selector)
|
||||
{
|
||||
CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0");
|
||||
|
@ -571,7 +573,7 @@ void CCMenuItemSprite::setDisabledImage(CCNode* pImage)
|
|||
|
||||
CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite)
|
||||
{
|
||||
return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)NULL);
|
||||
return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, (const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
|
@ -726,12 +728,12 @@ CCMenuItemImage* CCMenuItemImage::create()
|
|||
|
||||
bool CCMenuItemImage::init(void)
|
||||
{
|
||||
return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)NULL);
|
||||
return initWithNormalImage(NULL, NULL, NULL, (const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage)
|
||||
{
|
||||
return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)NULL);
|
||||
return CCMenuItemImage::create(normalImage, selectedImage, NULL, (const ccMenuCallback&)nullptr);
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
|
@ -773,7 +775,7 @@ CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *s
|
|||
CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage)
|
||||
{
|
||||
CCMenuItemImage *pRet = new CCMenuItemImage();
|
||||
if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)NULL))
|
||||
if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, (const ccMenuCallback&)nullptr))
|
||||
{
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
|
@ -846,6 +848,7 @@ CCArray* CCMenuItemToggle::getSubItems()
|
|||
return m_pSubItems;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems)
|
||||
{
|
||||
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||
|
@ -864,6 +867,25 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu
|
|||
return pRet;
|
||||
}
|
||||
|
||||
CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCArray* menuItems)
|
||||
{
|
||||
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||
pRet->CCMenuItem::initWithCallback(callback);
|
||||
pRet->m_pSubItems = CCArray::create();
|
||||
pRet->m_pSubItems->retain();
|
||||
|
||||
for (unsigned int z=0; z < menuItems->count(); z++)
|
||||
{
|
||||
CCMenuItem* menuItem = (CCMenuItem*)menuItems->objectAtIndex(z);
|
||||
pRet->m_pSubItems->addObject(menuItem);
|
||||
}
|
||||
|
||||
pRet->m_uSelectedIndex = UINT_MAX;
|
||||
pRet->setSelectedIndex(0);
|
||||
return pRet;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
@ -875,6 +897,17 @@ CCMenuItemToggle * CCMenuItemToggle::createWithTarget(CCObject* target, SEL_Menu
|
|||
return pRet;
|
||||
}
|
||||
|
||||
CCMenuItemToggle * CCMenuItemToggle::createWithCallback(const ccMenuCallback &callback, CCMenuItem* item, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, item);
|
||||
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||
pRet->initWithCallback(callback, item, args);
|
||||
pRet->autorelease();
|
||||
va_end(args);
|
||||
return pRet;
|
||||
}
|
||||
|
||||
CCMenuItemToggle * CCMenuItemToggle::create()
|
||||
{
|
||||
CCMenuItemToggle *pRet = new CCMenuItemToggle();
|
||||
|
@ -883,14 +916,22 @@ CCMenuItemToggle * CCMenuItemToggle::create()
|
|||
return pRet;
|
||||
}
|
||||
|
||||
// XXX: deprecated
|
||||
bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args)
|
||||
{
|
||||
CCMenuItem::initWithTarget(target, selector);
|
||||
_target = target;
|
||||
CC_SAFE_RETAIN(_target);
|
||||
return initWithCallback(std::bind( selector, target, std::placeholders::_1), item, args);
|
||||
}
|
||||
|
||||
bool CCMenuItemToggle::initWithCallback(const ccMenuCallback &callback, CCMenuItem *item, va_list args)
|
||||
{
|
||||
CCMenuItem::initWithCallback(callback);
|
||||
this->m_pSubItems = CCArray::create();
|
||||
this->m_pSubItems->retain();
|
||||
int z = 0;
|
||||
CCMenuItem *i = item;
|
||||
while(i)
|
||||
while(i)
|
||||
{
|
||||
z++;
|
||||
m_pSubItems->addObject(i);
|
||||
|
@ -911,7 +952,7 @@ CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item)
|
|||
|
||||
bool CCMenuItemToggle::initWithItem(CCMenuItem *item)
|
||||
{
|
||||
CCMenuItem::initWithCallback((const ccMenuCallback&)NULL);
|
||||
CCMenuItem::initWithCallback((const ccMenuCallback&)nullptr);
|
||||
setSubItems(CCArray::create());
|
||||
|
||||
if (item)
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
, m_bEnabled(false)
|
||||
, m_nScriptTapHandler(0)
|
||||
, _target(NULL)
|
||||
, _callback(NULL)
|
||||
, _callback(nullptr)
|
||||
{}
|
||||
virtual ~CCMenuItem();
|
||||
|
||||
|
@ -374,12 +374,12 @@ public:
|
|||
/** creates a menu item from a CCArray with a target selector */
|
||||
CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle * createWithTarget(CCObject* target, SEL_MenuHandler selector, CCArray* menuItems);
|
||||
/** creates a menu item from a CCArray with a callable object */
|
||||
static CCMenuItemToggle * createWithTarget(const ccMenuCallback& callback, CCArray* menuItems);
|
||||
static CCMenuItemToggle * createWithCallback(const ccMenuCallback& callback, CCArray* menuItems);
|
||||
|
||||
/** creates a menu item from a list of items with a target/selector */
|
||||
CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* createWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
|
||||
/** creates a menu item from a list of items with a callable object */
|
||||
static CCMenuItemToggle* createWithTarget(const ccMenuCallback& callback, CCMenuItem* item, ...);
|
||||
static CCMenuItemToggle* createWithCallback(const ccMenuCallback& callback, CCMenuItem* item, ...);
|
||||
|
||||
/** creates a menu item with no target/selector and no items */
|
||||
static CCMenuItemToggle* create();
|
||||
|
@ -387,7 +387,7 @@ public:
|
|||
/** initializes a menu item from a list of items with a target selector */
|
||||
CC_DEPRECATED_ATTRIBUTE bool initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args);
|
||||
/** initializes a menu item from a list of items with a callable object */
|
||||
bool initWithTarget(const ccMenuCallback& callback, CCMenuItem* item, va_list args);
|
||||
bool initWithCallback(const ccMenuCallback& callback, CCMenuItem* item, va_list args);
|
||||
|
||||
/** creates a menu item with a item */
|
||||
static CCMenuItemToggle* create(CCMenuItem *item);
|
||||
|
|
|
@ -166,7 +166,7 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h
|
|||
|
||||
bool CCEGLViewProtocol::isScissorEnabled()
|
||||
{
|
||||
return glIsEnabled(GL_SCISSOR_TEST);
|
||||
return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true;
|
||||
}
|
||||
|
||||
CCRect CCEGLViewProtocol::getScissorRect()
|
||||
|
|
|
@ -118,10 +118,11 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (pszFileName[0] != '/')
|
||||
string fullPath = fullPathForFilename(pszFileName);
|
||||
|
||||
if (fullPath[0] != '/')
|
||||
{
|
||||
//CCLOG("GETTING FILE RELATIVE DATA: %s", pszFileName);
|
||||
string fullPath = fullPathForFilename(pszFileName);
|
||||
pData = s_pZipFile->getFileData(fullPath.c_str(), pSize);
|
||||
}
|
||||
else
|
||||
|
@ -130,7 +131,7 @@ unsigned char* CCFileUtilsAndroid::getFileData(const char* pszFileName, const ch
|
|||
{
|
||||
// read rrom other path than user set it
|
||||
//CCLOG("GETTING FILE ABSOLUTE DATA: %s", pszFileName);
|
||||
FILE *fp = fopen(pszFileName, pszMode);
|
||||
FILE *fp = fopen(fullPath.c_str(), pszMode);
|
||||
CC_BREAK_IF(!fp);
|
||||
|
||||
unsigned long size;
|
||||
|
|
|
@ -12,4 +12,4 @@
|
|||
|
||||
android.library=true
|
||||
# Project target.
|
||||
target=android-17
|
||||
target=android-8
|
||||
|
|
|
@ -65,7 +65,6 @@ public class Cocos2dxETCLoader {
|
|||
|
||||
texture = ETC1Util.createTexture(inputStream);
|
||||
inputStream.close();
|
||||
assetManager.close();
|
||||
} catch (Exception e) {
|
||||
Log.d("Cocos2dx", "Unable to create texture for " + filePath);
|
||||
|
||||
|
@ -73,24 +72,29 @@ public class Cocos2dxETCLoader {
|
|||
}
|
||||
|
||||
if (texture != null) {
|
||||
boolean ret = true;
|
||||
|
||||
try {
|
||||
int width = texture.getWidth();
|
||||
int height = texture.getHeight();
|
||||
final int width = texture.getWidth();
|
||||
final int height = texture.getHeight();
|
||||
final int length = texture.getData().remaining();
|
||||
|
||||
final byte[] data = new byte[width * height * 3];
|
||||
final byte[] data = new byte[length];
|
||||
final ByteBuffer buf = ByteBuffer.wrap(data);
|
||||
buf.order(ByteOrder.nativeOrder());
|
||||
buf.put(texture.getData());
|
||||
|
||||
nativeSetTextureInfo(width,
|
||||
height,
|
||||
data);
|
||||
data,
|
||||
length);
|
||||
} catch (Exception e)
|
||||
{
|
||||
Log.d("invoke native function error", e.toString());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -100,5 +104,6 @@ public class Cocos2dxETCLoader {
|
|||
Cocos2dxETCLoader.context = context;
|
||||
}
|
||||
|
||||
private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data);
|
||||
private static native void nativeSetTextureInfo(final int width, final int height, final byte[] data,
|
||||
final int dataLength);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ static id s_sharedDirectorCaller;
|
|||
-(void) dealloc
|
||||
{
|
||||
s_sharedDirectorCaller = nil;
|
||||
CCLOG("cocos2d: deallocing CCDirectorCaller %x", self);
|
||||
CCLOG("cocos2d: deallocing CCDirectorCaller %p", self);
|
||||
if (displayLink) {
|
||||
CVDisplayLinkRelease(displayLink);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ CCEGLView::CCEGLView(void)
|
|||
|
||||
CCEGLView::~CCEGLView(void)
|
||||
{
|
||||
CCLOG("cocos2d: deallocing CCEGLView %0x", this);
|
||||
CCLOG("cocos2d: deallocing CCEGLView %p", this);
|
||||
s_sharedView = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -579,7 +579,7 @@ bool CCImage::initWithImageData(void * pData,
|
|||
}
|
||||
else if (kFmtRawData == eFmt)
|
||||
{
|
||||
bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent);
|
||||
bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent, false);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -1074,7 +1074,7 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent)
|
||||
bool CCImage::_initWithRawData(void * pData, int nDatalen, int nWidth, int nHeight, int nBitsPerComponent, bool bPreMulti)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
|
|
@ -29,8 +29,6 @@ THE SOFTWARE.
|
|||
#include <FGraphicsOpengl2.h>
|
||||
using namespace Tizen::Graphics::Opengl;
|
||||
|
||||
typedef char GLchar;
|
||||
|
||||
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
||||
|
||||
#define glClearDepth glClearDepthf
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <float.h>
|
||||
|
||||
#ifndef MIN
|
||||
|
@ -40,4 +41,6 @@ THE SOFTWARE.
|
|||
#define MAX(x,y) (((x) < (y)) ? (y) : (x))
|
||||
#endif // MAX
|
||||
|
||||
#define nullptr __null
|
||||
|
||||
#endif // __CC_STD_C_H__
|
||||
|
|
|
@ -1 +1 @@
|
|||
125800bcfe2802d3c6a965a3aa337147d20bf187
|
||||
5b8ea64c349dcc515312773df1d8d0d5d20abfbe
|
|
@ -30,12 +30,12 @@
|
|||
</outputEntries>
|
||||
</builder>
|
||||
<tool command="i386-linux-gnueabi-ar.exe" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -57,7 +57,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -65,14 +64,15 @@
|
|||
<listOptionValue builtIn="false" value="_DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="TIZEN"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.other.other.857204721" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
|
||||
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -91,7 +91,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -102,12 +101,11 @@
|
|||
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
</tool>
|
||||
|
|
|
@ -57,7 +57,7 @@ CCGLProgram::CCGLProgram()
|
|||
|
||||
CCGLProgram::~CCGLProgram()
|
||||
{
|
||||
CCLOGINFO("cocos2d: %s %d deallocing 0x%X", __FUNCTION__, __LINE__, this);
|
||||
CCLOGINFO("cocos2d: %s %d deallocing %p", __FUNCTION__, __LINE__, this);
|
||||
|
||||
// there is no need to delete the shaders. They should have been already deleted.
|
||||
CCAssert(m_uVertShader == 0, "Vertex Shaders should have been already deleted");
|
||||
|
|
|
@ -71,7 +71,7 @@ CCShaderCache::CCShaderCache()
|
|||
|
||||
CCShaderCache::~CCShaderCache()
|
||||
{
|
||||
CCLOGINFO("cocos2d deallocing 0x%X", this);
|
||||
CCLOGINFO("cocos2d deallocing %p", this);
|
||||
m_pPrograms->release();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ bool CCAnimationFrame::initWithSpriteFrame(CCSpriteFrame* spriteFrame, float del
|
|||
|
||||
CCAnimationFrame::~CCAnimationFrame()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing %s", this);
|
||||
CCLOGINFO( "cocos2d: deallocing %p", this);
|
||||
|
||||
CC_SAFE_RELEASE(m_pSpriteFrame);
|
||||
CC_SAFE_RELEASE(m_pUserInfo);
|
||||
|
|
|
@ -153,8 +153,6 @@ bool CCSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect, bool r
|
|||
if (CCNodeRGBA::init())
|
||||
{
|
||||
m_pobBatchNode = NULL;
|
||||
// shader program
|
||||
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
|
||||
|
||||
m_bRecursiveDirty = false;
|
||||
setDirty(false);
|
||||
|
@ -556,17 +554,13 @@ void CCSprite::draw(void)
|
|||
if (m_pobTexture != NULL)
|
||||
{
|
||||
ccGLBindTexture2D( m_pobTexture->getName() );
|
||||
ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
|
||||
}
|
||||
else
|
||||
{
|
||||
ccGLBindTexture2D(0);
|
||||
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color );
|
||||
}
|
||||
|
||||
//
|
||||
// Attributes
|
||||
//
|
||||
|
||||
ccGLEnableVertexAttribs( kCCVertexAttribFlag_PosColorTex );
|
||||
|
||||
#define kQuadSize sizeof(m_sQuad.bl)
|
||||
#ifdef EMSCRIPTEN
|
||||
|
@ -580,10 +574,13 @@ void CCSprite::draw(void)
|
|||
int diff = offsetof( ccV3F_C4B_T2F, vertices);
|
||||
glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));
|
||||
|
||||
// texCoods
|
||||
diff = offsetof( ccV3F_C4B_T2F, texCoords);
|
||||
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
|
||||
|
||||
if (m_pobTexture != NULL)
|
||||
{
|
||||
// texCoods
|
||||
diff = offsetof( ccV3F_C4B_T2F, texCoords);
|
||||
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));
|
||||
}
|
||||
|
||||
// color
|
||||
diff = offsetof( ccV3F_C4B_T2F, colors);
|
||||
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));
|
||||
|
@ -1085,6 +1082,16 @@ void CCSprite::setTexture(CCTexture2D *texture)
|
|||
// accept texture==nil as argument
|
||||
CCAssert( !texture || dynamic_cast<CCTexture2D*>(texture), "setTexture expects a CCTexture2D. Invalid argument");
|
||||
|
||||
// shader program
|
||||
if (texture)
|
||||
{
|
||||
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColor));
|
||||
}
|
||||
else
|
||||
{
|
||||
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionColor));
|
||||
}
|
||||
|
||||
if (!m_pobBatchNode && m_pobTexture != texture)
|
||||
{
|
||||
CC_SAFE_RETAIN(texture);
|
||||
|
|
|
@ -207,7 +207,7 @@ CCTextureCache::CCTextureCache()
|
|||
|
||||
CCTextureCache::~CCTextureCache()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing CCTextureCache.");
|
||||
CCLOGINFO("cocos2d: deallocing CCTextureCache: %p", this);
|
||||
need_quit = true;
|
||||
|
||||
pthread_cond_signal(&s_SleepCondition);
|
||||
|
@ -232,6 +232,7 @@ CCDictionary* CCTextureCache::snapshotTextures()
|
|||
{
|
||||
pRet->setObject(pElement->getObject(), pElement->getStrKey());
|
||||
}
|
||||
pRet->autorelease();
|
||||
return pRet;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,11 +81,11 @@ static unsigned int sLength = 0;
|
|||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data)
|
||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxETCLoader_nativeSetTextureInfo(JNIEnv* env, jobject thiz, jint width, jint height, jbyteArray data, jint dataLength)
|
||||
{
|
||||
sWidth = (unsigned int)width;
|
||||
sHeight = (unsigned int)height;
|
||||
sLength = sWidth * sHeight * 3;
|
||||
sLength = dataLength;
|
||||
sData = new unsigned char[sLength];
|
||||
env->GetByteArrayRegion(data, 0, sLength, (jbyte*)sData);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ CCTexturePVR::CCTexturePVR()
|
|||
|
||||
CCTexturePVR::~CCTexturePVR()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing CCTexturePVR" );
|
||||
CCLOGINFO( "cocos2d: deallocing CCTexturePVR: %p", this );
|
||||
|
||||
if (m_uName != 0 && ! m_bRetainName)
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ CCTMXObjectGroup::CCTMXObjectGroup()
|
|||
}
|
||||
CCTMXObjectGroup::~CCTMXObjectGroup()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing.");
|
||||
CCLOGINFO( "cocos2d: deallocing: %p", this);
|
||||
CC_SAFE_RELEASE(m_pObjects);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ CCTMXLayerInfo::CCTMXLayerInfo()
|
|||
|
||||
CCTMXLayerInfo::~CCTMXLayerInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing.");
|
||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
if( m_bOwnTiles && m_pTiles )
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ CCTMXTilesetInfo::CCTMXTilesetInfo()
|
|||
}
|
||||
CCTMXTilesetInfo::~CCTMXTilesetInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing.");
|
||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||
}
|
||||
CCRect CCTMXTilesetInfo::rectForGID(unsigned int gid)
|
||||
{
|
||||
|
@ -208,7 +208,7 @@ CCTMXMapInfo::CCTMXMapInfo()
|
|||
|
||||
CCTMXMapInfo::~CCTMXMapInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing.");
|
||||
CCLOGINFO("cocos2d: deallocing: %p", this);
|
||||
CC_SAFE_RELEASE(m_pTilesets);
|
||||
CC_SAFE_RELEASE(m_pLayers);
|
||||
CC_SAFE_RELEASE(m_pProperties);
|
||||
|
|
|
@ -621,7 +621,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
|
|||
// Read properties
|
||||
ccNodeLoader->parseProperties(node, pParent, this);
|
||||
|
||||
bool isCCBFileNode = dynamic_cast<CCBFile*>(node);
|
||||
bool isCCBFileNode = (NULL == dynamic_cast<CCBFile*>(node)) ? false : true;
|
||||
// Handle sub ccb files (remove middle node)
|
||||
if (isCCBFileNode)
|
||||
{
|
||||
|
|
|
@ -46,24 +46,9 @@ CCControlColourPicker::CCControlColourPicker()
|
|||
|
||||
CCControlColourPicker::~CCControlColourPicker()
|
||||
{
|
||||
if (m_background)
|
||||
{
|
||||
m_background->removeFromParentAndCleanup(true);
|
||||
}
|
||||
|
||||
if (m_huePicker)
|
||||
{
|
||||
m_huePicker->removeFromParentAndCleanup(true);
|
||||
}
|
||||
|
||||
if (m_colourPicker)
|
||||
{
|
||||
m_colourPicker->removeFromParentAndCleanup(true);
|
||||
}
|
||||
|
||||
m_background = NULL;
|
||||
m_huePicker = NULL;
|
||||
m_colourPicker = NULL;
|
||||
CC_SAFE_RELEASE(m_background);
|
||||
CC_SAFE_RELEASE(m_huePicker);
|
||||
CC_SAFE_RELEASE(m_colourPicker);
|
||||
}
|
||||
|
||||
bool CCControlColourPicker::init()
|
||||
|
@ -94,7 +79,8 @@ bool CCControlColourPicker::init()
|
|||
|
||||
// Add image
|
||||
m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png", spriteSheet, CCPointZero, ccp(0.5f, 0.5f));
|
||||
|
||||
CC_SAFE_RETAIN(m_background);
|
||||
|
||||
CCPoint backgroundPointZero = ccpSub(m_background->getPosition(), ccp (m_background->getContentSize().width / 2, m_background->getContentSize().height / 2));
|
||||
|
||||
// Setup panels
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
"[WebSocket module] is based in part on the work of the libwebsockets project
|
||||
(http://libwebsockets.org)"
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "WebSocket.h"
|
||||
|
@ -553,6 +557,8 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx,
|
|||
CC_SAFE_DELETE(data);
|
||||
CC_SAFE_DELETE_ARRAY(buf);
|
||||
}
|
||||
|
||||
CC_SAFE_DELETE(subThreadMsg);
|
||||
}
|
||||
|
||||
_wsHelper->_subThreadWsMessageQueue->clear();
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
"[WebSocket module] is based in part on the work of the libwebsockets project
|
||||
(http://libwebsockets.org)"
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __CC_WEBSOCKET_H__
|
||||
|
|
|
@ -30,18 +30,19 @@
|
|||
</outputEntries>
|
||||
</builder>
|
||||
<tool command="i386-linux-gnueabi-ar.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="" id="org.tizen.nativecpp.tool.sbi.gnu.archiver.689316005" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
|
||||
<tool command="clang++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1533358351" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1726560828" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1554282679" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debug.applog.1800109419" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.796499718" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1887202981" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/extensions""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/CocosDenshion/include""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/external/chipmunk/include/chipmunk""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/external/libwebsockets/tizen/include""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/external""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_SRC}""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_SRC}/include""/>
|
||||
|
@ -59,7 +60,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1942713160" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -69,14 +69,15 @@
|
|||
<listOptionValue builtIn="false" value="CC_ENABLE_CHIPMUNK_INTEGRATION=1"/>
|
||||
<listOptionValue builtIn="false" value="CC_ENABLE_BOX2D_INTEGRATION=0"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.other.other.1649119739" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
|
||||
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.2085750802" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool command="clang.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<tool command="i386-linux-gnueabi-gcc.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.263460224" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.819197061" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debugging.level.709891206" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debug.applog.1166511754" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.c.compiler.option.1738169580" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.staticLib"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.staticLib"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.paths.821405214" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -95,7 +96,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.1131449804" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIC"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -108,12 +108,11 @@
|
|||
<inputType id="sbi.gnu.c.compiler.tizen.inputType.94264147" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.792552065" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1518096171" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.43791296" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.181465864" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/ -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
</tool>
|
||||
|
|
|
@ -35,8 +35,11 @@ void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
|
|||
CCTextureAtlas* textureAtlas = CCTextureAtlas::createWithTexture(texture, 4);
|
||||
textureAtlas->retain();
|
||||
self->rendererObject = textureAtlas;
|
||||
self->width = texture->getPixelsWide();
|
||||
self->height = texture->getPixelsHigh();
|
||||
// Using getContentSize to make it supports the strategy of loading resources in cocos2d-x.
|
||||
// self->width = texture->getPixelsWide();
|
||||
// self->height = texture->getPixelsHigh();
|
||||
self->width = texture->getContentSize().width;
|
||||
self->height = texture->getContentSize().height;
|
||||
}
|
||||
|
||||
void _AtlasPage_disposeTexture (AtlasPage* self) {
|
||||
|
|
|
@ -0,0 +1,977 @@
|
|||
/*
|
||||
* libwebsockets - small server side websockets and web server implementation
|
||||
*
|
||||
* Copyright (C) 2010-2013 Andy Green <andy@warmcat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation:
|
||||
* version 2.1 of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __LIBWEBSOCKET_H__
|
||||
#define __LIBWEBSOCKET_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <stddef.h>
|
||||
#include "../win32port/win32helpers/websock-w32.h"
|
||||
|
||||
#include "../win32port/win32helpers/gettimeofday.h"
|
||||
|
||||
#define strcasecmp stricmp
|
||||
#define getdtablesize() 30000
|
||||
|
||||
typedef int ssize_t;
|
||||
|
||||
#ifdef LWS_DLL
|
||||
#ifdef LWS_INTERNAL
|
||||
#define LWS_EXTERN extern __declspec(dllexport)
|
||||
#else
|
||||
#define LWS_EXTERN extern __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else // NOT WIN32
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef LWS_EXTERN
|
||||
#define LWS_EXTERN extern
|
||||
#endif
|
||||
|
||||
#define CONTEXT_PORT_NO_LISTEN 0
|
||||
#define MAX_MUX_RECURSION 2
|
||||
|
||||
enum lws_log_levels {
|
||||
LLL_ERR = 1 << 0,
|
||||
LLL_WARN = 1 << 1,
|
||||
LLL_NOTICE = 1 << 2,
|
||||
LLL_INFO = 1 << 3,
|
||||
LLL_DEBUG = 1 << 4,
|
||||
LLL_PARSER = 1 << 5,
|
||||
LLL_HEADER = 1 << 6,
|
||||
LLL_EXT = 1 << 7,
|
||||
LLL_CLIENT = 1 << 8,
|
||||
LLL_LATENCY = 1 << 9,
|
||||
|
||||
LLL_COUNT = 10 /* set to count of valid flags */
|
||||
};
|
||||
|
||||
LWS_EXTERN void _lws_log(int filter, const char *format, ...);
|
||||
|
||||
/* notice, warn and log are always compiled in */
|
||||
#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)
|
||||
#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__)
|
||||
#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__)
|
||||
/*
|
||||
* weaker logging can be deselected at configure time using --disable-debug
|
||||
* that gets rid of the overhead of checking while keeping _warn and _err
|
||||
* active
|
||||
*/
|
||||
#ifdef _DEBUG
|
||||
|
||||
#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__)
|
||||
#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__)
|
||||
#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__)
|
||||
#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__)
|
||||
#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__)
|
||||
#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)
|
||||
#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)
|
||||
LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
|
||||
|
||||
#else /* no debug */
|
||||
|
||||
#define lwsl_info(...)
|
||||
#define lwsl_debug(...)
|
||||
#define lwsl_parser(...)
|
||||
#define lwsl_header(...)
|
||||
#define lwsl_ext(...)
|
||||
#define lwsl_client(...)
|
||||
#define lwsl_latency(...)
|
||||
#define lwsl_hexdump(a, b)
|
||||
|
||||
#endif
|
||||
|
||||
enum libwebsocket_context_options {
|
||||
LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = 2,
|
||||
LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = 4,
|
||||
};
|
||||
|
||||
enum libwebsocket_callback_reasons {
|
||||
LWS_CALLBACK_ESTABLISHED,
|
||||
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
|
||||
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
|
||||
LWS_CALLBACK_CLIENT_ESTABLISHED,
|
||||
LWS_CALLBACK_CLOSED,
|
||||
LWS_CALLBACK_RECEIVE,
|
||||
LWS_CALLBACK_CLIENT_RECEIVE,
|
||||
LWS_CALLBACK_CLIENT_RECEIVE_PONG,
|
||||
LWS_CALLBACK_CLIENT_WRITEABLE,
|
||||
LWS_CALLBACK_SERVER_WRITEABLE,
|
||||
LWS_CALLBACK_HTTP,
|
||||
LWS_CALLBACK_HTTP_FILE_COMPLETION,
|
||||
LWS_CALLBACK_HTTP_WRITEABLE,
|
||||
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
|
||||
LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
|
||||
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
|
||||
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
|
||||
LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION,
|
||||
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER,
|
||||
LWS_CALLBACK_CONFIRM_EXTENSION_OKAY,
|
||||
LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED,
|
||||
LWS_CALLBACK_PROTOCOL_INIT,
|
||||
LWS_CALLBACK_PROTOCOL_DESTROY,
|
||||
/* external poll() management support */
|
||||
LWS_CALLBACK_ADD_POLL_FD,
|
||||
LWS_CALLBACK_DEL_POLL_FD,
|
||||
LWS_CALLBACK_SET_MODE_POLL_FD,
|
||||
LWS_CALLBACK_CLEAR_MODE_POLL_FD,
|
||||
};
|
||||
|
||||
#ifndef LWS_NO_EXTENSIONS
|
||||
enum libwebsocket_extension_callback_reasons {
|
||||
LWS_EXT_CALLBACK_SERVER_CONTEXT_CONSTRUCT,
|
||||
LWS_EXT_CALLBACK_CLIENT_CONTEXT_CONSTRUCT,
|
||||
LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT,
|
||||
LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT,
|
||||
LWS_EXT_CALLBACK_CONSTRUCT,
|
||||
LWS_EXT_CALLBACK_CLIENT_CONSTRUCT,
|
||||
LWS_EXT_CALLBACK_CHECK_OK_TO_REALLY_CLOSE,
|
||||
LWS_EXT_CALLBACK_CHECK_OK_TO_PROPOSE_EXTENSION,
|
||||
LWS_EXT_CALLBACK_DESTROY,
|
||||
LWS_EXT_CALLBACK_DESTROY_ANY_WSI_CLOSING,
|
||||
LWS_EXT_CALLBACK_ANY_WSI_ESTABLISHED,
|
||||
LWS_EXT_CALLBACK_PACKET_RX_PREPARSE,
|
||||
LWS_EXT_CALLBACK_PACKET_TX_PRESEND,
|
||||
LWS_EXT_CALLBACK_PACKET_TX_DO_SEND,
|
||||
LWS_EXT_CALLBACK_HANDSHAKE_REPLY_TX,
|
||||
LWS_EXT_CALLBACK_FLUSH_PENDING_TX,
|
||||
LWS_EXT_CALLBACK_EXTENDED_PAYLOAD_RX,
|
||||
LWS_EXT_CALLBACK_CAN_PROXY_CLIENT_CONNECTION,
|
||||
LWS_EXT_CALLBACK_1HZ,
|
||||
LWS_EXT_CALLBACK_REQUEST_ON_WRITEABLE,
|
||||
LWS_EXT_CALLBACK_IS_WRITEABLE,
|
||||
LWS_EXT_CALLBACK_PAYLOAD_TX,
|
||||
LWS_EXT_CALLBACK_PAYLOAD_RX,
|
||||
};
|
||||
#endif
|
||||
|
||||
enum libwebsocket_write_protocol {
|
||||
LWS_WRITE_TEXT,
|
||||
LWS_WRITE_BINARY,
|
||||
LWS_WRITE_CONTINUATION,
|
||||
LWS_WRITE_HTTP,
|
||||
|
||||
/* special 04+ opcodes */
|
||||
|
||||
LWS_WRITE_CLOSE,
|
||||
LWS_WRITE_PING,
|
||||
LWS_WRITE_PONG,
|
||||
|
||||
/* flags */
|
||||
|
||||
LWS_WRITE_NO_FIN = 0x40,
|
||||
/*
|
||||
* client packet payload goes out on wire unmunged
|
||||
* only useful for security tests since normal servers cannot
|
||||
* decode the content if used
|
||||
*/
|
||||
LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80
|
||||
};
|
||||
|
||||
/*
|
||||
* you need these to look at headers that have been parsed if using the
|
||||
* LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum
|
||||
* list below is absent, .token = NULL and token_len = 0. Otherwise .token
|
||||
* points to .token_len chars containing that header content.
|
||||
*/
|
||||
|
||||
struct lws_tokens {
|
||||
char *token;
|
||||
int token_len;
|
||||
};
|
||||
|
||||
enum lws_token_indexes {
|
||||
WSI_TOKEN_GET_URI,
|
||||
WSI_TOKEN_HOST,
|
||||
WSI_TOKEN_CONNECTION,
|
||||
WSI_TOKEN_KEY1,
|
||||
WSI_TOKEN_KEY2,
|
||||
WSI_TOKEN_PROTOCOL,
|
||||
WSI_TOKEN_UPGRADE,
|
||||
WSI_TOKEN_ORIGIN,
|
||||
WSI_TOKEN_DRAFT,
|
||||
WSI_TOKEN_CHALLENGE,
|
||||
|
||||
/* new for 04 */
|
||||
WSI_TOKEN_KEY,
|
||||
WSI_TOKEN_VERSION,
|
||||
WSI_TOKEN_SWORIGIN,
|
||||
|
||||
/* new for 05 */
|
||||
WSI_TOKEN_EXTENSIONS,
|
||||
|
||||
/* client receives these */
|
||||
WSI_TOKEN_ACCEPT,
|
||||
WSI_TOKEN_NONCE,
|
||||
WSI_TOKEN_HTTP,
|
||||
WSI_TOKEN_MUXURL,
|
||||
|
||||
/* use token storage to stash these */
|
||||
|
||||
_WSI_TOKEN_CLIENT_SENT_PROTOCOLS,
|
||||
_WSI_TOKEN_CLIENT_PEER_ADDRESS,
|
||||
_WSI_TOKEN_CLIENT_URI,
|
||||
_WSI_TOKEN_CLIENT_HOST,
|
||||
_WSI_TOKEN_CLIENT_ORIGIN,
|
||||
|
||||
/* always last real token index*/
|
||||
WSI_TOKEN_COUNT,
|
||||
/* parser state additions */
|
||||
WSI_TOKEN_NAME_PART,
|
||||
WSI_TOKEN_SKIPPING,
|
||||
WSI_TOKEN_SKIPPING_SAW_CR,
|
||||
WSI_PARSING_COMPLETE,
|
||||
WSI_INIT_TOKEN_MUXURL,
|
||||
};
|
||||
|
||||
/*
|
||||
* From RFC 6455
|
||||
1000
|
||||
|
||||
1000 indicates a normal closure, meaning that the purpose for
|
||||
which the connection was established has been fulfilled.
|
||||
|
||||
1001
|
||||
|
||||
1001 indicates that an endpoint is "going away", such as a server
|
||||
going down or a browser having navigated away from a page.
|
||||
|
||||
1002
|
||||
|
||||
1002 indicates that an endpoint is terminating the connection due
|
||||
to a protocol error.
|
||||
|
||||
1003
|
||||
|
||||
1003 indicates that an endpoint is terminating the connection
|
||||
because it has received a type of data it cannot accept (e.g., an
|
||||
endpoint that understands only text data MAY send this if it
|
||||
receives a binary message).
|
||||
|
||||
1004
|
||||
|
||||
Reserved. The specific meaning might be defined in the future.
|
||||
|
||||
1005
|
||||
|
||||
1005 is a reserved value and MUST NOT be set as a status code in a
|
||||
Close control frame by an endpoint. It is designated for use in
|
||||
applications expecting a status code to indicate that no status
|
||||
code was actually present.
|
||||
|
||||
1006
|
||||
|
||||
1006 is a reserved value and MUST NOT be set as a status code in a
|
||||
Close control frame by an endpoint. It is designated for use in
|
||||
applications expecting a status code to indicate that the
|
||||
connection was closed abnormally, e.g., without sending or
|
||||
receiving a Close control frame.
|
||||
|
||||
1007
|
||||
|
||||
1007 indicates that an endpoint is terminating the connection
|
||||
because it has received data within a message that was not
|
||||
consistent with the type of the message (e.g., non-UTF-8 [RFC3629]
|
||||
data within a text message).
|
||||
|
||||
1008
|
||||
|
||||
1008 indicates that an endpoint is terminating the connection
|
||||
because it has received a message that violates its policy. This
|
||||
is a generic status code that can be returned when there is no
|
||||
other more suitable status code (e.g., 1003 or 1009) or if there
|
||||
is a need to hide specific details about the policy.
|
||||
|
||||
1009
|
||||
|
||||
1009 indicates that an endpoint is terminating the connection
|
||||
because it has received a message that is too big for it to
|
||||
process.
|
||||
|
||||
1010
|
||||
|
||||
1010 indicates that an endpoint (client) is terminating the
|
||||
connection because it has expected the server to negotiate one or
|
||||
more extension, but the server didn't return them in the response
|
||||
message of the WebSocket handshake. The list of extensions that
|
||||
are needed SHOULD appear in the /reason/ part of the Close frame.
|
||||
Note that this status code is not used by the server, because it
|
||||
can fail the WebSocket handshake instead.
|
||||
|
||||
1011
|
||||
|
||||
1011 indicates that a server is terminating the connection because
|
||||
it encountered an unexpected condition that prevented it from
|
||||
fulfilling the request.
|
||||
|
||||
1015
|
||||
|
||||
1015 is a reserved value and MUST NOT be set as a status code in a
|
||||
Close control frame by an endpoint. It is designated for use in
|
||||
applications expecting a status code to indicate that the
|
||||
connection was closed due to a failure to perform a TLS handshake
|
||||
(e.g., the server certificate can't be verified).
|
||||
*/
|
||||
|
||||
enum lws_close_status {
|
||||
LWS_CLOSE_STATUS_NOSTATUS = 0,
|
||||
LWS_CLOSE_STATUS_NORMAL = 1000,
|
||||
LWS_CLOSE_STATUS_GOINGAWAY = 1001,
|
||||
LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002,
|
||||
LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003,
|
||||
LWS_CLOSE_STATUS_RESERVED = 1004,
|
||||
LWS_CLOSE_STATUS_NO_STATUS = 1005,
|
||||
LWS_CLOSE_STATUS_ABNORMAL_CLOSE = 1006,
|
||||
LWS_CLOSE_STATUS_INVALID_PAYLOAD = 1007,
|
||||
LWS_CLOSE_STATUS_POLICY_VIOLATION = 1008,
|
||||
LWS_CLOSE_STATUS_MESSAGE_TOO_LARGE = 1009,
|
||||
LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010,
|
||||
LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011,
|
||||
LWS_CLOSE_STATUS_TLS_FAILURE = 1015,
|
||||
};
|
||||
|
||||
struct libwebsocket;
|
||||
struct libwebsocket_context;
|
||||
/* needed even with extensions disabled for create context */
|
||||
struct libwebsocket_extension;
|
||||
|
||||
/**
|
||||
* callback_function() - User server actions
|
||||
* @context: Websockets context
|
||||
* @wsi: Opaque websocket instance pointer
|
||||
* @reason: The reason for the call
|
||||
* @user: Pointer to per-session user data allocated by library
|
||||
* @in: Pointer used for some callback reasons
|
||||
* @len: Length set for some callback reasons
|
||||
*
|
||||
* This callback is the way the user controls what is served. All the
|
||||
* protocol detail is hidden and handled by the library.
|
||||
*
|
||||
* For each connection / session there is user data allocated that is
|
||||
* pointed to by "user". You set the size of this user data area when
|
||||
* the library is initialized with libwebsocket_create_server.
|
||||
*
|
||||
* You get an opportunity to initialize user data when called back with
|
||||
* LWS_CALLBACK_ESTABLISHED reason.
|
||||
*
|
||||
* LWS_CALLBACK_ESTABLISHED: after the server completes a handshake with
|
||||
* an incoming client
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_CONNECTION_ERROR: the request client connection has
|
||||
* been unable to complete a handshake with the remote server
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH: this is the last chance for the
|
||||
* client user code to examine the http headers
|
||||
* and decide to reject the connection. If the
|
||||
* content in the headers is interesting to the
|
||||
* client (url, etc) it needs to copy it out at
|
||||
* this point since it will be destroyed before
|
||||
* the CLIENT_ESTABLISHED call
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_ESTABLISHED: after your client connection completed
|
||||
* a handshake with the remote server
|
||||
*
|
||||
* LWS_CALLBACK_CLOSED: when the websocket session ends
|
||||
*
|
||||
* LWS_CALLBACK_RECEIVE: data has appeared for this server endpoint from a
|
||||
* remote client, it can be found at *in and is
|
||||
* len bytes long
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_RECEIVE_PONG: if you elected to see PONG packets,
|
||||
* they appear with this callback reason. PONG
|
||||
* packets only exist in 04+ protocol
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_RECEIVE: data has appeared from the server for the
|
||||
* client connection, it can be found at *in and
|
||||
* is len bytes long
|
||||
*
|
||||
* LWS_CALLBACK_HTTP: an http request has come from a client that is not
|
||||
* asking to upgrade the connection to a websocket
|
||||
* one. This is a chance to serve http content,
|
||||
* for example, to send a script to the client
|
||||
* which will then open the websockets connection.
|
||||
* @in points to the URI path requested and
|
||||
* libwebsockets_serve_http_file() makes it very
|
||||
* simple to send back a file to the client.
|
||||
* Normally after sending the file you are done
|
||||
* with the http connection, since the rest of the
|
||||
* activity will come by websockets from the script
|
||||
* that was delivered by http, so you will want to
|
||||
* return 1; to close and free up the connection.
|
||||
* That's important because it uses a slot in the
|
||||
* total number of client connections allowed set
|
||||
* by MAX_CLIENTS.
|
||||
*
|
||||
* LWS_CALLBACK_HTTP_WRITEABLE: you can write more down the http protocol
|
||||
* link now.
|
||||
*
|
||||
* LWS_CALLBACK_HTTP_FILE_COMPLETION: a file requested to be send down
|
||||
* http link has completed.
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_WRITEABLE:
|
||||
* LWS_CALLBACK_SERVER_WRITEABLE: If you call
|
||||
* libwebsocket_callback_on_writable() on a connection, you will
|
||||
* get one of these callbacks coming when the connection socket
|
||||
* is able to accept another write packet without blocking.
|
||||
* If it already was able to take another packet without blocking,
|
||||
* you'll get this callback at the next call to the service loop
|
||||
* function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE
|
||||
* and servers get LWS_CALLBACK_SERVER_WRITEABLE.
|
||||
*
|
||||
* LWS_CALLBACK_FILTER_NETWORK_CONNECTION: called when a client connects to
|
||||
* the server at network level; the connection is accepted but then
|
||||
* passed to this callback to decide whether to hang up immediately
|
||||
* or not, based on the client IP. @in contains the connection
|
||||
* socket's descriptor. Return non-zero to terminate
|
||||
* the connection before sending or receiving anything.
|
||||
* Because this happens immediately after the network connection
|
||||
* from the client, there's no websocket protocol selected yet so
|
||||
* this callback is issued only to protocol 0.
|
||||
*
|
||||
* LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has
|
||||
* been received and parsed from the client, but the response is
|
||||
* not sent yet. Return non-zero to disallow the connection.
|
||||
* @user is a pointer to an array of struct lws_tokens, you can
|
||||
* use the header enums lws_token_indexes from libwebsockets.h
|
||||
* to check for and read the supported header presence and
|
||||
* content before deciding to allow the handshake to proceed or
|
||||
* to kill the connection.
|
||||
*
|
||||
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS: if configured for
|
||||
* including OpenSSL support, this callback allows your user code
|
||||
* to perform extra SSL_CTX_load_verify_locations() or similar
|
||||
* calls to direct OpenSSL where to find certificates the client
|
||||
* can use to confirm the remote server identity. @user is the
|
||||
* OpenSSL SSL_CTX*
|
||||
*
|
||||
* LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS: if configured for
|
||||
* including OpenSSL support, this callback allows your user code
|
||||
* to load extra certifcates into the server which allow it to
|
||||
* verify the validity of certificates returned by clients. @user
|
||||
* is the server's OpenSSL SSL_CTX*
|
||||
*
|
||||
* LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: if the
|
||||
* libwebsockets context was created with the option
|
||||
* LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this
|
||||
* callback is generated during OpenSSL verification of the cert
|
||||
* sent from the client. It is sent to protocol[0] callback as
|
||||
* no protocol has been negotiated on the connection yet.
|
||||
* Notice that the libwebsockets context and wsi are both NULL
|
||||
* during this callback. See
|
||||
* http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html
|
||||
* to understand more detail about the OpenSSL callback that
|
||||
* generates this libwebsockets callback and the meanings of the
|
||||
* arguments passed. In this callback, @user is the x509_ctx,
|
||||
* @in is the ssl pointer and @len is preverify_ok
|
||||
* Notice that this callback maintains libwebsocket return
|
||||
* conventions, return 0 to mean the cert is OK or 1 to fail it.
|
||||
* This also means that if you don't handle this callback then
|
||||
* the default callback action of returning 0 allows the client
|
||||
* certificates.
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER: this callback happens
|
||||
* when a client handshake is being compiled. @user is NULL,
|
||||
* @in is a char **, it's pointing to a char * which holds the
|
||||
* next location in the header buffer where you can add
|
||||
* headers, and @len is the remaining space in the header buffer,
|
||||
* which is typically some hundreds of bytes. So, to add a canned
|
||||
* cookie, your handler code might look similar to:
|
||||
*
|
||||
* char **p = (char **)in;
|
||||
*
|
||||
* if (len < 100)
|
||||
* return 1;
|
||||
*
|
||||
* *p += sprintf(*p, "Cookie: a=b\x0d\x0a");
|
||||
*
|
||||
* return 0;
|
||||
*
|
||||
* Notice if you add anything, you just have to take care about
|
||||
* the CRLF on the line you added. Obviously this callback is
|
||||
* optional, if you don't handle it everything is fine.
|
||||
*
|
||||
* Notice the callback is coming to protocols[0] all the time,
|
||||
* because there is no specific protocol handshook yet.
|
||||
*
|
||||
* LWS_CALLBACK_CONFIRM_EXTENSION_OKAY: When the server handshake code
|
||||
* sees that it does support a requested extension, before
|
||||
* accepting the extension by additing to the list sent back to
|
||||
* the client it gives this callback just to check that it's okay
|
||||
* to use that extension. It calls back to the requested protocol
|
||||
* and with @in being the extension name, @len is 0 and @user is
|
||||
* valid. Note though at this time the ESTABLISHED callback hasn't
|
||||
* happened yet so if you initialize @user content there, @user
|
||||
* content during this callback might not be useful for anything.
|
||||
* Notice this callback comes to protocols[0].
|
||||
*
|
||||
* LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED: When a client
|
||||
* connection is being prepared to start a handshake to a server,
|
||||
* each supported extension is checked with protocols[0] callback
|
||||
* with this reason, giving the user code a chance to suppress the
|
||||
* claim to support that extension by returning non-zero. If
|
||||
* unhandled, by default 0 will be returned and the extension
|
||||
* support included in the header to the server. Notice this
|
||||
* callback comes to protocols[0].
|
||||
*
|
||||
* LWS_CALLBACK_PROTOCOL_INIT: One-time call per protocol so it can
|
||||
* do initial setup / allocations etc
|
||||
*
|
||||
* LWS_CALLBACK_PROTOCOL_DESTROY: One-time call per protocol indicating
|
||||
* this protocol won't get used at all after this callback, the
|
||||
* context is getting destroyed. Take the opportunity to
|
||||
* deallocate everything that was allocated by the protocol.
|
||||
*
|
||||
* The next four reasons are optional and only need taking care of if you
|
||||
* will be integrating libwebsockets sockets into an external polling
|
||||
* array.
|
||||
*
|
||||
* LWS_CALLBACK_ADD_POLL_FD: libwebsocket deals with its poll() loop
|
||||
* internally, but in the case you are integrating with another
|
||||
* server you will need to have libwebsocket sockets share a
|
||||
* polling array with the other server. This and the other
|
||||
* POLL_FD related callbacks let you put your specialized
|
||||
* poll array interface code in the callback for protocol 0, the
|
||||
* first protocol you support, usually the HTTP protocol in the
|
||||
* serving case. This callback happens when a socket needs to be
|
||||
* added to the polling loop: @in contains the fd, and
|
||||
* @len is the events bitmap (like, POLLIN). If you are using the
|
||||
* internal polling loop (the "service" callback), you can just
|
||||
* ignore these callbacks.
|
||||
*
|
||||
* LWS_CALLBACK_DEL_POLL_FD: This callback happens when a socket descriptor
|
||||
* needs to be removed from an external polling array. @in is
|
||||
* the socket desricptor. If you are using the internal polling
|
||||
* loop, you can just ignore it.
|
||||
*
|
||||
* LWS_CALLBACK_SET_MODE_POLL_FD: This callback happens when libwebsockets
|
||||
* wants to modify the events for the socket descriptor in @in.
|
||||
* The handler should OR @len on to the events member of the pollfd
|
||||
* struct for this socket descriptor. If you are using the
|
||||
* internal polling loop, you can just ignore it.
|
||||
*
|
||||
* LWS_CALLBACK_CLEAR_MODE_POLL_FD: This callback occurs when libwebsockets
|
||||
* wants to modify the events for the socket descriptor in @in.
|
||||
* The handler should AND ~@len on to the events member of the
|
||||
* pollfd struct for this socket descriptor. If you are using the
|
||||
* internal polling loop, you can just ignore it.
|
||||
*/
|
||||
LWS_EXTERN int callback(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_callback_reasons reason, void *user,
|
||||
void *in, size_t len);
|
||||
|
||||
typedef int (callback_function)(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_callback_reasons reason, void *user,
|
||||
void *in, size_t len);
|
||||
|
||||
#ifndef LWS_NO_EXTENSIONS
|
||||
/**
|
||||
* extension_callback_function() - Hooks to allow extensions to operate
|
||||
* @context: Websockets context
|
||||
* @ext: This extension
|
||||
* @wsi: Opaque websocket instance pointer
|
||||
* @reason: The reason for the call
|
||||
* @user: Pointer to per-session user data allocated by library
|
||||
* @in: Pointer used for some callback reasons
|
||||
* @len: Length set for some callback reasons
|
||||
*
|
||||
* Each extension that is active on a particular connection receives
|
||||
* callbacks during the connection lifetime to allow the extension to
|
||||
* operate on websocket data and manage itself.
|
||||
*
|
||||
* Libwebsockets takes care of allocating and freeing "user" memory for
|
||||
* each active extension on each connection. That is what is pointed to
|
||||
* by the @user parameter.
|
||||
*
|
||||
* LWS_EXT_CALLBACK_CONSTRUCT: called when the server has decided to
|
||||
* select this extension from the list provided by the client,
|
||||
* just before the server will send back the handshake accepting
|
||||
* the connection with this extension active. This gives the
|
||||
* extension a chance to initialize its connection context found
|
||||
* in @user.
|
||||
*
|
||||
* LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: same as LWS_EXT_CALLBACK_CONSTRUCT
|
||||
* but called when client is instantiating this extension. Some
|
||||
* extensions will work the same on client and server side and then
|
||||
* you can just merge handlers for both CONSTRUCTS.
|
||||
*
|
||||
* LWS_EXT_CALLBACK_DESTROY: called when the connection the extension was
|
||||
* being used on is about to be closed and deallocated. It's the
|
||||
* last chance for the extension to deallocate anything it has
|
||||
* allocated in the user data (pointed to by @user) before the
|
||||
* user data is deleted. This same callback is used whether you
|
||||
* are in client or server instantiation context.
|
||||
*
|
||||
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: when this extension was active on
|
||||
* a connection, and a packet of data arrived at the connection,
|
||||
* it is passed to this callback to give the extension a chance to
|
||||
* change the data, eg, decompress it. @user is pointing to the
|
||||
* extension's private connection context data, @in is pointing
|
||||
* to an lws_tokens struct, it consists of a char * pointer called
|
||||
* token, and an int called token_len. At entry, these are
|
||||
* set to point to the received buffer and set to the content
|
||||
* length. If the extension will grow the content, it should use
|
||||
* a new buffer allocated in its private user context data and
|
||||
* set the pointed-to lws_tokens members to point to its buffer.
|
||||
*
|
||||
* LWS_EXT_CALLBACK_PACKET_TX_PRESEND: this works the same way as
|
||||
* LWS_EXT_CALLBACK_PACKET_RX_PREPARSE above, except it gives the
|
||||
* extension a chance to change websocket data just before it will
|
||||
* be sent out. Using the same lws_token pointer scheme in @in,
|
||||
* the extension can change the buffer and the length to be
|
||||
* transmitted how it likes. Again if it wants to grow the
|
||||
* buffer safely, it should copy the data into its own buffer and
|
||||
* set the lws_tokens token pointer to it.
|
||||
*/
|
||||
LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
void *user, void *in, size_t len);
|
||||
|
||||
typedef int (extension_callback_function)(struct libwebsocket_context *context,
|
||||
struct libwebsocket_extension *ext,
|
||||
struct libwebsocket *wsi,
|
||||
enum libwebsocket_extension_callback_reasons reason,
|
||||
void *user, void *in, size_t len);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct libwebsocket_protocols - List of protocols and handlers server
|
||||
* supports.
|
||||
* @name: Protocol name that must match the one given in the client
|
||||
* Javascript new WebSocket(url, 'protocol') name
|
||||
* @callback: The service callback used for this protocol. It allows the
|
||||
* service action for an entire protocol to be encapsulated in
|
||||
* the protocol-specific callback
|
||||
* @per_session_data_size: Each new connection using this protocol gets
|
||||
* this much memory allocated on connection establishment and
|
||||
* freed on connection takedown. A pointer to this per-connection
|
||||
* allocation is passed into the callback in the 'user' parameter
|
||||
* @rx_buffer_size: if you want atomic frames delivered to the callback, you
|
||||
* should set this to the size of the biggest legal frame that
|
||||
* you support. If the frame size is exceeded, there is no
|
||||
* error, but the buffer will spill to the user callback when
|
||||
* full, which you can detect by using
|
||||
* libwebsockets_remaining_packet_payload(). Notice that you
|
||||
* just talk about frame size here, the LWS_SEND_BUFFER_PRE_PADDING
|
||||
* and post-padding are automatically also allocated on top.
|
||||
* @owning_server: the server init call fills in this opaque pointer when
|
||||
* registering this protocol with the server.
|
||||
* @protocol_index: which protocol we are starting from zero
|
||||
*
|
||||
* This structure represents one protocol supported by the server. An
|
||||
* array of these structures is passed to libwebsocket_create_server()
|
||||
* allows as many protocols as you like to be handled by one server.
|
||||
*/
|
||||
|
||||
struct libwebsocket_protocols {
|
||||
const char *name;
|
||||
callback_function *callback;
|
||||
size_t per_session_data_size;
|
||||
size_t rx_buffer_size;
|
||||
|
||||
/*
|
||||
* below are filled in on server init and can be left uninitialized,
|
||||
* no need for user to use them directly either
|
||||
*/
|
||||
|
||||
struct libwebsocket_context *owning_server;
|
||||
int protocol_index;
|
||||
};
|
||||
|
||||
#ifndef LWS_NO_EXTENSIONS
|
||||
/**
|
||||
* struct libwebsocket_extension - An extension we know how to cope with
|
||||
*
|
||||
* @name: Formal extension name, eg, "deflate-stream"
|
||||
* @callback: Service callback
|
||||
* @per_session_data_size: Libwebsockets will auto-malloc this much
|
||||
* memory for the use of the extension, a pointer
|
||||
* to it comes in the @user callback parameter
|
||||
* @per_context_private_data: Optional storage for this extension that
|
||||
* is per-context, so it can track stuff across
|
||||
* all sessions, etc, if it wants
|
||||
*/
|
||||
|
||||
struct libwebsocket_extension {
|
||||
const char *name;
|
||||
extension_callback_function *callback;
|
||||
size_t per_session_data_size;
|
||||
void *per_context_private_data;
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* struct lws_context_creation_info: parameters to create context with
|
||||
*
|
||||
* @port: Port to listen on... you can use 0 to suppress listening on
|
||||
* any port, that's what you want if you are not running a
|
||||
* websocket server at all but just using it as a client
|
||||
* @iface: NULL to bind the listen socket to all interfaces, or the
|
||||
* interface name, eg, "eth2"
|
||||
* @protocols: Array of structures listing supported protocols and a protocol-
|
||||
* specific callback for each one. The list is ended with an
|
||||
* entry that has a NULL callback pointer.
|
||||
* It's not const because we write the owning_server member
|
||||
* @extensions: NULL or array of libwebsocket_extension structs listing the
|
||||
* extensions this context supports. If you configured with
|
||||
* --without-extensions, you should give NULL here.
|
||||
* @ssl_cert_filepath: If libwebsockets was compiled to use ssl, and you want
|
||||
* to listen using SSL, set to the filepath to fetch the
|
||||
* server cert from, otherwise NULL for unencrypted
|
||||
* @ssl_private_key_filepath: filepath to private key if wanting SSL mode,
|
||||
* else ignored
|
||||
* @ssl_ca_filepath: CA certificate filepath or NULL
|
||||
* @ssl_cipher_list: List of valid ciphers to use (eg,
|
||||
* "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL"
|
||||
* or you can leave it as NULL to get "DEFAULT"
|
||||
* @gid: group id to change to after setting listen socket, or -1.
|
||||
* @uid: user id to change to after setting listen socket, or -1.
|
||||
* @options: 0, or LWS_SERVER_OPTION_DEFEAT_CLIENT_MASK
|
||||
* @user: optional user pointer that can be recovered via the context
|
||||
* pointer using libwebsocket_context_user
|
||||
* @ka_time: 0 for no keepalive, otherwise apply this keepalive timeout to
|
||||
* all libwebsocket sockets, client or server
|
||||
* @ka_probes: if ka_time was nonzero, after the timeout expires how many
|
||||
* times to try to get a response from the peer before giving up
|
||||
* and killing the connection
|
||||
* @ka_interval: if ka_time was nonzero, how long to wait before each ka_probes
|
||||
* attempt
|
||||
*/
|
||||
|
||||
struct lws_context_creation_info {
|
||||
int port;
|
||||
const char *iface;
|
||||
struct libwebsocket_protocols *protocols;
|
||||
struct libwebsocket_extension *extensions;
|
||||
const char *ssl_cert_filepath;
|
||||
const char *ssl_private_key_filepath;
|
||||
const char *ssl_ca_filepath;
|
||||
const char *ssl_cipher_list;
|
||||
int gid;
|
||||
int uid;
|
||||
unsigned int options;
|
||||
void *user;
|
||||
int ka_time;
|
||||
int ka_probes;
|
||||
int ka_interval;
|
||||
|
||||
};
|
||||
|
||||
LWS_EXTERN
|
||||
void lws_set_log_level(int level,
|
||||
void (*log_emit_function)(int level, const char *line));
|
||||
|
||||
LWS_EXTERN void
|
||||
lwsl_emit_syslog(int level, const char *line);
|
||||
|
||||
LWS_EXTERN struct libwebsocket_context *
|
||||
libwebsocket_create_context(struct lws_context_creation_info *info);
|
||||
|
||||
LWS_EXTERN void
|
||||
libwebsocket_context_destroy(struct libwebsocket_context *context);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_service_fd(struct libwebsocket_context *context,
|
||||
struct pollfd *pollfd);
|
||||
|
||||
LWS_EXTERN void *
|
||||
libwebsocket_context_user(struct libwebsocket_context *context);
|
||||
|
||||
/*
|
||||
* IMPORTANT NOTICE!
|
||||
*
|
||||
* When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY)
|
||||
* the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE
|
||||
* buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + len).
|
||||
*
|
||||
* This allows us to add protocol info before and after the data, and send as
|
||||
* one packet on the network without payload copying, for maximum efficiency.
|
||||
*
|
||||
* So for example you need this kind of code to use libwebsocket_write with a
|
||||
* 128-byte payload
|
||||
*
|
||||
* char buf[LWS_SEND_BUFFER_PRE_PADDING + 128 + LWS_SEND_BUFFER_POST_PADDING];
|
||||
*
|
||||
* // fill your part of the buffer... for example here it's all zeros
|
||||
* memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, 128);
|
||||
*
|
||||
* libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], 128);
|
||||
*
|
||||
* When sending LWS_WRITE_HTTP, there is no protocol addition and you can just
|
||||
* use the whole buffer without taking care of the above.
|
||||
*/
|
||||
|
||||
/*
|
||||
* this is the frame nonce plus two header plus 8 length
|
||||
* there's an additional two for mux extension per mux nesting level
|
||||
* 2 byte prepend on close will already fit because control frames cannot use
|
||||
* the big length style
|
||||
*/
|
||||
|
||||
#define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION))
|
||||
#define LWS_SEND_BUFFER_POST_PADDING 4
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
|
||||
enum libwebsocket_write_protocol protocol);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsockets_serve_http_file(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi, const char *file,
|
||||
const char *content_type);
|
||||
LWS_EXTERN int
|
||||
libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN const struct libwebsocket_protocols *
|
||||
libwebsockets_get_protocol(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_callback_on_writable(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_callback_on_writable_all_protocol(
|
||||
const struct libwebsocket_protocols *protocol);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_get_socket_fd(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_is_final_fragment(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN unsigned char
|
||||
libwebsocket_get_reserved_bits(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
|
||||
|
||||
LWS_EXTERN size_t
|
||||
libwebsockets_remaining_packet_payload(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN struct libwebsocket *
|
||||
libwebsocket_client_connect(struct libwebsocket_context *clients,
|
||||
const char *address,
|
||||
int port,
|
||||
int ssl_connection,
|
||||
const char *path,
|
||||
const char *host,
|
||||
const char *origin,
|
||||
const char *protocol,
|
||||
int ietf_version_or_minus_one);
|
||||
|
||||
LWS_EXTERN struct libwebsocket *
|
||||
libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
|
||||
const char *address,
|
||||
int port,
|
||||
int ssl_connection,
|
||||
const char *path,
|
||||
const char *host,
|
||||
const char *origin,
|
||||
const char *protocol,
|
||||
int ietf_version_or_minus_one,
|
||||
void *userdata);
|
||||
|
||||
LWS_EXTERN const char *
|
||||
libwebsocket_canonical_hostname(struct libwebsocket_context *context);
|
||||
|
||||
|
||||
LWS_EXTERN void
|
||||
libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi, int fd, char *name, int name_len,
|
||||
char *rip, int rip_len);
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsockets_get_random(struct libwebsocket_context *context,
|
||||
void *buf, int len);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_daemonize(const char *_lock_path);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_send_pipe_choked(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_frame_is_binary(struct libwebsocket *wsi);
|
||||
|
||||
LWS_EXTERN unsigned char *
|
||||
libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_b64_decode_string(const char *in, char *out, int out_size);
|
||||
|
||||
LWS_EXTERN const char *
|
||||
lws_get_library_version(void);
|
||||
|
||||
/* access to headers... only valid while headers valid */
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h);
|
||||
|
||||
LWS_EXTERN int
|
||||
lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
|
||||
enum lws_token_indexes h);
|
||||
|
||||
/*
|
||||
* Note: this is not normally needed as a user api. It's provided in case it is
|
||||
* useful when integrating with other app poll loop service code.
|
||||
*/
|
||||
|
||||
LWS_EXTERN int
|
||||
libwebsocket_read(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi,
|
||||
unsigned char *buf, size_t len);
|
||||
|
||||
#ifndef LWS_NO_EXTENSIONS
|
||||
LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1 @@
|
|||
2e9ff412352827591ef1389f336b01d179260293
|
|
@ -551,8 +551,6 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer: 彬 张 (BE3QDJTL78)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 彬 张 (BE3QDJTL78)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
|
@ -568,8 +566,6 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer: 彬 张 (BE3QDJTL78)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 彬 张 (BE3QDJTL78)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
|
||||
<builder autoBuildTarget="all" buildPath="${workspace_loc:/proj.tizen/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
|
||||
<tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -50,7 +50,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIE"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -58,14 +57,15 @@
|
|||
<listOptionValue builtIn="false" value="_DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="TIZEN"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.other.other.434981835" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
|
||||
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -85,7 +85,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIE"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -96,7 +95,7 @@
|
|||
<inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_SRC}/proj.tizen/Debug-Tizen-Emulator""/>
|
||||
|
@ -105,7 +104,7 @@
|
|||
<listOptionValue builtIn="false" value=""${COCOS_SRC}/platform/third_party/tizen/prebuilt/libwebp/libs/x86""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="-pie -lpthread "/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker -rpath="/opt/usr/apps/chzfHkPFS6/lib""/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
|
||||
|
|
|
@ -25,12 +25,12 @@
|
|||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.771100885" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
|
||||
<builder autoBuildTarget="all" buildPath="${workspace_loc:/SimpleGame/Debug-Tizen-Emulator}" enableAutoBuild="true" id="org.tizen.nativecpp.target.sbi.gnu.builder.1673976780" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecpp.target.sbi.gnu.builder"/>
|
||||
<tool id="org.tizen.nativecpp.tool.sbi.gnu.archiver.1194564992" name="Archiver" superClass="org.tizen.nativecpp.tool.sbi.gnu.archiver"/>
|
||||
<tool command="clang++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler.1949458252" name="C++ Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.787208976" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debugging.level.1233378155" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.debug.applog.862858860" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.cpp.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.cpp.compiler.option.1553557316" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1728288273" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -54,7 +54,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp.1312278881" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.cpp.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIE"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -62,14 +61,15 @@
|
|||
<listOptionValue builtIn="false" value="_DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="TIZEN"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.other.other.1216683783" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=c++0x" valueType="string"/>
|
||||
<inputType id="sbi.gnu.cpp.compiler.tizen.inputType.1730431593" superClass="sbi.gnu.cpp.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool command="clang.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<tool command="i386-linux-gnueabi-gcc.exe" id="org.tizen.nativecpp.tool.sbi.gnu.c.compiler.246785327" name="C Compiler" superClass="org.tizen.nativecpp.tool.sbi.gnu.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.202586047" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debugging.level.883578246" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="sbi.gnu.c.compiler.option.debug.applog.1308017770" name="Enable application logging (-D_APP_LOG)" superClass="sbi.gnu.c.compiler.option.debug.applog" value="true" valueType="boolean"/>
|
||||
<option id="sbi.gnu.c.compiler.option.1193657309" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_llvm31.i386.cpp.app"/>
|
||||
<listOptionValue builtIn="false" value="tizen-emulator-2.1.native_gcc45.i386.cpp.app"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.include.paths.2082336934" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
|
@ -88,7 +88,6 @@
|
|||
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/osp""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.c.compiler.option.frameworks_cflags.cpp.733263569" name="Tizen-Frameworks-Other-Cflags" superClass="sbi.gnu.c.compiler.option.frameworks_cflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Wno-gnu"/>
|
||||
<listOptionValue builtIn="false" value=" -fPIE"/>
|
||||
<listOptionValue builtIn="false" value="--sysroot="${SBI_SYSROOT}""/>
|
||||
</option>
|
||||
|
@ -99,7 +98,7 @@
|
|||
<inputType id="sbi.gnu.c.compiler.tizen.inputType.10864777" superClass="sbi.gnu.c.compiler.tizen.inputType"/>
|
||||
</tool>
|
||||
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.818620439" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
|
||||
<tool command="clang++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<tool command="i386-linux-gnueabi-g++.exe" id="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker.1117400778" name="C++ Linker" superClass="org.tizen.nativecpp.tool.sbi.gnu.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.1869893869" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lib}""/>
|
||||
<listOptionValue builtIn="false" value=""${COCOS_SRC}/platform/third_party/tizen/rootstraps/tizen-emulator-2.1.native/lib""/>
|
||||
|
@ -109,7 +108,7 @@
|
|||
<listOptionValue builtIn="false" value=""${COCOS_ROOT}/CocosDenshion/proj.tizen/Debug-Tizen-Emulator""/>
|
||||
</option>
|
||||
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp.231803493" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.cpp" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="-target i386-tizen-linux-gnueabi -gcc-toolchain "C:/tizen-sdk/tools/smart-build-interface/../i386-linux-gnueabi-gcc-4.5/" -ccc-gcc-name i386-linux-gnueabi-g++ -march=i386 -Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker --as-needed"/>
|
||||
<listOptionValue builtIn="false" value="-pie -lpthread "/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker -rpath="/opt/usr/apps/9SFk2uuXBH/lib""/>
|
||||
<listOptionValue builtIn="false" value="-Xlinker -rpath="/home/developer/sdk_tools/lib""/>
|
||||
|
|
|
@ -100,6 +100,7 @@ Classes/ConfigurationTest/ConfigurationTest.cpp \
|
|||
Classes/controller.cpp \
|
||||
Classes/testBasic.cpp \
|
||||
Classes/AppDelegate.cpp \
|
||||
Classes/BaseTest.cpp \
|
||||
Classes/VisibleRect.cpp
|
||||
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
|
||||
|
|
|
@ -82,28 +82,6 @@ std::string ActionManagerTest::title()
|
|||
return "No title";
|
||||
}
|
||||
|
||||
void ActionManagerTest::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&ActionManagerTest::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&ActionManagerTest::restartCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&ActionManagerTest::nextCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
void ActionManagerTest::restartCallback(CCObject* pSender)
|
||||
{
|
||||
CCScene* s = new ActionManagerTestScene();
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define _ACTION_MANAGER_TEST_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class ActionManagerTest: public CCLayer
|
||||
class ActionManagerTest: public BaseTest
|
||||
{
|
||||
protected:
|
||||
CCTextureAtlas* m_atlas;
|
||||
|
@ -15,7 +16,6 @@ public:
|
|||
~ActionManagerTest(void);
|
||||
|
||||
virtual std::string title();
|
||||
virtual void onEnter();
|
||||
|
||||
void restartCallback(CCObject* pSender);
|
||||
void nextCallback(CCObject* pSender);
|
||||
|
|
|
@ -606,7 +606,7 @@ std::string EaseSpriteDemo::title()
|
|||
|
||||
void EaseSpriteDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
BaseTest::onEnter();
|
||||
|
||||
// Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too
|
||||
m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain();
|
||||
|
@ -620,23 +620,6 @@ void EaseSpriteDemo::onEnter()
|
|||
m_grossini->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*1/5));
|
||||
m_kathia->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2.5f/5));
|
||||
m_tamara->setPosition(ccp(VisibleRect::left().x + 60, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*4/5));
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label);
|
||||
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind(&EaseSpriteDemo::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind(&EaseSpriteDemo::restartCallback , this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind(&EaseSpriteDemo::nextCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y + item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
void EaseSpriteDemo::restartCallback(CCObject* pSender)
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
////----#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
class EaseSpriteDemo : public CCLayer
|
||||
class EaseSpriteDemo : public BaseTest
|
||||
{
|
||||
protected:
|
||||
CCSprite* m_grossini;
|
||||
|
|
|
@ -90,32 +90,7 @@ std::string SpriteDemo::subtitle()
|
|||
|
||||
void SpriteDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
|
||||
CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255));
|
||||
addChild(background, -10);
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define _ACTIONS_PROGRESS_TEST_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class SpriteDemo : public CCLayer
|
||||
class SpriteDemo : public BaseTest
|
||||
{
|
||||
public:
|
||||
SpriteDemo(void);
|
||||
|
|
|
@ -2,101 +2,53 @@
|
|||
#include "../testResource.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
TESTLAYER_CREATE_FUNC(ActionManual);
|
||||
TESTLAYER_CREATE_FUNC(ActionMove);
|
||||
TESTLAYER_CREATE_FUNC(ActionRotate);
|
||||
TESTLAYER_CREATE_FUNC(ActionScale);
|
||||
TESTLAYER_CREATE_FUNC(ActionSkew);
|
||||
TESTLAYER_CREATE_FUNC(ActionRotationalSkew);
|
||||
TESTLAYER_CREATE_FUNC(ActionRotationalSkewVSStandardSkew);
|
||||
TESTLAYER_CREATE_FUNC(ActionSkewRotateScale);
|
||||
TESTLAYER_CREATE_FUNC(ActionJump);
|
||||
TESTLAYER_CREATE_FUNC(ActionCardinalSpline);
|
||||
TESTLAYER_CREATE_FUNC(ActionCatmullRom);
|
||||
TESTLAYER_CREATE_FUNC(ActionBezier);
|
||||
TESTLAYER_CREATE_FUNC(ActionBlink);
|
||||
TESTLAYER_CREATE_FUNC(ActionFade);
|
||||
TESTLAYER_CREATE_FUNC(ActionTint);
|
||||
TESTLAYER_CREATE_FUNC(ActionAnimate);
|
||||
TESTLAYER_CREATE_FUNC(ActionSequence);
|
||||
TESTLAYER_CREATE_FUNC(ActionSequence2);
|
||||
TESTLAYER_CREATE_FUNC(ActionSpawn);
|
||||
TESTLAYER_CREATE_FUNC(ActionReverse);
|
||||
TESTLAYER_CREATE_FUNC(ActionDelayTime);
|
||||
TESTLAYER_CREATE_FUNC(ActionRepeat);
|
||||
TESTLAYER_CREATE_FUNC(ActionRepeatForever);
|
||||
TESTLAYER_CREATE_FUNC(ActionRotateToRepeat);
|
||||
TESTLAYER_CREATE_FUNC(ActionRotateJerk);
|
||||
TESTLAYER_CREATE_FUNC(ActionCallFunction);
|
||||
TESTLAYER_CREATE_FUNC(ActionCallFunc);
|
||||
TESTLAYER_CREATE_FUNC(ActionCallFuncND);
|
||||
TESTLAYER_CREATE_FUNC(ActionReverseSequence);
|
||||
TESTLAYER_CREATE_FUNC(ActionReverseSequence2);
|
||||
TESTLAYER_CREATE_FUNC(ActionRemoveSelf);
|
||||
TESTLAYER_CREATE_FUNC(ActionOrbit);
|
||||
TESTLAYER_CREATE_FUNC(ActionFollow);
|
||||
TESTLAYER_CREATE_FUNC(ActionTargeted);
|
||||
TESTLAYER_CREATE_FUNC(ActionMoveStacked);
|
||||
TESTLAYER_CREATE_FUNC(ActionMoveJumpStacked);
|
||||
TESTLAYER_CREATE_FUNC(ActionMoveBezierStacked);
|
||||
TESTLAYER_CREATE_FUNC(ActionCardinalSplineStacked);
|
||||
TESTLAYER_CREATE_FUNC(ActionCatmullRomStacked);
|
||||
TESTLAYER_CREATE_FUNC(PauseResumeActions);
|
||||
TESTLAYER_CREATE_FUNC(Issue1305);
|
||||
TESTLAYER_CREATE_FUNC(Issue1305_2);
|
||||
TESTLAYER_CREATE_FUNC(Issue1288);
|
||||
TESTLAYER_CREATE_FUNC(Issue1288_2);
|
||||
TESTLAYER_CREATE_FUNC(Issue1327);
|
||||
TESTLAYER_CREATE_FUNC(Issue1398);
|
||||
|
||||
|
||||
static NEWTESTFUNC createFunctions[] = {
|
||||
CF(ActionManual),
|
||||
CF(ActionMove),
|
||||
CF(ActionRotate),
|
||||
CF(ActionScale),
|
||||
CF(ActionSkew),
|
||||
CF(ActionRotationalSkew),
|
||||
CF(ActionRotationalSkewVSStandardSkew),
|
||||
CF(ActionSkewRotateScale),
|
||||
CF(ActionJump),
|
||||
CF(ActionCardinalSpline),
|
||||
CF(ActionCatmullRom),
|
||||
CF(ActionBezier),
|
||||
CF(ActionBlink),
|
||||
CF(ActionFade),
|
||||
CF(ActionTint),
|
||||
CF(ActionAnimate),
|
||||
CF(ActionSequence),
|
||||
CF(ActionSequence2),
|
||||
CF(ActionRemoveSelf),
|
||||
CF(ActionSpawn),
|
||||
CF(ActionReverse),
|
||||
CF(ActionDelayTime),
|
||||
CF(ActionRepeat),
|
||||
CF(ActionRepeatForever),
|
||||
CF(ActionRotateToRepeat),
|
||||
CF(ActionRotateJerk),
|
||||
CF(ActionCallFunction),
|
||||
CF(ActionCallFunc),
|
||||
CF(ActionCallFuncND),
|
||||
CF(ActionReverseSequence),
|
||||
CF(ActionReverseSequence2),
|
||||
CF(ActionOrbit),
|
||||
CF(ActionFollow),
|
||||
CF(ActionTargeted),
|
||||
CF(ActionMoveStacked),
|
||||
CF(ActionMoveJumpStacked),
|
||||
CF(ActionMoveBezierStacked),
|
||||
CF(ActionCardinalSplineStacked),
|
||||
CF(ActionCatmullRomStacked),
|
||||
CF(PauseResumeActions),
|
||||
CF(Issue1305),
|
||||
CF(Issue1305_2),
|
||||
CF(Issue1288),
|
||||
CF(Issue1288_2),
|
||||
CF(Issue1327),
|
||||
CF(Issue1398)
|
||||
static std::function<CCLayer*()> createFunctions[] = {
|
||||
CL(ActionManual),
|
||||
CL(ActionMove),
|
||||
CL(ActionRotate),
|
||||
CL(ActionScale),
|
||||
CL(ActionSkew),
|
||||
CL(ActionRotationalSkew),
|
||||
CL(ActionRotationalSkewVSStandardSkew),
|
||||
CL(ActionSkewRotateScale),
|
||||
CL(ActionJump),
|
||||
CL(ActionCardinalSpline),
|
||||
CL(ActionCatmullRom),
|
||||
CL(ActionBezier),
|
||||
CL(ActionBlink),
|
||||
CL(ActionFade),
|
||||
CL(ActionTint),
|
||||
CL(ActionAnimate),
|
||||
CL(ActionSequence),
|
||||
CL(ActionSequence2),
|
||||
CL(ActionRemoveSelf),
|
||||
CL(ActionSpawn),
|
||||
CL(ActionReverse),
|
||||
CL(ActionDelayTime),
|
||||
CL(ActionRepeat),
|
||||
CL(ActionRepeatForever),
|
||||
CL(ActionRotateToRepeat),
|
||||
CL(ActionRotateJerk),
|
||||
CL(ActionCallFunction),
|
||||
CL(ActionCallFunc),
|
||||
CL(ActionCallFuncND),
|
||||
CL(ActionReverseSequence),
|
||||
CL(ActionReverseSequence2),
|
||||
CL(ActionOrbit),
|
||||
CL(ActionFollow),
|
||||
CL(ActionTargeted),
|
||||
CL(ActionMoveStacked),
|
||||
CL(ActionMoveJumpStacked),
|
||||
CL(ActionMoveBezierStacked),
|
||||
CL(ActionCardinalSplineStacked),
|
||||
CL(ActionCatmullRomStacked),
|
||||
CL(PauseResumeActions),
|
||||
CL(Issue1305),
|
||||
CL(Issue1305_2),
|
||||
CL(Issue1288),
|
||||
CL(Issue1288_2),
|
||||
CL(Issue1327),
|
||||
CL(Issue1398)
|
||||
};
|
||||
|
||||
static int sceneIdx=-1;
|
||||
|
@ -158,7 +110,7 @@ std::string ActionsDemo::subtitle()
|
|||
|
||||
void ActionsDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
BaseTest::onEnter();
|
||||
|
||||
// Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
|
||||
m_grossini = CCSprite::create(s_pPathGrossini);
|
||||
|
@ -177,35 +129,6 @@ void ActionsDemo::onEnter()
|
|||
m_grossini->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/3));
|
||||
m_tamara->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height*2/3));
|
||||
m_kathia->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+VisibleRect::getVisibleRect().size.height/2));
|
||||
|
||||
// add title and subtitle
|
||||
std::string str = title();
|
||||
const char * pTitle = str.c_str();
|
||||
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||
}
|
||||
|
||||
// add menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &ActionsDemo::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &ActionsDemo::restartCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &ActionsDemo::nextCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
void ActionsDemo::onExit()
|
||||
|
@ -214,7 +137,7 @@ void ActionsDemo::onExit()
|
|||
m_tamara->release();
|
||||
m_kathia->release();
|
||||
|
||||
CCLayer::onExit();
|
||||
BaseTest::onExit();
|
||||
}
|
||||
|
||||
void ActionsDemo::restartCallback(CCObject* pSender)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _ActionsTest_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
////----#include "cocos2d.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class ActionsDemo : public CCLayer
|
||||
class ActionsDemo : public BaseTest
|
||||
{
|
||||
protected:
|
||||
CCSprite* m_grossini;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
//
|
||||
// BaseTest.cpp
|
||||
// TestCpp
|
||||
//
|
||||
// Created by Ricardo Quesada on 6/6/13.
|
||||
//
|
||||
//
|
||||
|
||||
#include "BaseTest.h"
|
||||
#include "VisibleRect.h"
|
||||
#include "testResource.h"
|
||||
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
void BaseTest::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
// add title and subtitle
|
||||
std::string str = title();
|
||||
const char * pTitle = str.c_str();
|
||||
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||
}
|
||||
|
||||
// add menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, std::bind( &BaseTest::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, std::bind( &BaseTest::restartCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, std::bind( &BaseTest::nextCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
|
||||
}
|
||||
|
||||
void BaseTest::onExit()
|
||||
{
|
||||
CCLayer::onExit();
|
||||
}
|
||||
|
||||
std::string BaseTest::title()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string BaseTest::subtitle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void BaseTest::restartCallback(CCObject* pSender)
|
||||
{
|
||||
CCLog("override restart!");
|
||||
}
|
||||
|
||||
void BaseTest::nextCallback(CCObject* pSender)
|
||||
{
|
||||
CCLog("override next!");
|
||||
}
|
||||
|
||||
void BaseTest::backCallback(CCObject* pSender)
|
||||
{
|
||||
CCLog("override back!");
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// BaseTest.h
|
||||
// TestCpp
|
||||
//
|
||||
// Created by Ricardo Quesada on 6/6/13.
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef __TestCpp__BaseTest__
|
||||
#define __TestCpp__BaseTest__
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
class BaseTest : public cocos2d::CCLayer
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
|
||||
virtual void restartCallback(CCObject* pSender);
|
||||
virtual void nextCallback(CCObject* pSender);
|
||||
virtual void backCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
|
||||
#endif /* defined(__TestCpp__BaseTest__) */
|
|
@ -115,7 +115,14 @@ void Box2DTestLayer::initPhysics()
|
|||
|
||||
void Box2DTestLayer::createResetButton()
|
||||
{
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(Box2DTestLayer::reset));
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", [](CCObject *sender) {
|
||||
CCScene* s = new Box2DTestScene();
|
||||
Box2DTestLayer* child = new Box2DTestLayer();
|
||||
s->addChild(child);
|
||||
child->release();
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
});
|
||||
|
||||
CCMenu *menu = CCMenu::create(reset, NULL);
|
||||
|
||||
|
@ -124,16 +131,6 @@ void Box2DTestLayer::createResetButton()
|
|||
|
||||
}
|
||||
|
||||
void Box2DTestLayer::reset(CCObject* sender)
|
||||
{
|
||||
CCScene* s = new Box2DTestScene();
|
||||
Box2DTestLayer* child = new Box2DTestLayer();
|
||||
s->addChild(child);
|
||||
child->release();
|
||||
CCDirector::sharedDirector()->replaceScene(s);
|
||||
s->release();
|
||||
}
|
||||
|
||||
void Box2DTestLayer::draw()
|
||||
{
|
||||
//
|
||||
|
|
|
@ -28,7 +28,6 @@ public:
|
|||
|
||||
void initPhysics();
|
||||
void createResetButton();
|
||||
void reset(CCObject* sender);
|
||||
virtual void draw();
|
||||
|
||||
void addNewSpriteAtPosition(CCPoint p);
|
||||
|
|
|
@ -67,9 +67,9 @@ bool MenuLayer::initWithEntryID(int entryId)
|
|||
addChild(label, 1);
|
||||
label->setPosition( ccp(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) );
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) );
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &MenuLayer::backCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", std::bind( &MenuLayer::restartCallback, this, std::placeholders::_1) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &MenuLayer::nextCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ bool Bug1159Layer::init()
|
|||
sprite_b->setPosition(ccp(s.width/2, s.height/2));
|
||||
addChild(sprite_b);
|
||||
|
||||
CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack));
|
||||
CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), std::bind( &Bug1159Layer::callBack, this, std::placeholders::_1) );
|
||||
CCMenu *menu = CCMenu::create(label, NULL);
|
||||
menu->setPosition(ccp(s.width - 200.0f, 50.0f));
|
||||
addChild(menu);
|
||||
|
|
|
@ -31,9 +31,9 @@ void Bug422Layer::reset()
|
|||
removeChild(node, false);
|
||||
// [self removeChildByTag:localtag-1 cleanup:NO];
|
||||
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("One", this, menu_selector(Bug422Layer::menuCallback));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("One", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
|
||||
CCLog("MenuItemFont: %p", item1);
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Two", this, menu_selector(Bug422Layer::menuCallback));
|
||||
CCMenuItem *item2 = CCMenuItemFont::create("Two", std::bind( &Bug422Layer::menuCallback, this, std::placeholders::_1) );
|
||||
CCMenu *menu = CCMenu::create(item1, item2, NULL);
|
||||
menu->alignItemsVertically();
|
||||
|
||||
|
|
|
@ -21,13 +21,13 @@ bool Bug458Layer::init()
|
|||
// [question setContentSize:CGSizeMake(50,50)];
|
||||
// [question2 setContentSize:CGSizeMake(50,50)];
|
||||
|
||||
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer));
|
||||
CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
|
||||
CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100);
|
||||
question->release();
|
||||
question2->release();
|
||||
|
||||
CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100);
|
||||
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, (CCObject*)this, menu_selector(Bug458Layer::selectAnswer));
|
||||
CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, std::bind( &Bug458Layer::selectAnswer, this, std::placeholders::_1) );
|
||||
CCMenu* menu = CCMenu::create(sprite, sprite2, NULL);
|
||||
menu->alignItemsVerticallyWithPadding(100);
|
||||
menu->setPosition(ccp(size.width / 2, size.height / 2));
|
||||
|
|
|
@ -46,7 +46,7 @@ bool Bug914Layer::init()
|
|||
|
||||
// create and initialize a Label
|
||||
CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64);
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart));
|
||||
CCMenuItem *item1 = CCMenuItemFont::create("restart", std::bind( &Bug914Layer::restart, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, NULL);
|
||||
menu->alignItemsVertically();
|
||||
|
|
|
@ -9,38 +9,42 @@
|
|||
#include "Bug-1159.h"
|
||||
#include "Bug-1174.h"
|
||||
|
||||
#define TEST_BUG(bugNO) \
|
||||
{ \
|
||||
CCScene* pScene = CCScene::create(); \
|
||||
Bug##bugNO##Layer* pLayer = new Bug##bugNO##Layer(); \
|
||||
pLayer->init(); \
|
||||
pScene->addChild(pLayer); \
|
||||
CCDirector::sharedDirector()->replaceScene(pScene); \
|
||||
pLayer->autorelease(); \
|
||||
#define TEST_BUG(__bug__) \
|
||||
{ \
|
||||
CCScene* pScene = CCScene::create(); \
|
||||
Bug##__bug__##Layer* pLayer = new Bug##__bug__##Layer(); \
|
||||
pLayer->init(); \
|
||||
pScene->addChild(pLayer); \
|
||||
CCDirector::sharedDirector()->replaceScene(pScene); \
|
||||
pLayer->autorelease(); \
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_COUNT = 9,
|
||||
LINE_SPACE = 40,
|
||||
kItemTagBasic = 5432,
|
||||
};
|
||||
|
||||
static CCPoint s_tCurPos = CCPointZero;
|
||||
|
||||
const std::string testsName[MAX_COUNT] =
|
||||
{
|
||||
"Bug-350",
|
||||
"Bug-422",
|
||||
"Bug-458",
|
||||
"Bug-624",
|
||||
"Bug-886",
|
||||
"Bug-899",
|
||||
"Bug-914",
|
||||
"Bug-1159",
|
||||
"Bug-1174"
|
||||
struct {
|
||||
const char *test_name;
|
||||
std::function<void(CCObject*)> callback;
|
||||
} g_bugs[] = {
|
||||
{ "Bug-350", [](CCObject* sender){ TEST_BUG(350)} },
|
||||
{ "Bug-422", [](CCObject* sender){ TEST_BUG(422)} },
|
||||
{ "Bug-458", [](CCObject* sender){ TEST_BUG(458)} },
|
||||
{ "Bug-624", [](CCObject* sender){ TEST_BUG(624)} },
|
||||
{ "Bug-886", [](CCObject* sender){ TEST_BUG(886)} },
|
||||
{ "Bug-899", [](CCObject* sender){ TEST_BUG(899)} },
|
||||
{ "Bug-914", [](CCObject* sender){ TEST_BUG(914)} },
|
||||
{ "Bug-1159", [](CCObject* sender){ TEST_BUG(1159)} },
|
||||
{ "Bug-1174", [](CCObject* sender){ TEST_BUG(1174)} },
|
||||
};
|
||||
|
||||
static const int g_maxitems = sizeof(g_bugs) / sizeof(g_bugs[0]);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// BugsTestMainLayer
|
||||
|
@ -54,10 +58,9 @@ void BugsTestMainLayer::onEnter()
|
|||
m_pItmeMenu = CCMenu::create();
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < MAX_COUNT; ++i)
|
||||
for (int i = 0; i < g_maxitems; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
||||
menu_selector(BugsTestMainLayer::menuCallback));
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(g_bugs[i].test_name, g_bugs[i].callback);
|
||||
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||
m_pItmeMenu->addChild(pItem, kItemTagBasic + i);
|
||||
}
|
||||
|
@ -67,45 +70,6 @@ void BugsTestMainLayer::onEnter()
|
|||
setTouchEnabled(true);
|
||||
}
|
||||
|
||||
void BugsTestMainLayer::menuCallback(CCObject* pSender)
|
||||
{
|
||||
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
||||
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
||||
|
||||
switch (nIndex)
|
||||
{
|
||||
case 0:
|
||||
TEST_BUG(350);
|
||||
break;
|
||||
case 1:
|
||||
TEST_BUG(422);
|
||||
break;
|
||||
case 2:
|
||||
TEST_BUG(458);
|
||||
break;
|
||||
case 3:
|
||||
TEST_BUG(624);
|
||||
break;
|
||||
case 4:
|
||||
TEST_BUG(886);
|
||||
break;
|
||||
case 5:
|
||||
TEST_BUG(899);
|
||||
break;
|
||||
case 6:
|
||||
TEST_BUG(914);
|
||||
break;
|
||||
case 7:
|
||||
TEST_BUG(1159);
|
||||
break;
|
||||
case 8:
|
||||
TEST_BUG(1174);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BugsTestMainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||
{
|
||||
CCSetIterator it = pTouches->begin();
|
||||
|
@ -131,9 +95,9 @@ void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
|||
return;
|
||||
}
|
||||
|
||||
if (nextPos.y > ((MAX_COUNT + 1)* LINE_SPACE - winSize.height))
|
||||
if (nextPos.y > ((g_maxitems + 1)* LINE_SPACE - winSize.height))
|
||||
{
|
||||
m_pItmeMenu->setPosition(ccp(0, ((MAX_COUNT + 1)* LINE_SPACE - winSize.height)));
|
||||
m_pItmeMenu->setPosition(ccp(0, ((g_maxitems + 1)* LINE_SPACE - winSize.height)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,8 +117,7 @@ void BugsTestBaseLayer::onEnter()
|
|||
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(BugsTestBaseLayer::backCallback));
|
||||
CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", std::bind( &BugsTestBaseLayer::backCallback, this, std::placeholders::_1));
|
||||
pMainItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pMenu = CCMenu::create(pMainItem, NULL);
|
||||
pMenu->setPosition( CCPointZero );
|
||||
|
|
|
@ -7,7 +7,6 @@ class BugsTestMainLayer : public CCLayer
|
|||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void menuCallback(CCObject* pSender);
|
||||
|
||||
virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);
|
||||
virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);
|
||||
|
|
|
@ -50,7 +50,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
|
|||
|
||||
// menu for debug layer
|
||||
CCMenuItemFont::setFontSize(18);
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", this, menu_selector(ChipmunkTestLayer::toggleDebugCallback));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle debug", std::bind( &ChipmunkTestLayer::toggleDebugCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -147,7 +147,7 @@ void ChipmunkTestLayer::update(float delta)
|
|||
|
||||
void ChipmunkTestLayer::createResetButton()
|
||||
{
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(ChipmunkTestLayer::reset));
|
||||
CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &ChipmunkTestLayer::reset, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(reset, NULL);
|
||||
|
||||
|
|
|
@ -92,40 +92,13 @@ static CCLayer* restartAction()
|
|||
|
||||
bool BaseClippingNodeTest::init()
|
||||
{
|
||||
if (CCLayer::init()) {
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
if (BaseTest::init()) {
|
||||
|
||||
CCSprite *background = CCSprite::create(s_back3);
|
||||
background->setAnchorPoint( CCPointZero );
|
||||
background->setPosition( CCPointZero );
|
||||
this->addChild(background, -1);
|
||||
|
||||
CCLabelTTF *label = CCLabelTTF::create(this->title().c_str(), "Arial", 32);
|
||||
this->addChild(label, 1, kTagTitleLabel);
|
||||
label->setPosition( ccp(s.width / 2, s.height - 50));
|
||||
|
||||
std::string subtitleText = this->subtitle();
|
||||
if (subtitleText.length() > 0) {
|
||||
CCLabelTTF *subtitle = CCLabelTTF::create(subtitleText.c_str(), "Thonburi", 16);
|
||||
this->addChild(subtitle, 1, kTagSubtitleLabel);
|
||||
subtitle->setPosition(ccp(s.width / 2, s.height - 80));
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2,
|
||||
this, menu_selector(BaseClippingNodeTest::backCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2,
|
||||
this, menu_selector(BaseClippingNodeTest::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2,
|
||||
this, menu_selector(BaseClippingNodeTest::nextCallback));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
menu->setPosition( CCPointZero );
|
||||
item1->setPosition( ccp(s.width / 2 - item2->getContentSize().width * 2, item2->getContentSize().height / 2));
|
||||
item2->setPosition( ccp(s.width / 2, item2->getContentSize().height / 2));
|
||||
item3->setPosition( ccp(s.width / 2 + item2->getContentSize().width * 2, item2->getContentSize().height / 2));
|
||||
this->addChild(menu, 1);
|
||||
|
||||
this->setup();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define __CLIPPINGNODETEST_H__
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class BaseClippingNodeTest : public CCLayer
|
||||
class BaseClippingNodeTest : public BaseTest
|
||||
{
|
||||
public:
|
||||
~BaseClippingNodeTest();
|
||||
|
|
|
@ -63,7 +63,7 @@ m_nSoundId(0)
|
|||
//#else
|
||||
CCLabelTTF* label = CCLabelTTF::create(testItems[i].c_str(), "Arial", 24);
|
||||
//#endif
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(CocosDenshionTest::menuCallback));
|
||||
CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, std::bind( &CocosDenshionTest::menuCallback, this, std::placeholders::_1));
|
||||
|
||||
m_pItmeMenu->addChild(pMenuItem, i + 10000);
|
||||
pMenuItem->setPosition( ccp( VisibleRect::center().x, (VisibleRect::top().y - (i + 1) * LINE_SPACE) ));
|
||||
|
|
|
@ -76,41 +76,12 @@ std::string ConfigurationBase::subtitle()
|
|||
|
||||
void ConfigurationBase::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
// add title and subtitle
|
||||
std::string str = title();
|
||||
const char * pTitle = str.c_str();
|
||||
CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||
}
|
||||
|
||||
// add menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ConfigurationBase::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ConfigurationBase::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ConfigurationBase::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void ConfigurationBase::onExit()
|
||||
{
|
||||
CCLayer::onExit();
|
||||
BaseTest::onExit();
|
||||
}
|
||||
|
||||
void ConfigurationBase::restartCallback(CCObject* pSender)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __CONFIGURATIONTEST_H__
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class ConfigurationBase : public CCLayer
|
||||
class ConfigurationBase : public BaseTest
|
||||
{
|
||||
protected:
|
||||
|
||||
|
|
|
@ -66,33 +66,7 @@ BaseLayer::BaseLayer()
|
|||
|
||||
void BaseLayer::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label);
|
||||
label->setPosition(ccp(s.width/2, s.height-50));
|
||||
|
||||
string subTitle = subtitle();
|
||||
if (subTitle.size() > 0)
|
||||
{
|
||||
CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition(ccp(s.width/2, s.height-80));
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(BaseLayer::backCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(BaseLayer::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(BaseLayer::nextCallback));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
|
||||
item1->setPosition(ccp(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(s.width/2, item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||
addChild(menu, 100);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void BaseLayer::restartCallback(cocos2d::CCObject *pSender)
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class BaseLayer : public CCLayer
|
||||
class BaseLayer : public BaseTest
|
||||
{
|
||||
public:
|
||||
BaseLayer();
|
||||
|
|
|
@ -333,7 +333,7 @@ CCLayer* restartEffectAdvanceAction()
|
|||
|
||||
void EffectAdvanceTextLayer::onEnter(void)
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
BaseTest::onEnter();
|
||||
|
||||
CCSprite *bg = CCSprite::create("Images/background3.png");
|
||||
addChild(bg, 0, kTagBackground);
|
||||
|
@ -351,34 +351,7 @@ void EffectAdvanceTextLayer::onEnter(void)
|
|||
tamara->setPosition( ccp(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) );
|
||||
CCActionInterval* sc2 = CCScaleBy::create(2, 5);
|
||||
CCActionInterval* sc2_back = sc2->reverse();
|
||||
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) );
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28);
|
||||
|
||||
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
|
||||
addChild(label);
|
||||
label->setTag( kTagLabel );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 101);
|
||||
l->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL) ) );
|
||||
}
|
||||
|
||||
EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void)
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class EffectAdvanceTextLayer: public CCLayer
|
||||
class EffectAdvanceTextLayer: public BaseTest
|
||||
{
|
||||
protected:
|
||||
CCTextureAtlas* m_atlas;
|
||||
|
|
|
@ -337,8 +337,10 @@ void EffectTestScene::runThisTest()
|
|||
#define SID_RESTART 1
|
||||
|
||||
TextLayer::TextLayer(void)
|
||||
: BaseTest()
|
||||
{
|
||||
initWithColor( ccc4(32,128,32,255) );
|
||||
CCLayerColor *background = CCLayerColor::create( ccc4(32,128,32,255) );
|
||||
this->addChild(background,-20);
|
||||
|
||||
CCNode* node = CCNode::create();
|
||||
CCActionInterval* effect = getAction();
|
||||
|
@ -364,25 +366,6 @@ TextLayer::TextLayer(void)
|
|||
CCActionInterval* sc2_back = sc2->reverse();
|
||||
tamara->runAction( CCRepeatForever::create(CCSequence::create(sc2, sc2_back, NULL)) );
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32);
|
||||
|
||||
label->setPosition( ccp(VisibleRect::center().x,VisibleRect::top().y-80) );
|
||||
addChild(label);
|
||||
label->setTag( kTagLabel );
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
|
||||
schedule( schedule_selector(TextLayer::checkAnim) );
|
||||
}
|
||||
|
||||
|
@ -413,7 +396,7 @@ TextLayer* TextLayer::create()
|
|||
|
||||
void TextLayer::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void TextLayer::newScene()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define _EFFECTS_TEST_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class EffectTestScene : public TestScene
|
||||
{
|
||||
|
@ -9,7 +10,7 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class TextLayer : public CCLayerColor
|
||||
class TextLayer : public BaseTest
|
||||
{
|
||||
protected:
|
||||
//UxString m_strTitle;
|
||||
|
|
|
@ -42,8 +42,7 @@ bool CCControlScene::init()
|
|||
{
|
||||
if (CCLayer::init())
|
||||
{
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(CCControlScene::toExtensionsMainLayer));
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &CCControlScene::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
|
||||
pBackMenu->setPosition( CCPointZero );
|
||||
|
@ -66,9 +65,9 @@ bool CCControlScene::init()
|
|||
addChild(m_pSceneTitleLabel, 1);
|
||||
|
||||
// Add the menu
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback));
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", std::bind( &CCControlScene::previousCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", std::bind( &CCControlScene::restartCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", std::bind( &CCControlScene::nextCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item3, item2, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
|
|
|
@ -27,7 +27,7 @@ EditBoxTest::EditBoxTest()
|
|||
addChild(m_pTTFShowEditReturn);
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(EditBoxTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &EditBoxTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(visibleOrigin.x+visibleSize.width - 50, visibleOrigin.y+25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -22,38 +22,42 @@ enum
|
|||
kItemTagBasic = 1000,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TEST_NOTIFICATIONCENTER = 0,
|
||||
TEST_CCCONTROLBUTTON,
|
||||
TEST_COCOSBUILDER,
|
||||
TEST_HTTPCLIENT,
|
||||
static struct {
|
||||
const char *name;
|
||||
std::function<void(CCObject* sender)> callback;
|
||||
} g_extensionsTests[] = {
|
||||
{ "NotificationCenterTest", [](CCObject* sender) { runNotificationCenterTest(); }
|
||||
},
|
||||
{ "CCControlButtonTest", [](CCObject *sender){
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}},
|
||||
{ "CocosBuilderTest", [](CCObject *sender) {
|
||||
TestScene* pScene = new CocosBuilderTestScene();
|
||||
if (pScene)
|
||||
{
|
||||
pScene->runThisTest();
|
||||
pScene->release();
|
||||
}
|
||||
}},
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
{ "HttpClientTest", [](CCObject *sender){ runHttpClientTest();}
|
||||
},
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
TEST_WEBSOCKET,
|
||||
{ "WebSocketTest", [](CCObject *sender){ runWebSocketTest();}
|
||||
},
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
TEST_EDITBOX,
|
||||
{ "EditBoxTest", [](CCObject *sender){ runEditBoxTest();}
|
||||
},
|
||||
#endif
|
||||
TEST_TABLEVIEW,
|
||||
TEST_MAX_COUNT,
|
||||
{ "TableViewTest", [](CCObject *sender){ runTableViewTest();}
|
||||
},
|
||||
};
|
||||
|
||||
static const std::string testsName[TEST_MAX_COUNT] =
|
||||
{
|
||||
"NotificationCenterTest",
|
||||
"CCControlButtonTest",
|
||||
"CocosBuilderTest",
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
"HttpClientTest",
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
"WebSocketTest",
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
"EditBoxTest",
|
||||
#endif
|
||||
"TableViewTest"
|
||||
};
|
||||
static const int g_maxTests = sizeof(g_extensionsTests) / sizeof(g_extensionsTests[0]);
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -70,10 +74,9 @@ void ExtensionsMainLayer::onEnter()
|
|||
pMenu->setPosition( CCPointZero );
|
||||
CCMenuItemFont::setFontName("Arial");
|
||||
CCMenuItemFont::setFontSize(24);
|
||||
for (int i = 0; i < TEST_MAX_COUNT; ++i)
|
||||
for (int i = 0; i < g_maxTests; ++i)
|
||||
{
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this,
|
||||
menu_selector(ExtensionsMainLayer::menuCallback));
|
||||
CCMenuItemFont* pItem = CCMenuItemFont::create(g_extensionsTests[i].name, g_extensionsTests[i].callback);
|
||||
pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE));
|
||||
pMenu->addChild(pItem, kItemTagBasic + i);
|
||||
}
|
||||
|
@ -81,68 +84,6 @@ void ExtensionsMainLayer::onEnter()
|
|||
addChild(pMenu);
|
||||
}
|
||||
|
||||
void ExtensionsMainLayer::menuCallback(CCObject* pSender)
|
||||
{
|
||||
CCMenuItemFont* pItem = (CCMenuItemFont*)pSender;
|
||||
int nIndex = pItem->getZOrder() - kItemTagBasic;
|
||||
|
||||
switch (nIndex)
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) // MARMALADE CHANGE: Not yet avaiable on Marmalade
|
||||
case TEST_NOTIFICATIONCENTER:
|
||||
{
|
||||
runNotificationCenterTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TEST_CCCONTROLBUTTON:
|
||||
{
|
||||
CCControlSceneManager* pManager = CCControlSceneManager::sharedControlSceneManager();
|
||||
CCScene* pScene = pManager->currentControlScene();
|
||||
CCDirector::sharedDirector()->replaceScene(pScene);
|
||||
}
|
||||
break;
|
||||
case TEST_COCOSBUILDER:
|
||||
{
|
||||
TestScene* pScene = new CocosBuilderTestScene();
|
||||
if (pScene)
|
||||
{
|
||||
pScene->runThisTest();
|
||||
pScene->release();
|
||||
}
|
||||
}
|
||||
break;
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE && CC_TARGET_PLATFORM != CC_PLATFORM_NACL && CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
|
||||
case TEST_HTTPCLIENT:
|
||||
{
|
||||
runHttpClientTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
case TEST_WEBSOCKET:
|
||||
{
|
||||
runWebSocketTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_TIZEN)
|
||||
case TEST_EDITBOX:
|
||||
{
|
||||
runEditBoxTest();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case TEST_TABLEVIEW:
|
||||
{
|
||||
runTableViewTest();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//
|
||||
// ExtensionsTestScene
|
||||
|
|
|
@ -7,7 +7,6 @@ class ExtensionsMainLayer : public CCLayer
|
|||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
void menuCallback(CCObject* pSender);
|
||||
};
|
||||
|
||||
class ExtensionsTestScene : public TestScene
|
||||
|
|
|
@ -23,31 +23,31 @@ HttpClientTest::HttpClientTest()
|
|||
|
||||
// Get
|
||||
CCLabelTTF *labelGet = CCLabelTTF::create("Test Get", "Arial", 22);
|
||||
CCMenuItemLabel *itemGet = CCMenuItemLabel::create(labelGet, this, menu_selector(HttpClientTest::onMenuGetTestClicked));
|
||||
CCMenuItemLabel *itemGet = CCMenuItemLabel::create(labelGet, std::bind( &HttpClientTest::onMenuGetTestClicked, this, std::placeholders::_1));
|
||||
itemGet->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - SPACE));
|
||||
menuRequest->addChild(itemGet);
|
||||
|
||||
// Post
|
||||
CCLabelTTF *labelPost = CCLabelTTF::create("Test Post", "Arial", 22);
|
||||
CCMenuItemLabel *itemPost = CCMenuItemLabel::create(labelPost, this, menu_selector(HttpClientTest::onMenuPostTestClicked));
|
||||
CCMenuItemLabel *itemPost = CCMenuItemLabel::create(labelPost, std::bind( &HttpClientTest::onMenuPostTestClicked, this, std::placeholders::_1));
|
||||
itemPost->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 2 * SPACE));
|
||||
menuRequest->addChild(itemPost);
|
||||
|
||||
// Post Binary
|
||||
CCLabelTTF *labelPostBinary = CCLabelTTF::create("Test Post Binary", "Arial", 22);
|
||||
CCMenuItemLabel *itemPostBinary = CCMenuItemLabel::create(labelPostBinary, this, menu_selector(HttpClientTest::onMenuPostBinaryTestClicked));
|
||||
CCMenuItemLabel *itemPostBinary = CCMenuItemLabel::create(labelPostBinary, std::bind( &HttpClientTest::onMenuPostBinaryTestClicked, this, std::placeholders::_1));
|
||||
itemPostBinary->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 3 * SPACE));
|
||||
menuRequest->addChild(itemPostBinary);
|
||||
|
||||
// Put
|
||||
CCLabelTTF *labelPut = CCLabelTTF::create("Test Put", "Arial", 22);
|
||||
CCMenuItemLabel *itemPut = CCMenuItemLabel::create(labelPut, this, menu_selector(HttpClientTest::onMenuPutTestClicked));
|
||||
CCMenuItemLabel *itemPut = CCMenuItemLabel::create(labelPut, std::bind( &HttpClientTest::onMenuPutTestClicked, this, std::placeholders::_1));
|
||||
itemPut->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 4 * SPACE));
|
||||
menuRequest->addChild(itemPut);
|
||||
|
||||
// Delete
|
||||
CCLabelTTF *labelDelete = CCLabelTTF::create("Test Delete", "Arial", 22);
|
||||
CCMenuItemLabel *itemDelete = CCMenuItemLabel::create(labelDelete, this, menu_selector(HttpClientTest::onMenuDeleteTestClicked));
|
||||
CCMenuItemLabel *itemDelete = CCMenuItemLabel::create(labelDelete, std::bind( &HttpClientTest::onMenuDeleteTestClicked, this, std::placeholders::_1));
|
||||
itemDelete->setPosition(ccp(winSize.width / 2, winSize.height - MARGIN - 5 * SPACE));
|
||||
menuRequest->addChild(itemDelete);
|
||||
|
||||
|
@ -57,7 +57,7 @@ HttpClientTest::HttpClientTest()
|
|||
addChild(m_labelStatusCode);
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(HttpClientTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &HttpClientTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -82,8 +82,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
{
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this,
|
||||
menu_selector(NotificationCenterTest::toExtensionsMainLayer));
|
||||
CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", std::bind( &NotificationCenterTest::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL);
|
||||
pBackMenu->setPosition( CCPointZero );
|
||||
|
@ -93,7 +92,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("switch on", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind( &NotificationCenterTest::toggleSwitch, this, std::placeholders::_1), item1, item2, NULL);
|
||||
// turn on
|
||||
item->setSelectedIndex(1);
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
|
@ -115,7 +114,7 @@ NotificationCenterTest::NotificationCenterTest()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("connected", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind( &NotificationCenterTest::connectToSwitch, this, std::placeholders::_1), item1, item2, NULL);
|
||||
item->setTag(kTagConnect+i);
|
||||
item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50));
|
||||
menuConnect->addChild(item, 0);
|
||||
|
|
|
@ -39,7 +39,7 @@ bool TableViewTestLayer::init()
|
|||
tableView->reloadData();
|
||||
|
||||
// Back Menu
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(TableViewTestLayer::toExtensionsMainLayer));
|
||||
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", std::bind( &TableViewTestLayer::toExtensionsMainLayer, this, std::placeholders::_1));
|
||||
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
|
||||
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
|
||||
menuBack->setPosition(CCPointZero);
|
||||
|
|
|
@ -65,31 +65,7 @@ void FileUtilsTestScene::runThisTest()
|
|||
|
||||
void FileUtilsDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label);
|
||||
label->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-50));
|
||||
|
||||
std::string subTitle = subtitle();
|
||||
if(! subTitle.empty())
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y-80));
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(FileUtilsDemo::backCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(FileUtilsDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(FileUtilsDemo::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void FileUtilsDemo::backCallback(CCObject* pSender)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define __FILEUTILSTEST_H__
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace std;
|
||||
|
||||
|
@ -11,7 +13,7 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class FileUtilsDemo : public CCLayer
|
||||
class FileUtilsDemo : public BaseTest
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
|
|
|
@ -77,18 +77,8 @@ static const char* restartAction(void)
|
|||
|
||||
|
||||
FontTest::FontTest()
|
||||
: BaseTest()
|
||||
{
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback));
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback));
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
addChild(menu, 1);
|
||||
|
||||
showFont(restartAction());
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class FontTestScene : public TestScene
|
||||
{
|
||||
|
@ -10,7 +11,7 @@ public:
|
|||
virtual void runThisTest();
|
||||
};
|
||||
|
||||
class FontTest : public cocos2d::CCLayer
|
||||
class FontTest : public BaseTest
|
||||
{
|
||||
public:
|
||||
FontTest();
|
||||
|
|
|
@ -57,7 +57,12 @@ IntervalLayer::IntervalLayer()
|
|||
addChild(sprite);
|
||||
sprite->runAction( CCRepeatForever::create(CCSequence::create(jump, jump->reverse(), NULL) ));
|
||||
// pause button
|
||||
CCMenuItem* item1 = CCMenuItemFont::create("Pause", this, menu_selector(IntervalLayer::onPause) );
|
||||
CCMenuItem* item1 = CCMenuItemFont::create("Pause", [&](CCObject* sender) {
|
||||
if(CCDirector::sharedDirector()->isPaused())
|
||||
CCDirector::sharedDirector()->resume();
|
||||
else
|
||||
CCDirector::sharedDirector()->pause();
|
||||
});
|
||||
CCMenu* menu = CCMenu::create(item1, NULL);
|
||||
menu->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
|
@ -80,15 +85,6 @@ void IntervalLayer::update(float dt)
|
|||
m_label0->setString(time);
|
||||
}
|
||||
|
||||
void IntervalLayer::onPause(CCObject* pSender)
|
||||
{
|
||||
if(CCDirector::sharedDirector()->isPaused())
|
||||
CCDirector::sharedDirector()->resume();
|
||||
else
|
||||
CCDirector::sharedDirector()->pause();
|
||||
|
||||
}
|
||||
|
||||
void IntervalLayer::step1(float dt)
|
||||
{
|
||||
m_time1 +=dt;
|
||||
|
|
|
@ -18,7 +18,6 @@ public:
|
|||
IntervalLayer(void);
|
||||
virtual ~IntervalLayer();
|
||||
public:
|
||||
void onPause(CCObject* pSender);
|
||||
|
||||
void step1(float dt);
|
||||
void step2(float dt);
|
||||
|
|
|
@ -134,34 +134,7 @@ std::string AtlasDemo::subtitle()
|
|||
|
||||
void AtlasDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(AtlasDemo::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(AtlasDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(AtlasDemo::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition( CCPointZero );
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));;
|
||||
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void AtlasDemo::restartCallback(CCObject* pSender)
|
||||
|
@ -967,19 +940,19 @@ LabelTTFTest::LabelTTFTest()
|
|||
|
||||
CCMenuItemFont::setFontSize(30);
|
||||
CCMenu *menu = CCMenu::create(
|
||||
CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)),
|
||||
CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)),
|
||||
CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)),
|
||||
CCMenuItemFont::create("Left", std::bind( &LabelTTFTest::setAlignmentLeft, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Center", std::bind( &LabelTTFTest::setAlignmentCenter, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Right", std::bind( &LabelTTFTest::setAlignmentRight, this, std::placeholders::_1)),
|
||||
NULL);
|
||||
menu->alignItemsVerticallyWithPadding(4);
|
||||
menu->setPosition(ccp(50, s.height / 2 - 20));
|
||||
this->addChild(menu);
|
||||
|
||||
menu = CCMenu::create(
|
||||
CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)),
|
||||
CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)),
|
||||
CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)),
|
||||
NULL);
|
||||
CCMenuItemFont::create("Top", std::bind( &LabelTTFTest::setAlignmentTop, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Middle", std::bind( &LabelTTFTest::setAlignmentMiddle, this, std::placeholders::_1)),
|
||||
CCMenuItemFont::create("Bottom", std::bind( &LabelTTFTest::setAlignmentBottom, this, std::placeholders::_1)),
|
||||
NULL);
|
||||
menu->alignItemsVerticallyWithPadding(4);
|
||||
menu->setPosition(ccp(s.width - 50, s.height / 2 - 20));
|
||||
this->addChild(menu);
|
||||
|
@ -1182,9 +1155,9 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
|
|||
this->m_pArrowsShouldRetain->retain();
|
||||
|
||||
CCMenuItemFont::setFontSize(20);
|
||||
CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged));
|
||||
CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", std::bind( &BitmapFontMultiLineAlignment::stringChanged, this, std::placeholders::_1));
|
||||
CCMenu *stringMenu = CCMenu::create(longSentences, lineBreaks, mixed, NULL);
|
||||
stringMenu->alignItemsVertically();
|
||||
|
||||
|
@ -1196,9 +1169,9 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment()
|
|||
|
||||
CCMenuItemFont::setFontSize(30);
|
||||
|
||||
CCMenuItemFont *left = CCMenuItemFont::create("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *center = CCMenuItemFont::create("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *right = CCMenuItemFont::create("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged));
|
||||
CCMenuItemFont *left = CCMenuItemFont::create("Left", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *center = CCMenuItemFont::create("Center", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenuItemFont *right = CCMenuItemFont::create("Right", std::bind( &BitmapFontMultiLineAlignment::alignmentChanged, this, std::placeholders::_1));
|
||||
CCMenu *alignmentMenu = CCMenu::create(left, center, right, NULL);
|
||||
alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding);
|
||||
|
||||
|
@ -1497,7 +1470,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
addChild(layer, -10);
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
|
||||
ccColor3B tintColorRed = { 255, 0, 0 };
|
||||
ccColor3B tintColorYellow = { 255, 255, 0 };
|
||||
ccColor3B tintColorBlue = { 0, 0, 255 };
|
||||
|
@ -1506,9 +1479,6 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
|
||||
CCSize shadowOffset(12.0, 12.0);
|
||||
|
||||
// create the label shadow only
|
||||
CCLabelTTF* fontShadow = new CCLabelTTF();
|
||||
|
||||
ccFontDefinition shadowTextDef;
|
||||
shadowTextDef.m_fontSize = 20;
|
||||
shadowTextDef.m_fontName = std::string("Marker Felt");
|
||||
|
@ -1519,17 +1489,16 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
shadowTextDef.m_shadow.m_shadowBlur = 1.0;
|
||||
shadowTextDef.m_fontFillColor = tintColorRed;
|
||||
|
||||
fontShadow->initWithStringAndTextDefinition("Shadow Only Red Text", shadowTextDef);
|
||||
// shadow only label
|
||||
CCLabelTTF* fontShadow = CCLabelTTF::createWithFontDefinition("Shadow Only Red Text", shadowTextDef);
|
||||
|
||||
// add label to the scene
|
||||
this->addChild(fontShadow);
|
||||
fontShadow->setPosition(ccp(s.width/2,s.height/4*2.5));
|
||||
|
||||
|
||||
|
||||
// create the label stroke only
|
||||
CCLabelTTF* fontStroke = new CCLabelTTF();
|
||||
|
||||
|
||||
// create the stroke only label
|
||||
ccFontDefinition strokeTextDef;
|
||||
strokeTextDef.m_fontSize = 20;
|
||||
strokeTextDef.m_fontName = std::string("Marker Felt");
|
||||
|
@ -1540,7 +1509,8 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
|
||||
strokeTextDef.m_fontFillColor = tintColorYellow;
|
||||
|
||||
fontStroke->initWithStringAndTextDefinition("Stroke Only Yellow Text", strokeTextDef);
|
||||
// stroke only label
|
||||
CCLabelTTF* fontStroke = CCLabelTTF::createWithFontDefinition("Stroke Only Yellow Text", strokeTextDef);
|
||||
|
||||
// add label to the scene
|
||||
this->addChild(fontStroke);
|
||||
|
@ -1549,8 +1519,6 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
|
||||
|
||||
// create the label stroke and shadow
|
||||
CCLabelTTF* fontStrokeAndShadow = new CCLabelTTF();
|
||||
|
||||
ccFontDefinition strokeShaodwTextDef;
|
||||
strokeShaodwTextDef.m_fontSize = 20;
|
||||
strokeShaodwTextDef.m_fontName = std::string("Marker Felt");
|
||||
|
@ -1566,13 +1534,16 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
|
||||
|
||||
strokeShaodwTextDef.m_fontFillColor = tintColorBlue;
|
||||
|
||||
fontStrokeAndShadow->initWithStringAndTextDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef);
|
||||
|
||||
// shadow + stroke label
|
||||
CCLabelTTF* fontStrokeAndShadow = CCLabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef);
|
||||
|
||||
// add label to the scene
|
||||
this->addChild(fontStrokeAndShadow);
|
||||
fontStrokeAndShadow->setPosition(ccp(s.width/2,s.height/4*1.1));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
std::string TTFFontShadowAndStroke::title()
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#define _ATLAS_TEST_H_
|
||||
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class AtlasDemo : public CCLayer
|
||||
class AtlasDemo : public BaseTest
|
||||
{
|
||||
protected:
|
||||
|
||||
|
|
|
@ -6,36 +6,21 @@ enum
|
|||
kTagLayer = 1,
|
||||
};
|
||||
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityA);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityB);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingOpacityC);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorA);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorB);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestCascadingColorC);
|
||||
TESTLAYER_CREATE_FUNC(LayerTest1);
|
||||
TESTLAYER_CREATE_FUNC(LayerTest2);
|
||||
TESTLAYER_CREATE_FUNC(LayerTestBlend);
|
||||
TESTLAYER_CREATE_FUNC(LayerGradient);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointPos);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointRot);
|
||||
TESTLAYER_CREATE_FUNC(LayerIgnoreAnchorPointScale);
|
||||
TESTLAYER_CREATE_FUNC(LayerExtendedBlendOpacityTest);
|
||||
|
||||
static NEWTESTFUNC createFunctions[] = {
|
||||
CF(LayerTestCascadingOpacityA),
|
||||
CF(LayerTestCascadingOpacityB),
|
||||
CF(LayerTestCascadingOpacityC),
|
||||
CF(LayerTestCascadingColorA),
|
||||
CF(LayerTestCascadingColorB),
|
||||
CF(LayerTestCascadingColorC),
|
||||
CF(LayerTest1),
|
||||
CF(LayerTest2),
|
||||
CF(LayerTestBlend),
|
||||
CF(LayerGradient),
|
||||
CF(LayerIgnoreAnchorPointPos),
|
||||
CF(LayerIgnoreAnchorPointRot),
|
||||
CF(LayerIgnoreAnchorPointScale),
|
||||
CF(LayerExtendedBlendOpacityTest)
|
||||
static std::function<CCLayer*()> createFunctions[] = {
|
||||
CL(LayerTestCascadingOpacityA),
|
||||
CL(LayerTestCascadingOpacityB),
|
||||
CL(LayerTestCascadingOpacityC),
|
||||
CL(LayerTestCascadingColorA),
|
||||
CL(LayerTestCascadingColorB),
|
||||
CL(LayerTestCascadingColorC),
|
||||
CL(LayerTest1),
|
||||
CL(LayerTest2),
|
||||
CL(LayerTestBlend),
|
||||
CL(LayerGradient),
|
||||
CL(LayerIgnoreAnchorPointPos),
|
||||
CL(LayerIgnoreAnchorPointRot),
|
||||
CL(LayerIgnoreAnchorPointScale),
|
||||
CL(LayerExtendedBlendOpacityTest)
|
||||
};
|
||||
|
||||
static int sceneIdx=-1;
|
||||
|
@ -99,34 +84,7 @@ std::string LayerTest::title()
|
|||
|
||||
void LayerTest::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
string subtitle_ = subtitle();
|
||||
if (subtitle_.size() > 0)
|
||||
{
|
||||
CCLabelTTF *l = CCLabelTTF::create(subtitle_.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition(ccp(s.width / 2, s.height - 80));
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(LayerTest::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(LayerTest::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(LayerTest::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition( CCPointZero );
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void LayerTest::restartCallback(CCObject* pSender)
|
||||
|
@ -637,7 +595,7 @@ LayerGradient::LayerGradient()
|
|||
CCLabelTTF *label2 = CCLabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26);
|
||||
CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1);
|
||||
CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithTarget(this, menu_selector(LayerGradient::toggleItem), item1, item2, NULL);
|
||||
CCMenuItemToggle *item = CCMenuItemToggle::createWithCallback( std::bind(&LayerGradient::toggleItem, this, std::placeholders::_1), item1, item2, NULL);
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
addChild(menu);
|
||||
|
@ -702,7 +660,7 @@ void LayerIgnoreAnchorPointPos::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toggle ignore anchor point", std::bind( &LayerIgnoreAnchorPointPos::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -750,7 +708,7 @@ void LayerIgnoreAnchorPointRot::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", std::bind( &LayerIgnoreAnchorPointRot::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
@ -801,7 +759,7 @@ void LayerIgnoreAnchorPointScale::onEnter()
|
|||
CCSize lsize = l->getContentSize();
|
||||
child->setPosition(ccp(lsize.width/2, lsize.height/2));
|
||||
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle));
|
||||
CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", std::bind( &LayerIgnoreAnchorPointScale::onToggle, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
////----#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class LayerTest : public CCLayer
|
||||
class LayerTest : public BaseTest
|
||||
{
|
||||
protected:
|
||||
std::string m_strTitle;
|
||||
|
|
|
@ -34,42 +34,43 @@ MenuLayerMainMenu::MenuLayerMainMenu()
|
|||
CCSprite* spriteSelected = CCSprite::create(s_MenuItem, CCRectMake(0,23*1,115,23));
|
||||
CCSprite* spriteDisabled = CCSprite::create(s_MenuItem, CCRectMake(0,23*0,115,23));
|
||||
|
||||
CCMenuItemSprite* item1 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayerMainMenu::menuCallback) );
|
||||
CCMenuItemSprite* item1 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, std::bind(&MenuLayerMainMenu::menuCallback, this, std::placeholders::_1) );
|
||||
|
||||
// Image Item
|
||||
CCMenuItem* item2 = CCMenuItemImage::create(s_SendScore, s_PressSendScore, this, menu_selector(MenuLayerMainMenu::menuCallback2) );
|
||||
CCMenuItem* item2 = CCMenuItemImage::create(s_SendScore, s_PressSendScore, std::bind(&MenuLayerMainMenu::menuCallback2, this, std::placeholders::_1) );
|
||||
|
||||
// Label Item (LabelAtlas)
|
||||
CCLabelAtlas* labelAtlas = CCLabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.');
|
||||
CCMenuItemLabel* item3 = CCMenuItemLabel::create(labelAtlas, this, menu_selector(MenuLayerMainMenu::menuCallbackDisabled) );
|
||||
CCMenuItemLabel* item3 = CCMenuItemLabel::create(labelAtlas, std::bind(&MenuLayerMainMenu::menuCallbackDisabled, this, std::placeholders::_1) );
|
||||
item3->setDisabledColor( ccc3(32,32,64) );
|
||||
item3->setColor( ccc3(200,200,255) );
|
||||
|
||||
// Font Item
|
||||
CCMenuItemFont *item4 = CCMenuItemFont::create("I toggle enable items", this, menu_selector(MenuLayerMainMenu::menuCallbackEnable) );
|
||||
CCMenuItemFont *item4 = CCMenuItemFont::create("I toggle enable items", [&](CCObject *sender) {
|
||||
m_disabledItem->setEnabled(! m_disabledItem->isEnabled() );
|
||||
});
|
||||
|
||||
item4->setFontSizeObj(20);
|
||||
item4->setFontName("Marker Felt");
|
||||
|
||||
// Label Item (CCLabelBMFont)
|
||||
CCLabelBMFont* label = CCLabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt");
|
||||
CCMenuItemLabel* item5 = CCMenuItemLabel::create(label, this, menu_selector(MenuLayerMainMenu::menuCallbackConfig));
|
||||
CCMenuItemLabel* item5 = CCMenuItemLabel::create(label, std::bind(&MenuLayerMainMenu::menuCallbackConfig, this, std::placeholders::_1));
|
||||
|
||||
// Testing issue #500
|
||||
item5->setScale( 0.8f );
|
||||
|
||||
// Events
|
||||
CCMenuItemFont::setFontName("Marker Felt");
|
||||
CCMenuItemFont *item6 = CCMenuItemFont::create("Priority Test", this, menu_selector(MenuLayerMainMenu::menuCallbackPriorityTest));
|
||||
CCMenuItemFont *item6 = CCMenuItemFont::create("Priority Test", std::bind(&MenuLayerMainMenu::menuCallbackPriorityTest, this, std::placeholders::_1));
|
||||
|
||||
// Bugs Item
|
||||
CCMenuItemFont *item7 = CCMenuItemFont::create("Bugs", this, menu_selector(MenuLayerMainMenu::menuCallbackBugsTest));
|
||||
CCMenuItemFont *item7 = CCMenuItemFont::create("Bugs", std::bind(&MenuLayerMainMenu::menuCallbackBugsTest, this, std::placeholders::_1));
|
||||
|
||||
// Font Item
|
||||
CCMenuItemFont* item8 = CCMenuItemFont::create("Quit", this, menu_selector(MenuLayerMainMenu::onQuit));
|
||||
CCMenuItemFont* item8 = CCMenuItemFont::create("Quit", std::bind(&MenuLayerMainMenu::onQuit, this, std::placeholders::_1));
|
||||
|
||||
CCMenuItemFont* item9 = CCMenuItemFont::create("Remove menu item when moving", this,
|
||||
menu_selector(MenuLayerMainMenu::menuMovingCallback));
|
||||
CCMenuItemFont* item9 = CCMenuItemFont::create("Remove menu item when moving", std::bind(&MenuLayerMainMenu::menuMovingCallback, this, std::placeholders::_1));
|
||||
|
||||
CCActionInterval* color_action = CCTintBy::create(0.5f, 0, -255, -255);
|
||||
CCActionInterval* color_back = color_action->reverse();
|
||||
|
@ -162,11 +163,6 @@ void MenuLayerMainMenu::menuCallbackDisabled(CCObject* sender)
|
|||
CCLog("TOUCHES DISABLED FOR 5 SECONDS");
|
||||
}
|
||||
|
||||
void MenuLayerMainMenu::menuCallbackEnable(CCObject* sender)
|
||||
{
|
||||
m_disabledItem->setEnabled(! m_disabledItem->isEnabled() );
|
||||
}
|
||||
|
||||
void MenuLayerMainMenu::menuCallback2(CCObject* sender)
|
||||
{
|
||||
((CCLayerMultiplex*)m_pParent)->switchTo(2);
|
||||
|
@ -202,9 +198,9 @@ MenuLayer2::MenuLayer2()
|
|||
{
|
||||
for( int i=0;i < 2;i++ )
|
||||
{
|
||||
CCMenuItemImage* item1 = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback));
|
||||
CCMenuItemImage* item2 = CCMenuItemImage::create(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) );
|
||||
CCMenuItemImage* item3 = CCMenuItemImage::create(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) );
|
||||
CCMenuItemImage* item1 = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect, std::bind( &MenuLayer2::menuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemImage* item2 = CCMenuItemImage::create(s_HighNormal, s_HighSelect, std::bind( &MenuLayer2::menuCallbackOpacity, this, std::placeholders::_1));
|
||||
CCMenuItemImage* item3 = CCMenuItemImage::create(s_AboutNormal, s_AboutSelect, std::bind( &MenuLayer2::menuCallbackAlign, this, std::placeholders::_1));
|
||||
|
||||
item1->setScaleX( 1.5f );
|
||||
item2->setScaleX( 0.5f );
|
||||
|
@ -313,15 +309,23 @@ MenuLayer3::MenuLayer3()
|
|||
CCMenuItemFont::setFontSize(28);
|
||||
|
||||
CCLabelBMFont* label = CCLabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
|
||||
CCMenuItemLabel* item1 = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer3::menuCallback2) );
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create("--- Go Back ---", this, menu_selector(MenuLayer3::menuCallback) );
|
||||
|
||||
CCMenuItemLabel* item1 = CCMenuItemLabel::create(label, [&](CCObject *sender) {
|
||||
//CCLOG("Label clicked. Toogling AtlasSprite");
|
||||
m_disabledItem->setEnabled( ! m_disabledItem->isEnabled() );
|
||||
m_disabledItem->stopAllActions();
|
||||
});
|
||||
CCMenuItemFont* item2 = CCMenuItemFont::create("--- Go Back ---", [&](CCObject *sender) {
|
||||
((CCLayerMultiplex*)m_pParent)->switchTo(0);
|
||||
});
|
||||
|
||||
CCSprite *spriteNormal = CCSprite::create(s_MenuItem, CCRectMake(0,23*2,115,23));
|
||||
CCSprite *spriteSelected = CCSprite::create(s_MenuItem, CCRectMake(0,23*1,115,23));
|
||||
CCSprite *spriteDisabled = CCSprite::create(s_MenuItem, CCRectMake(0,23*0,115,23));
|
||||
|
||||
|
||||
CCMenuItemSprite* item3 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer3::menuCallback3));
|
||||
CCMenuItemSprite* item3 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, [](CCObject *sender) {
|
||||
CCLog("sprite clicked!");
|
||||
});
|
||||
m_disabledItem = item3; item3->retain();
|
||||
m_disabledItem->setEnabled( false );
|
||||
|
||||
|
@ -355,23 +359,6 @@ MenuLayer3::~MenuLayer3()
|
|||
m_disabledItem->release();
|
||||
}
|
||||
|
||||
void MenuLayer3::menuCallback(CCObject* sender)
|
||||
{
|
||||
((CCLayerMultiplex*)m_pParent)->switchTo(0);
|
||||
}
|
||||
|
||||
void MenuLayer3::menuCallback2(CCObject* sender)
|
||||
{
|
||||
//CCLOG("Label clicked. Toogling AtlasSprite");
|
||||
m_disabledItem->setEnabled( ! m_disabledItem->isEnabled() );
|
||||
m_disabledItem->stopAllActions();
|
||||
}
|
||||
|
||||
void MenuLayer3::menuCallback3(CCObject* sender)
|
||||
{
|
||||
//CCLOG("MenuItemSprite clicked");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// MenuLayer4
|
||||
|
@ -385,8 +372,7 @@ MenuLayer4::MenuLayer4()
|
|||
title1->setEnabled(false);
|
||||
CCMenuItemFont::setFontName( "Marker Felt" );
|
||||
CCMenuItemFont::setFontSize(34);
|
||||
CCMenuItemToggle* item1 = CCMenuItemToggle::createWithTarget(this,
|
||||
menu_selector(MenuLayer4::menuCallback),
|
||||
CCMenuItemToggle* item1 = CCMenuItemToggle::createWithCallback( std::bind( &MenuLayer4::menuCallback, this, std::placeholders::_1),
|
||||
CCMenuItemFont::create( "On" ),
|
||||
CCMenuItemFont::create( "Off"),
|
||||
NULL );
|
||||
|
@ -397,8 +383,7 @@ MenuLayer4::MenuLayer4()
|
|||
title2->setEnabled(false);
|
||||
CCMenuItemFont::setFontName( "Marker Felt" );
|
||||
CCMenuItemFont::setFontSize(34);
|
||||
CCMenuItemToggle *item2 = CCMenuItemToggle::createWithTarget(this,
|
||||
menu_selector(MenuLayer4::menuCallback),
|
||||
CCMenuItemToggle *item2 = CCMenuItemToggle::createWithCallback(std::bind( &MenuLayer4::menuCallback, this, std::placeholders::_1),
|
||||
CCMenuItemFont::create( "On" ),
|
||||
CCMenuItemFont::create( "Off"),
|
||||
NULL );
|
||||
|
@ -409,8 +394,7 @@ MenuLayer4::MenuLayer4()
|
|||
title3->setEnabled( false );
|
||||
CCMenuItemFont::setFontName( "Marker Felt" );
|
||||
CCMenuItemFont::setFontSize(34);
|
||||
CCMenuItemToggle *item3 = CCMenuItemToggle::createWithTarget(this,
|
||||
menu_selector(MenuLayer4::menuCallback),
|
||||
CCMenuItemToggle *item3 = CCMenuItemToggle::createWithCallback(std::bind( &MenuLayer4::menuCallback, this, std::placeholders::_1),
|
||||
CCMenuItemFont::create( "High" ),
|
||||
CCMenuItemFont::create( "Low" ),
|
||||
NULL );
|
||||
|
@ -421,8 +405,7 @@ MenuLayer4::MenuLayer4()
|
|||
title4->setEnabled(false);
|
||||
CCMenuItemFont::setFontName( "Marker Felt" );
|
||||
CCMenuItemFont::setFontSize(34);
|
||||
CCMenuItemToggle *item4 = CCMenuItemToggle::createWithTarget(this,
|
||||
menu_selector(MenuLayer4::menuCallback),
|
||||
CCMenuItemToggle *item4 = CCMenuItemToggle::createWithCallback(std::bind( &MenuLayer4::menuCallback, this, std::placeholders::_1),
|
||||
CCMenuItemFont::create( "Off" ),
|
||||
NULL );
|
||||
|
||||
|
@ -443,7 +426,7 @@ MenuLayer4::MenuLayer4()
|
|||
CCMenuItemFont::setFontSize( 34 );
|
||||
|
||||
CCLabelBMFont *label = CCLabelBMFont::create( "go back", "fonts/bitmapFontTest3.fnt" );
|
||||
CCMenuItemLabel* back = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer4::backCallback) );
|
||||
CCMenuItemLabel* back = CCMenuItemLabel::create(label, std::bind( &MenuLayer4::backCallback, this, std::placeholders::_1) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(
|
||||
title1, title2,
|
||||
|
@ -484,8 +467,16 @@ MenuLayerPriorityTest::MenuLayerPriorityTest()
|
|||
// Menu 1
|
||||
CCMenuItemFont::setFontName("Marker Felt");
|
||||
CCMenuItemFont::setFontSize(18);
|
||||
CCMenuItemFont *item1 = CCMenuItemFont::create("Return to Main Menu", this, menu_selector(MenuLayerPriorityTest::menuCallback));
|
||||
CCMenuItemFont *item2 = CCMenuItemFont::create("Disable menu for 5 seconds", this, menu_selector(MenuLayerPriorityTest::disableMenuCallback));
|
||||
CCMenuItemFont *item1 = CCMenuItemFont::create("Return to Main Menu", std::bind( &MenuLayerPriorityTest::menuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemFont *item2 = CCMenuItemFont::create("Disable menu for 5 seconds", [&](CCObject *sender) {
|
||||
m_pMenu1->setEnabled(false);
|
||||
CCDelayTime *wait = CCDelayTime::create(5);
|
||||
CCCallFunc *enable = CCCallFunc::create( [&]() {
|
||||
m_pMenu1->setEnabled(true);
|
||||
});
|
||||
CCSequence* seq = CCSequence::create(wait, enable, NULL);
|
||||
m_pMenu1->runAction(seq);
|
||||
});
|
||||
|
||||
|
||||
m_pMenu1->addChild(item1);
|
||||
|
@ -498,7 +489,16 @@ MenuLayerPriorityTest::MenuLayerPriorityTest()
|
|||
// Menu 2
|
||||
m_bPriority = true;
|
||||
CCMenuItemFont::setFontSize(48);
|
||||
item1 = CCMenuItemFont::create("Toggle priority", this, menu_selector(MenuLayerPriorityTest::togglePriorityCallback));
|
||||
item1 = CCMenuItemFont::create("Toggle priority", [&](CCObject *sender) {
|
||||
if( m_bPriority) {
|
||||
m_pMenu2->setHandlerPriority(kCCMenuHandlerPriority + 20);
|
||||
m_bPriority = false;
|
||||
} else {
|
||||
m_pMenu2->setHandlerPriority(kCCMenuHandlerPriority - 20);
|
||||
m_bPriority = true;
|
||||
}
|
||||
});
|
||||
|
||||
item1->setColor(ccc3(0,0,255));
|
||||
m_pMenu2->addChild(item1);
|
||||
addChild(m_pMenu2);
|
||||
|
@ -515,38 +515,12 @@ void MenuLayerPriorityTest::menuCallback(CCObject* pSender)
|
|||
// [[CCDirector sharedDirector] popScene];
|
||||
}
|
||||
|
||||
void MenuLayerPriorityTest::disableMenuCallback(CCObject* pSender)
|
||||
{
|
||||
m_pMenu1->setEnabled(false);
|
||||
CCDelayTime *wait = CCDelayTime::create(5);
|
||||
CCCallFunc *enable = CCCallFunc::create(this, callfunc_selector(MenuLayerPriorityTest::enableMenuCallback));
|
||||
|
||||
CCSequence* seq = CCSequence::create(wait, enable, NULL);
|
||||
m_pMenu1->runAction(seq);
|
||||
}
|
||||
|
||||
void MenuLayerPriorityTest::enableMenuCallback()
|
||||
{
|
||||
m_pMenu1->setEnabled(true);
|
||||
}
|
||||
|
||||
void MenuLayerPriorityTest::togglePriorityCallback(CCObject* pSender)
|
||||
{
|
||||
if( m_bPriority) {
|
||||
m_pMenu2->setHandlerPriority(kCCMenuHandlerPriority + 20);
|
||||
m_bPriority = false;
|
||||
} else {
|
||||
m_pMenu2->setHandlerPriority(kCCMenuHandlerPriority - 20);
|
||||
m_bPriority = true;
|
||||
}
|
||||
}
|
||||
|
||||
// BugsTest
|
||||
BugsTest::BugsTest()
|
||||
{
|
||||
CCMenuItemFont *issue1410 = CCMenuItemFont::create("Issue 1410", this, menu_selector(BugsTest::issue1410MenuCallback));
|
||||
CCMenuItemFont *issue1410_2 = CCMenuItemFont::create("Issue 1410 #2", this, menu_selector(BugsTest::issue1410v2MenuCallback));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("Back", this, menu_selector(BugsTest::backMenuCallback));
|
||||
CCMenuItemFont *issue1410 = CCMenuItemFont::create("Issue 1410", std::bind( &BugsTest::issue1410MenuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemFont *issue1410_2 = CCMenuItemFont::create("Issue 1410 #2", std::bind( &BugsTest::issue1410v2MenuCallback, this, std::placeholders::_1));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("Back", std::bind( &BugsTest::backMenuCallback, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(issue1410, issue1410_2, back, NULL);
|
||||
addChild(menu);
|
||||
|
@ -590,7 +564,7 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
|
|||
item = CCMenuItemFont::create("item 1");
|
||||
item->retain();
|
||||
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("go back", this, menu_selector(RemoveMenuItemWhenMove::goBack));
|
||||
CCMenuItemFont *back = CCMenuItemFont::create("go back", std::bind( &RemoveMenuItemWhenMove::goBack, this, std::placeholders::_1));
|
||||
|
||||
CCMenu *menu = CCMenu::create(item, back, NULL);
|
||||
addChild(menu);
|
||||
|
|
|
@ -23,7 +23,6 @@ public:
|
|||
void menuCallback(CCObject* pSender);
|
||||
void menuCallbackConfig(CCObject* pSender);
|
||||
void menuCallbackDisabled(CCObject* pSender);
|
||||
void menuCallbackEnable(CCObject* pSender);
|
||||
void menuCallback2(CCObject* pSender);
|
||||
void menuCallbackPriorityTest(CCObject* pSender);
|
||||
void menuCallbackBugsTest(CCObject *pSender);
|
||||
|
@ -63,11 +62,6 @@ public:
|
|||
MenuLayer3(void);
|
||||
~MenuLayer3();
|
||||
|
||||
public:
|
||||
void menuCallback(CCObject* pSender);
|
||||
void menuCallback2(CCObject* pSender);
|
||||
void menuCallback3(CCObject* pSender);
|
||||
|
||||
//CREATE_NODE(MenuLayer3);
|
||||
};
|
||||
|
||||
|
@ -91,9 +85,6 @@ public:
|
|||
~MenuLayerPriorityTest();
|
||||
|
||||
void menuCallback(CCObject* pSender);
|
||||
void disableMenuCallback(CCObject* pSender);
|
||||
void enableMenuCallback();
|
||||
void togglePriorityCallback(CCObject* pSender);
|
||||
private:
|
||||
CCMenu* m_pMenu1;
|
||||
CCMenu* m_pMenu2;
|
||||
|
|
|
@ -228,36 +228,11 @@ std::string MotionStreakTest::subtitle()
|
|||
|
||||
void MotionStreakTest::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
BaseTest::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label, 0, kTagLabel);
|
||||
label->setPosition(ccp(s.width/2, s.height-50));
|
||||
|
||||
string subTitle = this->subtitle();
|
||||
if (subTitle.size() > 0)
|
||||
{
|
||||
CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition(ccp(s.width/2, s.height-80));
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(MotionStreakTest::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition(CCPointZero);
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
|
||||
CCMenuItemToggle *itemMode = CCMenuItemToggle::createWithTarget(this, menu_selector(MotionStreakTest::modeCallback),
|
||||
CCMenuItemToggle *itemMode = CCMenuItemToggle::createWithCallback( std::bind(&MotionStreakTest::modeCallback, this, std::placeholders::_1),
|
||||
CCMenuItemFont::create("Use High Quality Mode"),
|
||||
CCMenuItemFont::create("Use Fast Mode"),
|
||||
NULL);
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
////----#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
//USING_NS_CC;
|
||||
|
||||
class MotionStreakTest : public CCLayer
|
||||
class MotionStreakTest : public BaseTest
|
||||
{
|
||||
public:
|
||||
MotionStreakTest(void);
|
||||
|
|
|
@ -100,34 +100,7 @@ std::string TestCocosNodeDemo::subtitle()
|
|||
|
||||
void TestCocosNodeDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32);
|
||||
addChild(label, 10);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
std::string strSubtitle = subtitle();
|
||||
if( ! strSubtitle.empty() )
|
||||
{
|
||||
CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
|
||||
addChild(l, 1);
|
||||
l->setPosition( ccp(s.width/2, s.height-80) );
|
||||
}
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestCocosNodeDemo::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1,s_pPathR2, this, menu_selector(TestCocosNodeDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestCocosNodeDemo::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition( CCPointZero );
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 11);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void TestCocosNodeDemo::restartCallback(CCObject* pSender)
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
////----#include "cocos2d.h"
|
||||
#include "../testBasic.h"
|
||||
#include "../BaseTest.h"
|
||||
|
||||
class TestCocosNodeDemo : public CCLayer
|
||||
class TestCocosNodeDemo : public BaseTest
|
||||
{
|
||||
public:
|
||||
TestCocosNodeDemo(void);
|
||||
|
|
|
@ -216,26 +216,7 @@ std::string ParallaxDemo::title()
|
|||
|
||||
void ParallaxDemo::onEnter()
|
||||
{
|
||||
CCLayer::onEnter();
|
||||
|
||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
|
||||
addChild(label, 1);
|
||||
label->setPosition( ccp(s.width/2, s.height-50) );
|
||||
|
||||
CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ParallaxDemo::backCallback) );
|
||||
CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ParallaxDemo::restartCallback) );
|
||||
CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ParallaxDemo::nextCallback) );
|
||||
|
||||
CCMenu *menu = CCMenu::create(item1, item2, item3, NULL);
|
||||
|
||||
menu->setPosition( CCPointZero );
|
||||
item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
|
||||
|
||||
addChild(menu, 1);
|
||||
BaseTest::onEnter();
|
||||
}
|
||||
|
||||
void ParallaxDemo::restartCallback(CCObject* pSender)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue