Merge branch 'v3' into addStudio1.4
Conflicts: cocos/editor-support/cocostudio/WidgetReader/TextReader/TextReader.cpp
|
@ -8,7 +8,7 @@ import shutil
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
CPP_SAMPLES = ['cpp-empty-test', 'cpp-tests', 'game-controller-test']
|
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
|
ALL_SAMPLES = CPP_SAMPLES + LUA_SAMPLES
|
||||||
|
|
||||||
def get_num_of_cpu():
|
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")
|
resources_dir = os.path.join(app_android_root, "../../../cpp-tests/Resources")
|
||||||
copy_files(resources_dir, assets_res_dir)
|
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):
|
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",
|
"game-controller-test": "tests/game-controller-test/proj.android",
|
||||||
"cpp-tests": "tests/cpp-tests/proj.android",
|
"cpp-tests": "tests/cpp-tests/proj.android",
|
||||||
"lua-empty-test": "tests/lua-empty-test/project/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:
|
for target in build_targets:
|
||||||
|
|
|
@ -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>
|
|
@ -194,8 +194,8 @@ bool DrawNode::init()
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// Need to listen the event only when not use batchnode, because it will use VBO
|
// 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){
|
auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
|
||||||
/** listen the event that coming to foreground on Android */
|
/** listen the event that renderer was recreated on Android/WP8 */
|
||||||
this->init();
|
this->init();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "base/CCEventDispatcher.h"
|
#include "base/CCEventDispatcher.h"
|
||||||
#include "base/CCEventType.h"
|
#include "base/CCEventType.h"
|
||||||
|
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
const int FontAtlas::CacheTextureWidth = 512;
|
const int FontAtlas::CacheTextureWidth = 512;
|
||||||
|
@ -41,9 +42,9 @@ FontAtlas::FontAtlas(Font &theFont)
|
||||||
: _font(&theFont)
|
: _font(&theFont)
|
||||||
, _currentPageData(nullptr)
|
, _currentPageData(nullptr)
|
||||||
, _fontAscender(0)
|
, _fontAscender(0)
|
||||||
, _toForegroundListener(nullptr)
|
, _rendererRecreatedListener(nullptr)
|
||||||
, _toBackgroundListener(nullptr)
|
|
||||||
, _antialiasEnabled(true)
|
, _antialiasEnabled(true)
|
||||||
|
, _rendererRecreate(false)
|
||||||
{
|
{
|
||||||
_font->retain();
|
_font->retain();
|
||||||
|
|
||||||
|
@ -77,12 +78,12 @@ FontAtlas::FontAtlas(Font &theFont)
|
||||||
|
|
||||||
addTexture(texture,0);
|
addTexture(texture,0);
|
||||||
texture->release();
|
texture->release();
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
||||||
_toBackgroundListener = EventListenerCustom::create(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(FontAtlas::listenToBackground, this));
|
|
||||||
eventDispatcher->addEventListenerWithFixedPriority(_toBackgroundListener, 1);
|
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(FontAtlas::listenRendererRecreated, this));
|
||||||
_toForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(FontAtlas::listenToForeground, this));
|
eventDispatcher->addEventListenerWithFixedPriority(_rendererRecreatedListener, 1);
|
||||||
eventDispatcher->addEventListenerWithFixedPriority(_toForegroundListener, 1);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,19 +92,11 @@ FontAtlas::~FontAtlas()
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
|
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
|
||||||
if (fontTTf)
|
if (fontTTf && _rendererRecreatedListener)
|
||||||
{
|
{
|
||||||
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
||||||
if (_toForegroundListener)
|
eventDispatcher->removeEventListener(_rendererRecreatedListener);
|
||||||
{
|
_rendererRecreatedListener = nullptr;
|
||||||
eventDispatcher->removeEventListener(_toForegroundListener);
|
|
||||||
_toForegroundListener = nullptr;
|
|
||||||
}
|
|
||||||
if (_toBackgroundListener)
|
|
||||||
{
|
|
||||||
eventDispatcher->removeEventListener(_toBackgroundListener);
|
|
||||||
_toBackgroundListener = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
|
||||||
if (fontTTf && _atlasTextures.size() > 1)
|
if (fontTTf)
|
||||||
{
|
{
|
||||||
for( auto &item: _atlasTextures)
|
for( auto &item: _atlasTextures)
|
||||||
{
|
{
|
||||||
|
@ -171,30 +163,12 @@ void FontAtlas::listenToBackground(EventCustom *event)
|
||||||
_currentPage = 0;
|
_currentPage = 0;
|
||||||
_currentPageOrigX = 0;
|
_currentPageOrigX = 0;
|
||||||
_currentPageOrigY = 0;
|
_currentPageOrigY = 0;
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void FontAtlas::listenToForeground(EventCustom *event)
|
_rendererRecreate = true;
|
||||||
{
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
|
||||||
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
|
|
||||||
if (fontTTf)
|
|
||||||
{
|
|
||||||
if (_currentPageOrigX == 0 && _currentPageOrigY == 0)
|
|
||||||
{
|
|
||||||
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
auto eventDispatcher = Director::getInstance()->getEventDispatcher();
|
||||||
eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
|
eventDispatcher->dispatchCustomEvent(EVENT_PURGE_TEXTURES,this);
|
||||||
|
_rendererRecreate = false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
|
|
||||||
|
|
||||||
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
|
|
||||||
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition)
|
void FontAtlas::addLetterDefinition(const FontLetterDefinition &letterDefinition)
|
||||||
|
@ -332,6 +306,13 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(existNewLetter)
|
if(existNewLetter)
|
||||||
|
{
|
||||||
|
if (_rendererRecreate)
|
||||||
|
{
|
||||||
|
_atlasTextures[_currentPage]->initWithData(_currentPageData, _currentPageDataSize,
|
||||||
|
pixelFormat, CacheTextureWidth, CacheTextureHeight, Size(CacheTextureWidth,CacheTextureHeight) );
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
unsigned char *data = nullptr;
|
unsigned char *data = nullptr;
|
||||||
if(pixelFormat == Texture2D::PixelFormat::AI88)
|
if(pixelFormat == Texture2D::PixelFormat::AI88)
|
||||||
|
@ -345,6 +326,7 @@ bool FontAtlas::prepareLetterDefinitions(const std::u16string& utf16String)
|
||||||
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
|
_atlasTextures[_currentPage]->updateWithData(data, 0, startY,
|
||||||
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
|
CacheTextureWidth, _currentPageOrigY - startY + _commonLineHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,15 +84,10 @@ public:
|
||||||
Texture2D* getTexture(int slot);
|
Texture2D* getTexture(int slot);
|
||||||
const Font* getFont() const;
|
const Font* getFont() const;
|
||||||
|
|
||||||
/** Listen "come to background" message, and clear the texture atlas.
|
/** listen the event that renderer was recreated on Android/WP8
|
||||||
It only has effect on Android.
|
It only has effect on Android and WP8.
|
||||||
*/
|
*/
|
||||||
void listenToBackground(EventCustom *event);
|
void listenRendererRecreated(EventCustom *event);
|
||||||
|
|
||||||
/** Listen "come to foreground" message and restore the texture atlas.
|
|
||||||
It only has effect on Android.
|
|
||||||
*/
|
|
||||||
void listenToForeground(EventCustom *event);
|
|
||||||
|
|
||||||
/** Removes textures atlas.
|
/** Removes textures atlas.
|
||||||
It will purge the textures atlas and if multiple texture exist in the FontAtlas.
|
It will purge the textures atlas and if multiple texture exist in the FontAtlas.
|
||||||
|
@ -129,9 +124,9 @@ private:
|
||||||
bool _makeDistanceMap;
|
bool _makeDistanceMap;
|
||||||
|
|
||||||
int _fontAscender;
|
int _fontAscender;
|
||||||
EventListenerCustom* _toBackgroundListener;
|
EventListenerCustom* _rendererRecreatedListener;
|
||||||
EventListenerCustom* _toForegroundListener;
|
|
||||||
bool _antialiasEnabled;
|
bool _antialiasEnabled;
|
||||||
|
bool _rendererRecreate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -266,20 +266,13 @@ Label::Label(FontAtlas *atlas /* = nullptr */, TextHAlignment hAlignment /* = Te
|
||||||
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
|
||||||
reset();
|
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){
|
auto purgeTextureListener = EventListenerCustom::create(FontAtlas::EVENT_PURGE_TEXTURES, [this](EventCustom* event){
|
||||||
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
|
if (_fontAtlas && _currentLabelType == LabelType::TTF && event->getUserData() == _fontAtlas)
|
||||||
{
|
{
|
||||||
|
Node::removeAllChildrenWithCleanup(true);
|
||||||
|
_batchNodes.clear();
|
||||||
|
_batchNodes.push_back(this);
|
||||||
|
|
||||||
alignText();
|
alignText();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -135,7 +135,7 @@ bool ParticleSystemQuad::initWithTotalParticles(int numberOfParticles)
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// Need to listen the event only when not use batchnode, because it will use VBO
|
// 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);
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ void ParticleSystemQuad::setupVBO()
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleSystemQuad::listenBackToForeground(EventCustom* event)
|
void ParticleSystemQuad::listenRendererRecreated(EventCustom* event)
|
||||||
{
|
{
|
||||||
if (Configuration::getInstance()->supportsShareableVAO())
|
if (Configuration::getInstance()->supportsShareableVAO())
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,11 +81,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setTextureWithRect(Texture2D *texture, const Rect& rect);
|
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
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
void listenBackToForeground(EventCustom* event);
|
void listenRendererRecreated(EventCustom* event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @js NA
|
* @js NA
|
||||||
|
|
|
@ -322,22 +322,22 @@ void MeshCache::removeUnusedMesh()
|
||||||
|
|
||||||
MeshCache::MeshCache()
|
MeshCache::MeshCache()
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
// listen the event when app go to foreground
|
// listen the event that renderer was recreated on Android/WP8
|
||||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCache::listenBackToForeground, this));
|
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCache::listenRendererRecreated, this));
|
||||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
MeshCache::~MeshCache()
|
MeshCache::~MeshCache()
|
||||||
{
|
{
|
||||||
removeAllMeshes();
|
removeAllMeshes();
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
void MeshCache::listenBackToForeground(EventCustom* event)
|
void MeshCache::listenRendererRecreated(EventCustom* event)
|
||||||
{
|
{
|
||||||
for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
|
for (auto iter = _meshes.begin(); iter != _meshes.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,8 +166,8 @@ public:
|
||||||
/**remove unused meshes*/
|
/**remove unused meshes*/
|
||||||
void removeUnusedMesh();
|
void removeUnusedMesh();
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
void listenBackToForeground(EventCustom* event);
|
void listenRendererRecreated(EventCustom* event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
@ -181,8 +181,8 @@ protected:
|
||||||
|
|
||||||
std::unordered_map<std::string, Mesh*> _meshes; //cached meshes
|
std::unordered_map<std::string, Mesh*> _meshes; //cached meshes
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
EventListenerCustom* _backToForegroundlistener;
|
EventListenerCustom* _rendererRecreatedListener;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,7 @@ EventDispatcher::EventDispatcher()
|
||||||
// Therefore, internal listeners would not be cleaned when removeAllEventListeners is invoked.
|
// Therefore, internal listeners would not be cleaned when removeAllEventListeners is invoked.
|
||||||
_internalCustomListenerIDs.insert(EVENT_COME_TO_FOREGROUND);
|
_internalCustomListenerIDs.insert(EVENT_COME_TO_FOREGROUND);
|
||||||
_internalCustomListenerIDs.insert(EVENT_COME_TO_BACKGROUND);
|
_internalCustomListenerIDs.insert(EVENT_COME_TO_BACKGROUND);
|
||||||
|
_internalCustomListenerIDs.insert(EVENT_RENDERER_RECREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatcher::~EventDispatcher()
|
EventDispatcher::~EventDispatcher()
|
||||||
|
|
|
@ -30,13 +30,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The application will come to foreground.
|
// The application will come to foreground.
|
||||||
// This message is used for reloading resources before come to foreground on Android.
|
// This message is posted in cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp.
|
||||||
// This message is posted in main.cpp.
|
|
||||||
#define EVENT_COME_TO_FOREGROUND "event_come_to_foreground"
|
#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.
|
// The application will come to background.
|
||||||
// This message is used for doing something before coming to background, such as save RenderTexture.
|
// 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"
|
#define EVENT_COME_TO_BACKGROUND "event_come_to_background"
|
||||||
|
|
||||||
#endif // __CCEVENT_TYPE_H__
|
#endif // __CCEVENT_TYPE_H__
|
||||||
|
|
|
@ -102,6 +102,7 @@ namespace cocostudio
|
||||||
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
|
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
|
||||||
|
|
||||||
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
|
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "微软雅黑");
|
||||||
|
|
||||||
std::string fontFilePath = jsonPath.append(fontName);
|
std::string fontFilePath = jsonPath.append(fontName);
|
||||||
if (FileUtils::getInstance()->isFileExist(fontFilePath))
|
if (FileUtils::getInstance()->isFileExist(fontFilePath))
|
||||||
{
|
{
|
||||||
|
@ -111,7 +112,6 @@ namespace cocostudio
|
||||||
label->setFontName(fontName);
|
label->setFontName(fontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
|
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
|
||||||
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);
|
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);
|
||||||
if (aw && ah)
|
if (aw && ah)
|
||||||
|
|
|
@ -64,7 +64,9 @@ public:
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
virtual ~ApplicationProtocol(){
|
virtual ~ApplicationProtocol(){
|
||||||
|
#if CC_ENABLE_SCRIPT_BINDING
|
||||||
ScriptEngineManager::destroyInstance();
|
ScriptEngineManager::destroyInstance();
|
||||||
|
#endif
|
||||||
// clean auto release pool
|
// clean auto release pool
|
||||||
PoolManager::destroyInstance();
|
PoolManager::destroyInstance();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
|
||||||
mControllerService.setEnableLR2(true);
|
mControllerService.setEnableLR2(true);
|
||||||
mControllerService.setAutoKeyUpMode(false);
|
mControllerService.setAutoKeyUpMode(false);
|
||||||
|
|
||||||
mControllerService.checkNibiruInstall(mContext, true);
|
mControllerService.checkNibiruInstall(mContext, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi
|
||||||
cocos2d::DrawPrimitives::init();
|
cocos2d::DrawPrimitives::init();
|
||||||
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||||
|
|
||||||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
|
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
|
||||||
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
|
||||||
director->setGLDefaultValues();
|
director->setGLDefaultValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ extern "C" {
|
||||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
|
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
|
||||||
if (Director::getInstance()->getOpenGLView()) {
|
if (Director::getInstance()->getOpenGLView()) {
|
||||||
Application::getInstance()->applicationWillEnterForeground();
|
Application::getInstance()->applicationWillEnterForeground();
|
||||||
|
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
|
||||||
|
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ void Cocos2dRenderer::CreateGLResources()
|
||||||
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
|
cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
|
||||||
cocos2d::DrawPrimitives::init();
|
cocos2d::DrawPrimitives::init();
|
||||||
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
cocos2d::VolatileTextureMgr::reloadAllTextures();
|
||||||
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
|
cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
|
||||||
director->getEventDispatcher()->dispatchEvent(&foregroundEvent);
|
director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
|
||||||
cocos2d::Application::getInstance()->applicationWillEnterForeground();
|
cocos2d::Application::getInstance()->applicationWillEnterForeground();
|
||||||
director->setGLDefaultValues();
|
director->setGLDefaultValues();
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,9 +279,9 @@ GLProgramState::GLProgramState()
|
||||||
, _uniformAttributeValueDirty(true)
|
, _uniformAttributeValueDirty(true)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
// listen the event when app go to foreground
|
/** listen the event that renderer was recreated on Android/WP8 */
|
||||||
CCLOG("create _backToForegroundlistener for GLProgramState");
|
CCLOG("create rendererRecreatedListener for GLProgramState");
|
||||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
|
_backToForegroundlistener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom*) { _uniformAttributeValueDirty = true; });
|
||||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ MeshCommand::MeshCommand()
|
||||||
, _vao(0)
|
, _vao(0)
|
||||||
{
|
{
|
||||||
_type = RenderCommand::Type::MESH_COMMAND;
|
_type = RenderCommand::Type::MESH_COMMAND;
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
// listen the event when app go to foreground
|
// listen the event that renderer was recreated on Android/WP8
|
||||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(MeshCommand::listenBackToForeground, this));
|
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(MeshCommand::listenRendererRecreated, this));
|
||||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ void MeshCommand::setDisplayColor(const Vec4& color)
|
||||||
MeshCommand::~MeshCommand()
|
MeshCommand::~MeshCommand()
|
||||||
{
|
{
|
||||||
releaseVAO();
|
releaseVAO();
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ void MeshCommand::releaseVAO()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
void MeshCommand::listenBackToForeground(EventCustom* event)
|
void MeshCommand::listenRendererRecreated(EventCustom* event)
|
||||||
{
|
{
|
||||||
_vao = 0;
|
_vao = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
uint32_t getMaterialID() const { return _materialID; }
|
uint32_t getMaterialID() const { return _materialID; }
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
void listenBackToForeground(EventCustom* event);
|
void listenRendererRecreated(EventCustom* event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -122,8 +122,8 @@ protected:
|
||||||
// ModelView transform
|
// ModelView transform
|
||||||
Mat4 _mv;
|
Mat4 _mv;
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||||
EventListenerCustom* _backToForegroundlistener;
|
EventListenerCustom* _rendererRecreatedListener;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -145,8 +145,8 @@ Renderer::~Renderer()
|
||||||
void Renderer::initGLView()
|
void Renderer::initGLView()
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
_cacheTextureListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
|
_cacheTextureListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
|
||||||
/** listen the event that coming to foreground on Android */
|
/** listen the event that renderer was recreated on Android/WP8 */
|
||||||
this->setupBuffer();
|
this->setupBuffer();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ TextureAtlas::TextureAtlas()
|
||||||
,_texture(nullptr)
|
,_texture(nullptr)
|
||||||
,_quads(nullptr)
|
,_quads(nullptr)
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
,_backToForegroundlistener(nullptr)
|
,_rendererRecreatedListener(nullptr)
|
||||||
#endif
|
#endif
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ TextureAtlas::~TextureAtlas()
|
||||||
CC_SAFE_RELEASE(_texture);
|
CC_SAFE_RELEASE(_texture);
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
Director::getInstance()->getEventDispatcher()->removeEventListener(_backToForegroundlistener);
|
Director::getInstance()->getEventDispatcher()->removeEventListener(_rendererRecreatedListener);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,9 +192,9 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
|
||||||
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
|
memset( _indices, 0, _capacity * 6 * sizeof(GLushort) );
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
// listen the event when app go to background
|
/** listen the event that renderer was recreated on Android/WP8 */
|
||||||
_backToForegroundlistener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(TextureAtlas::listenBackToForeground, this));
|
_rendererRecreatedListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, CC_CALLBACK_1(TextureAtlas::listenRendererRecreated, this));
|
||||||
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_backToForegroundlistener, -1);
|
Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(_rendererRecreatedListener, -1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->setupIndices();
|
this->setupIndices();
|
||||||
|
@ -213,7 +213,7 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::listenBackToForeground(EventCustom* event)
|
void TextureAtlas::listenRendererRecreated(EventCustom* event)
|
||||||
{
|
{
|
||||||
if (Configuration::getInstance()->supportsShareableVAO())
|
if (Configuration::getInstance()->supportsShareableVAO())
|
||||||
{
|
{
|
||||||
|
|
|
@ -189,9 +189,9 @@ public:
|
||||||
/** draws all the Atlas's Quads
|
/** draws all the Atlas's Quads
|
||||||
*/
|
*/
|
||||||
void drawQuads();
|
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*/
|
/** whether or not the array buffer of the VBO needs to be updated*/
|
||||||
inline bool isDirty(void) { return _dirty; }
|
inline bool isDirty(void) { return _dirty; }
|
||||||
|
@ -244,7 +244,7 @@ protected:
|
||||||
V3F_C4B_T2F_Quad* _quads;
|
V3F_C4B_T2F_Quad* _quads;
|
||||||
|
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
EventListenerCustom* _backToForegroundlistener;
|
EventListenerCustom* _rendererRecreatedListener;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @module Bone3D
|
||||||
|
-- @extend Ref
|
||||||
|
-- @parent_module cc
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getInverseBindPose
|
||||||
|
-- @param self
|
||||||
|
-- @return mat4_table#mat4_table ret (return value: mat4_table)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] clearBoneBlendState
|
||||||
|
-- @param self
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] resetPose
|
||||||
|
-- @param self
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] setAnimationValue
|
||||||
|
-- @param self
|
||||||
|
-- @param #float float
|
||||||
|
-- @param #float float
|
||||||
|
-- @param #float float
|
||||||
|
-- @param #void void
|
||||||
|
-- @param #float float
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getChildBoneByIndex
|
||||||
|
-- @param self
|
||||||
|
-- @param #int int
|
||||||
|
-- @return Bone3D#Bone3D ret (return value: cc.Bone3D)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] removeChildBone
|
||||||
|
-- @param self
|
||||||
|
-- @param #cc.Bone3D bone3d
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getParentBone
|
||||||
|
-- @param self
|
||||||
|
-- @return Bone3D#Bone3D ret (return value: cc.Bone3D)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getName
|
||||||
|
-- @param self
|
||||||
|
-- @return string#string ret (return value: string)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] removeAllChildBone
|
||||||
|
-- @param self
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] addChildBone
|
||||||
|
-- @param self
|
||||||
|
-- @param #cc.Bone3D bone3d
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getChildBoneCount
|
||||||
|
-- @param self
|
||||||
|
-- @return long#long ret (return value: long)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] updateJointMatrix
|
||||||
|
-- @param self
|
||||||
|
-- @param #vec4_table vec4
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] setInverseBindPose
|
||||||
|
-- @param self
|
||||||
|
-- @param #mat4_table mat4
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] getWorldMat
|
||||||
|
-- @param self
|
||||||
|
-- @return mat4_table#mat4_table ret (return value: mat4_table)
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] updateWorldMat
|
||||||
|
-- @param self
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] setOriPose
|
||||||
|
-- @param self
|
||||||
|
-- @param #mat4_table mat4
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] removeChildBoneByIndex
|
||||||
|
-- @param self
|
||||||
|
-- @param #int int
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
-- @function [parent=#Bone3D] create
|
||||||
|
-- @param self
|
||||||
|
-- @param #string str
|
||||||
|
-- @return Bone3D#Bone3D ret (return value: cc.Bone3D)
|
||||||
|
|
||||||
|
return nil
|
|
@ -1211,6 +1211,11 @@
|
||||||
-- @field [parent=#cc] Mesh#Mesh Mesh preloaded module
|
-- @field [parent=#cc] Mesh#Mesh Mesh preloaded module
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------
|
||||||
|
-- the cc Bone3D
|
||||||
|
-- @field [parent=#cc] Bone3D#Bone3D Bone3D preloaded module
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
-- the cc Animation3D
|
-- the cc Animation3D
|
||||||
-- @field [parent=#cc] Animation3D#Animation3D Animation3D preloaded module
|
-- @field [parent=#cc] Animation3D#Animation3D Animation3D preloaded module
|
||||||
|
|
|
@ -63081,6 +63081,884 @@ int lua_register_cocos2dx_Mesh(lua_State* tolua_S)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lua_cocos2dx_Bone3D_getInverseBindPose(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getInverseBindPose'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
const cocos2d::Mat4& ret = cobj->getInverseBindPose();
|
||||||
|
mat4_to_luaval(tolua_S, ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getInverseBindPose",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getInverseBindPose'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_clearBoneBlendState(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_clearBoneBlendState'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->clearBoneBlendState();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "clearBoneBlendState",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_clearBoneBlendState'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_resetPose(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_resetPose'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->resetPose();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "resetPose",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_resetPose'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_setAnimationValue(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_setAnimationValue'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
float* arg0;
|
||||||
|
float* arg1;
|
||||||
|
float* arg2;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->setAnimationValue(arg0, arg1, arg2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
float* arg0;
|
||||||
|
float* arg1;
|
||||||
|
float* arg2;
|
||||||
|
void* arg3;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR void*;
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->setAnimationValue(arg0, arg1, arg2, arg3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (argc == 5)
|
||||||
|
{
|
||||||
|
float* arg0;
|
||||||
|
float* arg1;
|
||||||
|
float* arg2;
|
||||||
|
void* arg3;
|
||||||
|
double arg4;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR float*;
|
||||||
|
|
||||||
|
#pragma warning NO CONVERSION TO NATIVE FOR void*;
|
||||||
|
|
||||||
|
ok &= luaval_to_number(tolua_S, 6,&arg4);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->setAnimationValue(arg0, arg1, arg2, arg3, arg4);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setAnimationValue",argc, 3);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_setAnimationValue'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_getChildBoneByIndex(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getChildBoneByIndex'", 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;
|
||||||
|
cocos2d::Bone3D* ret = cobj->getChildBoneByIndex(arg0);
|
||||||
|
object_to_luaval<cocos2d::Bone3D>(tolua_S, "cc.Bone3D",(cocos2d::Bone3D*)ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildBoneByIndex",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getChildBoneByIndex'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_removeChildBone(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_removeChildBone'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
cocos2d::Bone3D* arg0;
|
||||||
|
|
||||||
|
ok &= luaval_to_object<cocos2d::Bone3D>(tolua_S, 2, "cc.Bone3D",&arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->removeChildBone(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildBone",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_removeChildBone'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_getParentBone(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getParentBone'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cocos2d::Bone3D* ret = cobj->getParentBone();
|
||||||
|
object_to_luaval<cocos2d::Bone3D>(tolua_S, "cc.Bone3D",(cocos2d::Bone3D*)ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getParentBone",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getParentBone'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_getName(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getName'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
const std::string& ret = cobj->getName();
|
||||||
|
tolua_pushcppstring(tolua_S,ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getName",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getName'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_removeAllChildBone(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_removeAllChildBone'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->removeAllChildBone();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeAllChildBone",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_removeAllChildBone'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_addChildBone(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_addChildBone'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
cocos2d::Bone3D* arg0;
|
||||||
|
|
||||||
|
ok &= luaval_to_object<cocos2d::Bone3D>(tolua_S, 2, "cc.Bone3D",&arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->addChildBone(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "addChildBone",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_addChildBone'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_getChildBoneCount(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getChildBoneCount'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
ssize_t ret = cobj->getChildBoneCount();
|
||||||
|
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getChildBoneCount",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getChildBoneCount'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_updateJointMatrix(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_updateJointMatrix'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
cocos2d::Vec4* arg0;
|
||||||
|
|
||||||
|
ok &= luaval_to_object<cocos2d::Vec4>(tolua_S, 2, "cc.Vec4",&arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->updateJointMatrix(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateJointMatrix",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_updateJointMatrix'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_setInverseBindPose(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_setInverseBindPose'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
cocos2d::Mat4 arg0;
|
||||||
|
|
||||||
|
ok &= luaval_to_mat4(tolua_S, 2, &arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->setInverseBindPose(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setInverseBindPose",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_setInverseBindPose'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_getWorldMat(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_getWorldMat'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
const cocos2d::Mat4& ret = cobj->getWorldMat();
|
||||||
|
mat4_to_luaval(tolua_S, ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getWorldMat",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_getWorldMat'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_updateWorldMat(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_updateWorldMat'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->updateWorldMat();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "updateWorldMat",argc, 0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_updateWorldMat'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_setOriPose(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_setOriPose'", nullptr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S)-1;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
cocos2d::Mat4 arg0;
|
||||||
|
|
||||||
|
ok &= luaval_to_mat4(tolua_S, 2, &arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cobj->setOriPose(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOriPose",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_setOriPose'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_removeChildBoneByIndex(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
cocos2d::Bone3D* 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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cobj = (cocos2d::Bone3D*)tolua_tousertype(tolua_S,1,0);
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
if (!cobj)
|
||||||
|
{
|
||||||
|
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Bone3D_removeChildBoneByIndex'", 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->removeChildBoneByIndex(arg0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "removeChildBoneByIndex",argc, 1);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_removeChildBoneByIndex'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int lua_cocos2dx_Bone3D_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.Bone3D",0,&tolua_err)) goto tolua_lerror;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argc = lua_gettop(tolua_S) - 1;
|
||||||
|
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
std::string arg0;
|
||||||
|
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
||||||
|
if(!ok)
|
||||||
|
return 0;
|
||||||
|
cocos2d::Bone3D* ret = cocos2d::Bone3D::create(arg0);
|
||||||
|
object_to_luaval<cocos2d::Bone3D>(tolua_S, "cc.Bone3D",(cocos2d::Bone3D*)ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "create",argc, 1);
|
||||||
|
return 0;
|
||||||
|
#if COCOS2D_DEBUG >= 1
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Bone3D_create'.",&tolua_err);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static int lua_cocos2dx_Bone3D_finalize(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
printf("luabindings: finalizing LUA object (Bone3D)");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lua_register_cocos2dx_Bone3D(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
tolua_usertype(tolua_S,"cc.Bone3D");
|
||||||
|
tolua_cclass(tolua_S,"Bone3D","cc.Bone3D","cc.Ref",nullptr);
|
||||||
|
|
||||||
|
tolua_beginmodule(tolua_S,"Bone3D");
|
||||||
|
tolua_function(tolua_S,"getInverseBindPose",lua_cocos2dx_Bone3D_getInverseBindPose);
|
||||||
|
tolua_function(tolua_S,"clearBoneBlendState",lua_cocos2dx_Bone3D_clearBoneBlendState);
|
||||||
|
tolua_function(tolua_S,"resetPose",lua_cocos2dx_Bone3D_resetPose);
|
||||||
|
tolua_function(tolua_S,"setAnimationValue",lua_cocos2dx_Bone3D_setAnimationValue);
|
||||||
|
tolua_function(tolua_S,"getChildBoneByIndex",lua_cocos2dx_Bone3D_getChildBoneByIndex);
|
||||||
|
tolua_function(tolua_S,"removeChildBone",lua_cocos2dx_Bone3D_removeChildBone);
|
||||||
|
tolua_function(tolua_S,"getParentBone",lua_cocos2dx_Bone3D_getParentBone);
|
||||||
|
tolua_function(tolua_S,"getName",lua_cocos2dx_Bone3D_getName);
|
||||||
|
tolua_function(tolua_S,"removeAllChildBone",lua_cocos2dx_Bone3D_removeAllChildBone);
|
||||||
|
tolua_function(tolua_S,"addChildBone",lua_cocos2dx_Bone3D_addChildBone);
|
||||||
|
tolua_function(tolua_S,"getChildBoneCount",lua_cocos2dx_Bone3D_getChildBoneCount);
|
||||||
|
tolua_function(tolua_S,"updateJointMatrix",lua_cocos2dx_Bone3D_updateJointMatrix);
|
||||||
|
tolua_function(tolua_S,"setInverseBindPose",lua_cocos2dx_Bone3D_setInverseBindPose);
|
||||||
|
tolua_function(tolua_S,"getWorldMat",lua_cocos2dx_Bone3D_getWorldMat);
|
||||||
|
tolua_function(tolua_S,"updateWorldMat",lua_cocos2dx_Bone3D_updateWorldMat);
|
||||||
|
tolua_function(tolua_S,"setOriPose",lua_cocos2dx_Bone3D_setOriPose);
|
||||||
|
tolua_function(tolua_S,"removeChildBoneByIndex",lua_cocos2dx_Bone3D_removeChildBoneByIndex);
|
||||||
|
tolua_function(tolua_S,"create", lua_cocos2dx_Bone3D_create);
|
||||||
|
tolua_endmodule(tolua_S);
|
||||||
|
std::string typeName = typeid(cocos2d::Bone3D).name();
|
||||||
|
g_luaType[typeName] = "cc.Bone3D";
|
||||||
|
g_typeCast["Bone3D"] = "cc.Bone3D";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int lua_cocos2dx_Animation3D_getDuration(lua_State* tolua_S)
|
int lua_cocos2dx_Animation3D_getDuration(lua_State* tolua_S)
|
||||||
{
|
{
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
|
@ -65335,6 +66213,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S)
|
||||||
lua_register_cocos2dx_EaseCubicActionOut(tolua_S);
|
lua_register_cocos2dx_EaseCubicActionOut(tolua_S);
|
||||||
lua_register_cocos2dx_EventListenerTouchOneByOne(tolua_S);
|
lua_register_cocos2dx_EventListenerTouchOneByOne(tolua_S);
|
||||||
lua_register_cocos2dx_ParticleRain(tolua_S);
|
lua_register_cocos2dx_ParticleRain(tolua_S);
|
||||||
|
lua_register_cocos2dx_Bone3D(tolua_S);
|
||||||
lua_register_cocos2dx_Waves(tolua_S);
|
lua_register_cocos2dx_Waves(tolua_S);
|
||||||
lua_register_cocos2dx_EaseOut(tolua_S);
|
lua_register_cocos2dx_EaseOut(tolua_S);
|
||||||
lua_register_cocos2dx_Animate3D(tolua_S);
|
lua_register_cocos2dx_Animate3D(tolua_S);
|
||||||
|
|
|
@ -1556,6 +1556,25 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,14 @@ extern "C" {
|
||||||
#include "platform/android/CCLuaJavaBridge.h"
|
#include "platform/android/CCLuaJavaBridge.h"
|
||||||
#endif
|
#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)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||||
#include "Lua_web_socket.h"
|
#include "Lua_web_socket.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "LuaOpengl.h"
|
#include "LuaOpengl.h"
|
||||||
#include "LuaScriptHandlerMgr.h"
|
#include "LuaScriptHandlerMgr.h"
|
||||||
#include "lua_cocos2dx_auto.hpp"
|
#include "lua_cocos2dx_auto.hpp"
|
||||||
|
@ -173,6 +178,7 @@ bool LuaStack::init(void)
|
||||||
register_all_cocos2dx_physics(_state);
|
register_all_cocos2dx_physics(_state);
|
||||||
register_all_cocos2dx_physics_manual(_state);
|
register_all_cocos2dx_physics_manual(_state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||||
LuaObjcBridge::luaopen_luaoc(_state);
|
LuaObjcBridge::luaopen_luaoc(_state);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -163,6 +163,13 @@ public:
|
||||||
|
|
||||||
EVENT_FOCUS,
|
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_BEGAN = 10000,
|
||||||
EVENT_CUSTOM_ENDED = 11000,
|
EVENT_CUSTOM_ENDED = 11000,
|
||||||
};
|
};
|
||||||
|
|
|
@ -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)
|
|
@ -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
|
|
@ -349,6 +349,14 @@ cc.Handler.EVENT_PHYSICS_CONTACT_BEGIN = 53
|
||||||
cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54
|
cc.Handler.EVENT_PHYSICS_CONTACT_PRESOLVE = 54
|
||||||
cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55
|
cc.Handler.EVENT_PHYSICS_CONTACT_POSTSOLVE = 55
|
||||||
cc.Handler.EVENT_PHYSICS_CONTACT_SEPERATE = 56
|
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_UNKNOWN = 0
|
||||||
cc.EVENT_TOUCH_ONE_BY_ONE = 1
|
cc.EVENT_TOUCH_ONE_BY_ONE = 1
|
||||||
|
@ -569,5 +577,38 @@ cc.EventCode =
|
||||||
CANCELLED = 3,
|
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,
|
||||||
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ ShaderNode* ShaderNode::shaderNodeWithVertex(const std::string &vert, const std:
|
||||||
bool ShaderNode::initWithVertex(const std::string &vert, const std::string &frag)
|
bool ShaderNode::initWithVertex(const std::string &vert, const std::string &frag)
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
|
auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
|
||||||
this->setGLProgramState(nullptr);
|
this->setGLProgramState(nullptr);
|
||||||
loadShaderVertex(_vertFileName, _fragFileName);
|
loadShaderVertex(_vertFileName, _fragFileName);
|
||||||
});
|
});
|
||||||
|
@ -458,7 +458,7 @@ bool SpriteBlur::initWithTexture(Texture2D* texture, const Rect& rect)
|
||||||
if( Sprite::initWithTexture(texture, rect) )
|
if( Sprite::initWithTexture(texture, rect) )
|
||||||
{
|
{
|
||||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||||
auto listener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND, [this](EventCustom* event){
|
auto listener = EventListenerCustom::create(EVENT_RENDERER_RECREATED, [this](EventCustom* event){
|
||||||
setGLProgram(nullptr);
|
setGLProgram(nullptr);
|
||||||
initGLProgram();
|
initGLProgram();
|
||||||
});
|
});
|
||||||
|
|
|
@ -222,7 +222,7 @@ Effect::Effect()
|
||||||
: _glprogramstate(nullptr)
|
: _glprogramstate(nullptr)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
_backgroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND,
|
_backgroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
|
||||||
[this](EventCustom*)
|
[this](EventCustom*)
|
||||||
{
|
{
|
||||||
auto glProgram = _glprogramstate->getGLProgram();
|
auto glProgram = _glprogramstate->getGLProgram();
|
||||||
|
|
|
@ -325,7 +325,7 @@ Effect3DOutline::Effect3DOutline()
|
||||||
, _sprite(nullptr)
|
, _sprite(nullptr)
|
||||||
{
|
{
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
_backToForegroundListener = EventListenerCustom::create(EVENT_COME_TO_FOREGROUND,
|
_backToForegroundListener = EventListenerCustom::create(EVENT_RENDERER_RECREATED,
|
||||||
[this](EventCustom*)
|
[this](EventCustom*)
|
||||||
{
|
{
|
||||||
auto glProgram = _glProgramState->getGLProgram();
|
auto glProgram = _glProgramState->getGLProgram();
|
||||||
|
|
|
@ -37,8 +37,8 @@ public class AppActivity extends GameControllerActivity {
|
||||||
//The standard controller,without doing anything special. e.g: Amazon Fire TV
|
//The standard controller,without doing anything special. e.g: Amazon Fire TV
|
||||||
|
|
||||||
//Manually specify an adapter.
|
//Manually specify an adapter.
|
||||||
//this.connectController(DRIVERTYPE_NIBIRU);
|
this.connectController(DRIVERTYPE_NIBIRU);
|
||||||
//this.connectController(DRIVERTYPE_MOGA);
|
this.connectController(DRIVERTYPE_MOGA);
|
||||||
//this.connectController(DRIVERTYPE_OUYA);
|
this.connectController(DRIVERTYPE_OUYA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"ios_cfg": {
|
||||||
|
"project_path": "../../build",
|
||||||
|
"project_file": "cocos2d_tests.xcodeproj",
|
||||||
|
"target_name": "lua-game-controller-test iOS"
|
||||||
|
},
|
||||||
|
"project_type": "lua",
|
||||||
|
"has_native": true,
|
||||||
|
"android_cfg": {
|
||||||
|
"project_path": "project/proj.android"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
#include "cocos2d.h"
|
||||||
|
#include "AppDelegate.h"
|
||||||
|
#include "audio/include/SimpleAudioEngine.h"
|
||||||
|
#include "base/CCScriptSupport.h"
|
||||||
|
#include "CCLuaEngine.h"
|
||||||
|
#include "scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.hpp"
|
||||||
|
#include "scripting/lua-bindings/manual/lua_cocos2dx_controller_manual.hpp"
|
||||||
|
|
||||||
|
USING_NS_CC;
|
||||||
|
using namespace CocosDenshion;
|
||||||
|
|
||||||
|
AppDelegate::AppDelegate()
|
||||||
|
{
|
||||||
|
// fixed me
|
||||||
|
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppDelegate::~AppDelegate()
|
||||||
|
{
|
||||||
|
// end simple audio engine here, or it may crashed on win32
|
||||||
|
SimpleAudioEngine::getInstance()->end();
|
||||||
|
//CCScriptEngineManager::destroyInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AppDelegate::applicationDidFinishLaunching()
|
||||||
|
{
|
||||||
|
|
||||||
|
auto director = Director::getInstance();
|
||||||
|
auto glview = director->getOpenGLView();
|
||||||
|
if(!glview) {
|
||||||
|
glview = GLView::create("Lua Game Controller Test");
|
||||||
|
director->setOpenGLView(glview);
|
||||||
|
}
|
||||||
|
|
||||||
|
director->setOpenGLView(glview);
|
||||||
|
|
||||||
|
LuaEngine* engine = LuaEngine::getInstance();
|
||||||
|
ScriptEngineManager::getInstance()->setScriptEngine(engine);
|
||||||
|
LuaStack* stack = engine->getLuaStack();
|
||||||
|
lua_State* L = stack->getLuaState();
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID ||CC_TARGET_PLATFORM == CC_PLATFORM_IOS )
|
||||||
|
lua_getglobal(L, "_G");
|
||||||
|
if (lua_istable(L,-1))//stack:...,_G,
|
||||||
|
{
|
||||||
|
register_all_cocos2dx_controller(L);
|
||||||
|
register_all_cocos2dx_controller_manual(L);
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);//statck:...
|
||||||
|
#endif
|
||||||
|
|
||||||
|
engine->executeString("require 'src/main.lua'");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
|
||||||
|
void AppDelegate::applicationDidEnterBackground()
|
||||||
|
{
|
||||||
|
Director::getInstance()->stopAnimation();
|
||||||
|
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
|
||||||
|
}
|
||||||
|
|
||||||
|
// this function will be called when the app is active again
|
||||||
|
void AppDelegate::applicationWillEnterForeground()
|
||||||
|
{
|
||||||
|
Director::getInstance()->startAnimation();
|
||||||
|
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
#ifndef _APP_DELEGATE_H_
|
||||||
|
#define _APP_DELEGATE_H_
|
||||||
|
|
||||||
|
#include "CCApplication.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The cocos2d Application.
|
||||||
|
|
||||||
|
The reason for implement as private inheritance is to hide some interface call by Director.
|
||||||
|
*/
|
||||||
|
class AppDelegate : private cocos2d::Application
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AppDelegate();
|
||||||
|
virtual ~AppDelegate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Implement Director and Scene init code here.
|
||||||
|
@return true Initialize success, app continue.
|
||||||
|
@return false Initialize failed, app terminate.
|
||||||
|
*/
|
||||||
|
virtual bool applicationDidFinishLaunching();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The function be called when the application enter background
|
||||||
|
@param the pointer of the application
|
||||||
|
*/
|
||||||
|
virtual void applicationDidEnterBackground();
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief The function be called when the application enter foreground
|
||||||
|
@param the pointer of the application
|
||||||
|
*/
|
||||||
|
virtual void applicationWillEnterForeground();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _APP_DELEGATE_H_
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
|
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="gen"/>
|
||||||
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
|
</classpath>
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>LuaGameControllerTest</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="org.cocos2dx.LuaGameControllerTest"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="1.0">
|
||||||
|
|
||||||
|
<uses-sdk android:minSdkVersion="9"/>
|
||||||
|
<uses-feature android:glEsVersion="0x00020000" />
|
||||||
|
|
||||||
|
<application android:label="@string/app_name"
|
||||||
|
android:icon="@drawable/icon">
|
||||||
|
|
||||||
|
<!-- Tell Cocos2dxActivity the name of our .so -->
|
||||||
|
<meta-data android:name="android.app.lib_name"
|
||||||
|
android:value="lua_game_controller" />
|
||||||
|
|
||||||
|
<activity android:name=".AppActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="landscape"
|
||||||
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
android:configChanges="orientation">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
<supports-screens android:anyDensity="true"
|
||||||
|
android:smallScreens="true"
|
||||||
|
android:normalScreens="true"
|
||||||
|
android:largeScreens="true"
|
||||||
|
android:xlargeScreens="true"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
|
@ -0,0 +1,17 @@
|
||||||
|
# This file is used to override default values used by the Ant build system.
|
||||||
|
#
|
||||||
|
# This file must be checked into Version Control Systems, as it is
|
||||||
|
# integral to the build system of your project.
|
||||||
|
|
||||||
|
# This file is only used by the Ant script.
|
||||||
|
|
||||||
|
# You can use this to override default values such as
|
||||||
|
# 'source.dir' for the location of your java source folder and
|
||||||
|
# 'out.dir' for the location of your output folder.
|
||||||
|
|
||||||
|
# You can also use it define how the release builds are signed by declaring
|
||||||
|
# the following properties:
|
||||||
|
# 'key.store' for the location of your keystore and
|
||||||
|
# 'key.alias' for the name of the key to use.
|
||||||
|
# The password will be asked during the build when you use the 'release' target.
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"ndk_module_path" :[
|
||||||
|
"../../../..",
|
||||||
|
"../../../../cocos",
|
||||||
|
"../../../../external"
|
||||||
|
],
|
||||||
|
"copy_resources": [
|
||||||
|
{
|
||||||
|
"from": "../../src",
|
||||||
|
"to": "src"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "../../res",
|
||||||
|
"to": "res"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "../../../../cocos/scripting/lua-bindings/script",
|
||||||
|
"to": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "../../../../external/lua/luasocket",
|
||||||
|
"to": "",
|
||||||
|
"include": [
|
||||||
|
"*.lua"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": "../../../game-controller-test/Resources",
|
||||||
|
"to": "res",
|
||||||
|
"exclude": [
|
||||||
|
"*.gz"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="LuaGameControllerTest" default="help">
|
||||||
|
|
||||||
|
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||||
|
It contains the path to the SDK. It should *NOT* be checked into
|
||||||
|
Version Control Systems. -->
|
||||||
|
<property file="local.properties" />
|
||||||
|
|
||||||
|
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||||
|
'android' tool to add properties to it.
|
||||||
|
This is the place to change some Ant specific build properties.
|
||||||
|
Here are some properties you may want to change/update:
|
||||||
|
|
||||||
|
source.dir
|
||||||
|
The name of the source directory. Default is 'src'.
|
||||||
|
out.dir
|
||||||
|
The name of the output directory. Default is 'bin'.
|
||||||
|
|
||||||
|
For other overridable properties, look at the beginning of the rules
|
||||||
|
files in the SDK, at tools/ant/build.xml
|
||||||
|
|
||||||
|
Properties related to the SDK location or the project target should
|
||||||
|
be updated using the 'android' tool with the 'update' action.
|
||||||
|
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<property file="ant.properties" />
|
||||||
|
|
||||||
|
<!-- The project.properties file is created and updated by the 'android'
|
||||||
|
tool, as well as ADT.
|
||||||
|
|
||||||
|
This contains project specific properties such as project target, and library
|
||||||
|
dependencies. Lower level build properties are stored in ant.properties
|
||||||
|
(or in .classpath for Eclipse projects).
|
||||||
|
|
||||||
|
This file is an integral part of the build system for your
|
||||||
|
application and should be checked into Version Control Systems. -->
|
||||||
|
<loadproperties srcFile="project.properties" />
|
||||||
|
|
||||||
|
<!-- quick check on sdk.dir -->
|
||||||
|
<fail
|
||||||
|
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
|
||||||
|
unless="sdk.dir"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Import per project custom build rules if present at the root of the project.
|
||||||
|
This is the place to put custom intermediary targets such as:
|
||||||
|
-pre-build
|
||||||
|
-pre-compile
|
||||||
|
-post-compile (This is typically used for code obfuscation.
|
||||||
|
Compiled code location: ${out.classes.absolute.dir}
|
||||||
|
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||||
|
-post-package
|
||||||
|
-post-build
|
||||||
|
-pre-clean
|
||||||
|
-->
|
||||||
|
<import file="custom_rules.xml" optional="true" />
|
||||||
|
|
||||||
|
<!-- Import the actual build file.
|
||||||
|
|
||||||
|
To customize existing targets, there are two options:
|
||||||
|
- Customize only one target:
|
||||||
|
- copy/paste the target into this file, *before* the
|
||||||
|
<import> task.
|
||||||
|
- customize it to your needs.
|
||||||
|
- Customize the whole content of build.xml
|
||||||
|
- copy/paste the content of the rules files (minus the top node)
|
||||||
|
into this file, replacing the <import> task.
|
||||||
|
- customize to your needs.
|
||||||
|
|
||||||
|
***********************
|
||||||
|
****** IMPORTANT ******
|
||||||
|
***********************
|
||||||
|
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||||
|
in order to avoid having your file be overridden by tools such as "android update project"
|
||||||
|
-->
|
||||||
|
<!-- version-tag: 1 -->
|
||||||
|
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,25 @@
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := lua_game_controller_test_shared
|
||||||
|
|
||||||
|
LOCAL_MODULE_FILENAME := liblua_game_controller
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := main.cpp \
|
||||||
|
../../Classes/AppDelegate.cpp \
|
||||||
|
../../../../../cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp \
|
||||||
|
../../../../../cocos/scripting/lua-bindings/manual/lua_cocos2dx_controller_manual.cpp \
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
|
||||||
|
$(LOCAL_PATH)/../../../../../external/lua/tolua \
|
||||||
|
$(LOCAL_PATH)/../../../../../cocos/scripting/lua-bindings/auto \
|
||||||
|
$(LOCAL_PATH)/../../../../../cocos/scripting/lua-bindings/manual \
|
||||||
|
$(LOCAL_PATH)/../../../../../cocos/base
|
||||||
|
|
||||||
|
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_lua_static
|
||||||
|
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
$(call import-module,scripting/lua-bindings)
|
|
@ -0,0 +1,15 @@
|
||||||
|
APP_STL := c++_static
|
||||||
|
NDK_TOOLCHAIN_VERSION=clang
|
||||||
|
|
||||||
|
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
|
||||||
|
APP_LDFLAGS := -latomic
|
||||||
|
|
||||||
|
|
||||||
|
APP_DEBUG := $(strip $(NDK_DEBUG))
|
||||||
|
ifeq ($(APP_DEBUG),1)
|
||||||
|
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
|
||||||
|
APP_OPTIM := debug
|
||||||
|
else
|
||||||
|
APP_CPPFLAGS += -DNDEBUG
|
||||||
|
APP_OPTIM := release
|
||||||
|
endif
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "AppDelegate.h"
|
||||||
|
#include "cocos2d.h"
|
||||||
|
#include "platform/android/jni/JniHelper.h"
|
||||||
|
#include <jni.h>
|
||||||
|
#include <android/log.h>
|
||||||
|
|
||||||
|
#define LOG_TAG "main"
|
||||||
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
|
||||||
|
|
||||||
|
using namespace cocos2d;
|
||||||
|
|
||||||
|
void cocos_android_app_init (JNIEnv* env, jobject thiz) {
|
||||||
|
LOGD("cocos_android_app_init");
|
||||||
|
AppDelegate *pAppDelegate = new AppDelegate();
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
# To enable ProGuard in your project, edit project.properties
|
||||||
|
# to define the proguard.config property as described in that file.
|
||||||
|
#
|
||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# By default, the flags in this file are appended to flags specified
|
||||||
|
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||||
|
# You can edit the include path and order by changing the ProGuard
|
||||||
|
# include property in project.properties.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
|
@ -0,0 +1,13 @@
|
||||||
|
# This file is automatically generated by Android Tools.
|
||||||
|
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||||
|
#
|
||||||
|
# This file must be checked in Version Control Systems.
|
||||||
|
#
|
||||||
|
# To customize properties used by the Ant build system use,
|
||||||
|
# "ant.properties", and override values to adapt the script to your
|
||||||
|
# project structure.
|
||||||
|
|
||||||
|
# Project target.
|
||||||
|
target=android-16
|
||||||
|
|
||||||
|
android.library.reference.1=../../../../cocos/platform/android/ControllerManualAdapter
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 7.4 KiB |
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">LuaGameControllerTest</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.cocos2dx.LuaGameControllerTest;
|
||||||
|
|
||||||
|
import org.cocos2dx.lib.GameControllerActivity;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class AppActivity extends GameControllerActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
//The standard controller,without doing anything special. e.g: Amazon Fire TV
|
||||||
|
|
||||||
|
//Manually specify an adapter.
|
||||||
|
this.connectController(DRIVERTYPE_NIBIRU);
|
||||||
|
//this.connectController(DRIVERTYPE_MOGA);
|
||||||
|
//this.connectController(DRIVERTYPE_OUYA);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
@class RootViewController;
|
||||||
|
|
||||||
|
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
|
||||||
|
UIWindow *window;
|
||||||
|
RootViewController *viewController;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
|
@ -0,0 +1,139 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010 cocos2d-x.org
|
||||||
|
|
||||||
|
http://www.cocos2d-x.org
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
****************************************************************************/
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "AppController.h"
|
||||||
|
#import "cocos2d.h"
|
||||||
|
#import "CCEAGLView.h"
|
||||||
|
#import "AppDelegate.h"
|
||||||
|
|
||||||
|
#import "RootViewController.h"
|
||||||
|
|
||||||
|
@implementation AppController
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Application lifecycle
|
||||||
|
|
||||||
|
// cocos2d application instance
|
||||||
|
static AppDelegate s_sharedApplication;
|
||||||
|
|
||||||
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
|
|
||||||
|
// Override point for customization after application launch.
|
||||||
|
|
||||||
|
// Add the view controller's view to the window and display.
|
||||||
|
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
|
||||||
|
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
|
||||||
|
pixelFormat: kEAGLColorFormatRGBA8
|
||||||
|
depthFormat: GL_DEPTH_COMPONENT16
|
||||||
|
preserveBackbuffer: NO
|
||||||
|
sharegroup: nil
|
||||||
|
multiSampling: NO
|
||||||
|
numberOfSamples: 0 ];
|
||||||
|
|
||||||
|
// Use RootViewController manage CCEAGLView
|
||||||
|
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
|
||||||
|
viewController.wantsFullScreenLayout = YES;
|
||||||
|
viewController.view = eaglView;
|
||||||
|
|
||||||
|
// Set RootViewController to window
|
||||||
|
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
|
||||||
|
{
|
||||||
|
// warning: addSubView doesn't work on iOS6
|
||||||
|
[window addSubview: viewController.view];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// use this method on ios6
|
||||||
|
[window setRootViewController:viewController];
|
||||||
|
}
|
||||||
|
|
||||||
|
[window makeKeyAndVisible];
|
||||||
|
|
||||||
|
[[UIApplication sharedApplication] setStatusBarHidden: YES];
|
||||||
|
|
||||||
|
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
|
||||||
|
cocos2d::GLView *glview = cocos2d::GLView::createWithEAGLView(eaglView);
|
||||||
|
cocos2d::Director::getInstance()->setOpenGLView(glview);
|
||||||
|
|
||||||
|
cocos2d::Application *app = cocos2d::Application::getInstance();
|
||||||
|
app->run();
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||||
|
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||||
|
*/
|
||||||
|
cocos2d::Director::getInstance()->pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||||
|
*/
|
||||||
|
cocos2d::Director::getInstance()->resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||||
|
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||||
|
*/
|
||||||
|
cocos2d::Application::getInstance()->applicationDidEnterBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||||
|
*/
|
||||||
|
cocos2d::Application::getInstance()->applicationWillEnterForeground();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Called when the application is about to terminate.
|
||||||
|
See also applicationDidEnterBackground:.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Memory management
|
||||||
|
|
||||||
|
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
||||||
|
/*
|
||||||
|
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 567 KiB |
|
@ -0,0 +1,8 @@
|
||||||
|
//
|
||||||
|
// Prefix header for all source files of the 'HelloLua' target in the 'HelloLua' project
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#endif
|
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>English</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>Icon-57.png</string>
|
||||||
|
<key>CFBundleIcons</key>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundlePrimaryIcon</key>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleIconFiles</key>
|
||||||
|
<array>
|
||||||
|
<string></string>
|
||||||
|
<string>Icon.png</string>
|
||||||
|
<string>Icon-57.png</string>
|
||||||
|
<string>Icon-114.png</string>
|
||||||
|
<string>Icon-72.png</string>
|
||||||
|
<string>Icon-144.png</string>
|
||||||
|
</array>
|
||||||
|
<key>UIPrerenderedIcon</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>org.cocos2dx.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>${PRODUCT_NAME}</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>UIPrerenderedIcon</key>
|
||||||
|
<true/>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<dict>
|
||||||
|
<key>accelerometer</key>
|
||||||
|
<true/>
|
||||||
|
<key>opengles-1</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
<key>UIStatusBarHidden</key>
|
||||||
|
<true/>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
|
@ -0,0 +1,33 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010-2011 cocos2d-x.org
|
||||||
|
Copyright (c) 2010 Ricardo Quesada
|
||||||
|
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
|
||||||
|
@interface RootViewController : UIViewController {
|
||||||
|
|
||||||
|
}
|
||||||
|
- (BOOL)prefersStatusBarHidden;
|
||||||
|
@end
|
|
@ -0,0 +1,96 @@
|
||||||
|
/****************************************************************************
|
||||||
|
Copyright (c) 2010-2011 cocos2d-x.org
|
||||||
|
Copyright (c) 2010 Ricardo Quesada
|
||||||
|
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#import "RootViewController.h"
|
||||||
|
|
||||||
|
|
||||||
|
@implementation RootViewController
|
||||||
|
|
||||||
|
/*
|
||||||
|
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
|
||||||
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
||||||
|
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
|
||||||
|
// Custom initialization
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Implement loadView to create a view hierarchy programmatically, without using a nib.
|
||||||
|
- (void)loadView {
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
||||||
|
- (void)viewDidLoad {
|
||||||
|
[super viewDidLoad];
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
// Override to allow orientations other than the default portrait orientation.
|
||||||
|
// This method is deprecated on ios6
|
||||||
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
||||||
|
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
|
||||||
|
}
|
||||||
|
|
||||||
|
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
|
||||||
|
- (NSUInteger) supportedInterfaceOrientations{
|
||||||
|
#ifdef __IPHONE_6_0
|
||||||
|
return UIInterfaceOrientationMaskAllButUpsideDown;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) shouldAutorotate {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
//fix not hide status on ios7
|
||||||
|
- (BOOL)prefersStatusBarHidden
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)didReceiveMemoryWarning {
|
||||||
|
// Releases the view if it doesn't have a superview.
|
||||||
|
[super didReceiveMemoryWarning];
|
||||||
|
|
||||||
|
// Release any cached data, images, etc that aren't in use.
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewDidUnload {
|
||||||
|
[super viewDidUnload];
|
||||||
|
// Release any retained subviews of the main view.
|
||||||
|
// e.g. self.myOutlet = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// main.m
|
||||||
|
// HelloLua
|
||||||
|
//
|
||||||
|
// Created by Walzer on 11-6-15.
|
||||||
|
// Copyright __MyCompanyName__ 2011. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
|
||||||
|
[pool release];
|
||||||
|
return retVal;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
#Do now ignore Marmalade icf files
|
||||||
|
!*.icf
|
|
@ -0,0 +1,403 @@
|
||||||
|
|
||||||
|
local ControllerHolder = class("ControllerHolder")
|
||||||
|
|
||||||
|
function ControllerHolder:ctor()
|
||||||
|
self.controller = nil
|
||||||
|
self._holderNode = nil
|
||||||
|
|
||||||
|
self._leftJoystick = nil
|
||||||
|
self._rightJoystick = nil
|
||||||
|
|
||||||
|
self._dpadLeft = nil
|
||||||
|
self._dpadRight = nil
|
||||||
|
self._dpadUp = nil
|
||||||
|
self._dpadDown = nil
|
||||||
|
|
||||||
|
self._buttonX = nil
|
||||||
|
self._buttonY = nil
|
||||||
|
self._buttonA = nil
|
||||||
|
self._buttonB = nil
|
||||||
|
|
||||||
|
self._buttonL1 = nil
|
||||||
|
self._buttonR1 = nil
|
||||||
|
self._buttonL2 = nil
|
||||||
|
self._buttonR2 = nil
|
||||||
|
|
||||||
|
self.deviceLabel = nil
|
||||||
|
self.externalKeyLabel = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local GameControllerTest = class("GameControllerTest", function()
|
||||||
|
return cc.Layer:create()
|
||||||
|
end)
|
||||||
|
|
||||||
|
function GameControllerTest:ctor()
|
||||||
|
self:init()
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameControllerTest:createControllerSprite(holder)
|
||||||
|
|
||||||
|
holder._holderNode = cc.Node:create()
|
||||||
|
holder._holderNode:setContentSize(cc.size(998,1000))
|
||||||
|
|
||||||
|
local controllerBg1 = cc.Sprite:create("controller-1.png")
|
||||||
|
controllerBg1:setPosition(cc.p(0, 0))
|
||||||
|
controllerBg1:setAnchorPoint(cc.p(0, 0))
|
||||||
|
holder._holderNode:addChild(controllerBg1)
|
||||||
|
|
||||||
|
local controllerBg2 = cc.Sprite:create("controller-2.png")
|
||||||
|
controllerBg2:setPosition(cc.p(499,1000))
|
||||||
|
controllerBg2:setAnchorPoint(cc.p(0.5, 1.0))
|
||||||
|
holder._holderNode:addChild(controllerBg2)
|
||||||
|
|
||||||
|
holder._leftJoystick = cc.Sprite:create("joystick.png")
|
||||||
|
holder._leftJoystick:setPosition(cc.p(238,460))
|
||||||
|
holder._holderNode:addChild(holder._leftJoystick)
|
||||||
|
|
||||||
|
holder._rightJoystick = cc.Sprite:create("joystick.png")
|
||||||
|
holder._rightJoystick:setPosition(cc.p(606,293))
|
||||||
|
holder._holderNode:addChild(holder._rightJoystick)
|
||||||
|
|
||||||
|
holder._deviceLabel = cc.Label:createWithTTF("Disconnected","fonts/Marker Felt.ttf",36)
|
||||||
|
holder._deviceLabel:setPosition(cc.p(499,650))
|
||||||
|
holder._deviceLabel:setTextColor(cc.c4b(255, 0, 0, 255))
|
||||||
|
holder._holderNode:addChild(holder._deviceLabel)
|
||||||
|
|
||||||
|
holder._externalKeyLabel = cc.Label:createWithTTF("Key event","fonts/Marker Felt.ttf",36)
|
||||||
|
holder._externalKeyLabel:setPosition(cc.p(499,500))
|
||||||
|
holder._externalKeyLabel:setTextColor(cc.c4b(255, 0, 0, 255))
|
||||||
|
holder._holderNode:addChild(holder._externalKeyLabel)
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
local dPadTexture = cc.Director:getInstance():getTextureCache():addImage("dPad.png")
|
||||||
|
|
||||||
|
local dPadCenter = cc.Sprite:createWithTexture(dPadTexture,cc.rect(60,60,68,68))
|
||||||
|
dPadCenter:setPosition(cc.p(371,294))
|
||||||
|
holder._holderNode:addChild(dPadCenter)
|
||||||
|
|
||||||
|
holder._dpadLeft = cc.Sprite:createWithTexture(dPadTexture,cc.rect(0,60,60,60))
|
||||||
|
holder._dpadLeft:setPosition(cc.p(371 - 64,296))
|
||||||
|
holder._holderNode:addChild(holder._dpadLeft)
|
||||||
|
|
||||||
|
holder._dpadRight = cc.Sprite:createWithTexture(dPadTexture,cc.rect(128,60,60,60))
|
||||||
|
holder._dpadRight:setPosition(cc.p(371 + 64,296))
|
||||||
|
holder._holderNode:addChild(holder._dpadRight)
|
||||||
|
|
||||||
|
holder._dpadUp = cc.Sprite:createWithTexture(dPadTexture,cc.rect(60,0,60,60))
|
||||||
|
holder._dpadUp:setPosition(cc.p(369,294 + 64))
|
||||||
|
holder._holderNode:addChild(holder._dpadUp)
|
||||||
|
|
||||||
|
holder._dpadDown = cc.Sprite:createWithTexture(dPadTexture,cc.rect(60,128,60,60))
|
||||||
|
holder._dpadDown:setPosition(cc.p(369,294 - 64))
|
||||||
|
holder._holderNode:addChild(holder._dpadDown)
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
holder._buttonL1 = cc.Sprite:create("L1.png")
|
||||||
|
holder._buttonL1:setPosition(cc.p(290,792))
|
||||||
|
holder._holderNode:addChild(holder._buttonL1)
|
||||||
|
|
||||||
|
holder._buttonR1 = cc.Sprite:create("R1.png")
|
||||||
|
holder._buttonR1:setPosition(cc.p(998 - 290,792))
|
||||||
|
holder._holderNode:addChild(holder._buttonR1)
|
||||||
|
|
||||||
|
local buttonL2 = cc.Sprite:create("L2.png")
|
||||||
|
buttonL2:setPosition(cc.p(220,910))
|
||||||
|
holder._holderNode:addChild(buttonL2)
|
||||||
|
|
||||||
|
local buttonR2 = cc.Sprite:create("R2.png")
|
||||||
|
buttonR2:setPosition(cc.p(998-220,910))
|
||||||
|
holder._holderNode:addChild(buttonR2)
|
||||||
|
|
||||||
|
holder._buttonL2 = cc.Sprite:create("L2.png")
|
||||||
|
holder._buttonL2:setOpacity(0)
|
||||||
|
holder._buttonL2:setColor(cc.c3b(255,0,0))
|
||||||
|
holder._buttonL2:setPosition(cc.p(220,910))
|
||||||
|
holder._holderNode:addChild(holder._buttonL2)
|
||||||
|
|
||||||
|
holder._buttonR2 = cc.Sprite:create("R2.png")
|
||||||
|
holder._buttonR2:setOpacity(0)
|
||||||
|
holder._buttonR2:setColor(cc.c3b(255,0,0))
|
||||||
|
holder._buttonR2:setPosition(cc.p(998-220,910))
|
||||||
|
holder._holderNode:addChild(holder._buttonR2)
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
holder._buttonX = cc.Sprite:create("X.png")
|
||||||
|
holder._buttonX:setPosition(cc.p(750 - 70,460))
|
||||||
|
holder._holderNode:addChild(holder._buttonX)
|
||||||
|
|
||||||
|
holder._buttonY = cc.Sprite:create("Y.png")
|
||||||
|
holder._buttonY:setPosition(cc.p(750,460 + 70))
|
||||||
|
holder._holderNode:addChild(holder._buttonY)
|
||||||
|
|
||||||
|
holder._buttonA = cc.Sprite:create("A.png")
|
||||||
|
holder._buttonA:setPosition(cc.p(750,460 - 70))
|
||||||
|
holder._holderNode:addChild(holder._buttonA)
|
||||||
|
|
||||||
|
holder._buttonB = cc.Sprite:create("B.png")
|
||||||
|
holder._buttonB:setPosition(cc.p(750 + 70,460))
|
||||||
|
holder._holderNode:addChild(holder._buttonB)
|
||||||
|
end
|
||||||
|
|
||||||
|
function GameControllerTest:registerControllerListener()
|
||||||
|
|
||||||
|
local function resetControllerHolderState(holder)
|
||||||
|
holder._buttonA:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._buttonB:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._buttonX:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._buttonY:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._dpadUp:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._dpadDown:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._dpadLeft:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._dpadRight:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._buttonL1:setColor(cc.c3b(255, 255, 255))
|
||||||
|
holder._buttonR1:setColor(cc.c3b(255, 255, 255))
|
||||||
|
|
||||||
|
holder._leftJoystick:setPosition(cc.p(238,460))
|
||||||
|
holder._rightJoystick:setPosition(cc.p(606,293))
|
||||||
|
holder._deviceLabel:setString("Disconnected")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onConnectController(controller, event)
|
||||||
|
if controller == nil or controller == self._firstHolder.controller or controller == self._secondHolder.controller then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||||
|
if targetPlatform == cc.PLATFORM_OS_ANDROID then
|
||||||
|
--do sth
|
||||||
|
-- //receive back key
|
||||||
|
-- controller:receiveExternalKeyEvent(4,true)
|
||||||
|
-- //receive menu key
|
||||||
|
-- controller:receiveExternalKeyEvent(82,true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local deviceInfo = string.format("%s id:%d", controller:getDeviceName(), controller:getDeviceId())
|
||||||
|
print(deviceInfo)
|
||||||
|
|
||||||
|
|
||||||
|
if self._firstHolder.controller == nil and self._secondHolder.controller == nil then
|
||||||
|
if self._firstHolder._holderNode then
|
||||||
|
self._firstHolder.controller = controller
|
||||||
|
self._firstHolder._deviceLabel:setString(deviceInfo)
|
||||||
|
else
|
||||||
|
self._secondHolder.controller = controller
|
||||||
|
self._secondHolder._deviceLabel:setString(deviceInfo)
|
||||||
|
end
|
||||||
|
elseif self._secondHolder.controller == nil then
|
||||||
|
self._secondHolder.controller = controller
|
||||||
|
if self._secondHolder._holderNode == nil then
|
||||||
|
createControllerSprite(self._secondHolder)
|
||||||
|
|
||||||
|
self._firstHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 0.5, 0.5))
|
||||||
|
self._firstHolder._holderNode:runAction(cc.MoveTo:create(0.3,cc.p(self._visibleQuarterX, self_visibleCentreY)))
|
||||||
|
|
||||||
|
self._secondHolder._holderNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||||
|
self._secondHolder._holderNode:setScale(0.1)
|
||||||
|
self._secondHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 0.5, 0.5))
|
||||||
|
self._secondHolder._holderNode:setPosition(cc.p(self._visibleThreeQuarterX, self._visibleCentreY))
|
||||||
|
self:addChild(self._secondHolder._holderNode)
|
||||||
|
end
|
||||||
|
|
||||||
|
self._secondHolder._deviceLabel:setString(deviceInfo)
|
||||||
|
else
|
||||||
|
self._firstHolder.controller = controller
|
||||||
|
if self._firstHolder._holderNode == nil then
|
||||||
|
createControllerSprite(self._firstHolder)
|
||||||
|
|
||||||
|
self._secondHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 0.5, 0.5))
|
||||||
|
self._secondHolder._holderNode:runAction(cc.MoveTo:create(0.3, cc.p(self._visibleQuarterX, self._visibleCentreY)))
|
||||||
|
|
||||||
|
self._firstHolder._holderNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||||
|
self._firstHolder._holderNode:setScale(0.1)
|
||||||
|
self._firstHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 0.5,0.5))
|
||||||
|
self._firstHolder._holderNode:setPosition(cc.p(self._visibleThreeQuarterX, self._visibleCentreY))
|
||||||
|
self:addChild(self._firstHolder._holderNode)
|
||||||
|
end
|
||||||
|
|
||||||
|
self._firstHolder._deviceLabel:setString(deviceInfo)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onDisconnectedController(controller, event)
|
||||||
|
print("onDisconnectedController:",controller:getDeviceId())
|
||||||
|
if self._firstHolder.controller == controller then
|
||||||
|
self._firstHolder.controller = nil
|
||||||
|
|
||||||
|
if self._secondHolder.controller ~= nil then
|
||||||
|
self._firstHolder._holderNode:runAction(cc.MoveBy:create(0.3,cc.p(0,self._visibleSize.height)))
|
||||||
|
|
||||||
|
self._secondHolder._holderNode:runAction(cc.MoveTo:create(0.3, cc.p(self._visibleCentreX, self._visibleCentreY) ))
|
||||||
|
self._secondHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 1.0,1.0))
|
||||||
|
else
|
||||||
|
resetControllerHolderState(self._firstHolder)
|
||||||
|
end
|
||||||
|
elseif self._secondHolder.controller == controller then
|
||||||
|
self._secondHolder.controller = nil
|
||||||
|
|
||||||
|
if self._firstHolder.controller ~= nil then
|
||||||
|
self._secondHolder._holderNode:runAction(cc.MoveBy:create(0.3, cc.p(0, self._visibleSize.height)))
|
||||||
|
|
||||||
|
self._firstHolder._holderNode:runAction(cc.MoveTo:create(0.3, cc.p(self._visibleCentreX, self._visibleCentreY)))
|
||||||
|
self._firstHolder._holderNode:runAction(cc.ScaleTo:create(0.3, 1.0,1.0))
|
||||||
|
else
|
||||||
|
resetControllerHolderState(self._secondHolder)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function showButtonState(controller, keyCode, isPressed)
|
||||||
|
onConnectController(controller, nil)
|
||||||
|
local holder = nil
|
||||||
|
|
||||||
|
if controller == self._firstHolder.controller then
|
||||||
|
holder = self._firstHolder
|
||||||
|
elseif controller == self._secondHolder.controller then
|
||||||
|
holder = self._secondHolder
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if isPressed then
|
||||||
|
if keyCode == cc.ControllerKey.BUTTON_A then
|
||||||
|
holder._buttonA:setColor(cc.c3b(250,103,93))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_B then
|
||||||
|
holder._buttonB:setColor(cc.c3b(92,214,183))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_X then
|
||||||
|
holder._buttonX:setColor(cc.c3b(96,113,192))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_Y then
|
||||||
|
holder._buttonY:setColor(cc.c3b(199,222,118))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_UP then
|
||||||
|
holder._dpadUp:setColor(cc.c3b(0,115,158))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_DOWN then
|
||||||
|
holder._dpadDown:setColor(cc.c3b(0,115,158))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_LEFT then
|
||||||
|
holder._dpadLeft:setColor(cc.c3b(170,216,0))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_RIGHT then
|
||||||
|
holder._dpadRight:setColor(cc.c3b(170,216,0))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_LEFT_SHOULDER then
|
||||||
|
holder._buttonL1:setColor(cc.c3b(19,231,238))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_RIGHT_SHOULDER then
|
||||||
|
holder._buttonR1:setColor(cc.c3b(19,231,238))
|
||||||
|
else
|
||||||
|
local ketStatus = string.format("Key Down:%d",keyCode)
|
||||||
|
holder._externalKeyLabel:setString(ketStatus)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if keyCode == cc.ControllerKey.BUTTON_A then
|
||||||
|
holder._buttonA:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_B then
|
||||||
|
holder._buttonB:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_X then
|
||||||
|
holder._buttonX:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_Y then
|
||||||
|
holder._buttonY:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_UP then
|
||||||
|
holder._dpadUp:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_DOWN then
|
||||||
|
holder._dpadDown:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_LEFT then
|
||||||
|
holder._dpadLeft:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_DPAD_RIGHT then
|
||||||
|
holder._dpadRight:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_LEFT_SHOULDER then
|
||||||
|
holder._buttonL1:setColor(cc.c3b(250,255,255))
|
||||||
|
elseif keyCode == cc.ControllerKey.BUTTON_RIGHT_SHOULDER then
|
||||||
|
holder._buttonR1:setColor(cc.c3b(250,255,255))
|
||||||
|
else
|
||||||
|
local ketStatus = string.format("Key Up:%d",keyCode)
|
||||||
|
holder._externalKeyLabel:setString(ketStatus)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onKeyDown(controller, keyCode, event)
|
||||||
|
showButtonState(controller, keyCode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onKeyUp(controller, keyCode, event)
|
||||||
|
showButtonState(controller, keyCode, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function onAxisEvent(controller, keyCode, event)
|
||||||
|
local holder = nil
|
||||||
|
|
||||||
|
if controller == self._firstHolder.controller then
|
||||||
|
holder = self._firstHolder
|
||||||
|
elseif controller == self._secondHolder.controller then
|
||||||
|
holder = self._secondHolder
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ketStatus = controller:getKeyStatus(keyCode)
|
||||||
|
if keyCode == cc.ControllerKey.JOYSTICK_LEFT_X then
|
||||||
|
holder._leftJoystick:setPositionX(238 + ketStatus.value * 24)
|
||||||
|
elseif keyCode == cc.ControllerKey.JOYSTICK_LEFT_Y then
|
||||||
|
holder._leftJoystick:setPositionY(460 - ketStatus.value * 24)
|
||||||
|
elseif keyCode == cc.ControllerKey.JOYSTICK_RIGHT_X then
|
||||||
|
holder._rightJoystick:setPositionX(606 + ketStatus.value * 24)
|
||||||
|
elseif keyCode == cc.ControllerKey.JOYSTICK_RIGHT_Y then
|
||||||
|
holder._rightJoystick:setPositionY(293 - ketStatus.value * 24)
|
||||||
|
elseif keyCode == cc.ControllerKey.AXIS_LEFT_TRIGGER then
|
||||||
|
holder._buttonL2:setOpacity(200 * controller:getKeyStatus(keyCode).value)
|
||||||
|
elseif keyCode == cc.ControllerKey.AXIS_RIGHT_TRIGGER then
|
||||||
|
holder._buttonR2:setOpacity(200 * controller:getKeyStatus(keyCode).value)
|
||||||
|
else
|
||||||
|
--do nothing
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- body
|
||||||
|
self._listener = cc.EventListenerController:create()
|
||||||
|
self._listener:registerScriptHandler(onConnectController, cc.Handler.EVENT_CONTROLLER_CONNECTED)
|
||||||
|
self._listener:registerScriptHandler(onDisconnectedController, cc.Handler.EVENT_CONTROLLER_DISCONNECTED)
|
||||||
|
|
||||||
|
self._listener:registerScriptHandler(onKeyDown, cc.Handler.EVENT_CONTROLLER_KEYDOWN)
|
||||||
|
self._listener:registerScriptHandler(onKeyUp, cc.Handler.EVENT_CONTROLLER_KEYUP)
|
||||||
|
self._listener:registerScriptHandler(onAxisEvent, cc.Handler.EVENT_CONTROLLER_AXIS)
|
||||||
|
|
||||||
|
local eventDispatcher = self:getEventDispatcher()
|
||||||
|
eventDispatcher:addEventListenerWithSceneGraphPriority(self._listener, self)
|
||||||
|
|
||||||
|
cc.Controller:startDiscoveryController()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function GameControllerTest:init()
|
||||||
|
self._currControllerCount = 0
|
||||||
|
self._visibleSize = cc.Director:getInstance():getVisibleSize()
|
||||||
|
self._visibleOrigin = cc.Director:getInstance():getVisibleOrigin()
|
||||||
|
|
||||||
|
local tmpPos = cc.p(self._visibleSize.width / 2 + self._visibleOrigin.x, self._visibleSize.height / 2 + self._visibleOrigin.y)
|
||||||
|
|
||||||
|
self._visibleCentreX = self._visibleOrigin.x + self._visibleSize.width / 2
|
||||||
|
self._visibleCentreY = self._visibleOrigin.y + self._visibleSize.height / 2
|
||||||
|
self._visibleQuarterX = self._visibleOrigin.x + self._visibleSize.width / 4
|
||||||
|
self._visibleThreeQuarterX = self._visibleOrigin.x + self._visibleSize.width * 0.75
|
||||||
|
|
||||||
|
self._firstHolder = ControllerHolder.new()
|
||||||
|
self._secondHolder = ControllerHolder.new()
|
||||||
|
self._firstHolder.controller = nil
|
||||||
|
self._secondHolder.controller = nil
|
||||||
|
|
||||||
|
self:createControllerSprite(self._firstHolder)
|
||||||
|
self._firstHolder._holderNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||||
|
self._firstHolder._holderNode:setPosition(tmpPos)
|
||||||
|
self:addChild(self._firstHolder._holderNode)
|
||||||
|
|
||||||
|
self:registerControllerListener()
|
||||||
|
|
||||||
|
-- local function menuCloseCallback(tag, sender)
|
||||||
|
|
||||||
|
-- end
|
||||||
|
-- local closeItem = cc.MenuItemImage:create("CloseNormal.png", "CloseSelected.png")
|
||||||
|
-- closeItem:setPosition(cc.p(self._visibleOrigin.x + self._visibleSize.width - closeItem:getContentSize().width / 2, self._visibleOrigin.y + self._visibleSize.height - closeItem:getContentSize().height / 2))
|
||||||
|
|
||||||
|
-- local menu = cc.Menu:create()
|
||||||
|
-- menu:addChild(closeItem)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return GameControllerTest
|
|
@ -0,0 +1,52 @@
|
||||||
|
require("Cocos2d")
|
||||||
|
require("Cocos2dConstants")
|
||||||
|
|
||||||
|
collectgarbage("setpause", 100)
|
||||||
|
collectgarbage("setstepmul", 5000)
|
||||||
|
|
||||||
|
local mediumResource =
|
||||||
|
{
|
||||||
|
size = cc.size(960, 540),
|
||||||
|
directory = "ipad",
|
||||||
|
}
|
||||||
|
|
||||||
|
local largeResource =
|
||||||
|
{
|
||||||
|
size = cc.size(1920, 1080),
|
||||||
|
directory = "ipadhd",
|
||||||
|
}
|
||||||
|
|
||||||
|
local glView = cc.Director:getInstance():getOpenGLView()
|
||||||
|
local designResolutionSize = cc.size(1920, 1080)
|
||||||
|
|
||||||
|
glView:setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, 2)
|
||||||
|
|
||||||
|
local frameSize = glView:getFrameSize()
|
||||||
|
|
||||||
|
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||||
|
local resPrefix = ""
|
||||||
|
if targetPlatform == cc.PLATFORM_OS_ANDROID then
|
||||||
|
resPrefix = "res/"
|
||||||
|
end
|
||||||
|
|
||||||
|
local fileUtils = cc.FileUtils:getInstance()
|
||||||
|
local searchPaths = fileUtils:getSearchPaths()
|
||||||
|
|
||||||
|
table.insert(searchPaths, 1, resPrefix)
|
||||||
|
if frameSize.height > mediumResource.size.height then
|
||||||
|
table.insert(searchPaths, 1, resPrefix..largeResource.directory)
|
||||||
|
cc.Director:getInstance():setContentScaleFactor(math.min(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width))
|
||||||
|
else
|
||||||
|
table.insert(searchPaths, 1, resPrefix..mediumResource.directory)
|
||||||
|
cc.Director:getInstance():setContentScaleFactor(math.min(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width))
|
||||||
|
end
|
||||||
|
|
||||||
|
fileUtils:setSearchPaths(searchPaths)
|
||||||
|
|
||||||
|
local scene = cc.Scene:create()
|
||||||
|
scene:addChild(require("src/GameControllerTest").new())
|
||||||
|
if cc.Director:getInstance():getRunningScene() then
|
||||||
|
cc.Director:getInstance():replaceScene(scene)
|
||||||
|
else
|
||||||
|
cc.Director:getInstance():runWithScene(scene)
|
||||||
|
end
|
|
@ -0,0 +1,61 @@
|
||||||
|
[cocos2dx_controller]
|
||||||
|
# the prefix to be added to the generated functions. You might or might not use this in your own
|
||||||
|
# templates
|
||||||
|
prefix = cocos2dx_controller
|
||||||
|
|
||||||
|
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
|
||||||
|
# all classes will be embedded in that namespace
|
||||||
|
target_namespace = cc
|
||||||
|
|
||||||
|
macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
||||||
|
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
|
||||||
|
android_flags = -D_SIZE_T_DEFINED_
|
||||||
|
|
||||||
|
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
|
||||||
|
clang_flags = -nostdinc -x c++ -std=c++11
|
||||||
|
|
||||||
|
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/base -I%(cocosdir)s/cocos/platform/android
|
||||||
|
cocos_flags = -DANDROID
|
||||||
|
|
||||||
|
cxxgenerator_headers =
|
||||||
|
|
||||||
|
# extra arguments for clang
|
||||||
|
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
|
||||||
|
|
||||||
|
# what headers to parse
|
||||||
|
headers = %(cocosdir)s/cocos/base/CCGameController.h
|
||||||
|
|
||||||
|
# what classes to produce code for. You can use regular expressions here. When testing the regular
|
||||||
|
# expression, it will be enclosed in "^$", like this: "^Menu*$".
|
||||||
|
classes = Controller EventController EventListenerController
|
||||||
|
|
||||||
|
# what should we skip? in the format ClassName::[function function]
|
||||||
|
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
|
||||||
|
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
|
||||||
|
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
|
||||||
|
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||||
|
# functions from all classes.
|
||||||
|
|
||||||
|
skip = Controller::[getAllController getKeyStatus]
|
||||||
|
|
||||||
|
rename_functions =
|
||||||
|
|
||||||
|
rename_classes =
|
||||||
|
|
||||||
|
# for all class names, should we remove something when registering in the target VM?
|
||||||
|
remove_prefix =
|
||||||
|
|
||||||
|
# classes for which there will be no "parent" lookup
|
||||||
|
classes_have_no_parents =
|
||||||
|
|
||||||
|
# base classes which will be skipped when their sub-classes found them.
|
||||||
|
base_classes_to_skip =
|
||||||
|
|
||||||
|
# classes that create no constructor
|
||||||
|
# Set is special and we will use a hand-written constructor
|
||||||
|
abstract_classes =
|
||||||
|
|
||||||
|
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||||
|
script_control_cpp = no
|
||||||
|
|
|
@ -133,6 +133,7 @@ def main():
|
||||||
'cocos2dx_spine.ini' : ('cocos2dx_spine', 'lua_cocos2dx_spine_auto'), \
|
'cocos2dx_spine.ini' : ('cocos2dx_spine', 'lua_cocos2dx_spine_auto'), \
|
||||||
'cocos2dx_physics.ini' : ('cocos2dx_physics', 'lua_cocos2dx_physics_auto'), \
|
'cocos2dx_physics.ini' : ('cocos2dx_physics', 'lua_cocos2dx_physics_auto'), \
|
||||||
'cocos2dx_experimental_video.ini' : ('cocos2dx_experimental_video', 'lua_cocos2dx_experimental_video_auto'), \
|
'cocos2dx_experimental_video.ini' : ('cocos2dx_experimental_video', 'lua_cocos2dx_experimental_video_auto'), \
|
||||||
|
'cocos2dx_controller.ini' : ('cocos2dx_controller', 'lua_cocos2dx_controller_auto'), \
|
||||||
}
|
}
|
||||||
target = 'lua'
|
target = 'lua'
|
||||||
generator_py = '%s/generator.py' % cxx_generator_root
|
generator_py = '%s/generator.py' % cxx_generator_root
|
||||||
|
|