Merge branch 'v3' into v3_dll

This commit is contained in:
Huabing.Xu 2014-07-16 11:15:16 +08:00
commit 0350186589
194 changed files with 11574 additions and 1342 deletions

View File

@ -828,6 +828,7 @@ Developers:
Added missing Text Font and Placeholder feature of EditBox for Mac platform
HttpRequest uses std::function as callback
EditBox: mac secure input
Fix a bug that can not get/set text in password mode on Mac OS X
iSevenDays
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
@ -896,7 +897,8 @@ Developers:
kyokomi
Fix the bug that UIButton doesn't support TTF font
Fix a but of TextReader
Fix a bug of TextReader
Fix a bug that UITextField doesn't support TTF font
gin0606
Add a new line at the end of a file

View File

@ -1,6 +1,7 @@
cocos2d-x-3.2 ??
[FIX] Animation3D: getOrCreate is deprecated and replaced with Animation3D::create
[FIX] Animate3D: setSpeed() accept negtive value, which means play reverse, getPlayback and setPlayBack are deprecated
[FIX] EditBox: can not set/get text in password mode on Mac OS X
[FIX] GLView: cursor position is not correct if design resolution is different from device resolution
[FIX] Label: color can not be set correctly if using system font
[FIX] Lua-binding: support UIVideoPlayer
@ -10,10 +11,12 @@ cocos2d-x-3.2 ??
[FIX] SpriteBatchNode: opacity can not work
[FIX] Sprite3D: may crash on Android if playing animation and replace Scene after come from background
[FIX] UIdget: opacity is wrong when replace texture
[FIX] UIText: can not wrap words automatically
[FIX] UITextField: keyboard can not hide if touching space outside of keyboard
[FIX] Others: don't release singleton objects correctly that are needed in the whole game, which will be treated
as memory leak when using VLD.
[FIX] Others: compiling error when building for iOS 64-bit devices with Xcode6 beta3
cocos2d-x-3.2rc0 Jul.7 2014

View File

@ -8,7 +8,7 @@ import shutil
from optparse import OptionParser
CPP_SAMPLES = ['cpp-empty-test', 'cpp-tests', 'game-controller-test']
LUA_SAMPLES = ['lua-empty-test', 'lua-tests']
LUA_SAMPLES = ['lua-empty-test', 'lua-tests', 'lua-game-controller-test']
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
def get_num_of_cpu():
@ -172,6 +172,10 @@ def copy_resources(target, app_android_root):
resources_dir = os.path.join(app_android_root, "../../../cpp-tests/Resources")
copy_files(resources_dir, assets_res_dir)
if target == "lua-game-controller-test":
print("coming generator game controller")
resources_dir = os.path.join(app_android_root, "../../../game-controller-test/Resources")
copy_files(resources_dir, assets_res_dir)
def build_samples(target,ndk_build_param,android_platform,build_mode):
@ -203,7 +207,8 @@ def build_samples(target,ndk_build_param,android_platform,build_mode):
"game-controller-test": "tests/game-controller-test/proj.android",
"cpp-tests": "tests/cpp-tests/proj.android",
"lua-empty-test": "tests/lua-empty-test/project/proj.android",
"lua-tests": "tests/lua-tests/project/proj.android"
"lua-tests": "tests/lua-tests/project/proj.android",
"lua-game-controller-test": "tests/lua-game-controller-test/project/proj.android"
}
for target in build_targets:

View File

@ -7475,15 +7475,6 @@
"\"$(SRCROOT)/../external/websockets/prebuilt/ios\"",
"\"$(SRCROOT)/../external/curl/prebuilt/ios\"",
);
"OTHER_LDFLAGS[arch=arm64]" = (
"-lcurl_arm64",
"-ljpeg_arm64",
"-lpng_arm64",
"-ltiff_arm64",
"-lwebp_arm64",
"-lwebsockets_arm64",
"-lfreetype_arm64",
);
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios";
@ -7515,15 +7506,6 @@
"\"$(SRCROOT)/../external/websockets/prebuilt/ios\"",
"\"$(SRCROOT)/../external/curl/prebuilt/ios\"",
);
"OTHER_LDFLAGS[arch=arm64]" = (
"-lcurl_arm64",
"-ljpeg_arm64",
"-lpng_arm64",
"-ltiff_arm64",
"-lwebp_arm64",
"-lwebsockets_arm64",
"-lfreetype_arm64",
);
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/websockets/include/ios $(SRCROOT)/../external/freetype2/include/ios $(SRCROOT)/../external/curl/include/ios $(SRCROOT)/../external/webp/include/ios $(SRCROOT)/../external/tiff/include/ios $(SRCROOT)/../external/jpeg/include/ios $(SRCROOT)/../external/png/include/ios";

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "15CBA015196EE56C005877BB"
BuildableName = "lua-game-controller-test iOS.app"
BlueprintName = "lua-game-controller-test iOS"
ReferencedContainer = "container:cocos2d_tests.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -89,10 +89,11 @@ public:
return nullptr;
}
protected:
CC_CONSTRUCTOR_ACCESS:
/** initializes the action */
bool initWithDuration(float d);
protected:
float _elapsed;
bool _firstTick;
};
@ -597,6 +598,8 @@ public:
CC_CONSTRUCTOR_ACCESS:
JumpTo() {}
virtual ~JumpTo() {}
private:
CC_DISALLOW_COPY_AND_ASSIGN(JumpTo);
};

View File

@ -194,8 +194,8 @@ bool DrawNode::init()
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
/** listen the event that coming to foreground on Android */
auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
/** listen the event that renderer was recreated on Android/WP8 */
this->init();
});

View File

@ -31,6 +31,7 @@
#include "base/CCEventDispatcher.h"
#include "base/CCEventType.h"
NS_CC_BEGIN
const int FontAtlas::CacheTextureWidth = 512;
@ -41,9 +42,9 @@ FontAtlas::FontAtlas(Font &theFont)
: _font(&theFont)
, _currentPageData(nullptr)
, _fontAscender(0)
, _toForegroundListener(nullptr)
, _toBackgroundListener(nullptr)
, _rendererRecreatedListener(nullptr)
, _antialiasEnabled(true)
, _rendererRecreate(false)
{
_font->retain();
@ -77,12 +78,12 @@ FontAtlas::FontAtlas(Font &theFont)
addTexture(texture,0);
texture->release();
#if CC_ENABLE_CACHE_TEXTURE_DATA
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
_toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(FontAtlas::listenToBackground, this));
eventDispatcher->addEventListenerWithFixedPriority(_toBackgroundListener, 1);
_toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(FontAtlas::listenToForeground, this));
eventDispatcher->addEventListenerWithFixedPriority(_toForegroundListener, 1);
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(FontAtlas::listenRendererRecreated, this));
eventDispatcher->addEventListenerWithFixedPriority(_rendererRecreatedListener, 1);
#endif
}
}
@ -91,19 +92,11 @@ FontAtlas::~FontAtlas()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf)
if (fontTTf && _rendererRecreatedListener)
{
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
if (_toForegroundListener)
{
eventDispatcher->removeEventListener(_toForegroundListener);
_toForegroundListener = nullptr;
}
if (_toBackgroundListener)
{
eventDispatcher->removeEventListener(_toBackgroundListener);
_toBackgroundListener = nullptr;
}
eventDispatcher->removeEventListener(_rendererRecreatedListener);
_rendererRecreatedListener = nullptr;
}
#endif
@ -149,11 +142,10 @@ void FontAtlas::purgeTexturesAtlas()
}
}
void FontAtlas::listenToBackground(EventCustom *event)
void FontAtlas::listenRendererRecreated(EventCustom *event)
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf && _atlasTextures.size() > 1)
if (fontTTf)
{
for( auto &item: _atlasTextures)
{
@ -171,30 +163,12 @@ void FontAtlas::listenToBackground(EventCustom *event)
_currentPage = 0;
_currentPageOrigX = 0;
_currentPageOrigY = 0;
}
#endif
}
void FontAtlas::listenToForeground(EventCustom *event)
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if (fontTTf)
{
if (_currentPageOrigX == 0 && _currentPageOrigY == 0)
{
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
}
else
{
auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
}
_rendererRecreate = true;
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
_rendererRecreate = false;
}
#endif
}
void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition)
@ -223,7 +197,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
if(fontTTf == nullptr)
return false;
size_t length = utf16String.length();
float offsetAdjust = _letterPadding / 2;
@ -333,17 +307,25 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
if(existNewLetter)
{
unsigned char *data = nullptr;
if(pixelFormat == Texture2D::PixelFormat::AI88)
if (_rendererRecreate)
{
data = _currentPageData + CacheTextureWidth * (int)startY * 2;
}
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
}
else
{
data = _currentPageData + CacheTextureWidth * (int)startY;
unsigned char *data = nullptr;
if(pixelFormat == Texture2D::PixelFormat::AI88)
{
data = _currentPageData + CacheTextureWidth * (int)startY * 2;
}
else
{
data = _currentPageData + CacheTextureWidth * (int)startY;
}
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
}
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
}
return true;
}

View File

@ -84,15 +84,10 @@ public:
Texture2D* getTexture(int slot);
const Font* getFont() const;
/** Listen "come to background" message, and clear the texture atlas.
It only has effect on Android.
/** listen the event that renderer was recreated on Android/WP8
It only has effect on Android and WP8.
*/
void listenToBackground(EventCustom *event);
/** Listen "come to foreground" message and restore the texture atlas.
It only has effect on Android.
*/
void listenToForeground(EventCustom *event);
void listenRendererRecreated(EventCustom *event);
/** Removes textures atlas.
It will purge the textures atlas and if multiple texture exist in the FontAtlas.
@ -129,9 +124,9 @@ private:
bool _makeDistanceMap;
int _fontAscender;
EventListenerCustom* _toBackgroundListener;
EventListenerCustom* _toForegroundListener;
EventListenerCustom* _rendererRecreatedListener;
bool _antialiasEnabled;
bool _rendererRecreate;
};

View File

@ -22,11 +22,11 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include <sstream>
#include "2d/CCFontAtlasCache.h"
#include <iostream>
#include <sstream>
#include "2d/CCFontFNT.h"
#include "2d/CCFontFreeType.h"
#include "CCFontCharMap.h"

View File

@ -26,7 +26,6 @@
#ifndef _CCFontAtlasCache_h_
#define _CCFontAtlasCache_h_
#include <iostream>
#include <unordered_map>
#include "2d/CCFontAtlas.h"

View File

@ -266,20 +266,13 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
reset();
#if CC_ENABLE_CACHE_TEXTURE_DATA
auto toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF)
{
_batchNodes.clear();
_batchNodes.push_back(this);
Node::removeAllChildrenWithCleanup(true);
}
});
_eventDispatcher->addEventListenerWithSceneGraphPriority(toBackgroundListener, this);
#endif
auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, [this](EventCustom* event){
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
{
Node::removeAllChildrenWithCleanup(true);
_batchNodes.clear();
_batchNodes.push_back(this);
alignText();
}
});

View File

@ -839,6 +839,18 @@ MenuItemToggle * MenuItemToggle::createWithTarget(Ref* target, SEL_MenuHandler s
return ret;
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MenuItemToggle * MenuItemToggle::createWithCallbackVA(const ccMenuCallback &callback, MenuItem* item, ...)
{
va_list args;
va_start(args, item);
MenuItemToggle *ret = new MenuItemToggle();
ret->initWithCallback(callback, item, args);
ret->autorelease();
va_end(args);
return ret;
}
#else
MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callback, MenuItem* item, ...)
{
va_list args;
@ -849,6 +861,7 @@ MenuItemToggle * MenuItemToggle::createWithCallback(const ccMenuCallback &callba
va_end(args);
return ret;
}
#endif
MenuItemToggle * MenuItemToggle::create()
{

View File

@ -478,7 +478,25 @@ public:
/** creates a menu item from a Array with a callable object */
static MenuItemToggle * createWithCallback(const ccMenuCallback& callback, const Vector<MenuItem*>& menuItems);
/** creates a menu item from a list of items with a callable object */
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
typedef MenuItem* M;
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, NULL); }
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, M m1, M m2, M m3, M m4, M m5, M m6, M m7, M m8, M m9, M m10, std::nullptr_t listEnd) { return createWithCallbackVA(callback, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, NULL); }
// On WP8 for lists longer than 10 items, use createWithArray or variadicCreate with NULL as the last argument
static MenuItemToggle* createWithCallbackVA(const ccMenuCallback& callback, M item, ...);
#else
static MenuItemToggle* createWithCallback(const ccMenuCallback& callback, MenuItem* item, ...) CC_REQUIRES_NULL_TERMINATION;
#endif
/** creates a menu item with no target/selector and no items */
static MenuItemToggle* create();
/** creates a menu item with a item */

View File

@ -135,7 +135,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
#if CC_ENABLE_CACHE_TEXTURE_DATA
// Need to listen the event only when not use batchnode, because it will use VBO
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(ParticleSystemQuad::listenBackToForeground, this));
auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(ParticleSystemQuad::listenRendererRecreated, this));
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
#endif
@ -509,7 +509,7 @@ void ParticleSystemQuad::setupVBO()
CHECK_GL_ERROR_DEBUG();
}
void ParticleSystemQuad::listenBackToForeground(EventCustom* event)
void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
{
if (Configuration::getInstance()->supportsShareableVAO())
{

View File

@ -81,11 +81,11 @@ public:
*/
void setTextureWithRect(Texture2D *texture, const Rect& rect);
/** listen the event that coming to foreground on Android
/** listen the event that renderer was recreated on Android/WP8
* @js NA
* @lua NA
*/
void listenBackToForeground(EventCustom* event);
void listenRendererRecreated(EventCustom* event);
/**
* @js NA

View File

@ -153,7 +153,7 @@ public:
//
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionRotoZoom();
virtual ~TransitionRotoZoom();
@ -175,7 +175,7 @@ public:
//
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionJumpZoom();
virtual ~TransitionJumpZoom();
@ -201,10 +201,11 @@ public:
//
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionMoveInL();
virtual ~TransitionMoveInL();
protected:
/** initializes the scenes */
virtual void initScenes();
@ -220,10 +221,11 @@ class CC_DLL TransitionMoveInR : public TransitionMoveInL
public:
static TransitionMoveInR* create(float t, Scene* scene);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionMoveInR();
virtual ~TransitionMoveInR();
protected:
virtual void initScenes();
private:
@ -238,10 +240,11 @@ class CC_DLL TransitionMoveInT : public TransitionMoveInL
public:
static TransitionMoveInT* create(float t, Scene* scene);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionMoveInT();
virtual ~TransitionMoveInT();
protected:
virtual void initScenes();
private:
@ -256,10 +259,11 @@ class CC_DLL TransitionMoveInB : public TransitionMoveInL
public:
static TransitionMoveInB* create(float t, Scene* scene);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionMoveInB();
virtual ~TransitionMoveInB();
protected:
virtual void initScenes();
private:
@ -284,10 +288,11 @@ public:
//
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSlideInL();
virtual ~TransitionSlideInL();
protected:
/** initializes the scenes */
virtual void initScenes(void);
@ -308,10 +313,11 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSlideInR();
virtual ~TransitionSlideInR();
protected:
/** initializes the scenes */
virtual void initScenes(void);
@ -332,10 +338,11 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSlideInB();
virtual ~TransitionSlideInB();
protected:
/** initializes the scenes */
virtual void initScenes();
@ -356,10 +363,11 @@ public:
/** returns the action that will be performed by the incoming and outgoing scene */
virtual ActionInterval* action(void);
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSlideInT();
virtual ~TransitionSlideInT();
protected:
/** initializes the scenes */
virtual void initScenes(void);
@ -387,7 +395,7 @@ public:
virtual void onEnter() override;
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionShrinkGrow();
virtual ~TransitionShrinkGrow();
@ -414,7 +422,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFlipX();
virtual ~TransitionFlipX();
@ -441,7 +449,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFlipY();
virtual ~TransitionFlipY();
@ -468,7 +476,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFlipAngular();
virtual ~TransitionFlipAngular();
@ -495,7 +503,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionZoomFlipX();
virtual ~TransitionZoomFlipX();
@ -522,7 +530,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionZoomFlipY();
virtual ~TransitionZoomFlipY();
@ -549,7 +557,7 @@ public:
*/
virtual void onEnter() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionZoomFlipAngular();
virtual ~TransitionZoomFlipAngular();
@ -625,7 +633,7 @@ public :
*/
virtual void onExit() override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionCrossFade();
virtual ~TransitionCrossFade();
@ -653,10 +661,11 @@ public :
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionTurnOffTiles();
virtual ~TransitionTurnOffTiles();
protected:
virtual void sceneOrder() override;
NodeGrid* _outSceneProxy;
@ -685,9 +694,12 @@ public:
virtual ActionInterval * easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSplitCols();
virtual ~TransitionSplitCols();
protected:
void switchTargetToInscene();
NodeGrid* _gridProxy;
private:
@ -707,7 +719,7 @@ public:
//
virtual ActionInterval* action(void) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionSplitRows();
virtual ~TransitionSplitRows();
@ -736,10 +748,12 @@ public:
virtual ActionInterval* easeActionWithAction(ActionInterval * action) override;
virtual void onExit() override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFadeTR();
virtual ~TransitionFadeTR();
protected:
virtual void sceneOrder();
NodeGrid* _outSceneProxy;
@ -761,7 +775,7 @@ public:
//
virtual ActionInterval* actionWithSize(const Size& size) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFadeBL();
virtual ~TransitionFadeBL();
@ -782,7 +796,7 @@ public:
//
virtual ActionInterval* actionWithSize(const Size& size) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFadeUp();
virtual ~TransitionFadeUp();
@ -803,7 +817,7 @@ public:
//
virtual ActionInterval* actionWithSize(const Size& size) override;
protected:
CC_CONSTRUCTOR_ACCESS:
TransitionFadeDown();
virtual ~TransitionFadeDown();

View File

@ -59,15 +59,6 @@ public:
* scene is being turned from left over the outgoing scene.
*/
static TransitionPageTurn* create(float t,Scene* scene,bool backwards);
/**
* @js ctor
*/
TransitionPageTurn();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionPageTurn();
//
// Overrides
@ -89,6 +80,17 @@ public:
virtual void onEnter() override;
virtual void onExit() override;
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionPageTurn();
/**
* @js NA
* @lua NA
*/
virtual ~TransitionPageTurn();
protected:
virtual void sceneOrder() override;

View File

@ -44,14 +44,16 @@ class CC_DLL TransitionProgress : public TransitionScene
public:
static TransitionProgress* create(float t, Scene* scene);
TransitionProgress();
//
// Overrides
//
virtual void onEnter() override;
virtual void onExit() override;
CC_CONSTRUCTOR_ACCESS:
TransitionProgress();
virtual ~TransitionProgress(){}
protected:
virtual void sceneOrder() override;
@ -74,6 +76,13 @@ class CC_DLL TransitionProgressRadialCCW : public TransitionProgress
public:
static TransitionProgressRadialCCW* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressRadialCCW(){}
virtual ~TransitionProgressRadialCCW(){}
protected:
//
// Overrides
@ -91,6 +100,13 @@ class CC_DLL TransitionProgressRadialCW : public TransitionProgress
public:
static TransitionProgressRadialCW* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressRadialCW(){}
virtual ~TransitionProgressRadialCW(){}
protected:
//
// Overrides
@ -107,6 +123,13 @@ class CC_DLL TransitionProgressHorizontal : public TransitionProgress
public:
static TransitionProgressHorizontal* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressHorizontal(){}
virtual ~TransitionProgressHorizontal(){}
protected:
//
// Overrides
@ -119,6 +142,13 @@ class CC_DLL TransitionProgressVertical : public TransitionProgress
public:
static TransitionProgressVertical* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressVertical(){}
virtual ~TransitionProgressVertical(){}
protected:
//
// Overrides
@ -131,6 +161,13 @@ class CC_DLL TransitionProgressInOut : public TransitionProgress
public:
static TransitionProgressInOut* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressInOut(){}
virtual ~TransitionProgressInOut(){}
protected:
//
// Overrides
@ -145,6 +182,13 @@ class CC_DLL TransitionProgressOutIn : public TransitionProgress
public:
static TransitionProgressOutIn* create(float t, Scene* scene);
CC_CONSTRUCTOR_ACCESS:
/**
* @js ctor
*/
TransitionProgressOutIn(){}
virtual ~TransitionProgressOutIn(){}
protected:
//
// Overrides

View File

@ -322,22 +322,22 @@ void MeshCache::removeUnusedMesh()
MeshCache::MeshCache()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// listen the event when app go to foreground
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCache::listenBackToForeground, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// listen the event that renderer was recreated on Android/WP8
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCache::listenRendererRecreated, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
#endif
}
MeshCache::~MeshCache()
{
removeAllMeshes();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
#endif
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
void MeshCache::listenBackToForeground(EventCustom* event)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void MeshCache::listenRendererRecreated(EventCustom* event)
{
for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
{

View File

@ -166,8 +166,8 @@ public:
/**remove unused meshes*/
void removeUnusedMesh();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
void listenBackToForeground(EventCustom* event);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void listenRendererRecreated(EventCustom* event);
#endif
CC_CONSTRUCTOR_ACCESS:
@ -181,8 +181,8 @@ protected:
std::unordered_map<std::string, Mesh*> _meshes; //cached meshes
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
EventListenerCustom* _backToForegroundlistener;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
EventListenerCustom* _rendererRecreatedListener;
#endif
};

View File

@ -223,9 +223,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static
# define the macro to compile through support/zip_support/ioapi.c
LOCAL_CFLAGS := -DUSE_FILE32API
LOCAL_CPPFLAGS := -Wno-deprecated-declarations
LOCAL_CPPFLAGS := -Wno-deprecated-declarations -Wno-extern-c-compat
LOCAL_EXPORT_CFLAGS := -DUSE_FILE32API
LOCAL_EXPORT_CPPFLAGS := -Wno-deprecated-declarations
LOCAL_EXPORT_CPPFLAGS := -Wno-deprecated-declarations -Wno-extern-c-compat
include $(BUILD_STATIC_LIBRARY)

View File

@ -30,7 +30,7 @@
#include "ccMacros.h"
#include "CCDirector.h"
#include "jni/JniHelper.h"
#include "base/CCEventController.h"
NS_CC_BEGIN

View File

@ -41,6 +41,9 @@ class EventDispatcher;
class Controller
{
public:
/** Controllers' standard key
* Controller receives only standard key which contained within enum Key by default.
*/
enum Key
{
JOYSTICK_LEFT_X = 1000,
@ -87,9 +90,17 @@ public:
static const int TAG_UNSET = -1;
static const std::vector<Controller*>& getAllController(){ return s_allController;}
/** Gets a controller with its tag
* @param tag An identifier to find the controller.
*/
static Controller* getControllerByTag(int tag);
/** To start discovering new controllers
* @warning The API only work on the IOS platform.Empty implementation on Android
*/
static void startDiscoveryController();
/** End the discovery process
* @warning The API only work on the IOS platform.Empty implementation on Android
*/
static void stopDiscoveryController();
const std::string& getDeviceName() const { return _deviceName;}
@ -108,7 +119,15 @@ public:
*/
void receiveExternalKeyEvent(int externalKeyCode,bool receive);
/** Changes the tag that is used to identify the controller easily.
* @param tag A integer that identifies the controller.
*/
void setTag(int tag) { _controllerTag = tag;}
/**
* Returns a tag that is used to identify the controller easily.
*
* @return An integer that identifies the controller.
*/
int getTag() const { return _controllerTag;}
private:

View File

@ -211,6 +211,7 @@ EventDispatcher::EventDispatcher()
// Therefore, internal listeners would not be cleaned when removeAllEventListeners is invoked.
_internalCustomListenerIDs.insert(EVENT_COME_TO_FOREGROUND);
_internalCustomListenerIDs.insert(EVENT_COME_TO_BACKGROUND);
_internalCustomListenerIDs.insert(EVENT_RENDERER_RECREATED);
}
EventDispatcher::~EventDispatcher()

View File

@ -30,13 +30,17 @@
*/
// The application will come to foreground.
// This message is used for reloading resources before come to foreground on Android.
// This message is posted in main.cpp.
// This message is posted in cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp.
#define EVENT_COME_TO_FOREGROUND "event_come_to_foreground"
// The renderer[android:GLSurfaceView.Renderer WP8:Cocos2dRenderer] was recreated.
// This message is used for reloading resources before renderer is recreated on Android/WP8.
// This message is posted in cocos/platform/android/javaactivity.cpp and cocos\platform\wp8-xaml\cpp\Cocos2dRenderer.cpp.
#define EVENT_RENDERER_RECREATED "event_renderer_recreated"
// The application will come to background.
// This message is used for doing something before coming to background, such as save RenderTexture.
// This message is posted in cocos2dx/platform/android/jni/MessageJni.cpp.
// This message is posted in cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp and cocos\platform\wp8-xaml\cpp\Cocos2dRenderer.cpp.
#define EVENT_COME_TO_BACKGROUND "event_come_to_background"
#endif // __CCEVENT_TYPE_H__

View File

@ -455,7 +455,7 @@ void UserDefault::setDataForKey(const char* pKey, const Data& value)
deleteNodeByKey(pKey);
#endif
CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), value.getSize());
CCLOG("SET DATA FOR KEY: --%s--%d", value.getBytes(), (int)(value.getSize()));
char * encodedData = nullptr;
unsigned int encodedDataLen = base64Encode(value.getBytes(), value.getSize(), &encodedData);

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "cocos2d-x 3.2beta0";
return "cocos2d-x 3.2";
}
NS_CC_END

View File

@ -253,6 +253,8 @@ THE SOFTWARE.
#include "2d/CCTMXTiledMap.h"
#include "2d/CCTMXXMLParser.h"
#include "2d/CCTileMapAtlas.h"
#include "2d/CCFastTMXTiledMap.h"
#include "2d/CCFastTMXLayer.h"
// component
#include "2d/CCComponent.h"

View File

@ -157,8 +157,8 @@ void Timeline::binarySearchKeyFrame(int frameIndex)
break;
}
int target = -1;
int low=0,high=length-1,mid;
long target = -1;
long low=0,high=length-1,mid=0;
while(low<=high){
mid=(low+high)/2;
if(frameIndex >= _frames.at(mid)->getFrameIndex() && frameIndex < _frames.at(mid+1)->getFrameIndex())

View File

@ -1459,7 +1459,7 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
}
setPropsForAllCustomWidgetFromJsonDictionary(classname, widget, customJsonDict);
}else{
CCLOG("Widget or WidgetReader doesn't exists!!! Please check your csb file.");
CCLOG("Widget or WidgetReader doesn't exists!!! Please check your json file.");
}
}

View File

@ -160,6 +160,7 @@ void Skin::updateTransform()
//
// calculate the Quad based on the Affine Matrix
//
Mat4 transform = getNodeToParentTransform();
Size &size = _rect.size;
@ -169,13 +170,13 @@ void Skin::updateTransform()
float x2 = x1 + size.width;
float y2 = y1 + size.height;
float x = _transform.m[12];
float y = _transform.m[13];
float x = transform.m[12];
float y = transform.m[13];
float cr = _transform.m[0];
float sr = _transform.m[1];
float cr2 = _transform.m[5];
float sr2 = -_transform.m[4];
float cr = transform.m[0];
float sr = transform.m[1];
float cr2 = transform.m[5];
float sr2 = -transform.m[4];
float ax = x1 * cr - y1 * sr2 + x;
float ay = x1 * sr + y1 * cr2 + y;

View File

@ -130,18 +130,15 @@ char* stExpCocoNode::GetName(CocoLoader* pCoco)
}
char* stExpCocoNode::GetValue(CocoLoader* pCoco)
{
char* szValue = ( pCoco->GetMemoryAddr_String() + m_szValue );
if(GetType(pCoco) == kStringType )
{
if(szValue && 0==strcmp(szValue,"null"))
{
strcpy(szValue,"");
}
}
return szValue;
}
char* stExpCocoNode::GetValue(CocoLoader* pCoco)
{
char* szValue = ( pCoco->GetMemoryAddr_String() + m_szValue );
if( 0==strcmp(szValue,"null") && GetType(pCoco) == kStringType )
{
strcpy(szValue,"");
}
return szValue;
}
int stExpCocoNode::GetChildNum()
@ -198,27 +195,6 @@ bool CocoLoader::ReadCocoBinBuff(char* pBinBuff)
return true;
}
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(const char* szObjDesc)
{
for(int i = 0 ; i < m_pFileHeader->m_ObjectCount ; i++)
{
if(0 == strcmp((char*)m_pObjectDescArray[i].m_szName,szObjDesc))
{
return &m_pObjectDescArray[i];
}
}
return nullptr;
}
stExpCocoObjectDesc* CocoLoader::GetCocoObjectDesc(int vIndex)
{
if(vIndex >= 0 && vIndex < m_pFileHeader->m_ObjectCount)
{
return &m_pObjectDescArray[vIndex];
}
return nullptr;
}
char* CocoLoader::GetMemoryAddr_AttribDesc()
{
return m_pMemoryBuff + m_pFileHeader->m_lAttribMemAddr ;

View File

@ -104,8 +104,6 @@ public:
stCocoFileHeader* GetFileHeader(){return m_pFileHeader;}
stExpCocoNode* GetRootCocoNode(){return m_pRootNode;}
stExpCocoObjectDesc* GetCocoObjectDescArray(){return m_pObjectDescArray;}
stExpCocoObjectDesc* GetCocoObjectDesc(const char* szObjDesc);
stExpCocoObjectDesc* GetCocoObjectDesc(int vIndex);
char* GetMemoryAddr_AttribDesc();
char* GetMemoryAddr_CocoNode();
char* GetMemoryAddr_String();

View File

@ -71,7 +71,11 @@ namespace cocostudio
}else if(key == P_FontName){
std::string fontFilePath;
fontFilePath = binaryFilePath.append(value);
label->setFontName(fontFilePath);
if (FileUtils::getInstance()->isFileExist(fontFilePath)) {
label->setFontName(fontFilePath);
}else{
label->setFontName(value);
}
}else if(key == P_AreaWidth){
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));
}else if(key == P_AreaHeight){
@ -102,8 +106,15 @@ namespace cocostudio
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
std::string fontFilePath = jsonPath.append(fontName);
label->setFontName(fontFilePath);
if (FileUtils::getInstance()->isFileExist(fontFilePath))
{
label->setFontName(fontFilePath);
}
else{
label->setFontName(fontName);
}
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);

View File

@ -64,7 +64,9 @@ public:
* @lua NA
*/
virtual ~ApplicationProtocol(){
#if CC_ENABLE_SCRIPT_BINDING
ScriptEngineManager::destroyInstance();
#endif
// clean auto release pool
PoolManager::destroyInstance();
}

View File

@ -315,7 +315,7 @@ void GLViewProtocol::handleTouchesMove(int num, intptr_t ids[], float xs[], floa
else
{
// It is error, should return.
CCLOG("Moving touches with id: %ld error", id);
CCLOG("Moving touches with id: %ld error", (long int)id);
return;
}
}

View File

@ -73,7 +73,7 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
mControllerService.setEnableLR2(true);
mControllerService.setAutoKeyUpMode(false);
mControllerService.checkNibiruInstall(mContext, true);
mControllerService.checkNibiruInstall(mContext, false);
}
}

View File

@ -75,8 +75,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
director->setGLDefaultValues();
}

View File

@ -24,6 +24,8 @@ extern "C" {
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
if (Director::getInstance()->getOpenGLView()) {
Application::getInstance()->applicationWillEnterForeground();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent);
}
}

View File

@ -123,6 +123,21 @@ public:
nFindPos = fontName.rfind(".");
fontName = fontName.substr(0,nFindPos);
}
else
{
auto nFindPos = fontName.rfind("/");
if (nFindPos != fontName.npos)
{
if (fontName.length() == nFindPos + 1)
{
fontName = "";
}
else
{
fontName = &fontName[nFindPos+1];
}
}
}
tNewFont.lfCharSet = DEFAULT_CHARSET;
strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, fontName.c_str());
}

View File

@ -103,7 +103,7 @@ const char * Application::getCurrentLanguageCode()
if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH))
{
wchar_t* primary = wcstok(localeName, L"-");
std::string code = CCUnicodeToUtf8(primary);
code = CCUnicodeToUtf8(primary);
}
else
{

View File

@ -67,8 +67,8 @@ void Cocos2dRenderer::CreateGLResources()
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
cocos2d::Application::getInstance()->applicationWillEnterForeground();
director->setGLDefaultValues();
}

View File

@ -279,9 +279,9 @@ GLProgramState::GLProgramState()
, _uniformAttributeValueDirty(true)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// listen the event when app go to foreground
CCLOG("create _backToForegroundlistener for GLProgramState");
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
/** listen the event that renderer was recreated on Android/WP8 */
CCLOG("create rendererRecreatedListener for GLProgramState");
_backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
#endif
}

View File

@ -56,10 +56,10 @@ MeshCommand::MeshCommand()
, _vao(0)
{
_type = RenderCommand::Type::MESH_COMMAND;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// listen the event when app go to foreground
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCommand::listenBackToForeground, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
// listen the event that renderer was recreated on Android/WP8
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCommand::listenRendererRecreated, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
#endif
}
@ -117,8 +117,8 @@ void MeshCommand::setDisplayColor(const Vec4& color)
MeshCommand::~MeshCommand()
{
releaseVAO();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
#endif
}
@ -292,8 +292,8 @@ void MeshCommand::releaseVAO()
}
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
void MeshCommand::listenBackToForeground(EventCustom* event)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void MeshCommand::listenRendererRecreated(EventCustom* event)
{
_vao = 0;
}

View File

@ -74,8 +74,8 @@ public:
uint32_t getMaterialID() const { return _materialID; }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
void listenBackToForeground(EventCustom* event);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
void listenRendererRecreated(EventCustom* event);
#endif
protected:
@ -122,8 +122,8 @@ protected:
// ModelView transform
Mat4 _mv;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
EventListenerCustom* _backToForegroundlistener;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
EventListenerCustom* _rendererRecreatedListener;
#endif
};

View File

@ -145,8 +145,8 @@ Renderer::~Renderer()
void Renderer::initGLView()
{
#if CC_ENABLE_CACHE_TEXTURE_DATA
_cacheTextureListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
/** listen the event that coming to foreground on Android */
_cacheTextureListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
/** listen the event that renderer was recreated on Android/WP8 */
this->setupBuffer();
});

View File

@ -57,7 +57,7 @@ TextureAtlas::TextureAtlas()
,_texture(nullptr)
,_quads(nullptr)
#if CC_ENABLE_CACHE_TEXTURE_DATA
,_backToForegroundlistener(nullptr)
,_rendererRecreatedListener(nullptr)
#endif
{}
@ -78,7 +78,7 @@ TextureAtlas::~TextureAtlas()
CC_SAFE_RELEASE(_texture);
#if CC_ENABLE_CACHE_TEXTURE_DATA
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
#endif
}
@ -192,9 +192,9 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
#if CC_ENABLE_CACHE_TEXTURE_DATA
// listen the event when app go to background
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(TextureAtlas::listenBackToForeground, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
/** listen the event that renderer was recreated on Android/WP8 */
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(TextureAtlas::listenRendererRecreated, this));
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
#endif
this->setupIndices();
@ -213,7 +213,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
return true;
}
void TextureAtlas::listenBackToForeground(EventCustom* event)
void TextureAtlas::listenRendererRecreated(EventCustom* event)
{
if (Configuration::getInstance()->supportsShareableVAO())
{

View File

@ -189,9 +189,9 @@ public:
/** draws all the Atlas's Quads
*/
void drawQuads();
/** listen the event that coming to foreground on Android
/** listen the event that renderer was recreated on Android
*/
void listenBackToForeground(EventCustom* event);
void listenRendererRecreated(EventCustom* event);
/** whether or not the array buffer of the VBO needs to be updated*/
inline bool isDirty(void) { return _dirty; }
@ -244,7 +244,7 @@ protected:
V3F_C4B_T2F_Quad* _quads;
#if CC_ENABLE_CACHE_TEXTURE_DATA
EventListenerCustom* _backToForegroundlistener;
EventListenerCustom* _rendererRecreatedListener;
#endif
};

View File

@ -0,0 +1,51 @@
--------------------------------
-- @module Controller
-- @parent_module cc
--------------------------------
-- @function [parent=#Controller] receiveExternalKeyEvent
-- @param self
-- @param #int int
-- @param #bool bool
--------------------------------
-- @function [parent=#Controller] getDeviceName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#Controller] isConnected
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#Controller] getDeviceId
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#Controller] setTag
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#Controller] getTag
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#Controller] startDiscoveryController
-- @param self
--------------------------------
-- @function [parent=#Controller] stopDiscoveryController
-- @param self
--------------------------------
-- @function [parent=#Controller] getControllerByTag
-- @param self
-- @param #int int
-- @return Controller#Controller ret (return value: cc.Controller)
return nil

View File

@ -0,0 +1,48 @@
--------------------------------
-- @module EventController
-- @extend Event
-- @parent_module cc
--------------------------------
-- @function [parent=#EventController] getControllerEventType
-- @param self
-- @return EventController::ControllerEventType#EventController::ControllerEventType ret (return value: cc.EventController::ControllerEventType)
--------------------------------
-- @function [parent=#EventController] setConnectStatus
-- @param self
-- @param #bool bool
--------------------------------
-- @function [parent=#EventController] isConnected
-- @param self
-- @return bool#bool ret (return value: bool)
--------------------------------
-- @function [parent=#EventController] setKeyCode
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#EventController] getController
-- @param self
-- @return Controller#Controller ret (return value: cc.Controller)
--------------------------------
-- @function [parent=#EventController] getKeyCode
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- overload function: EventController(cc.EventController::ControllerEventType, cc.Controller, bool)
--
-- overload function: EventController(cc.EventController::ControllerEventType, cc.Controller, int)
--
-- @function [parent=#EventController] EventController
-- @param self
-- @param #cc.EventController::ControllerEventType controllereventtype
-- @param #cc.Controller controller
-- @param #int int
return nil

View File

@ -0,0 +1,22 @@
--------------------------------
-- @module EventListenerController
-- @extend EventListener
-- @parent_module cc
--------------------------------
-- @function [parent=#EventListenerController] create
-- @param self
-- @return EventListenerController#EventListenerController ret (return value: cc.EventListenerController)
--------------------------------
-- @function [parent=#EventListenerController] clone
-- @param self
-- @return EventListenerController#EventListenerController ret (return value: cc.EventListenerController)
--------------------------------
-- @function [parent=#EventListenerController] checkAvailable
-- @param self
-- @return bool#bool ret (return value: bool)
return nil

View File

@ -0,0 +1,146 @@
--------------------------------
-- @module FastTMXLayer
-- @extend Node
-- @parent_module cc
--------------------------------
-- @function [parent=#FastTMXLayer] getPositionAt
-- @param self
-- @param #vec2_table vec2
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- @function [parent=#FastTMXLayer] setLayerOrientation
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#FastTMXLayer] getLayerSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#FastTMXLayer] setMapTileSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#FastTMXLayer] getLayerOrientation
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#FastTMXLayer] setProperties
-- @param self
-- @param #map_table map
--------------------------------
-- @function [parent=#FastTMXLayer] setLayerName
-- @param self
-- @param #string str
--------------------------------
-- @function [parent=#FastTMXLayer] removeTileAt
-- @param self
-- @param #vec2_table vec2
--------------------------------
-- overload function: getProperties()
--
-- overload function: getProperties()
--
-- @function [parent=#FastTMXLayer] getProperties
-- @param self
-- @return map_table#map_table ret (retunr value: map_table)
--------------------------------
-- @function [parent=#FastTMXLayer] setupTiles
-- @param self
--------------------------------
-- @function [parent=#FastTMXLayer] setupTileSprite
-- @param self
-- @param #cc.Sprite sprite
-- @param #vec2_table vec2
-- @param #int int
--------------------------------
-- overload function: setTileGID(int, vec2_table, cc.TMXTileFlags_)
--
-- overload function: setTileGID(int, vec2_table)
--
-- @function [parent=#FastTMXLayer] setTileGID
-- @param self
-- @param #int int
-- @param #vec2_table vec2
-- @param #cc.TMXTileFlags_ tmxtileflags_
--------------------------------
-- @function [parent=#FastTMXLayer] getMapTileSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#FastTMXLayer] getProperty
-- @param self
-- @param #string str
-- @return Value#Value ret (return value: cc.Value)
--------------------------------
-- @function [parent=#FastTMXLayer] setLayerSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#FastTMXLayer] getLayerName
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#FastTMXLayer] setTileSet
-- @param self
-- @param #cc.TMXTilesetInfo tmxtilesetinfo
--------------------------------
-- @function [parent=#FastTMXLayer] getTileSet
-- @param self
-- @return TMXTilesetInfo#TMXTilesetInfo ret (return value: cc.TMXTilesetInfo)
--------------------------------
-- @function [parent=#FastTMXLayer] getTileAt
-- @param self
-- @param #vec2_table vec2
-- @return Sprite#Sprite ret (return value: cc.Sprite)
--------------------------------
-- @function [parent=#FastTMXLayer] create
-- @param self
-- @param #cc.TMXTilesetInfo tmxtilesetinfo
-- @param #cc.TMXLayerInfo tmxlayerinfo
-- @param #cc.TMXMapInfo map
-- @return FastTMXLayer#FastTMXLayer ret (return value: cc.FastTMXLayer)
--------------------------------
-- @function [parent=#FastTMXLayer] removeChild
-- @param self
-- @param #cc.Node node
-- @param #bool bool
--------------------------------
-- @function [parent=#FastTMXLayer] draw
-- @param self
-- @param #cc.Renderer renderer
-- @param #mat4_table mat4
-- @param #unsigned int int
--------------------------------
-- @function [parent=#FastTMXLayer] getDescription
-- @param self
-- @return string#string ret (return value: string)
--------------------------------
-- @function [parent=#FastTMXLayer] FastTMXLayer
-- @param self
return nil

View File

@ -0,0 +1,103 @@
--------------------------------
-- @module FastTMXTiledMap
-- @extend Node
-- @parent_module cc
--------------------------------
-- @function [parent=#FastTMXTiledMap] setObjectGroups
-- @param self
-- @param #array_table array
--------------------------------
-- @function [parent=#FastTMXTiledMap] getProperty
-- @param self
-- @param #string str
-- @return Value#Value ret (return value: cc.Value)
--------------------------------
-- @function [parent=#FastTMXTiledMap] setMapSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#FastTMXTiledMap] getObjectGroup
-- @param self
-- @param #string str
-- @return TMXObjectGroup#TMXObjectGroup ret (return value: cc.TMXObjectGroup)
--------------------------------
-- overload function: getObjectGroups()
--
-- overload function: getObjectGroups()
--
-- @function [parent=#FastTMXTiledMap] getObjectGroups
-- @param self
-- @return array_table#array_table ret (retunr value: array_table)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getTileSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getMapSize
-- @param self
-- @return size_table#size_table ret (return value: size_table)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getProperties
-- @param self
-- @return map_table#map_table ret (return value: map_table)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getPropertiesForGID
-- @param self
-- @param #int int
-- @return Value#Value ret (return value: cc.Value)
--------------------------------
-- @function [parent=#FastTMXTiledMap] setTileSize
-- @param self
-- @param #size_table size
--------------------------------
-- @function [parent=#FastTMXTiledMap] setProperties
-- @param self
-- @param #map_table map
--------------------------------
-- @function [parent=#FastTMXTiledMap] getLayer
-- @param self
-- @param #string str
-- @return FastTMXLayer#FastTMXLayer ret (return value: cc.FastTMXLayer)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getMapOrientation
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#FastTMXTiledMap] setMapOrientation
-- @param self
-- @param #int int
--------------------------------
-- @function [parent=#FastTMXTiledMap] create
-- @param self
-- @param #string str
-- @return FastTMXTiledMap#FastTMXTiledMap ret (return value: cc.FastTMXTiledMap)
--------------------------------
-- @function [parent=#FastTMXTiledMap] createWithXML
-- @param self
-- @param #string str
-- @param #string str
-- @return FastTMXTiledMap#FastTMXTiledMap ret (return value: cc.FastTMXTiledMap)
--------------------------------
-- @function [parent=#FastTMXTiledMap] getDescription
-- @param self
-- @return string#string ret (return value: string)
return nil

View File

@ -15,6 +15,11 @@
-- @param #cc.Texture2D texture2d
-- @param #rect_table rect
--------------------------------
-- @function [parent=#ParticleSystemQuad] listenRendererRecreated
-- @param self
-- @param #cc.EventCustom eventcustom
--------------------------------
-- overload function: create(string)
--

View File

@ -33,8 +33,4 @@
-- @param #mat4_table mat4
-- @param #unsigned int int
--------------------------------
-- @function [parent=#TransitionPageTurn] TransitionPageTurn
-- @param self
return nil

View File

@ -11,8 +11,4 @@
-- @param #cc.Scene scene
-- @return TransitionProgress#TransitionProgress ret (return value: cc.TransitionProgress)
--------------------------------
-- @function [parent=#TransitionProgress] TransitionProgress
-- @param self
return nil

View File

@ -1196,6 +1196,16 @@
-- @field [parent=#cc] TileMapAtlas#TileMapAtlas TileMapAtlas preloaded module
--------------------------------------------------------
-- the cc FastTMXTiledMap
-- @field [parent=#cc] FastTMXTiledMap#FastTMXTiledMap FastTMXTiledMap preloaded module
--------------------------------------------------------
-- the cc FastTMXLayer
-- @field [parent=#cc] FastTMXLayer#FastTMXLayer FastTMXLayer preloaded module
--------------------------------------------------------
-- the cc Component
-- @field [parent=#cc] Component#Component Component preloaded module

View File

@ -0,0 +1,19 @@
--------------------------------
-- @module cc
--------------------------------------------------------
-- the cc Controller
-- @field [parent=#cc] Controller#Controller Controller preloaded module
--------------------------------------------------------
-- the cc EventController
-- @field [parent=#cc] EventController#EventController EventController preloaded module
--------------------------------------------------------
-- the cc EventListenerController
-- @field [parent=#cc] EventListenerController#EventListenerController EventListenerController preloaded module
return nil

File diff suppressed because it is too large Load Diff

View File

@ -1555,6 +1555,44 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -0,0 +1,826 @@
#include "lua_cocos2dx_controller_auto.hpp"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "CCGameController.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
int lua_cocos2dx_controller_Controller_receiveExternalKeyEvent(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 2)
{
int arg0;
bool arg1;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
ok &= luaval_to_boolean(tolua_S, 3,&arg1);
if(!ok)
return 0;
cobj->receiveExternalKeyEvent(arg0, arg1);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "receiveExternalKeyEvent",argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_receiveExternalKeyEvent'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_getDeviceName(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceName'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::string& ret = cobj->getDeviceName();
tolua_pushcppstring(tolua_S,ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDeviceName",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceName'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_isConnected(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_isConnected'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
bool ret = cobj->isConnected();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isConnected",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_isConnected'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_getDeviceId(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getDeviceId'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = cobj->getDeviceId();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDeviceId",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getDeviceId'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_setTag(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_setTag'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if(!ok)
return 0;
cobj->setTag(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setTag",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_setTag'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_getTag(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Controller* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Controller*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_Controller_getTag'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = cobj->getTag();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTag",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getTag'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_startDiscoveryController(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::Controller::startDiscoveryController();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "startDiscoveryController",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_startDiscoveryController'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_stopDiscoveryController(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::Controller::stopDiscoveryController();
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "stopDiscoveryController",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_stopDiscoveryController'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_Controller_getControllerByTag(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.Controller",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if(!ok)
return 0;
cocos2d::Controller* ret = cocos2d::Controller::getControllerByTag(arg0);
object_to_luaval<cocos2d::Controller>(tolua_S, "cc.Controller",(cocos2d::Controller*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "getControllerByTag",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_Controller_getControllerByTag'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_controller_Controller_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (Controller)");
return 0;
}
int lua_register_cocos2dx_controller_Controller(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.Controller");
tolua_cclass(tolua_S,"Controller","cc.Controller","",nullptr);
tolua_beginmodule(tolua_S,"Controller");
tolua_function(tolua_S,"receiveExternalKeyEvent",lua_cocos2dx_controller_Controller_receiveExternalKeyEvent);
tolua_function(tolua_S,"getDeviceName",lua_cocos2dx_controller_Controller_getDeviceName);
tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_Controller_isConnected);
tolua_function(tolua_S,"getDeviceId",lua_cocos2dx_controller_Controller_getDeviceId);
tolua_function(tolua_S,"setTag",lua_cocos2dx_controller_Controller_setTag);
tolua_function(tolua_S,"getTag",lua_cocos2dx_controller_Controller_getTag);
tolua_function(tolua_S,"startDiscoveryController", lua_cocos2dx_controller_Controller_startDiscoveryController);
tolua_function(tolua_S,"stopDiscoveryController", lua_cocos2dx_controller_Controller_stopDiscoveryController);
tolua_function(tolua_S,"getControllerByTag", lua_cocos2dx_controller_Controller_getControllerByTag);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::Controller).name();
g_luaType[typeName] = "cc.Controller";
g_typeCast["Controller"] = "cc.Controller";
return 1;
}
int lua_cocos2dx_controller_EventController_getControllerEventType(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getControllerEventType'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = (int)cobj->getControllerEventType();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getControllerEventType",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getControllerEventType'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_setConnectStatus(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setConnectStatus'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0);
if(!ok)
return 0;
cobj->setConnectStatus(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setConnectStatus",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setConnectStatus'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_isConnected(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_isConnected'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
bool ret = cobj->isConnected();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "isConnected",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_isConnected'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_setKeyCode(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_setKeyCode'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
int arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if(!ok)
return 0;
cobj->setKeyCode(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setKeyCode",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_setKeyCode'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_getController(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getController'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::Controller* ret = cobj->getController();
object_to_luaval<cocos2d::Controller>(tolua_S, "cc.Controller",(cocos2d::Controller*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getController",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getController'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_getKeyCode(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.EventController",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::EventController*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_controller_EventController_getKeyCode'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
int ret = cobj->getKeyCode();
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getKeyCode",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_getKeyCode'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_controller_EventController_constructor(lua_State* tolua_S)
{
int argc = 0;
cocos2d::EventController* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
argc = lua_gettop(tolua_S)-1;
do{
if (argc == 3) {
cocos2d::EventController::ControllerEventType arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if (!ok) { break; }
cocos2d::Controller* arg1;
ok &= luaval_to_object<cocos2d::Controller>(tolua_S, 3, "cc.Controller",&arg1);
if (!ok) { break; }
bool arg2;
ok &= luaval_to_boolean(tolua_S, 4,&arg2);
if (!ok) { break; }
cobj = new cocos2d::EventController(arg0, arg1, arg2);
cobj->autorelease();
int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController");
return 1;
}
}while(0);
ok = true;
do{
if (argc == 3) {
cocos2d::EventController::ControllerEventType arg0;
ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0);
if (!ok) { break; }
cocos2d::Controller* arg1;
ok &= luaval_to_object<cocos2d::Controller>(tolua_S, 3, "cc.Controller",&arg1);
if (!ok) { break; }
int arg2;
ok &= luaval_to_int32(tolua_S, 4,(int *)&arg2);
if (!ok) { break; }
cobj = new cocos2d::EventController(arg0, arg1, arg2);
cobj->autorelease();
int ID = (int)cobj->_ID ;
int* luaID = &cobj->_luaID ;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)cobj,"cc.EventController");
return 1;
}
}while(0);
ok = true;
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "EventController",argc, 3);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventController_constructor'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_controller_EventController_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (EventController)");
return 0;
}
int lua_register_cocos2dx_controller_EventController(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.EventController");
tolua_cclass(tolua_S,"EventController","cc.EventController","cc.Event",nullptr);
tolua_beginmodule(tolua_S,"EventController");
tolua_function(tolua_S,"new",lua_cocos2dx_controller_EventController_constructor);
tolua_function(tolua_S,"getControllerEventType",lua_cocos2dx_controller_EventController_getControllerEventType);
tolua_function(tolua_S,"setConnectStatus",lua_cocos2dx_controller_EventController_setConnectStatus);
tolua_function(tolua_S,"isConnected",lua_cocos2dx_controller_EventController_isConnected);
tolua_function(tolua_S,"setKeyCode",lua_cocos2dx_controller_EventController_setKeyCode);
tolua_function(tolua_S,"getController",lua_cocos2dx_controller_EventController_getController);
tolua_function(tolua_S,"getKeyCode",lua_cocos2dx_controller_EventController_getKeyCode);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::EventController).name();
g_luaType[typeName] = "cc.EventController";
g_typeCast["EventController"] = "cc.EventController";
return 1;
}
int lua_cocos2dx_controller_EventListenerController_create(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"cc.EventListenerController",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
return 0;
cocos2d::EventListenerController* ret = cocos2d::EventListenerController::create();
object_to_luaval<cocos2d::EventListenerController>(tolua_S, "cc.EventListenerController",(cocos2d::EventListenerController*)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_controller_EventListenerController_create'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_controller_EventListenerController_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (EventListenerController)");
return 0;
}
int lua_register_cocos2dx_controller_EventListenerController(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.EventListenerController");
tolua_cclass(tolua_S,"EventListenerController","cc.EventListenerController","cc.EventListener",nullptr);
tolua_beginmodule(tolua_S,"EventListenerController");
tolua_function(tolua_S,"create", lua_cocos2dx_controller_EventListenerController_create);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::EventListenerController).name();
g_luaType[typeName] = "cc.EventListenerController";
g_typeCast["EventListenerController"] = "cc.EventListenerController";
return 1;
}
TOLUA_API int register_all_cocos2dx_controller(lua_State* tolua_S)
{
tolua_open(tolua_S);
tolua_module(tolua_S,"cc",0);
tolua_beginmodule(tolua_S,"cc");
lua_register_cocos2dx_controller_EventListenerController(tolua_S);
lua_register_cocos2dx_controller_Controller(tolua_S);
lua_register_cocos2dx_controller_EventController(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
#endif

View File

@ -0,0 +1,37 @@
#include "base/ccConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#ifndef __cocos2dx_controller_h__
#define __cocos2dx_controller_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "tolua++.h"
#ifdef __cplusplus
}
#endif
int register_all_cocos2dx_controller(lua_State* tolua_S);
#endif // __cocos2dx_controller_h__
#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

View File

@ -46,9 +46,14 @@ extern "C" {
#include "platform/android/CCLuaJavaBridge.h"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCLuaJavaBridge.h"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "Lua_web_socket.h"
#endif
#include "LuaOpengl.h"
#include "LuaScriptHandlerMgr.h"
#include "lua_cocos2dx_auto.hpp"
@ -173,6 +178,7 @@ bool LuaStack::init(void)
register_all_cocos2dx_physics(_state);
register_all_cocos2dx_physics_manual(_state);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
LuaObjcBridge::luaopen_luaoc(_state);
#endif
@ -501,86 +507,92 @@ int LuaStack::reallocateScriptHandler(int nHandler)
int LuaStack::executeFunctionReturnArray(int handler,int numArgs,int numResults,__Array& resultArray)
{
int top = lua_gettop(_state);
if (pushFunctionByHandler(handler)) /* L: ... arg1 arg2 ... func */
{
if (numArgs > 0)
{
lua_insert(_state, -(numArgs + 1)); /* L: ... func arg1 arg2 ... */
int functionIndex = -(numArgs + 1);
if (!lua_isfunction(_state, functionIndex))
}
int functionIndex = -(numArgs + 1);
if (!lua_isfunction(_state, functionIndex))
{
CCLOG("value at stack [%d] is not function", functionIndex);
lua_pop(_state, numArgs + 1); // remove function and arguments
lua_settop(_state,top);
return 0;
}
int traceback = 0;
lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */
if (!lua_isfunction(_state, -1))
{
lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */
}
else
{
lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */
traceback = functionIndex - 1;
}
int error = 0;
++_callFromLua;
error = lua_pcall(_state, numArgs, numResults, traceback); /* L: ... [G] ret1 ret2 ... retResults*/
--_callFromLua;
if (error)
{
if (traceback == 0)
{
CCLOG("value at stack [%d] is not function", functionIndex);
lua_pop(_state, numArgs + 1); // remove function and arguments
return 0;
CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */
lua_pop(_state, 1); // remove error message from stack
}
int traceback = 0;
lua_getglobal(_state, "__G__TRACKBACK__"); /* L: ... func arg1 arg2 ... G */
if (!lua_isfunction(_state, -1))
else /* L: ... G error */
{
lua_pop(_state, 1); /* L: ... func arg1 arg2 ... */
lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack
}
else
{
lua_insert(_state, functionIndex - 1); /* L: ... G func arg1 arg2 ... */
traceback = functionIndex - 1;
}
int error = 0;
++_callFromLua;
error = lua_pcall(_state, numArgs, numResults, traceback); /* L: ... [G] ret1 ret2 ... retResults*/
--_callFromLua;
if (error)
{
if (traceback == 0)
{
CCLOG("[LUA ERROR] %s", lua_tostring(_state, - 1)); /* L: ... error */
lua_pop(_state, 1); // remove error message from stack
}
else /* L: ... G error */
{
lua_pop(_state, 2); // remove __G__TRACKBACK__ and error message from stack
}
return 0;
}
// get return value,don't pass LUA_MULTRET to numResults,
if (numResults <= 0)
return 0;
for (int i = 0 ; i < numResults; i++)
{
if (lua_type(_state, -1) == LUA_TBOOLEAN) {
bool value = lua_toboolean(_state, -1);
resultArray.addObject(Bool::create(value)) ;
}else if (lua_type(_state, -1) == LUA_TNUMBER) {
double value = lua_tonumber(_state, -1);
resultArray.addObject(Double::create(value));
}else if (lua_type(_state, -1) == LUA_TSTRING) {
const char* value = lua_tostring(_state, -1);
resultArray.addObject(String::create(value));
}else{
resultArray.addObject(static_cast<Ref*>(tolua_tousertype(_state, -1, NULL)));
}
// remove return value from stack
lua_pop(_state, 1); /* L: ... [G] ret1 ret2 ... ret*/
}
/* L: ... [G]*/
if (traceback)
{
lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */
lua_settop(_state,top);
return 0;
}
// get return value,don't pass LUA_MULTRET to numResults,
if (numResults <= 0)
{
lua_settop(_state,top);
return 0;
}
for (int i = 0 ; i < numResults; i++)
{
if (lua_type(_state, -1) == LUA_TBOOLEAN) {
bool value = lua_toboolean(_state, -1);
resultArray.addObject(Bool::create(value)) ;
}else if (lua_type(_state, -1) == LUA_TNUMBER) {
double value = lua_tonumber(_state, -1);
resultArray.addObject(Double::create(value));
}else if (lua_type(_state, -1) == LUA_TSTRING) {
const char* value = lua_tostring(_state, -1);
resultArray.addObject(String::create(value));
}else{
resultArray.addObject(static_cast<Ref*>(tolua_tousertype(_state, -1, NULL)));
}
// remove return value from stack
lua_pop(_state, 1); /* L: ... [G] ret1 ret2 ... ret*/
}
/* L: ... [G]*/
if (traceback)
{
lua_pop(_state, 1); // remove __G__TRACKBACK__ from stack /* L: ... */
}
}
lua_settop(_state, 0);
lua_settop(_state,top);
return 1;
}

View File

@ -79,7 +79,7 @@ extern bool luaval_to_ttfconfig(lua_State* L, int lo, cocos2d::TTFConfig* outVal
extern bool luaval_to_uniform(lua_State* L, int lo, cocos2d::Uniform* outValue);
extern bool luaval_to_vertexattrib(lua_State* L, int lo, cocos2d::VertexAttrib* outValue);
CC_DEPRECATED_ATTRIBUTE static inline bool luaval_to_point(lua_State* L,int lo,cocos2d::Vec2* outValue)
static inline bool luaval_to_point(lua_State* L,int lo,cocos2d::Vec2* outValue)
{
return luaval_to_vec2(L, lo, outValue);
}
@ -258,7 +258,7 @@ extern void ttfconfig_to_luaval(lua_State* L, const cocos2d::TTFConfig& config);
extern void uniform_to_luaval(lua_State* L, const cocos2d::Uniform& uniform);
extern void vertexattrib_to_luaval(lua_State* L, const cocos2d::VertexAttrib& verAttrib);
CC_DEPRECATED_ATTRIBUTE static inline void point_to_luaval(lua_State* L,const cocos2d::Vec2& pt)
static inline void point_to_luaval(lua_State* L,const cocos2d::Vec2& pt)
{
vec2_to_luaval(L, pt);
}

View File

@ -163,6 +163,13 @@ public:
EVENT_FOCUS,
EVENT_CONTROLLER_CONNECTED,
EVENT_CONTROLLER_DISCONNECTED,
EVENT_CONTROLLER_KEYDOWN,
EVENT_CONTROLLER_KEYUP,
EVENT_CONTROLLER_KEYREPEAT,
EVENT_CONTROLLER_AXIS,
EVENT_CUSTOM_BEGAN = 10000,
EVENT_CUSTOM_ENDED = 11000,
};

View File

@ -201,8 +201,8 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L)
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err);
return 0;
#endif
return 0;
}
static void extendArmatureAnimation(lua_State* L)
@ -293,8 +293,8 @@ static int lua_cocos2dx_ArmatureDataManager_addArmatureFileInfoAsyncCallFunc(lua
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'addArmatureFileInfoAsync'.",&tolua_err);
return 0;
#endif
return 0;
}
static void extendArmatureDataManager(lua_State* L)
@ -538,8 +538,8 @@ static int lua_cocos2dx_ActionTimeline_setFrameEventCallFunc(lua_State* L)
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'setFrameEventCallFunc'.",&tolua_err);
return 0;
#endif
return 0;
}
static void extendActionTimeline(lua_State* L)

View File

@ -0,0 +1,373 @@
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "lua_cocos2dx_controller_manual.hpp"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "cocos2d.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
#include "LuaScriptHandlerMgr.h"
#include "CCLuaValue.h"
#include "CCLuaEngine.h"
#include "CCGameController.h"
static void cloneEventListenerControllerHandler(const cocos2d::EventListenerController* src,cocos2d::EventListenerController* dst, ScriptHandlerMgr::HandlerType type)
{
if (nullptr == src || nullptr == dst)
return;
LUA_FUNCTION handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)src, type);
if (0 != handler)
{
int newscriptHandler = ScriptEngineManager::getInstance()->getScriptEngine()->reallocateScriptHandler(handler);
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)dst, newscriptHandler, type);
switch (type)
{
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_CONNECTED:
{
dst->onConnected = [=](cocos2d::Controller* controller, Event* event){
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_DISCONNECTED:
{
dst->onDisconnected = [=](cocos2d::Controller* controller, Event* event){
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYDOWN:
{
dst->onKeyDown = [=](cocos2d::Controller* controller, int keyCode, Event* event){
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYUP:
{
dst->onKeyUp = [=](cocos2d::Controller* controller, int keyCode, Event* event){
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYREPEAT:
{
dst->onKeyRepeat = [=](cocos2d::Controller* controller, int keyCode, Event* event){
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_AXIS:
{
dst->onAxisEvent = [=](cocos2d::Controller* controller, int keyCode, Event* event){
};
}
break;
default:
break;
}
}
}
static int tolua_cocos2dx_EventListenerController_clone(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
cocos2d::EventListenerController* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerController", 0, &tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::EventListenerController*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerController_clone'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
cocos2d::EventListenerController* tolua_ret = cocos2d::EventListenerController::create();
if(nullptr == tolua_ret)
return 0;
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_CONNECTED);
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_DISCONNECTED);
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYDOWN);
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYUP);
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYREPEAT);
cloneEventListenerControllerHandler(self, tolua_ret, ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_AXIS);
int ID = (tolua_ret) ? (int)tolua_ret->_ID : -1;
int* luaID = (tolua_ret) ? &tolua_ret->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tolua_ret,"cc.EventListenerController");
return 1;
}
CCLOG("'clone' has wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'clone'.",&tolua_err);
return 0;
#endif
}
static int tolua_cocos2dx_EventListenerController_registerScriptHandler(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
cocos2d::EventListenerController* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S, 1, "cc.EventListenerController", 0, &tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::EventListenerController*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_EventListenerController_registerScriptHandler'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 2)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = toluafix_ref_function(tolua_S,2,0);
ScriptHandlerMgr::HandlerType type = static_cast<ScriptHandlerMgr::HandlerType>((int)tolua_tonumber(tolua_S, 3, 0));
switch (type)
{
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_CONNECTED:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onConnected = [=](cocos2d::Controller* controller, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_DISCONNECTED:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onDisconnected = [=](cocos2d::Controller* controller, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYDOWN:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onKeyDown = [=](cocos2d::Controller* controller, int keyCode, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
tolua_pushnumber(tolua_S, (lua_Number) keyCode);
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 3);
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYUP:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onKeyUp = [=](cocos2d::Controller* controller, int keyCode, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
tolua_pushnumber(tolua_S, (lua_Number) keyCode);
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 3);
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_KEYREPEAT:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onKeyRepeat = [=](cocos2d::Controller* controller, int keyCode, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
tolua_pushnumber(tolua_S, (lua_Number) keyCode);
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 3);
};
}
break;
case ScriptHandlerMgr::HandlerType::EVENT_CONTROLLER_AXIS:
{
ScriptHandlerMgr::getInstance()->addObjectHandler((void*)self, handler, type);
self->onAxisEvent = [=](cocos2d::Controller* controller, int keyCode, Event* event){
tolua_pushusertype(tolua_S, (void*)controller, "cc.Controller");
tolua_pushnumber(tolua_S, (lua_Number) keyCode);
int ID = (event) ? (int)event->_ID : -1;
int* luaID = (event) ? &event->_luaID : NULL;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)event,"cc.event");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 3);
};
}
break;
default:
break;
}
return 0;
}
CCLOG("'registerScriptHandler' has wrong number of arguments: %d, was expecting %d\n", argc, 2);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
static void extendEventListenerController(lua_State* L)
{
lua_pushstring(L, "cc.EventListenerController");
lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1))
{
tolua_function(L, "clone", tolua_cocos2dx_EventListenerController_clone);
tolua_function(L, "registerScriptHandler", tolua_cocos2dx_EventListenerController_registerScriptHandler);
}
lua_pop(L, 1);
}
static int tolua_cocos2dx_Controller_getKeyStatus(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0;
int argc = 0;
cocos2d::Controller* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S, 1, "cc.Controller", 0, &tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::Controller*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'tolua_cocos2dx_Controller_getKeyStatus'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 1)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isnumber(tolua_S, 2, 0, &tolua_err))
goto tolua_lerror;
#endif
int keyCode = (int)tolua_tonumber(tolua_S, 2, 0);
cocos2d::Controller::KeyStatus keyStatus = self->getKeyStatus(keyCode);
lua_newtable(tolua_S); /* L: table */
lua_pushstring(tolua_S, "isPressed"); /* L: table key */
lua_pushboolean(tolua_S, (int)keyStatus.isPressed); /* L: table key value*/
lua_rawset(tolua_S, -3); /* table[key] = value, L: table */
lua_pushstring(tolua_S, "value"); /* L: table key */
lua_pushnumber(tolua_S, (lua_Number) keyStatus.value); /* L: table key value*/
lua_rawset(tolua_S, -3); /* table[key] = value, L: table */
lua_pushstring(tolua_S, "isAnalog"); /* L: table key */
lua_pushnumber(tolua_S, (int) keyStatus.isAnalog); /* L: table key value*/
lua_rawset(tolua_S, -3); /* table[key] = value, L: table */
return 1;
}
CCLOG("'clone' has wrong number of arguments: %d, was expecting %d\n", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'getKeyStatus'.",&tolua_err);
return 0;
#endif
}
static void extendController(lua_State* L)
{
lua_pushstring(L, "cc.Controller");
lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1))
{
tolua_function(L, "getKeyStatus", tolua_cocos2dx_Controller_getKeyStatus);
}
lua_pop(L, 1);
}
int register_all_cocos2dx_controller_manual(lua_State* L)
{
if (nullptr == L)
return 0;
extendEventListenerController(L);
extendController(L);
return 0;
}
#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

View File

@ -0,0 +1,41 @@
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CONTROLLER_MANUAL_H
#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CONTROLLER_MANUAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tolua++.h"
#ifdef __cplusplus
}
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
TOLUA_API int register_all_cocos2dx_controller_manual(lua_State* L);
#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#endif // #ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_CONTROLLER_MANUAL_H

View File

@ -5900,7 +5900,7 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S
if(!ok)
return 0;
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5);
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)&arg5);
return 0;
}
else if (argc == 7)
@ -6090,7 +6090,8 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S)
return 0;
unsigned int ret = cobj->getTileGIDAt(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
tolua_pushnumber(tolua_S,(lua_Number)0);
return 2;
}
if (argc == 2)
{
@ -6105,7 +6106,8 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S)
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
return 1;
tolua_pushnumber(tolua_S,(lua_Number)arg1);
return 2;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1);
return 0;
@ -6436,6 +6438,149 @@ static void extendApplication(lua_State* tolua_S)
lua_pop(tolua_S, 1);
}
static int lua_cocos2dx_FastTMXLayer_getTileGIDAt(lua_State* tolua_S)
{
int argc = 0;
cocos2d::FastTMXLayer* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.FastTMXLayer",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::FastTMXLayer*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec2 arg0;
ok &= luaval_to_vec2(tolua_S, 2, &arg0);
if(!ok)
return 0;
int ret = cobj->getTileGIDAt(arg0);
tolua_pushnumber(tolua_S,(lua_Number)ret);
tolua_pushnumber(tolua_S,(lua_Number)0);
return 2;
}
if (argc == 2)
{
cocos2d::Vec2 arg0;
int arg1 = 0;
ok &= luaval_to_vec2(tolua_S, 2, &arg0);
ok &= luaval_to_int32(tolua_S, 3, &arg1);
if(!ok)
return 0;
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
tolua_pushnumber(tolua_S,(lua_Number)ret);
tolua_pushnumber(tolua_S,(lua_Number)arg1);
return 2;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FastTMXLayer_getTileGIDAt'.",&tolua_err);
#endif
return 0;
}
static void extendFastTMXLayer(lua_State* tolua_S)
{
lua_pushstring(tolua_S, "cc.FastTMXLayer");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
tolua_function(tolua_S, "getTileGIDAt", lua_cocos2dx_FastTMXLayer_getTileGIDAt);
}
lua_pop(tolua_S, 1);
}
static int lua_cocos2dx_TextureCache_addImageAsync(lua_State* tolua_S)
{
if (nullptr == tolua_S)
return 0 ;
int argc = 0;
TextureCache* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<TextureCache*>(tolua_tousertype(tolua_S,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(tolua_S,"invalid 'self' in function 'lua_cocos2dx_TextureCache_addImageAsync'\n", NULL);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (2 == argc)
{
#if COCOS2D_DEBUG >= 1
if (!tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
const char* configFilePath = tolua_tostring(tolua_S, 2, "");
LUA_FUNCTION handler = ( toluafix_ref_function(tolua_S, 3, 0));
self->addImageAsync(configFilePath, [=](Texture2D* tex){
int ID = (tex) ? (int)tex->_ID : -1;
int* luaID = (tex) ? &tex->_luaID : nullptr;
toluafix_pushusertype_ccobject(tolua_S, ID, luaID, (void*)tex, "cc.Texture2D");
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler,1);
LuaEngine::getInstance()->removeScriptHandler(handler);
});
return 0;
}
CCLOG("'addImageAsync' function of TextureCache has wrong number of arguments: %d, was expecting %d\n", argc, 1);
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'addImageAsync'.",&tolua_err);
#endif
return 0;
}
static void extendTextureCache(lua_State* tolua_S)
{
lua_pushstring(tolua_S, "cc.TextureCache");
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
if (lua_istable(tolua_S,-1))
{
tolua_function(tolua_S, "addImageAsync", lua_cocos2dx_TextureCache_addImageAsync);
}
lua_pop(tolua_S, 1);
}
int register_all_cocos2dx_manual(lua_State* tolua_S)
{
if (NULL == tolua_S)
@ -6489,6 +6634,8 @@ int register_all_cocos2dx_manual(lua_State* tolua_S)
extendTMXLayer(tolua_S);
extendEventListenerFocus(tolua_S);
extendApplication(tolua_S);
extendFastTMXLayer(tolua_S);
extendTextureCache(tolua_S);
return 0;
}

View File

@ -136,8 +136,8 @@ static int lua_cocos2dx_CCSkeletonAnimation_createWithFile(lua_State* L)
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L,"#ferror in function 'createWithFile'.",&tolua_err);
return 0;
#endif
return 0;
}
int tolua_Cocos2d_CCSkeletonAnimation_registerSpineEventHandler00(lua_State* tolua_S)

View File

@ -211,6 +211,7 @@
2905FAD718CF143800240AA3 /* lua_cocos2dx_ui_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905FAD418CF143800240AA3 /* lua_cocos2dx_ui_manual.cpp */; };
2905FAD818CF143800240AA3 /* lua_cocos2dx_ui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2905FAD518CF143800240AA3 /* lua_cocos2dx_ui_manual.hpp */; };
2905FAD918CF143800240AA3 /* lua_cocos2dx_ui_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2905FAD518CF143800240AA3 /* lua_cocos2dx_ui_manual.hpp */; };
C08D4F731974E00F00C87690 /* liblua.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D9BAFA1974D30000EC35BB /* liblua.a */; };
C0FEF4D618BE0E70001F446C /* lua_debugger.c in Sources */ = {isa = PBXBuildFile; fileRef = C0FEF4D418BE0E70001F446C /* lua_debugger.c */; };
C0FEF4D718BE0E70001F446C /* lua_debugger.c in Sources */ = {isa = PBXBuildFile; fileRef = C0FEF4D418BE0E70001F446C /* lua_debugger.c */; };
C0FEF4D818BE0E70001F446C /* lua_debugger.h in Headers */ = {isa = PBXBuildFile; fileRef = C0FEF4D518BE0E70001F446C /* lua_debugger.h */; };
@ -325,6 +326,7 @@
2905FACF18CF12E600240AA3 /* lua_cocos2dx_ui_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_ui_auto.hpp; sourceTree = "<group>"; };
2905FAD418CF143800240AA3 /* lua_cocos2dx_ui_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_ui_manual.cpp; sourceTree = "<group>"; };
2905FAD518CF143800240AA3 /* lua_cocos2dx_ui_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_ui_manual.hpp; sourceTree = "<group>"; };
C0D9BAFA1974D30000EC35BB /* liblua.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblua.a; path = ../../../../external/lua/lua/prebuilt/ios/liblua.a; sourceTree = "<group>"; };
C0FEF4D418BE0E70001F446C /* lua_debugger.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lua_debugger.c; sourceTree = "<group>"; };
C0FEF4D518BE0E70001F446C /* lua_debugger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua_debugger.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -334,6 +336,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C08D4F731974E00F00C87690 /* liblua.a in Frameworks */,
1ABCA1F418CD8F540087CE3A /* libluajit.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -362,6 +365,7 @@
1551A334158F2AB200E66CFE = {
isa = PBXGroup;
children = (
C0D9BAFA1974D30000EC35BB /* liblua.a */,
1ABCA1E218CD8F230087CE3A /* external */,
1AACE74818BC45C200215002 /* auto */,
1AACE75B18BC45C200215002 /* manual */,
@ -959,7 +963,6 @@
"$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios",
"$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios",
);
"OTHER_LDFLAGS[arch=arm64]" = "-llua";
"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
"OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua";
SDKROOT = iphoneos;
@ -985,7 +988,6 @@
"$(SRCROOT)/../../../../external/lua/luajit/prebuilt/ios",
"$(SRCROOT)/../../../../external/lua/lua/prebuilt/ios",
);
"OTHER_LDFLAGS[arch=arm64]" = "-llua";
"OTHER_LDFLAGS[sdk=iphonesimulator7.1]" = "-llua";
"OTHER_LDFLAGS[sdk=iphonesimulator8.0]" = "-llua";
SDKROOT = iphoneos;

View File

@ -349,6 +349,14 @@ cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN = 53
cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54
cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55
cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE = 56
cc.Handler.EVENT_FOCUS = 57
cc.Handler.EVENT_CONTROLLER_CONNECTED = 58
cc.Handler.EVENT_CONTROLLER_DISCONNECTED = 59
cc.Handler.EVENT_CONTROLLER_KEYDOWN = 60
cc.Handler.EVENT_CONTROLLER_KEYUP = 61
cc.Handler.EVENT_CONTROLLER_KEYREPEAT = 62
cc.Handler.EVENT_CONTROLLER_AXIS = 63
cc.EVENT_UNKNOWN = 0
cc.EVENT_TOUCH_ONE_BY_ONE = 1
@ -569,5 +577,38 @@ cc.EventCode =
CANCELLED = 3,
}
cc.ControllerKey =
{
JOYSTICK_LEFT_X = 1000,
JOYSTICK_LEFT_Y = 1001,
JOYSTICK_RIGHT_X = 1002,
JOYSTICK_RIGHT_Y = 1003,
BUTTON_A = 1004,
BUTTON_B = 1005,
BUTTON_C = 1006,
BUTTON_X = 1007,
BUTTON_Y = 1008,
BUTTON_Z = 1009,
BUTTON_DPAD_UP = 1010,
BUTTON_DPAD_DOWN = 1011,
BUTTON_DPAD_LEFT = 1012,
BUTTON_DPAD_RIGHT = 1013,
BUTTON_DPAD_CENTER = 1014,
BUTTON_LEFT_SHOULDER = 1015,
BUTTON_RIGHT_SHOULDER = 1016,
AXIS_LEFT_TRIGGER = 1017,
AXIS_RIGHT_TRIGGER = 1018,
BUTTON_LEFT_THUMBSTICK = 1019,
BUTTON_RIGHT_THUMBSTICK = 1020,
BUTTON_START = 1021,
BUTTON_SELECT = 1022,
BUTTON_PAUSE = 1023,
KEY_MAX = 1024,
}

View File

@ -0,0 +1,95 @@
-- bit operation
bit = bit or {}
bit.data32 = {}
for i=1,32 do
bit.data32[i]=2^(32-i)
end
function bit._b2d(arg)
local nr=0
for i=1,32 do
if arg[i] ==1 then
nr=nr+bit.data32[i]
end
end
return nr
end
function bit._d2b(arg)
arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1)
local tr={}
for i=1,32 do
if arg >= bit.data32[i] then
tr[i]=1
arg=arg-bit.data32[i]
else
tr[i]=0
end
end
return tr
end
function bit._and(a,b)
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 and op2[i]==1 then
r[i]=1
else
r[i]=0
end
end
return bit._b2d(r)
end
function bit._rshift(a,n)
local op1=bit._d2b(a)
n = n <= 32 and n or 32
n = n >= 0 and n or 0
for i=32, n+1, -1 do
op1[i] = op1[i-n]
end
for i=1, n do
op1[i] = 0
end
return bit._b2d(op1)
end
function bit._not(a)
local op1=bit._d2b(a)
local r={}
for i=1,32 do
if op1[i]==1 then
r[i]=0
else
r[i]=1
end
end
return bit._b2d(r)
end
function bit._or(a,b)
local op1=bit._d2b(a)
local op2=bit._d2b(b)
local r={}
for i=1,32 do
if op1[i]==1 or op2[i]==1 then
r[i]=1
else
r[i]=0
end
end
return bit._b2d(r)
end
bit.band = bit.band or bit._and
bit.rshift = bit.rshift or bit._rshift
bit.bnot = bit.bnot or bit._not

View File

@ -80,7 +80,7 @@ public:
*
* @param disabled disabled state texture name.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextures(const std::string& normal,
const std::string& selected,
@ -92,7 +92,7 @@ public:
*
* @param normal normal state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureNormal(const std::string& normal, TextureResType texType = TextureResType::LOCAL);
@ -101,7 +101,7 @@ public:
*
* @param selected selected state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTexturePressed(const std::string& selected, TextureResType texType = TextureResType::LOCAL);
@ -110,7 +110,7 @@ public:
*
* @param disabled dark state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureDisabled(const std::string& disabled, TextureResType texType = TextureResType::LOCAL);

View File

@ -86,7 +86,7 @@ public:
*
* @param frontCrossDisabled cross dark state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
static CheckBox* create(const std::string& backGround,
const std::string& backGroundSeleted,
@ -106,7 +106,7 @@ public:
*
* @param frontCrossDisabled cross dark state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextures(const std::string& backGround,
const std::string& backGroundSelected,
@ -120,7 +120,7 @@ public:
*
* @param backGround backGround texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureBackGround(const std::string& backGround,TextureResType type = TextureResType::LOCAL);
@ -129,7 +129,7 @@ public:
*
* @param backGroundSelected backGround selected state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = TextureResType::LOCAL);
@ -138,7 +138,7 @@ public:
*
* @param cross cross texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureFrontCross(const std::string&,TextureResType texType = TextureResType::LOCAL);
@ -147,7 +147,7 @@ public:
*
* @param backGroundDisabled backGroundDisabled texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = TextureResType::LOCAL);
@ -156,7 +156,7 @@ public:
*
* @param frontCrossDisabled frontCrossDisabled texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = TextureResType::LOCAL);

View File

@ -61,7 +61,7 @@ public:
*
* @param imageFileName file name of texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
static ImageView* create(const std::string& imageFileName, TextureResType texType = TextureResType::LOCAL);
@ -71,7 +71,7 @@ public:
*
* @param fileName file name of texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);

View File

@ -1137,7 +1137,7 @@ float Layout::calculateNearestDistance(Widget* baseWidget)
return distance;
}
float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
float Layout::calculateFarthestDistance(cocos2d::ui::Widget *baseWidget)
{
float distance = -FLT_MAX;
@ -1147,7 +1147,7 @@ float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
Layout *layout = dynamic_cast<Layout*>(node);
int length;
if (layout) {
length = layout->calculateFarestDistance(baseWidget);
length = layout->calculateFarthestDistance(baseWidget);
}
else
{
@ -1231,7 +1231,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi
return 0;
}
int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
int Layout::findFarthestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
{
if (baseWidget == nullptr || baseWidget == this)
{
@ -1256,7 +1256,7 @@ int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Wi
Layout *layout = dynamic_cast<Layout*>(w);
if (layout)
{
length = layout->calculateFarestDistance(baseWidget);
length = layout->calculateFarthestDistance(baseWidget);
}
else
{
@ -1337,11 +1337,11 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
}
else{
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
}
}else if(dir == FocusDirection::RIGHT){
if (previousWidgetPosition.x > widgetPosition.x) {
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
}
else{
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
@ -1350,13 +1350,13 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
if (previousWidgetPosition.y > widgetPosition.y) {
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
}else{
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
}
}else if(dir == FocusDirection::UP){
if (previousWidgetPosition.y < widgetPosition.y) {
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
}else{
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
}
}else{
CCASSERT(0, "invalid direction!");

View File

@ -110,7 +110,7 @@ public:
*
* @param fileName image file path.
*
* @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame.
* @param texType @see TextureResType. TextureResType::LOCAL means local file, TextureResType::PLIST means sprite frame.
*/
void setBackGroundImage(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);
@ -143,7 +143,7 @@ public:
bool isBackGroundImageScale9Enabled()const;
/**
* Sets background color for layout, if color type is LAYOUT_COLOR_SOLID
* Sets background color for layout, if color type is BackGroundColorType::SOLIDE
*
* @param color
*/
@ -152,7 +152,7 @@ public:
const Color3B& getBackGroundColor()const;
/**
* Sets background color for layout, if color type is LAYOUT_COLOR_GRADIENT
* Sets background color for layout, if color type is BackGroundColorType::GRADIENT
*
* @param start color
*
@ -174,7 +174,7 @@ public:
GLubyte getBackGroundColorOpacity()const;
/**
* Sets background color vector for layout, if color type is LAYOUT_COLOR_GRADIENT
* Sets background color vector for layout, if color type is BackGroundColorType::GRADIENT
*
* @param vector
*/
@ -365,11 +365,11 @@ protected:
/**
* When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child
* will get the focus. The current algorithm to determine which child will get focus is farest-distance-priority algorithm
* will get the focus. The current algorithm to determine which child will get focus is farthest-distance-priority algorithm
*@param dir next focused widget direction
*@return The index of child widget in the container
*/
int findFarestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
int findFarthestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
/**
* caculate the nearest distance between the baseWidget and the children of the layout
@ -379,15 +379,15 @@ protected:
float calculateNearestDistance(Widget* baseWidget);
/**
* caculate the farest distance between the baseWidget and the children of the layout
* caculate the farthest distance between the baseWidget and the children of the layout
*@param the base widget which will be used to caculate the distance between the layout's children and itself
*@return return the farest distance between the baseWidget and the layout's children
*@return return the farthest distance between the baseWidget and the layout's children
*/
float calculateFarestDistance(Widget* baseWidget);
float calculateFarthestDistance(Widget* baseWidget);
/**
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farest distance algorithm or not
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farthest distance algorithm or not
*/
void findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget);

View File

@ -180,9 +180,9 @@ public:
/**
* Changes scroll direction of scrollview.
*
* @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll
* @see Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll
*
* @param SCROLLVIEW_DIR
* @param dir, set the list view's scroll direction
*/
virtual void setDirection(Direction dir) override;

View File

@ -89,7 +89,7 @@ public:
*
* @param texture file name of texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadTexture(const std::string& texture,TextureResType texType = TextureResType::LOCAL);

View File

@ -127,8 +127,7 @@ public:
*/
ssize_t getCurPageIndex() const;
//TODO: add Vector<Layout*> member variables into UIPageView, but it only used for reference purpose,
//all the pages are added into proteced node, so does scrollview, listview
Vector<Layout*>& getPages();
Layout* getPage(ssize_t index);

View File

@ -95,18 +95,18 @@ public:
/**
* Changes scroll direction of scrollview.
*
* @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll
* @see Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll
*
* @param SCROLLVIEW_DIR
* @param dir
*/
virtual void setDirection(Direction dir);
/**
* Gets scroll direction of scrollview.
*
* @see SCROLLVIEW_DIR SCROLLVIEW_DIR_VERTICAL means vertical scroll, SCROLLVIEW_DIR_HORIZONTAL means horizontal scroll
* @see Direction Direction::VERTICAL means vertical scroll, Direction::HORIZONTAL means horizontal scroll
*
* @return SCROLLVIEW_DIR
* @return Direction
*/
Direction getDirection()const;

View File

@ -76,7 +76,7 @@ public:
*
* @param fileName file name of texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadBarTexture(const std::string& fileName,TextureResType texType = TextureResType::LOCAL);
@ -123,7 +123,7 @@ public:
*
* @param slider ball disabled dark state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadSlidBallTextures(const std::string& normal,
const std::string& pressed,
@ -135,7 +135,7 @@ public:
*
* @param normal normal state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = TextureResType::LOCAL);
@ -144,7 +144,7 @@ public:
*
* @param selected selected state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = TextureResType::LOCAL);
@ -153,7 +153,7 @@ public:
*
* @param disabled dark state texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = TextureResType::LOCAL);
@ -162,7 +162,7 @@ public:
*
* @param fileName file path of texture.
*
* @param texType @see UI_TEX_TYPE_LOCAL
* @param texType @see TextureResType
*/
void loadProgressBarTexture(const std::string& fileName, TextureResType texType = TextureResType::LOCAL);

View File

@ -296,7 +296,6 @@ void Text::labelScaleChangedWithSize()
{
if (_ignoreSize)
{
_labelRenderer->setDimensions(0,0);
_labelRenderer->setScale(1.0f);
_normalScaleValueX = _normalScaleValueY = 1.0f;
}

View File

@ -23,6 +23,7 @@ THE SOFTWARE.
****************************************************************************/
#include "ui/UITextField.h"
#include "platform/CCFileUtils.h"
NS_CC_BEGIN
@ -366,7 +367,10 @@ _textFieldEventListener(nullptr),
_textFieldEventSelector(nullptr),
_eventCallback(nullptr),
_passwordStyleText(""),
_textFieldRendererAdaptDirty(true)
_textFieldRendererAdaptDirty(true),
_fontName("Thonburi"),
_fontSize(10),
_fontType(FontType::SYSTEM)
{
}
@ -541,26 +545,44 @@ const std::string& TextField::getPlaceHolder()const
void TextField::setFontSize(int size)
{
_textFieldRenderer->setSystemFontSize(size);
if (_fontType == FontType::SYSTEM) {
_textFieldRenderer->setSystemFontSize(size);
} else {
TTFConfig config = _textFieldRenderer->getTTFConfig();
config.fontSize = size;
_textFieldRenderer->setTTFConfig(config);
}
_fontSize = size;
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
}
int TextField::getFontSize()const
{
return _textFieldRenderer->getSystemFontSize();
return _fontSize;
}
void TextField::setFontName(const std::string& name)
{
_textFieldRenderer->setSystemFontName(name);
if(FileUtils::getInstance()->isFileExist(name))
{
TTFConfig config = _textFieldRenderer->getTTFConfig();
config.fontFilePath = name;
config.fontSize = _fontSize;
_textFieldRenderer->setTTFConfig(config);
_fontType = FontType::TTF;
} else {
_textFieldRenderer->setSystemFontName(name);
_fontType = FontType::SYSTEM;
}
_fontName = name;
_textFieldRendererAdaptDirty = true;
updateContentSizeWithTextureSize(_textFieldRenderer->getContentSize());
}
const std::string& TextField::getFontName()const
{
return _textFieldRenderer->getSystemFontName();
return _fontName;
}
void TextField::didNotSelectSelf()
@ -831,8 +853,8 @@ void TextField::copySpecialProperties(Widget *widget)
{
setText(textField->_textFieldRenderer->getString());
setPlaceHolder(textField->getStringValue());
setFontSize(textField->_textFieldRenderer->getSystemFontSize());
setFontName(textField->_textFieldRenderer->getSystemFontName());
setFontSize(textField->_fontSize);
setFontName(textField->_fontName);
setMaxLengthEnabled(textField->isMaxLengthEnabled());
setMaxLength(textField->getMaxLength());
setPasswordEnabled(textField->isPasswordEnabled());

View File

@ -228,6 +228,16 @@ protected:
std::string _passwordStyleText;
bool _textFieldRendererAdaptDirty;
private:
enum class FontType
{
SYSTEM,
TTF
};
std::string _fontName;
int _fontSize;
FontType _fontType;
};
}

View File

@ -236,7 +236,6 @@ public:
CC_DEPRECATED_ATTRIBUTE void addTouchEventListener(Ref* target,SEL_TouchEvent selector);
void addTouchEventListener(ccWidgetTouchCallback callback);
//cocos2d property
/**
* Changes the position (x,y) of the widget in OpenGL coordinates
@ -249,10 +248,7 @@ public:
virtual void setPosition(const Vec2 &pos) override;
/**
* Changes the position (x,y) of the widget in OpenGL coordinates
*
* Usually we use p(x,y) to compose Vec2 object.
* The original point (0,0) is at the left-bottom corner of screen.
* Set the percent(x,y) of the widget in OpenGL coordinates
*
* @param percent The percent (x,y) of the widget in OpenGL coordinates
*/
@ -456,16 +452,18 @@ public:
/**
* Ignore the widget size
*
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
* Note: when you set _ignoreSize to true, no matther you call setContentSize or not,
* the widget size is always equal to the return value of the member function getVirtualRendererSize.
*
* @param ignore, set member variabl _ignoreSize to ignore
*/
virtual void ignoreContentAdaptWithSize(bool ignore);
/**
* Gets the widget if is ignore it's size.
* Query whether the widget ignores user deinfed content size or not
*
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
* @return bool
*/
bool isIgnoreContentAdaptWithSize() const;
@ -485,15 +483,9 @@ public:
*/
virtual Node* getVirtualRenderer();
// /**
// * Gets the content size of widget.
// *
// * Content size is widget's texture size.
// */
// virtual const Size& getContentSize() const;
virtual const Size& getVirtualRendererSize() const;
/**
* Returns the "class name" of widget.

View File

@ -1,8 +1,8 @@
# cocos2d-x v3.2rc0 Release Notes #
# cocos2d-x v3.2 Release Notes #
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
- [cocos2d-x v3.2rc0 Release Notes](#user-content-cocos2d-x-v32rc0-release-notes)
- [cocos2d-x v3.2 Release Notes](#user-content-cocos2d-x-v32-release-notes)
- [Misc Information](#user-content-misc-information)
- [Requirements](#user-content-requirements)
- [Runtime Requirements](#user-content-runtime-requirements)
@ -13,21 +13,23 @@
- [Windows](#user-content-windows)
- [Linux](#user-content-linux)
- [How to start a new game](#user-content-how-to-start-a-new-game)
- [Highlights of v3.2rc0](#user-content-highlights-of-v32rc0)
- [Highlights of v3.2](#user-content-highlights-of-v32)
- [Documents](#user-content-documents)
- [Toolchain requirement changed](#user-content-toolchain-requirement-changed)
- [Features in detail](#user-content-features-in-detail)
- [Sprite3d](#user-content-sprite3d)
- [Sprite3D & Animation3D](#user-content-sprite3d--animation3d)
- [fbx-conv usage](#user-content-fbx-conv-usage)
- [Controller support](#user-content-controller-support)
- [Game controller](#user-content-game-controller)
- [Fast tilemap](#user-content-fast-tilemap)
- [Node::enumerateChildren](#user-content-nodeenumeratechildren)
- [utils::findChildren](#user-content-utilsfindchildren)
- [Node::setNormalizedPosition](#user-content-nodesetnormalizedposition)
# Misc Information
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2rc0.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2rc0/CHANGELOG
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2rc0/index.html
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2/CHANGELOG
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2/index.html
* v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md)
# Requirements
@ -114,14 +116,22 @@ Run
Please refer to this document: [ReadMe](../README.md)
# Highlights of v3.2rc0
# Highlights of v3.2
* `fbx-conv` support generating binary format, and `Sprite3D` support it
* about 20% performance improved in `Sprite3D`
* game controller support
* fast tilemap support, it is faster for static tilemap
* physics body supports scale and rotation
* added Node::enumearteChildren(), and support c++ 11 regular expression
* `Animation3D`/`Animate3D`, new nodes for 3d animation
* `fbx-conv` supports generating binary format which is supported by `Sprite3D`
* Game controller support
* Fast tilemap support
* Added `utils::cpatureScreen` to take screenshot
* Physics body supports scale and rotation
* Added `Node::enumerateChildren` and `utils::findChildren`, and support c++ 11 regular expression
* Added `Node::setNormalizedPosition`, `Node`'s position in pixel will be calculated according its parent's content size
# Documents
* [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D)
* [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller)
* [How to compile shader on WP8](http://cocos2d-x.org/wiki/How_to_update_wp8_shader)
# Toolchain requirement changed
@ -133,14 +143,19 @@ Please refer to this document: [ReadMe](../README.md)
# Features in detail
## Sprite3d
## Sprite3D & Animation3D
Sample code to use binary version
```c++
auto sprite3d = Sprite3D::create("filename.c3b");
addChild(sprite3d);
auto animation3d = Animation3D("filename.c3b");
auto animate3d = Animate3D::create(animation3d);
sprite3d->runAction(RepeatForEver::create(animate));
```
Detail information please refer to [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D).
### `fbx-conv` usage
@ -164,19 +179,43 @@ Options:
* -b: export binary format
* -t: export text format
## Controller support
## Game controller
Supported controller type:
* amazon tv
* Android standard controllers
* Amazon tv
* OUYA
* Moga
* Nibiru
* iOS standard controllers
In order to use controller on Android, you should refer to this Android project(`COCOS2DX_ROOT/cocos/platform/android/ControllerManualAdapter`).
Sample codes
```c++
// register event listener
auto listener = EventListenerController::create();
listner->onKeyDown = ...
...
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
Full demo please refer to `COCOS2DX_ROOT/tests/game-controler-test`.
// start connecting controller
Controller::startDiscoveryController();
// handler key down/ key up event
void GameControllerTest::onKeyDown(Controller *controller, int keyCode, Event *event)
{
switch (keyCode)
{
case Controller::Key::BUTTON_A:
...
break;
...
}
}
```
Detail information please refer to [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller).
## Fast tilemap
@ -192,7 +231,7 @@ Full demo please refer to `COCOS2DX_ROOT/tests/cpp-tests/Classes/TileMapTest/Til
## Node::enumerateChildren
This functions is used to enumerate children of a `Node` recursively. It supports c++ 11 regular expression.
This functions is used to enumerate children of a `Node`. It supports c++ 11 regular expression.
```c++
// Find nodes whose name is 'nameToFind' and end with digits.
@ -200,6 +239,12 @@ node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool {
...
return false; // return true to stop at first match
});
// Find nodes whose name is 'nameToFind' and end with digits recursively.
node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool {
...
return false; // return true to stop at first match
});
```
Full test please refer to `NodeNameTest` in `COCOS2DX_ROOT/tests/cpp-tests/NodeTest/NodeTest.cpp`.
@ -215,3 +260,18 @@ auto children = utils::findChildren(node, "nameToFind");
...
```
## Node::setNormalizedPosition
Can use this function to set Node's position(x,y) using value between 0 and 1. `Can use this function when it has a parent node.` The positions in pixels is calculated like the following:
```c++
// pseudo code
void setNormalizedPosition(Vec2 pos)
{
Size s = getParent()->getContentSize();
_position = pos * s;
}
```
Full test please refer to `NodeNormalizedPositionTest1/2` in `tests/cpp-tests/Classes/NodeTest/NodeTest.cpp`.

View File

@ -404,11 +404,15 @@ void EditBoxImplMac::setText(const char* pText)
{
NSString *string = [NSString stringWithUTF8String:pText];
_sysEdit.textField.stringValue = string;
_sysEdit.textField.stringValue = string;
_sysEdit.secureTextField.stringValue = string;
}
const char* EditBoxImplMac::getText(void)
{
if (_sysEdit.secureTextField.superview) {
return [_sysEdit.secureTextField.stringValue UTF8String];
}
return [_sysEdit.textField.stringValue UTF8String];
}

View File

@ -1,5 +1,5 @@
{
"version":"v3-deps-4",
"version":"v3-deps-5",
"zip_file_size":"57171285",
"repo_name":"cocos2d-x-3rd-party-libs-bin",
"repo_parent":"https://github.com/cocos2d/"

View File

@ -218,7 +218,7 @@ class SetEnvVar(object):
return ret
def _find_environment_variable(self, var):
print(" ->Find environment variable %s..." % var)
print(" ->Search for environment variable %s..." % var)
ret = None
try:
ret = os.environ[var]
@ -529,49 +529,31 @@ class SetEnvVar(object):
return ret
def _get_ant_path(self):
print(" ->Find command ant in system...")
ret = None
if not self._isWindows():
import commands
state, result = commands.getstatusoutput("which ant")
if state == 0:
ret = os.path.dirname(result)
if ret is not None:
print(" ->Path \"%s\" was found\n" % ret)
else:
print(" ->Command ant not found\n")
return ret
return self._get_sdkpath_for_cmd("ant", False)
def _get_androidsdk_path(self):
print(" ->Find command android in system...")
ret = None
if not self._isWindows():
import commands
state, result = commands.getstatusoutput("which android")
if state == 0:
ret = os.path.dirname(result)
if ret is not None:
ret = os.path.abspath(os.path.join(ret,os.pardir))
print(" ->Path \"%s\" was found\n" % ret)
else:
print(" ->Command android not found\n")
return ret
return self._get_sdkpath_for_cmd("android")
def _get_ndkbuild_path(self):
print(" ->Find command ndk-build in system...")
return self._get_sdkpath_for_cmd("ndk-build", False)
def _get_sdkpath_for_cmd(self, cmd, has_bin_folder=True):
ret = None
print(" ->Search for command " + cmd + " in system...")
if not self._isWindows():
import commands
state, result = commands.getstatusoutput("which ndk-build")
state, result = commands.getstatusoutput("which " + cmd)
if state == 0:
ret = os.path.dirname(result)
ret = os.path.realpath(result)
ret = os.path.dirname(ret)
# Use parent folder if has_bin_folder was set
if has_bin_folder:
ret = os.path.dirname(ret)
if ret is not None:
print(" ->Path \"%s\" was found\n" % ret)
print(" ->Path " + ret + " was found\n")
else:
print(" ->Command ndk-build not found\n")
print(" ->Command " + ret + " not found\n")
return ret
def _find_value_from_sys(self, var_name):

View File

@ -1323,7 +1323,6 @@
"external/curl/prebuilt/android/armeabi/libcurl.a",
"external/curl/prebuilt/android/x86/libcurl.a",
"external/curl/prebuilt/ios/libcurl.a",
"external/curl/prebuilt/ios/libcurl_arm64.a",
"external/curl/prebuilt/win32/libcurl.dll",
"external/curl/prebuilt/win32/libcurl_imp.lib",
"external/curl/prebuilt/wp8/arm/libcurl.dll",
@ -1923,7 +1922,6 @@
"external/freetype2/prebuilt/android/armeabi/libfreetype.a",
"external/freetype2/prebuilt/android/x86/libfreetype.a",
"external/freetype2/prebuilt/ios/libfreetype.a",
"external/freetype2/prebuilt/ios/libfreetype_arm64.a",
"external/freetype2/prebuilt/linux/32-bit/libfreetype.a",
"external/freetype2/prebuilt/linux/64-bit/libfreetype.a",
"external/freetype2/prebuilt/mac/libfreetype.a",
@ -1978,7 +1976,6 @@
"external/jpeg/prebuilt/android/armeabi/libjpeg.a",
"external/jpeg/prebuilt/android/x86/libjpeg.a",
"external/jpeg/prebuilt/ios/libjpeg.a",
"external/jpeg/prebuilt/ios/libjpeg_arm64.a",
"external/jpeg/prebuilt/linux/32-bit/libjpeg.a",
"external/jpeg/prebuilt/linux/64-bit/libjpeg.a",
"external/jpeg/prebuilt/mac/libjpeg.a",
@ -2055,7 +2052,6 @@
"external/png/prebuilt/android/armeabi/libpng.a",
"external/png/prebuilt/android/x86/libpng.a",
"external/png/prebuilt/ios/libpng.a",
"external/png/prebuilt/ios/libpng_arm64.a",
"external/png/prebuilt/mac/libpng.a",
"external/png/prebuilt/win32/libpng.lib",
"external/png/prebuilt/winrt/ARM/libpng.lib",
@ -2108,7 +2104,6 @@
"external/tiff/prebuilt/android/armeabi/libtiff.a",
"external/tiff/prebuilt/android/x86/libtiff.a",
"external/tiff/prebuilt/ios/libtiff.a",
"external/tiff/prebuilt/ios/libtiff_arm64.a",
"external/tiff/prebuilt/linux/32-bit/libtiff.a",
"external/tiff/prebuilt/linux/64-bit/libtiff.a",
"external/tiff/prebuilt/mac/libtiff.a",
@ -2147,7 +2142,6 @@
"external/webp/prebuilt/android/armeabi/libwebp.a",
"external/webp/prebuilt/android/x86/libwebp.a",
"external/webp/prebuilt/ios/libwebp.a",
"external/webp/prebuilt/ios/libwebp_arm64.a",
"external/webp/prebuilt/linux/32-bit/libwebp.a",
"external/webp/prebuilt/linux/64-bit/libwebp.a",
"external/webp/prebuilt/mac/libwebp.a",
@ -2177,7 +2171,6 @@
"external/websockets/prebuilt/android/armeabi/libwebsockets.a",
"external/websockets/prebuilt/android/x86/libwebsockets.a",
"external/websockets/prebuilt/ios/libwebsockets.a",
"external/websockets/prebuilt/ios/libwebsockets_arm64.a",
"external/websockets/prebuilt/linux/32-bit/libwebsockets.a",
"external/websockets/prebuilt/linux/64-bit/libwebsockets.a",
"external/websockets/prebuilt/mac/libwebsockets.a",
@ -3631,6 +3624,7 @@
"cocos/scripting/lua-bindings/auto/api/ControlSlider.lua",
"cocos/scripting/lua-bindings/auto/api/ControlStepper.lua",
"cocos/scripting/lua-bindings/auto/api/ControlSwitch.lua",
"cocos/scripting/lua-bindings/auto/api/Controller.lua",
"cocos/scripting/lua-bindings/auto/api/DelayTime.lua",
"cocos/scripting/lua-bindings/auto/api/Director.lua",
"cocos/scripting/lua-bindings/auto/api/DisplayData.lua",
@ -3676,6 +3670,7 @@
"cocos/scripting/lua-bindings/auto/api/EditBox.lua",
"cocos/scripting/lua-bindings/auto/api/Event.lua",
"cocos/scripting/lua-bindings/auto/api/EventAcceleration.lua",
"cocos/scripting/lua-bindings/auto/api/EventController.lua",
"cocos/scripting/lua-bindings/auto/api/EventCustom.lua",
"cocos/scripting/lua-bindings/auto/api/EventDispatcher.lua",
"cocos/scripting/lua-bindings/auto/api/EventFocus.lua",
@ -3683,6 +3678,7 @@
"cocos/scripting/lua-bindings/auto/api/EventKeyboard.lua",
"cocos/scripting/lua-bindings/auto/api/EventListener.lua",
"cocos/scripting/lua-bindings/auto/api/EventListenerAcceleration.lua",
"cocos/scripting/lua-bindings/auto/api/EventListenerController.lua",
"cocos/scripting/lua-bindings/auto/api/EventListenerCustom.lua",
"cocos/scripting/lua-bindings/auto/api/EventListenerFocus.lua",
"cocos/scripting/lua-bindings/auto/api/EventListenerKeyboard.lua",
@ -3702,6 +3698,8 @@
"cocos/scripting/lua-bindings/auto/api/FadeOutTRTiles.lua",
"cocos/scripting/lua-bindings/auto/api/FadeOutUpTiles.lua",
"cocos/scripting/lua-bindings/auto/api/FadeTo.lua",
"cocos/scripting/lua-bindings/auto/api/FastTMXLayer.lua",
"cocos/scripting/lua-bindings/auto/api/FastTMXTiledMap.lua",
"cocos/scripting/lua-bindings/auto/api/FileUtils.lua",
"cocos/scripting/lua-bindings/auto/api/FiniteTimeAction.lua",
"cocos/scripting/lua-bindings/auto/api/FlipX.lua",
@ -3938,6 +3936,7 @@
"cocos/scripting/lua-bindings/auto/api/Widget.lua",
"cocos/scripting/lua-bindings/auto/api/ZOrderFrame.lua",
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua",
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_controller_auto_api.lua",
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_experimental_video_auto_api.lua",
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_extension_auto_api.lua",
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_physics_auto_api.lua",
@ -3946,6 +3945,8 @@
"cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_ui_auto_api.lua",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.hpp",
"cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp",
@ -3982,6 +3983,8 @@
"cocos/scripting/lua-bindings/manual/Lua_web_socket.h",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_coco_studio_manual.cpp",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_coco_studio_manual.hpp",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_controller_manual.cpp",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_controller_manual.hpp",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_deprecated.cpp",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_deprecated.h",
"cocos/scripting/lua-bindings/manual/lua_cocos2dx_experimental_video_manual.cpp",
@ -4028,6 +4031,7 @@
"cocos/scripting/lua-bindings/script/Opengl.lua",
"cocos/scripting/lua-bindings/script/OpenglConstants.lua",
"cocos/scripting/lua-bindings/script/StudioConstants.lua",
"cocos/scripting/lua-bindings/script/bitExtend.lua",
"cocos/scripting/lua-bindings/script/experimentalConstants.lua",
"cocos/scripting/lua-bindings/script/extern.lua",
"cocos/scripting/lua-bindings/script/json.lua",
@ -4413,6 +4417,7 @@
"tools/bindings-generator/tools/win32/cygwin1.dll",
"tools/tolua/README.mdown",
"tools/tolua/cocos2dx.ini",
"tools/tolua/cocos2dx_controller.ini",
"tools/tolua/cocos2dx_experimental_video.ini",
"tools/tolua/cocos2dx_extension.ini",
"tools/tolua/cocos2dx_physics.ini",

View File

@ -127,6 +127,7 @@ link_directories(
elseif(UNIX) #assumed linux
include_directories(
/usr/local/include/GLFW
/usr/include/GLFW
${COCOS2D_ROOT}
${COCOS2D_ROOT}/cocos
${COCOS2D_ROOT}/cocos/audio/include

View File

@ -941,6 +941,7 @@
"$(SRCROOT)/../cocos2d/external",
"$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
@ -969,6 +970,7 @@
"$(SRCROOT)/../cocos2d/external",
"$(SRCROOT)/../cocos2d/external/chipmunk/include/chipmunk",
);
MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;

View File

@ -67,8 +67,8 @@ void Cocos2dRenderer::CreateGLResources()
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
cocos2d::DrawPrimitives::init();
cocos2d::VolatileTextureMgr::reloadAllTextures();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
cocos2d::Application::getInstance()->applicationWillEnterForeground();
director->setGLDefaultValues();
}

View File

@ -19,23 +19,6 @@ AppDelegate::~AppDelegate()
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::createWithRect("HelloLua", Rect(0,0,900,640));
director->setOpenGLView(glview);
}
glview->setDesignResolutionSize(480, 320, ResolutionPolicy::NO_BORDER);
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
if (engine->executeScriptFile("src/main.lua")) {

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