mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' into perf-callback
Conflicts: build/cocos2d_tests.xcodeproj/project.pbxproj
This commit is contained in:
commit
037c57ef96
|
@ -111,3 +111,9 @@ CMakeCache.txt
|
|||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
|
||||
# Ignore files generated by console
|
||||
build/build/
|
||||
cocos/scripting/lua-bindings/proj.ios_mac/build/
|
||||
tests/*/runtime/
|
||||
tests/*/publish/
|
||||
|
|
3
AUTHORS
3
AUTHORS
|
@ -712,6 +712,7 @@ Developers:
|
|||
|
||||
kicktheken (Kenneth Chan)
|
||||
Fixed a bug that the setBlendFunc method of some classes wasn't exposed to LUA.
|
||||
Fix lua project template crash on iOS5.1 device
|
||||
|
||||
andyque
|
||||
Fixed a bug that missing to check self assignment of Vector<T>, Map<K,V>, Value and String.
|
||||
|
@ -813,11 +814,13 @@ Developers:
|
|||
|
||||
Mazyod
|
||||
Fixed a bug that HTTPClient reports 2xx status codes as errors
|
||||
Added missing Text Font and Placeholder feature of EditBox for Mac platform
|
||||
|
||||
iSevenDays
|
||||
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
|
||||
Fixed a potential memory leak in CCEditBoxImplIOS.mm
|
||||
Fixed incompatible pointer conversion in external/chipmunk/src/cpArray.c
|
||||
Fix memory leak in CCImage
|
||||
|
||||
ololomax
|
||||
Fixed a potential crash in SceneReader::createNodeWithSceneFile
|
||||
|
|
|
@ -1 +1 @@
|
|||
f9627687e49dc44eace02e9648208c4cd1987246
|
||||
02451d8f73c78341cb22b90556ab891ef136c5e1
|
|
@ -31,8 +31,8 @@ Example:
|
|||
$ cd cocos2d-x
|
||||
$ ./setup.py
|
||||
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
|
||||
$ cocos new MyGame -p com.your_company.mygame -l cpp -d /home
|
||||
$ cd /home/MyGame
|
||||
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
|
||||
$ cd NEW_PROJECTS_DIR/MyGame
|
||||
|
||||
### Build and run new project for android ###
|
||||
|
||||
|
@ -56,7 +56,7 @@ script in **cocos2d/build/install-deps-linux.sh**
|
|||
|
||||
Then
|
||||
|
||||
$ cd /home/MyGame
|
||||
$ cd NEW_PROJECTS_DIR/MyGame
|
||||
$ cocos run -p linux
|
||||
|
||||
Run
|
||||
|
|
|
@ -9,13 +9,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\cocos\editor
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosStudio", "..\cocos\editor-support\cocostudio\proj.wp8\libCocosStudio.vcxproj", "{51E5736E-E1A3-4C94-ABB7-E92ECEF9C12E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{04A0C42F-23BB-469B-A9D8-CA49136ADBD4} = {04A0C42F-23BB-469B-A9D8-CA49136ADBD4}
|
||||
{B5AF91B3-64EA-44E1-84B0-D759E93758FB} = {B5AF91B3-64EA-44E1-84B0-D759E93758FB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libCocosBuilder", "..\cocos\editor-support\cocosbuilder\proj.wp8\libCocosBuilder.vcxproj", "{20D4035D-FD3F-4FD3-BABA-97BC1C38DFC2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{04A0C42F-23BB-469B-A9D8-CA49136ADBD4} = {04A0C42F-23BB-469B-A9D8-CA49136ADBD4}
|
||||
{B5AF91B3-64EA-44E1-84B0-D759E93758FB} = {B5AF91B3-64EA-44E1-84B0-D759E93758FB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -29,6 +27,9 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chipmunk", "..\external\chipmunk\proj.wp8\chipmunk.vcxproj", "{BA568A33-98F9-4D2A-BFFF-C065ADCB447A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libLocalStorage", "..\cocos\storage\local-storage\proj.wp8\libLocalStorage.vcxproj", "{88982C27-5A7B-40A8-86E7-B3187B44B322}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{B5AF91B3-64EA-44E1-84B0-D759E93758FB} = {B5AF91B3-64EA-44E1-84B0-D759E93758FB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CocosDenshion", "..\cocos\audio\proj.wp8\CocosDenshion.vcxproj", "{DF125891-EEE9-4466-B903-F828FD272158}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
|
|
|
@ -1 +1 @@
|
|||
b5b636c8bcca1ce239847cab19cfafedf83ca250
|
||||
1f2c191d1027ab72afff7e81d1fb31fce82ce4b1
|
|
@ -1 +1 @@
|
|||
7c5537a4981f462fe84a5e213bb408b690fae66f
|
||||
2dcda958098d34a161aadd25d3afdab6b5a936e4
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.21005.1
|
||||
VisualStudioVersion = 12.0.30324.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Cocos2dShaderCompiler", "Cocos2dShaderCompiler.vcxproj", "{4F6DEF20-AC4C-487F-85B8-5993519E3911}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d_winrt.vcxproj", "{2330EDF4-5596-4B53-8BA5-158DDDE713D9}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libchipmunk", "..\..\..\external\chipmunk\proj.winrt\chipmunk.vcxproj", "{8B143765-5C1B-4076-9384-3E0EC3650B1A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\..\cocos\2d\cocos2d_winrt.vcxproj", "{2330EDF4-5596-4B53-8BA5-158DDDE713D9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
|
@ -37,18 +37,6 @@ Global
|
|||
{4F6DEF20-AC4C-487F-85B8-5993519E3911}.Release|x64.ActiveCfg = Release|x64
|
||||
{4F6DEF20-AC4C-487F-85B8-5993519E3911}.Release|x64.Build.0 = Release|x64
|
||||
{4F6DEF20-AC4C-487F-85B8-5993519E3911}.Release|x64.Deploy.0 = Release|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|x64.Build.0 = Debug|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|ARM.Build.0 = Release|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|Win32.Build.0 = Release|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|x64.ActiveCfg = Release|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|x64.Build.0 = Release|x64
|
||||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
|
@ -61,6 +49,18 @@ Global
|
|||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Release|Win32.Build.0 = Release|Win32
|
||||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Release|x64.ActiveCfg = Release|x64
|
||||
{8B143765-5C1B-4076-9384-3E0EC3650B1A}.Release|x64.Build.0 = Release|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Debug|x64.Build.0 = Debug|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|ARM.Build.0 = Release|ARM
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|Win32.Build.0 = Release|Win32
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|x64.ActiveCfg = Release|x64
|
||||
{2330EDF4-5596-4B53-8BA5-158DDDE713D9}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -159,7 +159,7 @@ Sequence* Sequence::createWithTwoActions(FiniteTimeAction *actionOne, FiniteTime
|
|||
return sequence;
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Sequence* Sequence::variadicCreate(FiniteTimeAction *action1, ...)
|
||||
{
|
||||
va_list params;
|
||||
|
@ -546,7 +546,7 @@ RepeatForever *RepeatForever::reverse() const
|
|||
// Spawn
|
||||
//
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Spawn* Spawn::variadicCreate(FiniteTimeAction *action1, ...)
|
||||
{
|
||||
va_list params;
|
||||
|
@ -1023,7 +1023,7 @@ void MoveBy::update(float t)
|
|||
_target->setPosition(newPos);
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, ccpMult(_positionDelta, t)));
|
||||
_target->setPosition(_startPosition + _positionDelta * t);
|
||||
#endif // CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
@ -1310,7 +1310,7 @@ void JumpBy::update(float t)
|
|||
|
||||
_previousPos = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
_target->setPosition(_startPosition + Point(x,y));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
@ -1433,7 +1433,7 @@ void BezierBy::update(float time)
|
|||
|
||||
_previousPosition = newPos;
|
||||
#else
|
||||
_target->setPosition(ccpAdd( _startPosition, Point(x,y)));
|
||||
_target->setPosition( _startPosition + Point(x,y));
|
||||
#endif // !CC_ENABLE_STACKABLE_ACTIONS
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class CC_DLL Sequence : public ActionInterval
|
|||
{
|
||||
public:
|
||||
/** helper constructor to create an array of sequenceable actions */
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
|
||||
typedef FiniteTimeAction* M;
|
||||
static Sequence* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
|
||||
|
@ -267,7 +267,7 @@ public:
|
|||
* in lua :local create(local object1,local object2, ...)
|
||||
* @endcode
|
||||
*/
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
|
||||
typedef FiniteTimeAction* M;
|
||||
static Spawn* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
|
||||
|
|
|
@ -158,7 +158,7 @@ bool Director::init(void)
|
|||
|
||||
_renderer = new Renderer;
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
_console = new Console;
|
||||
#endif
|
||||
return true;
|
||||
|
@ -176,7 +176,7 @@ Director::~Director(void)
|
|||
CC_SAFE_RELEASE(_notificationNode);
|
||||
CC_SAFE_RELEASE(_scheduler);
|
||||
CC_SAFE_RELEASE(_actionManager);
|
||||
CC_SAFE_RELEASE(_eventDispatcher);
|
||||
|
||||
|
||||
delete _eventAfterUpdate;
|
||||
delete _eventAfterDraw;
|
||||
|
@ -185,10 +185,12 @@ Director::~Director(void)
|
|||
|
||||
delete _renderer;
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
delete _console;
|
||||
#endif
|
||||
|
||||
CC_SAFE_RELEASE(_eventDispatcher);
|
||||
|
||||
// clean auto release pool
|
||||
PoolManager::destroyInstance();
|
||||
|
||||
|
@ -661,6 +663,17 @@ void Director::replaceScene(Scene *scene)
|
|||
{
|
||||
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
||||
CCASSERT(scene != nullptr, "the scene should not be null");
|
||||
|
||||
if (_nextScene)
|
||||
{
|
||||
if (_nextScene->isRunning())
|
||||
{
|
||||
_nextScene->onExitTransitionDidStart();
|
||||
_nextScene->onExit();
|
||||
}
|
||||
_nextScene->cleanup();
|
||||
_nextScene = nullptr;
|
||||
}
|
||||
|
||||
ssize_t index = _scenesStack.size();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class EventListenerCustom;
|
|||
class TextureCache;
|
||||
class Renderer;
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
class Console;
|
||||
#endif
|
||||
|
||||
|
@ -371,7 +371,7 @@ public:
|
|||
/** Returns the Console
|
||||
@since v3.0
|
||||
*/
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
Console* getConsole() const { return _console; }
|
||||
#endif
|
||||
|
||||
|
@ -482,7 +482,7 @@ protected:
|
|||
/* Renderer for the Director */
|
||||
Renderer *_renderer;
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
/* Console for the director */
|
||||
Console *_console;
|
||||
#endif
|
||||
|
|
|
@ -82,6 +82,8 @@ EventListenerTouchOneByOne* EventListenerTouchOneByOne::create()
|
|||
|
||||
bool EventListenerTouchOneByOne::checkAvailable()
|
||||
{
|
||||
// EventDispatcher will use the return value of 'onTouchBegan' to determine whether to pass following 'move', 'end'
|
||||
// message to 'EventListenerTouchOneByOne' or not. So 'onTouchBegan' needs to be set.
|
||||
if (onTouchBegan == nullptr)
|
||||
{
|
||||
CCASSERT(false, "Invalid EventListenerTouchOneByOne!");
|
||||
|
|
|
@ -221,7 +221,7 @@ bool FontAtlas::getLetterDefinitionForChar(unsigned short letteCharUTF16, FontL
|
|||
bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
||||
{
|
||||
FontFreeType* fontTTf = dynamic_cast<FontFreeType*>(_font);
|
||||
if(fontTTf == nullptr)
|
||||
if(fontTTf == nullptr || utf16String == nullptr)
|
||||
return false;
|
||||
|
||||
int length = cc_wcslen(utf16String);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "CCEventCustom.h"
|
||||
#include "platform/CCFileUtils.h"
|
||||
#include "deprecated/CCString.h"
|
||||
#include "CCProfiling.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -571,7 +572,7 @@ float Label::getScaleX() const
|
|||
|
||||
void Label::alignText()
|
||||
{
|
||||
if (_fontAtlas == nullptr)
|
||||
if (_fontAtlas == nullptr || _currentUTF16String == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,11 @@ THE SOFTWARE.
|
|||
#include "kazmath/GL/matrix.h"
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "CCDirector.h"
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
//CCLabelAtlas - Creation & Init
|
||||
|
@ -244,18 +249,34 @@ void LabelAtlas::updateColor()
|
|||
}
|
||||
|
||||
//CCLabelAtlas - draw
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
void LabelAtlas::draw()
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
void LabelAtlas::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
AtlasNode::draw();
|
||||
AtlasNode::draw(renderer, transform, transformUpdated);
|
||||
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
_customDebugDrawCommand.init(_globalZOrder);
|
||||
_customDebugDrawCommand.func = CC_CALLBACK_0(LabelAtlas::drawDebugData, this,transform,transformUpdated);
|
||||
renderer->addCommand(&_customDebugDrawCommand);
|
||||
}
|
||||
|
||||
void LabelAtlas::drawDebugData(const kmMat4& transform, bool transformUpdated)
|
||||
{
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto size = getContentSize();
|
||||
|
||||
Point vertices[4]=
|
||||
{
|
||||
Point::ZERO,
|
||||
Point(size.width, 0),
|
||||
Point(size.width, size.height),
|
||||
Point(0, size.height)
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@ THE SOFTWARE.
|
|||
#define __CCLABEL_ATLAS_H__
|
||||
|
||||
#include "CCAtlasNode.h"
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#endif
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
|
@ -82,7 +84,7 @@ public:
|
|||
virtual std::string getDescription() const override;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
virtual void draw() override;
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
@ -96,6 +98,11 @@ protected:
|
|||
}
|
||||
virtual void updateColor() override;
|
||||
|
||||
#if CC_LABELATLAS_DEBUG_DRAW
|
||||
CustomCommand _customDebugDrawCommand;
|
||||
void drawDebugData(const kmMat4& transform, bool transformUpdated);
|
||||
#endif
|
||||
|
||||
// string to render
|
||||
std::string _string;
|
||||
// the first char in the charmap
|
||||
|
|
|
@ -36,6 +36,11 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
|||
#include "deprecated/CCString.h"
|
||||
#include "CCSprite.h"
|
||||
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "CCDirector.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
|
@ -201,20 +206,36 @@ Rect LabelBMFont::getBoundingBox() const
|
|||
{
|
||||
return _label->getBoundingBox();
|
||||
}
|
||||
|
||||
//LabelBMFont - Debug draw
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
void LabelBMFont::draw()
|
||||
void LabelBMFont::draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated)
|
||||
{
|
||||
const Size& s = this->getContentSize();
|
||||
Point vertices[4]={
|
||||
Point(0,0),Point(s.width,0),
|
||||
Point(s.width,s.height),Point(0,s.height),
|
||||
};
|
||||
ccDrawPoly(vertices, 4, true);
|
||||
Node::draw(renderer, transform, transformUpdated);
|
||||
|
||||
_customDebugDrawCommand.init(_globalZOrder);
|
||||
_customDebugDrawCommand.func = CC_CALLBACK_0(LabelBMFont::drawDebugData, this,transform,transformUpdated);
|
||||
renderer->addCommand(&_customDebugDrawCommand);
|
||||
}
|
||||
|
||||
#endif // CC_LABELBMFONT_DEBUG_DRAW
|
||||
void LabelBMFont::drawDebugData(const kmMat4& transform, bool transformUpdated)
|
||||
{
|
||||
kmGLPushMatrix();
|
||||
kmGLLoadMatrix(&transform);
|
||||
|
||||
auto size = getContentSize();
|
||||
|
||||
Point vertices[4]=
|
||||
{
|
||||
Point::ZERO,
|
||||
Point(size.width, 0),
|
||||
Point(size.width, size.height),
|
||||
Point(0, size.height)
|
||||
};
|
||||
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
kmGLPopMatrix();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
|
||||
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
|
||||
|
|
|
@ -35,6 +35,9 @@ Use any of these editors to generate BMFonts:
|
|||
#define __CCBITMAP_FONT_ATLAS_H__
|
||||
|
||||
#include "CCLabel.h"
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -120,11 +123,15 @@ public:
|
|||
virtual Rect getBoundingBox() const override;
|
||||
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
virtual void draw();
|
||||
#endif // CC_LABELBMFONT_DEBUG_DRAW
|
||||
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if CC_LABELBMFONT_DEBUG_DRAW
|
||||
CustomCommand _customDebugDrawCommand;
|
||||
void drawDebugData(const kmMat4& transform, bool transformUpdated);
|
||||
#endif
|
||||
|
||||
// name of fntFile
|
||||
std::string _fntFile;
|
||||
|
|
|
@ -48,6 +48,10 @@ THE SOFTWARE.
|
|||
#include "renderer/CCRenderer.h"
|
||||
#include "deprecated/CCString.h"
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
#include "physics/CCPhysicsBody.h"
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
// Layer
|
||||
|
@ -60,6 +64,9 @@ Layer::Layer()
|
|||
, _accelerationListener(nullptr)
|
||||
, _touchMode(Touch::DispatchMode::ALL_AT_ONCE)
|
||||
, _swallowsTouches(true)
|
||||
#if CC_USE_PHYSICS
|
||||
, _physicsWorld(nullptr)
|
||||
#endif
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
@ -67,7 +74,9 @@ Layer::Layer()
|
|||
|
||||
Layer::~Layer()
|
||||
{
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
CC_SAFE_DELETE(_physicsWorld);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Layer::init()
|
||||
|
@ -431,6 +440,93 @@ std::string Layer::getDescription() const
|
|||
return StringUtils::format("<Layer | Tag = %d>", _tag);
|
||||
}
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
void Layer::onEnter()
|
||||
{
|
||||
Node::onEnter();
|
||||
|
||||
if (_physicsWorld != nullptr)
|
||||
{
|
||||
this->schedule(schedule_selector(Layer::updatePhysics));
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::onExit()
|
||||
{
|
||||
Node::onExit();
|
||||
|
||||
if (_physicsWorld != nullptr)
|
||||
{
|
||||
this->unschedule(schedule_selector(Layer::updatePhysics));
|
||||
}
|
||||
}
|
||||
|
||||
void Layer::updatePhysics(float delta)
|
||||
{
|
||||
if (nullptr != _physicsWorld)
|
||||
{
|
||||
_physicsWorld->update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
Layer* Layer::createWithPhysics()
|
||||
{
|
||||
Layer *ret = new Layer();
|
||||
if (ret && ret->initWithPhysics())
|
||||
{
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Layer::initWithPhysics()
|
||||
{
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
Director * director;
|
||||
CC_BREAK_IF( ! (director = Director::getInstance()) );
|
||||
this->setContentSize(director->getWinSize());
|
||||
CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this)));
|
||||
|
||||
// success
|
||||
ret = true;
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Layer::addChildToPhysicsWorld(Node* child)
|
||||
{
|
||||
if (_physicsWorld)
|
||||
{
|
||||
std::function<void(Node*)> addToPhysicsWorldFunc = nullptr;
|
||||
addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void
|
||||
{
|
||||
if (node->getPhysicsBody())
|
||||
{
|
||||
_physicsWorld->addBody(node->getPhysicsBody());
|
||||
|
||||
node->updatePhysicsBodyPosition(this);
|
||||
node->updatePhysicsBodyRotation(this);
|
||||
}
|
||||
|
||||
auto& children = node->getChildren();
|
||||
for( const auto &n : children) {
|
||||
addToPhysicsWorldFunc(n);
|
||||
}
|
||||
};
|
||||
|
||||
addToPhysicsWorldFunc(child);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
__LayerRGBA::__LayerRGBA()
|
||||
{
|
||||
CCLOG("LayerRGBA deprecated.");
|
||||
|
@ -849,7 +945,7 @@ LayerMultiplex::~LayerMultiplex()
|
|||
}
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
LayerMultiplex * LayerMultiplex::createVariadic(Layer * layer, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
|
|
@ -38,6 +38,8 @@ THE SOFTWARE.
|
|||
#include "CCEventKeyboard.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
|
||||
#include "CCPhysicsWorld.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
|
@ -169,6 +171,27 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
|
||||
virtual bool init() override;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
public:
|
||||
virtual void updatePhysics(float delta);
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; }
|
||||
static Layer *createWithPhysics();
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
bool initWithPhysics();
|
||||
|
||||
protected:
|
||||
void addChildToPhysicsWorld(Node* child);
|
||||
|
||||
PhysicsWorld* _physicsWorld;
|
||||
|
||||
friend class Node;
|
||||
friend class ProtectedNode;
|
||||
#endif // CC_USE_PHYSICS
|
||||
|
||||
protected:
|
||||
//add the api for avoid use deprecated api
|
||||
void _addTouchListener();
|
||||
|
@ -436,7 +459,7 @@ public:
|
|||
* In lua:local create(...)
|
||||
* @endcode
|
||||
*/
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
|
||||
typedef Layer* M;
|
||||
static LayerMultiplex* create(M m1, std::nullptr_t listEnd) { return createVariadic(m1, NULL); }
|
||||
|
|
|
@ -58,7 +58,7 @@ Menu* Menu::create()
|
|||
return Menu::create(nullptr, nullptr);
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
Menu * Menu::variadicCreate(MenuItem* item, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
/** creates an empty Menu */
|
||||
static Menu* create();
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// WP8 in VS2012 does not support nullptr in variable args lists and variadic templates are also not supported
|
||||
typedef MenuItem* M;
|
||||
static Menu* create(M m1, std::nullptr_t listEnd) { return variadicCreate(m1, NULL); }
|
||||
|
|
|
@ -43,7 +43,7 @@ THE SOFTWARE.
|
|||
#include "CCEventDispatcher.h"
|
||||
#include "CCEvent.h"
|
||||
#include "CCEventTouch.h"
|
||||
#include "CCScene.h"
|
||||
#include "CCLayer.h"
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
#include "CCPhysicsBody.h"
|
||||
|
@ -269,9 +269,10 @@ void Node::setRotation(float rotation)
|
|||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody)
|
||||
if (_physicsBody && !_physicsBody->_rotationResetTag)
|
||||
{
|
||||
_physicsBody->setRotation(rotation);
|
||||
Layer* layer = _physicsBody->getWorld() != nullptr ? &_physicsBody->getWorld()->getLayer() : nullptr;
|
||||
updatePhysicsBodyRotation(layer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -299,7 +300,8 @@ void Node::setRotation3D(const Vertex3F& rotation)
|
|||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody)
|
||||
{
|
||||
_physicsBody->setRotation(_rotationZ_X);
|
||||
Layer* layer = _physicsBody->getWorld() != nullptr ? &_physicsBody->getWorld()->getLayer() : nullptr;
|
||||
updatePhysicsBodyRotation(layer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -428,11 +430,10 @@ void Node::setPosition(const Point& position)
|
|||
_transformUpdated = _transformDirty = _inverseDirty = true;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (_physicsBody)
|
||||
if (_physicsBody != nullptr && !_physicsBody->_positionResetTag)
|
||||
{
|
||||
Node* parent = getParent();
|
||||
Point pos = parent != nullptr ? parent->convertToWorldSpace(getPosition()) : getPosition();
|
||||
_physicsBody->setPosition(pos);
|
||||
Layer* layer = _physicsBody->getWorld() != nullptr ? &_physicsBody->getWorld()->getLayer() : nullptr;
|
||||
updatePhysicsBodyPosition(layer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -727,27 +728,24 @@ void Node::addChild(Node *child, int zOrder, int tag)
|
|||
}
|
||||
|
||||
this->insertChild(child, zOrder);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (child->getPhysicsBody() != nullptr)
|
||||
{
|
||||
child->getPhysicsBody()->setPosition(this->convertToWorldSpace(child->getPosition()));
|
||||
}
|
||||
|
||||
for (Node* node = this->getParent(); node != nullptr; node = node->getParent())
|
||||
{
|
||||
if (dynamic_cast<Scene*>(node) != nullptr)
|
||||
{
|
||||
(dynamic_cast<Scene*>(node))->addChildToPhysicsWorld(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
child->_tag = tag;
|
||||
|
||||
child->setParent(this);
|
||||
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
// Recursive add children with which have physics body.
|
||||
for (Node* node = this; node != nullptr; node = node->getParent())
|
||||
{
|
||||
Layer* layer = dynamic_cast<Layer*>(node);
|
||||
if (layer != nullptr && layer->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
layer->addChildToPhysicsWorld(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( _running )
|
||||
{
|
||||
|
@ -1587,6 +1585,43 @@ void Node::removeAllComponents()
|
|||
}
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
|
||||
void Node::updatePhysicsBodyPosition(Layer* layer)
|
||||
{
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
if (layer != nullptr && layer->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
Point pos = getParent() == layer ? getPosition() : layer->convertToNodeSpace(_parent->convertToWorldSpace(getPosition()));
|
||||
_physicsBody->setPosition(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsBody->setPosition(getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Node::updatePhysicsBodyRotation(Layer* layer)
|
||||
{
|
||||
if (_physicsBody != nullptr)
|
||||
{
|
||||
if (layer != nullptr && layer->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
float rotation = _rotationZ_X;
|
||||
for (Node* parent = _parent; parent != layer; parent = parent->getParent())
|
||||
{
|
||||
rotation += parent->getRotation();
|
||||
}
|
||||
_physicsBody->setRotation(rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
_physicsBody->setRotation(_rotationZ_X);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Node::setPhysicsBody(PhysicsBody* body)
|
||||
{
|
||||
if (body != nullptr)
|
||||
|
@ -1617,12 +1652,23 @@ void Node::setPhysicsBody(PhysicsBody* body)
|
|||
}
|
||||
|
||||
_physicsBody = body;
|
||||
|
||||
if (body != nullptr)
|
||||
{
|
||||
Node* parent = getParent();
|
||||
Point pos = parent != nullptr ? parent->convertToWorldSpace(getPosition()) : getPosition();
|
||||
_physicsBody->setPosition(pos);
|
||||
_physicsBody->setRotation(getRotation());
|
||||
Node* node;
|
||||
Layer* layer = nullptr;
|
||||
for (node = this->getParent(); node != nullptr; node = node->getParent())
|
||||
{
|
||||
Layer* tmpLayer = dynamic_cast<Layer*>(node);
|
||||
if (tmpLayer != nullptr && tmpLayer->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
layer = tmpLayer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
updatePhysicsBodyPosition(layer);
|
||||
updatePhysicsBodyRotation(layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1364,6 +1364,11 @@ protected:
|
|||
virtual void updateCascadeColor();
|
||||
virtual void disableCascadeColor();
|
||||
virtual void updateColor() {}
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
virtual void updatePhysicsBodyPosition(Layer* layer);
|
||||
virtual void updatePhysicsBodyRotation(Layer* layer);
|
||||
#endif // CC_USE_PHYSICS
|
||||
|
||||
float _rotationX; ///< rotation on the X-axis
|
||||
float _rotationY; ///< rotation on the Y-axis
|
||||
|
@ -1455,6 +1460,10 @@ protected:
|
|||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Node);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
friend class Layer;
|
||||
#endif //CC_USTPS
|
||||
};
|
||||
|
||||
// NodeRGBA
|
||||
|
|
|
@ -280,7 +280,7 @@ bool RenderTexture::initWithWidthAndHeight(int w, int h, Texture2D::PixelFormat
|
|||
setSprite(Sprite::createWithTexture(_texture));
|
||||
|
||||
_texture->release();
|
||||
_sprite->setScaleY(-1);
|
||||
_sprite->setFlippedY(true);
|
||||
|
||||
_sprite->setBlendFunc( BlendFunc::ALPHA_PREMULTIPLIED );
|
||||
|
||||
|
@ -524,7 +524,9 @@ void RenderTexture::onBegin()
|
|||
kmGLGetMatrix(KM_GL_PROJECTION, &_oldProjMatrix);
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&_projectionMatrix);
|
||||
|
||||
|
||||
|
||||
|
||||
kmGLGetMatrix(KM_GL_MODELVIEW, &_oldTransMatrix);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
kmGLLoadMatrix(&_transformMatrix);
|
||||
|
@ -533,6 +535,15 @@ void RenderTexture::onBegin()
|
|||
{
|
||||
director->setProjection(director->getProjection());
|
||||
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8
|
||||
kmMat4 modifiedProjection;
|
||||
kmGLGetMatrix(KM_GL_PROJECTION, &modifiedProjection);
|
||||
kmMat4Multiply(&modifiedProjection, CCEGLView::sharedOpenGLView()->getReverseOrientationMatrix(), &modifiedProjection);
|
||||
kmGLMatrixMode(KM_GL_PROJECTION);
|
||||
kmGLLoadMatrix(&modifiedProjection);
|
||||
kmGLMatrixMode(KM_GL_MODELVIEW);
|
||||
#endif
|
||||
|
||||
const Size& texSize = _texture->getContentSizeInPixels();
|
||||
|
||||
// Calculate the adjustment ratios based on the old and new projections
|
||||
|
|
|
@ -36,9 +36,6 @@ THE SOFTWARE.
|
|||
NS_CC_BEGIN
|
||||
|
||||
Scene::Scene()
|
||||
#if CC_USE_PHYSICS
|
||||
: _physicsWorld(nullptr)
|
||||
#endif
|
||||
{
|
||||
_ignoreAnchorPointForPosition = true;
|
||||
setAnchorPoint(Point(0.5f, 0.5f));
|
||||
|
@ -46,9 +43,6 @@ Scene::Scene()
|
|||
|
||||
Scene::~Scene()
|
||||
{
|
||||
#if CC_USE_PHYSICS
|
||||
CC_SAFE_DELETE(_physicsWorld);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Scene::init()
|
||||
|
@ -90,75 +84,4 @@ Scene* Scene::getScene()
|
|||
return this;
|
||||
}
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
void Scene::addChild(Node* child, int zOrder, int tag)
|
||||
{
|
||||
Node::addChild(child, zOrder, tag);
|
||||
addChildToPhysicsWorld(child);
|
||||
}
|
||||
|
||||
void Scene::update(float delta)
|
||||
{
|
||||
Node::update(delta);
|
||||
if (nullptr != _physicsWorld)
|
||||
{
|
||||
_physicsWorld->update(delta);
|
||||
}
|
||||
}
|
||||
|
||||
Scene *Scene::createWithPhysics()
|
||||
{
|
||||
Scene *ret = new Scene();
|
||||
if (ret && ret->initWithPhysics())
|
||||
{
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Scene::initWithPhysics()
|
||||
{
|
||||
bool ret = false;
|
||||
do
|
||||
{
|
||||
Director * director;
|
||||
CC_BREAK_IF( ! (director = Director::getInstance()) );
|
||||
this->setContentSize(director->getWinSize());
|
||||
CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::construct(*this)));
|
||||
|
||||
this->scheduleUpdate();
|
||||
// success
|
||||
ret = true;
|
||||
} while (0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Scene::addChildToPhysicsWorld(Node* child)
|
||||
{
|
||||
if (_physicsWorld)
|
||||
{
|
||||
std::function<void(Node*)> addToPhysicsWorldFunc = nullptr;
|
||||
addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void
|
||||
{
|
||||
if (node->getPhysicsBody())
|
||||
{
|
||||
_physicsWorld->addBody(node->getPhysicsBody());
|
||||
}
|
||||
|
||||
auto& children = node->getChildren();
|
||||
for( const auto &n : children) {
|
||||
addToPhysicsWorldFunc(n);
|
||||
}
|
||||
};
|
||||
|
||||
addToPhysicsWorldFunc(child);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -67,28 +67,10 @@ CC_CONSTRUCTOR_ACCESS:
|
|||
virtual bool init() override;
|
||||
|
||||
protected:
|
||||
friend class Node;
|
||||
friend class ProtectedNode;
|
||||
friend class SpriteBatchNode;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Scene);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
public:
|
||||
virtual void addChild(Node* child, int zOrder, int tag) override;
|
||||
virtual void update(float delta) override;
|
||||
inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; }
|
||||
static Scene *createWithPhysics();
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
bool initWithPhysics();
|
||||
|
||||
protected:
|
||||
void addChildToPhysicsWorld(Node* child);
|
||||
|
||||
PhysicsWorld* _physicsWorld;
|
||||
#endif // CC_USE_PHYSICS
|
||||
};
|
||||
|
||||
// end of scene group
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "3.0-rc2";
|
||||
return "cocos2d-x 3.0";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -264,20 +264,22 @@
|
|||
<ClCompile Include="..\..\external\unzip\unzip.cpp" />
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\CCAffineTransform.cpp" />
|
||||
<ClCompile Include="..\base\CCArray.cpp" />
|
||||
<ClCompile Include="..\base\CCAutoreleasePool.cpp" />
|
||||
<ClCompile Include="..\base\CCConsole.cpp" />
|
||||
<ClCompile Include="..\base\CCData.cpp" />
|
||||
<ClCompile Include="..\base\CCDataVisitor.cpp" />
|
||||
<ClCompile Include="..\base\CCDictionary.cpp" />
|
||||
<ClCompile Include="..\base\CCGeometry.cpp" />
|
||||
<ClCompile Include="..\base\CCNS.cpp" />
|
||||
<ClCompile Include="..\base\CCRef.cpp" />
|
||||
<ClCompile Include="..\base\CCSet.cpp" />
|
||||
<ClCompile Include="..\base\CCString.cpp" />
|
||||
<ClCompile Include="..\base\CCValue.cpp" />
|
||||
<ClCompile Include="..\base\etc1.cpp" />
|
||||
<ClCompile Include="..\base\s3tc.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCArray.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCDeprecated.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCDictionary.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCSet.cpp" />
|
||||
<ClCompile Include="..\deprecated\CCString.cpp" />
|
||||
<ClCompile Include="..\math\kazmath\kazmath\aabb.c">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
|
||||
|
@ -500,7 +502,6 @@
|
|||
<ClCompile Include="CCComponent.cpp" />
|
||||
<ClCompile Include="CCComponentContainer.cpp" />
|
||||
<ClCompile Include="CCConfiguration.cpp" />
|
||||
<ClCompile Include="CCDeprecated.cpp" />
|
||||
<ClCompile Include="CCDirector.cpp" />
|
||||
<ClCompile Include="CCDrawingPrimitives.cpp" />
|
||||
<ClCompile Include="CCDrawNode.cpp" />
|
||||
|
@ -547,7 +548,6 @@
|
|||
<ClCompile Include="CCMenuItem.cpp" />
|
||||
<ClCompile Include="CCMotionStreak.cpp" />
|
||||
<ClCompile Include="CCNode.cpp" />
|
||||
<ClCompile Include="CCNotificationCenter.cpp" />
|
||||
<ClCompile Include="CCParallaxNode.cpp" />
|
||||
<ClCompile Include="CCParticleBatchNode.cpp" />
|
||||
<ClCompile Include="CCParticleExamples.cpp" />
|
||||
|
@ -622,28 +622,30 @@
|
|||
<ClInclude Include="..\..\external\unzip\unzip.h" />
|
||||
<ClInclude Include="..\base\atitc.h" />
|
||||
<ClInclude Include="..\base\CCAffineTransform.h" />
|
||||
<ClInclude Include="..\base\CCArray.h" />
|
||||
<ClInclude Include="..\base\CCAutoreleasePool.h" />
|
||||
<ClInclude Include="..\base\CCBool.h" />
|
||||
<ClInclude Include="..\base\CCConsole.h" />
|
||||
<ClInclude Include="..\base\CCData.h" />
|
||||
<ClInclude Include="..\base\CCDataVisitor.h" />
|
||||
<ClInclude Include="..\base\CCDictionary.h" />
|
||||
<ClInclude Include="..\base\CCDouble.h" />
|
||||
<ClInclude Include="..\base\CCFloat.h" />
|
||||
<ClInclude Include="..\base\CCGeometry.h" />
|
||||
<ClInclude Include="..\base\CCInteger.h" />
|
||||
<ClInclude Include="..\base\CCMap.h" />
|
||||
<ClInclude Include="..\base\CCNS.h" />
|
||||
<ClInclude Include="..\base\CCRef.h" />
|
||||
<ClInclude Include="..\base\CCPlatformConfig.h" />
|
||||
<ClInclude Include="..\base\CCPlatformMacros.h" />
|
||||
<ClInclude Include="..\base\CCSet.h" />
|
||||
<ClInclude Include="..\base\CCString.h" />
|
||||
<ClInclude Include="..\base\CCValue.h" />
|
||||
<ClInclude Include="..\base\CCVector.h" />
|
||||
<ClInclude Include="..\base\etc1.h" />
|
||||
<ClInclude Include="..\base\s3tc.h" />
|
||||
<ClInclude Include="..\deprecated\CCArray.h" />
|
||||
<ClInclude Include="..\deprecated\CCBool.h" />
|
||||
<ClInclude Include="..\deprecated\CCDeprecated.h" />
|
||||
<ClInclude Include="..\deprecated\CCDictionary.h" />
|
||||
<ClInclude Include="..\deprecated\CCDouble.h" />
|
||||
<ClInclude Include="..\deprecated\CCFloat.h" />
|
||||
<ClInclude Include="..\deprecated\CCInteger.h" />
|
||||
<ClInclude Include="..\deprecated\CCNotificationCenter.h" />
|
||||
<ClInclude Include="..\deprecated\CCSet.h" />
|
||||
<ClInclude Include="..\deprecated\CCString.h" />
|
||||
<ClInclude Include="..\math\kazmath\kazmath\aabb.h" />
|
||||
<ClInclude Include="..\math\kazmath\kazmath\GL\mat4stack.h" />
|
||||
<ClInclude Include="..\math\kazmath\kazmath\GL\matrix.h" />
|
||||
|
@ -736,7 +738,6 @@
|
|||
<ClInclude Include="CCMenuItem.h" />
|
||||
<ClInclude Include="CCMotionStreak.h" />
|
||||
<ClInclude Include="CCNode.h" />
|
||||
<ClInclude Include="CCNotificationCenter.h" />
|
||||
<ClInclude Include="CCParallaxNode.h" />
|
||||
<ClInclude Include="CCParticleBatchNode.h" />
|
||||
<ClInclude Include="CCParticleExamples.h" />
|
||||
|
|
|
@ -109,6 +109,9 @@
|
|||
<Filter Include="kazmath\include\GL">
|
||||
<UniqueIdentifier>{7c71abeb-8b4b-4be8-a23c-e32fedc65fc9}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="deprecated">
|
||||
<UniqueIdentifier>{6e394a3e-2c57-4988-bc51-bea18e491559}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
|
||||
|
@ -388,7 +391,6 @@
|
|||
<Filter>tilemap_parallax_nodes</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCConfiguration.cpp" />
|
||||
<ClCompile Include="CCDeprecated.cpp" />
|
||||
<ClCompile Include="CCDirector.cpp" />
|
||||
<ClCompile Include="ccFPSImages.c" />
|
||||
<ClCompile Include="CCScheduler.cpp" />
|
||||
|
@ -397,9 +399,6 @@
|
|||
<ClCompile Include="base64.cpp">
|
||||
<Filter>support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCNotificationCenter.cpp">
|
||||
<Filter>support</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCProfiling.cpp">
|
||||
<Filter>support</Filter>
|
||||
</ClCompile>
|
||||
|
@ -442,9 +441,6 @@
|
|||
<ClCompile Include="..\base\CCAffineTransform.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCArray.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCAutoreleasePool.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
@ -454,9 +450,6 @@
|
|||
<ClCompile Include="..\base\CCDataVisitor.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCDictionary.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCGeometry.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
|
@ -466,12 +459,6 @@
|
|||
<ClCompile Include="..\base\CCRef.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCSet.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\CCString.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ccUtils.cpp">
|
||||
<Filter>support</Filter>
|
||||
</ClCompile>
|
||||
|
@ -614,6 +601,24 @@
|
|||
<ClCompile Include="..\math\kazmath\kazmath\ray3.c">
|
||||
<Filter>kazmath\src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCArray.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCDeprecated.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCDictionary.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCNotificationCenter.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCSet.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deprecated\CCString.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -989,9 +994,6 @@
|
|||
<ClInclude Include="base64.h">
|
||||
<Filter>support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCNotificationCenter.h">
|
||||
<Filter>support</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCProfiling.h">
|
||||
<Filter>support</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1043,48 +1045,24 @@
|
|||
<ClInclude Include="..\base\CCAffineTransform.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCArray.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCAutoreleasePool.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCBool.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCData.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCDataVisitor.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCDictionary.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCDouble.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCFloat.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCGeometry.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCInteger.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCNS.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCRef.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCSet.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\base\CCString.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCEventListenerMouse.h">
|
||||
<Filter>event_dispatcher</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1240,5 +1218,35 @@
|
|||
<ClInclude Include="..\math\kazmath\kazmath\ray3.h">
|
||||
<Filter>kazmath\src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCArray.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCBool.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCDeprecated.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCDictionary.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCDouble.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCFloat.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCInteger.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCNotificationCenter.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCSet.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\deprecated\CCString.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -7,7 +7,7 @@
|
|||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)cocos;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)cocos;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\xxhash;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\curl\include\wp8;$(EngineRoot)external\curl\include\wp8\curl;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WP8;_LIB;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -93,7 +93,7 @@
|
|||
</Link>
|
||||
<Lib>
|
||||
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(EngineRoot)external\wp8-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\png\prebuilt\wp8\$(Platform);$(EngineRoot)external\jpeg\prebuilt\wp8\$(Platform);$(EngineRoot)external\tiff\prebuilt\wp8\$(Platform);$(EngineRoot)external\freetype2\prebuilt\wp8\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\curl\include\wp8;$(EngineRoot)external\curl\include\wp8\curl;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WP8;_LIB;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -118,17 +118,17 @@
|
|||
</Link>
|
||||
<Lib>
|
||||
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(EngineRoot)external\wp8-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\png\prebuilt\wp8\$(Platform);$(EngineRoot)external\jpeg\prebuilt\wp8\$(Platform);$(EngineRoot)external\tiff\prebuilt\wp8\$(Platform);$(EngineRoot)external\freetype2\prebuilt\wp8\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\curl\include\wp8;$(EngineRoot)external\curl\include\wp8\curl;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WP8;_LIB;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
|
@ -144,21 +144,20 @@
|
|||
</Link>
|
||||
<Lib>
|
||||
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(EngineRoot)external\wp8-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\png\prebuilt\wp8\$(Platform);$(EngineRoot)external\jpeg\prebuilt\wp8\$(Platform);$(EngineRoot)external\tiff\prebuilt\wp8\$(Platform);$(EngineRoot)external\freetype2\prebuilt\wp8\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_LIB;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)external\sqlite3\include;$(EngineRoot)external\unzip;$(EngineRoot)external\edtaa3func;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\png\include\wp8;$(EngineRoot)external\jpeg\include\wp8;$(EngineRoot)external\curl\include\wp8;$(EngineRoot)external\curl\include\wp8\curl;$(EngineRoot)external\tiff\include\wp8;$(EngineRoot)external\freetype2\include\wp8;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\xxhash;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WP8;_LIB;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
|
||||
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
|
||||
<CompileAs>CompileAsCpp</CompileAs>
|
||||
</ClCompile>
|
||||
|
@ -171,7 +170,7 @@
|
|||
</Link>
|
||||
<Lib>
|
||||
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>zlib.lib;libpng.lib;libjpeg.lib;libtiff.lib;freetype.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(EngineRoot)external\wp8-specific\zlib\prebuilt\$(Platform);$(EngineRoot)external\png\prebuilt\wp8\$(Platform);$(EngineRoot)external\jpeg\prebuilt\wp8\$(Platform);$(EngineRoot)external\tiff\prebuilt\wp8\$(Platform);$(EngineRoot)external\freetype2\prebuilt\wp8\$(Platform);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
|
@ -207,6 +206,8 @@
|
|||
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
|
||||
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</ForcedIncludeFiles>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\base\atitc.cpp" />
|
||||
<ClCompile Include="..\base\CCAffineTransform.cpp" />
|
||||
|
@ -668,11 +669,32 @@
|
|||
<ClCompile Include="platform\winrt\CCPrecompiledShaders.cpp" />
|
||||
<ClCompile Include="platform\winrt\CCStdC.cpp" />
|
||||
<ClCompile Include="platform\winrt\CCWinRTUtils.cpp" />
|
||||
<ClCompile Include="platform\winrt\inet_ntop_winrt.cpp">
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
|
||||
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">pch.h</ForcedIncludeFiles>
|
||||
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Cdecl</CallingConvention>
|
||||
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Cdecl</CallingConvention>
|
||||
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Cdecl</CallingConvention>
|
||||
<CallingConvention Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Cdecl</CallingConvention>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
|
||||
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">pch.h</ForcedIncludeFiles>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\winrt\InputEvent.cpp" />
|
||||
<ClCompile Include="platform\winrt\pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</MultiProcessorCompilation>
|
||||
<MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</MultiProcessorCompilation>
|
||||
<MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</MultiProcessorCompilation>
|
||||
<MultiProcessorCompilation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\winrt\sha1.cpp" />
|
||||
<ClCompile Include="platform\wp8\CCGLView.cpp" />
|
||||
|
@ -685,7 +707,6 @@
|
|||
<ClCompile Include="renderer\CCQuadCommand.cpp" />
|
||||
<ClCompile Include="renderer\CCRenderCommand.cpp" />
|
||||
<ClCompile Include="renderer\CCRenderer.cpp" />
|
||||
<ClCompile Include="renderer\CCRenderMaterial.cpp" />
|
||||
<ClCompile Include="TGAlib.cpp" />
|
||||
<ClCompile Include="TransformUtils.cpp" />
|
||||
<ClCompile Include="ZipUtils.cpp" />
|
||||
|
@ -826,23 +847,7 @@
|
|||
<ClInclude Include="CCScheduler.h" />
|
||||
<ClInclude Include="CCScriptSupport.h" />
|
||||
<ClInclude Include="CCShaderCache.h" />
|
||||
<ClInclude Include="ccShaderEx_SwitchMask_frag.h" />
|
||||
<ClInclude Include="ccShaders.h" />
|
||||
<ClInclude Include="ccShader_PositionColorLengthTexture_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionColorLengthTexture_vert.h" />
|
||||
<ClInclude Include="ccShader_PositionColor_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionColor_vert.h" />
|
||||
<ClInclude Include="ccShader_PositionTextureA8Color_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionTextureA8Color_vert.h" />
|
||||
<ClInclude Include="ccShader_PositionTextureColorAlphaTest_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionTextureColor_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionTextureColor_vert.h" />
|
||||
<ClInclude Include="ccShader_PositionTexture_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionTexture_uColor_frag.h" />
|
||||
<ClInclude Include="ccShader_PositionTexture_uColor_vert.h" />
|
||||
<ClInclude Include="ccShader_PositionTexture_vert.h" />
|
||||
<ClInclude Include="ccShader_Position_uColor_frag.h" />
|
||||
<ClInclude Include="ccShader_Position_uColor_vert.h" />
|
||||
<ClInclude Include="CCSprite.h" />
|
||||
<ClInclude Include="CCSpriteBatchNode.h" />
|
||||
<ClInclude Include="CCSpriteFrame.h" />
|
||||
|
@ -884,6 +889,9 @@
|
|||
<ClInclude Include="platform\winrt\CCPrecompiledShaders.h" />
|
||||
<ClInclude Include="platform\winrt\CCStdC.h" />
|
||||
<ClInclude Include="platform\winrt\CCWinRTUtils.h" />
|
||||
<ClInclude Include="platform\winrt\inet_ntop_winrt.h" />
|
||||
<ClInclude Include="platform\winrt\InputEvent.h" />
|
||||
<ClInclude Include="platform\winrt\InputEventTypes.h" />
|
||||
<ClInclude Include="platform\winrt\pch.h" />
|
||||
<ClInclude Include="platform\winrt\sha1.h" />
|
||||
<ClInclude Include="platform\wp8\CCGLView.h" />
|
||||
|
|
|
@ -501,9 +501,6 @@
|
|||
<ClCompile Include="renderer\CCRenderer.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\CCRenderMaterial.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="renderer\CCBatchCommand.cpp">
|
||||
<Filter>renderer</Filter>
|
||||
</ClCompile>
|
||||
|
@ -616,6 +613,12 @@
|
|||
<ClCompile Include="..\deprecated\CCString.cpp">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\winrt\InputEvent.cpp">
|
||||
<Filter>platform\winrt</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="platform\winrt\inet_ntop_winrt.cpp">
|
||||
<Filter>platform\winrt</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -861,51 +864,6 @@
|
|||
<ClInclude Include="..\base\s3tc.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_Position_uColor_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_Position_uColor_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionColor_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionColor_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionColorLengthTexture_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionColorLengthTexture_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTexture_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTexture_uColor_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTexture_uColor_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTexture_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTextureA8Color_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTextureA8Color_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTextureColor_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTextureColor_vert.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShader_PositionTextureColorAlphaTest_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCGLProgram.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
|
@ -915,9 +873,6 @@
|
|||
<ClInclude Include="CCShaderCache.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShaderEx_SwitchMask_frag.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ccShaders.h">
|
||||
<Filter>shaders</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1244,5 +1199,14 @@
|
|||
<ClInclude Include="..\deprecated\CCString.h">
|
||||
<Filter>deprecated</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\winrt\InputEvent.h">
|
||||
<Filter>platform\winrt</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\winrt\InputEventTypes.h">
|
||||
<Filter>platform\winrt</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="platform\winrt\inet_ntop_winrt.h">
|
||||
<Filter>platform\winrt</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -7,13 +7,13 @@
|
|||
<PropertyGroup />
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d\platform\wp8;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\ui;$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\deprecated;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>$(EngineRoot)cocos\2d\platform\wp8;$(EngineRoot)cocos\2d\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\math\kazmath;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\ui;$(EngineRoot)cocos;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\deprecated;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CompileAsWinRT>true</CompileAsWinRT>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4056;</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>4056;4996;</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/IGNORE:4264 %(AdditionalOptions)</AdditionalOptions>
|
||||
|
|
|
@ -942,7 +942,14 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
|
||||
_dataLen = rowbytes * _height;
|
||||
_data = static_cast<unsigned char*>(malloc(_dataLen * sizeof(unsigned char)));
|
||||
CC_BREAK_IF(!_data);
|
||||
if(!_data)
|
||||
{
|
||||
if (row_pointers != nullptr)
|
||||
{
|
||||
free(row_pointers);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned short i = 0; i < _height; ++i)
|
||||
{
|
||||
|
@ -957,7 +964,7 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
|
|||
if (row_pointers != nullptr)
|
||||
{
|
||||
free(row_pointers);
|
||||
};
|
||||
}
|
||||
|
||||
bRet = true;
|
||||
} while (0);
|
||||
|
@ -2028,6 +2035,9 @@ bool Image::saveImageToPNG(const std::string& filePath, bool isToRGB)
|
|||
{
|
||||
fclose(fp);
|
||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||
|
||||
free(row_pointers);
|
||||
row_pointers = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,7 @@ bool cocos2d::Image::saveToFile(const std::string& filename, bool isToRGB)
|
|||
|
||||
// The data has alpha channel, and want to save it with an RGB png file,
|
||||
// or want to save as jpg, remove the alpha channel.
|
||||
if ((saveToPNG && hasAlpha() && isToRGB)
|
||||
|| (! saveToPNG))
|
||||
if (hasAlpha() && bitsPerPixel == 24)
|
||||
{
|
||||
pixels = new unsigned char[myDataLength];
|
||||
|
||||
|
|
|
@ -46,20 +46,37 @@ int Device::getDPI()
|
|||
return floor(DisplayProperties::LogicalDpi / dipsPerInch + 0.5f); // Round to nearest integer.
|
||||
}
|
||||
|
||||
static Accelerometer^ sAccelerometer = nullptr;
|
||||
|
||||
|
||||
void Device::setAccelerometerEnabled(bool isEnabled)
|
||||
{
|
||||
static Windows::Foundation::EventRegistrationToken sToken;
|
||||
static bool sEnabled = false;
|
||||
|
||||
auto accelerometer = Accelerometer::GetDefault();
|
||||
if (isEnabled && accelerometer)
|
||||
if (isEnabled)
|
||||
{
|
||||
setAccelerometerInterval(0.0f);
|
||||
sAccelerometer = Accelerometer::GetDefault();
|
||||
|
||||
sToken = accelerometer->ReadingChanged += ref new TypedEventHandler
|
||||
if(sAccelerometer == nullptr)
|
||||
{
|
||||
MessageBox("This device does not have an accelerometer.","Alert");
|
||||
return;
|
||||
}
|
||||
|
||||
setAccelerometerInterval(0.0f);
|
||||
sEnabled = true;
|
||||
|
||||
sToken = sAccelerometer->ReadingChanged += ref new TypedEventHandler
|
||||
<Accelerometer^,AccelerometerReadingChangedEventArgs^>
|
||||
([=](Accelerometer^, AccelerometerReadingChangedEventArgs^)
|
||||
([](Accelerometer^ a, AccelerometerReadingChangedEventArgs^ e)
|
||||
{
|
||||
AccelerometerReading^ reading = accelerometer->GetCurrentReading();
|
||||
if (!sEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AccelerometerReading^ reading = e->Reading;
|
||||
cocos2d::Acceleration acc;
|
||||
acc.x = reading->AccelerationX;
|
||||
acc.y = reading->AccelerationY;
|
||||
|
@ -97,26 +114,34 @@ void Device::setAccelerometerEnabled(bool isEnabled)
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
cocos2d::EventAcceleration accEvent(acc);
|
||||
auto dispatcher = cocos2d::Director::getInstance()->getEventDispatcher();
|
||||
dispatcher->dispatchEvent(&accEvent);
|
||||
std::shared_ptr<cocos2d::InputEvent> event(new AccelerometerEvent(acc));
|
||||
cocos2d::GLView::sharedOpenGLView()->QueueEvent(event);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
accelerometer->ReadingChanged -= sToken;
|
||||
if (sAccelerometer)
|
||||
{
|
||||
sAccelerometer->ReadingChanged -= sToken;
|
||||
sAccelerometer = nullptr;
|
||||
}
|
||||
|
||||
sEnabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Device::setAccelerometerInterval(float interval)
|
||||
{
|
||||
auto a = Accelerometer::GetDefault();
|
||||
if(a)
|
||||
if (sAccelerometer)
|
||||
{
|
||||
int minInterval = a->MinimumReportInterval;
|
||||
int minInterval = sAccelerometer->MinimumReportInterval;
|
||||
int reqInterval = (int) interval;
|
||||
a->ReportInterval = reqInterval < minInterval ? minInterval : reqInterval;
|
||||
sAccelerometer->ReportInterval = reqInterval < minInterval ? minInterval : reqInterval;
|
||||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Device::setAccelerometerInterval: accelerometer not enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -580,9 +580,9 @@ unsigned char* CCFreeTypeFont::loadFont(const char *pFontName, ssize_t *size)
|
|||
lowerCase[i] = tolower(lowerCase[i]);
|
||||
}
|
||||
|
||||
if (std::string::npos == lowerCase.find("fonts\\"))
|
||||
if (std::string::npos == lowerCase.find("fonts/"))
|
||||
{
|
||||
path = "fonts\\";
|
||||
path = "fonts/";
|
||||
path += pFontName;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCGLView.h"
|
||||
#include "CCSet.h"
|
||||
#include "ccMacros.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCTouch.h"
|
||||
|
@ -516,4 +515,10 @@ void GLView::UpdateForWindowSizeChange()
|
|||
}
|
||||
}
|
||||
|
||||
void GLView::QueueEvent(std::shared_ptr<InputEvent>& event)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
mInputEvents.push(event);
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
|||
#include "CCStdC.h"
|
||||
#include "CCGL.h"
|
||||
#include "platform/CCCommon.h"
|
||||
#include "InputEvent.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "platform/CCGLViewProtocol.h"
|
||||
#include <agile.h>
|
||||
|
@ -37,7 +38,8 @@ THE SOFTWARE.
|
|||
|
||||
#include <agile.h>
|
||||
#include <DirectXMath.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -110,6 +112,7 @@ public:
|
|||
void UpdateForWindowSizeChange();
|
||||
void OnRendering();
|
||||
void OnSuspending();
|
||||
void GLView::QueueEvent(std::shared_ptr<InputEvent>& event);
|
||||
|
||||
private:
|
||||
Windows::Foundation::EventRegistrationToken m_eventToken;
|
||||
|
@ -148,6 +151,9 @@ private:
|
|||
float m_fFrameZoomFactor;
|
||||
WinRTWindow^ m_winRTWindow;
|
||||
Windows::Foundation::Rect m_keyboardRect;
|
||||
|
||||
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
||||
std::mutex mMutex;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
#include <wrl/client.h>
|
||||
#include <ppl.h>
|
||||
#include <ppltasks.h>
|
||||
#include <sstream>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -40,6 +41,7 @@ using namespace Platform;
|
|||
using namespace Windows::Storage;
|
||||
using namespace Windows::Storage::Pickers;
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Windows::Networking::Connectivity;
|
||||
|
||||
std::wstring CCUtf8ToUnicode(const char * pszUtf8Str, unsigned len/* = -1*/)
|
||||
{
|
||||
|
@ -105,6 +107,48 @@ float getScaledDPIValue(float v) {
|
|||
return v * dipFactor;
|
||||
}
|
||||
|
||||
void CC_DLL CCLogIPAddresses()
|
||||
{
|
||||
auto hostnames = NetworkInformation::GetHostNames();
|
||||
int length = hostnames->Size;
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
auto hn = hostnames->GetAt(i);
|
||||
if (hn->IPInformation != nullptr)
|
||||
{
|
||||
std::string s = PlatformStringToString(hn->DisplayName);
|
||||
CCLog("IP Address: %s:", s.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string CC_DLL getDeviceIPAddresses()
|
||||
{
|
||||
std::stringstream result;
|
||||
|
||||
auto hostnames = NetworkInformation::GetHostNames();
|
||||
int length = hostnames->Size;
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
auto hn = hostnames->GetAt(i);
|
||||
if (hn->IPInformation != nullptr)
|
||||
{
|
||||
result << PlatformStringToString(hn->DisplayName) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
|
||||
// Function that reads from a binary file asynchronously.
|
||||
|
|
|
@ -27,7 +27,6 @@ THE SOFTWARE.
|
|||
#define __CCWINRT_UTILS_H__
|
||||
|
||||
#include "CCPlatformMacros.h"
|
||||
#include "CCDictionary.h"
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <ppl.h>
|
||||
|
@ -49,6 +48,10 @@ float getScaledDPIValue(float v);
|
|||
|
||||
Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ path);
|
||||
|
||||
void CC_DLL CCLogIPAddresses();
|
||||
|
||||
std::string CC_DLL getDeviceIPAddresses();
|
||||
|
||||
|
||||
NS_CC_END
|
||||
|
||||
|
|
|
@ -24,29 +24,46 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "InputEvent.h"
|
||||
#include "Cocos2dRenderer.h"
|
||||
#include "CCGLView.h"
|
||||
#include "CCEventAcceleration.h"
|
||||
|
||||
namespace PhoneDirect3DXamlAppComponent
|
||||
NS_CC_BEGIN
|
||||
|
||||
using namespace PhoneDirect3DXamlAppComponent;
|
||||
|
||||
|
||||
AccelerometerEvent::AccelerometerEvent(const Acceleration& event)
|
||||
: m_event(event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AccelerometerEvent::execute()
|
||||
{
|
||||
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
||||
cocos2d::EventAcceleration accEvent(m_event);
|
||||
dispatcher->dispatchEvent(&accEvent);
|
||||
}
|
||||
|
||||
|
||||
PointerEvent::PointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args)
|
||||
: m_type(type), m_args(args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PointerEvent::execute(Cocos2dRenderer ^ renderer)
|
||||
void PointerEvent::execute()
|
||||
{
|
||||
switch(m_type)
|
||||
{
|
||||
case PointerEventType::PointerPressed:
|
||||
renderer->OnPointerPressed(m_args.Get());
|
||||
GLView::sharedOpenGLView()->OnPointerPressed(m_args.Get());
|
||||
break;
|
||||
case PointerEventType::PointerMoved:
|
||||
renderer->OnPointerMoved(m_args.Get());
|
||||
GLView::sharedOpenGLView()->OnPointerMoved(m_args.Get());
|
||||
break;
|
||||
case PointerEventType::PointerReleased:
|
||||
renderer->OnPointerReleased(m_args.Get());
|
||||
GLView::sharedOpenGLView()->OnPointerReleased(m_args.Get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -63,16 +80,34 @@ KeyboardEvent::KeyboardEvent(Cocos2dKeyEvent type, Platform::String^ text)
|
|||
|
||||
}
|
||||
|
||||
void KeyboardEvent::execute(Cocos2dRenderer ^ renderer)
|
||||
void KeyboardEvent::execute()
|
||||
{
|
||||
switch(m_type)
|
||||
{
|
||||
case Cocos2dKeyEvent::Text:
|
||||
renderer->OnKeyPressed(m_text.Get());
|
||||
{
|
||||
char szUtf8[8] = { 0 };
|
||||
int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR) m_text.Get()->Data(), 1, szUtf8, sizeof(szUtf8), NULL, NULL);
|
||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
renderer->OnCocos2dKeyEvent(m_type);
|
||||
break;
|
||||
switch (m_type)
|
||||
{
|
||||
case Cocos2dKeyEvent::Escape:
|
||||
//Director::getInstance()()->getKeypadDispatcher()->dispatchKeypadMSG(kTypeBackClicked);
|
||||
break;
|
||||
case Cocos2dKeyEvent::Back:
|
||||
IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
|
||||
break;
|
||||
case Cocos2dKeyEvent::Enter:
|
||||
//SetFocus(false);
|
||||
IMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,11 +117,12 @@ BackButtonEvent::BackButtonEvent()
|
|||
|
||||
}
|
||||
|
||||
void BackButtonEvent::execute(Cocos2dRenderer ^ renderer)
|
||||
void BackButtonEvent::execute()
|
||||
{
|
||||
renderer->OnBackKeyPress();
|
||||
GLView::sharedOpenGLView()->OnBackKeyPress();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
|
|
@ -26,21 +26,19 @@ THE SOFTWARE.
|
|||
#ifndef __INPUT_EVENT__
|
||||
#define __INPUT_EVENT__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "InputEventTypes.h"
|
||||
#include <agile.h>
|
||||
|
||||
ref class Cocos2dRenderer;
|
||||
|
||||
namespace PhoneDirect3DXamlAppComponent
|
||||
{
|
||||
public delegate void Cocos2dEventDelegate(Cocos2dEvent event);
|
||||
public delegate void Cocos2dMessageBoxDelegate(Platform::String^ title, Platform::String^ text);
|
||||
public delegate void Cocos2dEditBoxDelegate(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
|
||||
}
|
||||
|
||||
public delegate void Cocos2dEventDelegate(Cocos2dEvent event);
|
||||
|
||||
public delegate void Cocos2dMessageBoxDelegate(Platform::String^ title, Platform::String^ text);
|
||||
|
||||
public delegate void Cocos2dEditBoxDelegate(Platform::String^ strPlaceHolder, Platform::String^ strText, int maxLength, int inputMode, int inputFlag, Windows::Foundation::EventHandler<Platform::String^>^ receiveHandler);
|
||||
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
enum PointerEventType
|
||||
{
|
||||
|
@ -54,14 +52,25 @@ class InputEvent
|
|||
public:
|
||||
InputEvent() {};
|
||||
virtual ~InputEvent() {};
|
||||
virtual void execute(Cocos2dRenderer^ renderer) = 0;
|
||||
virtual void execute() = 0;
|
||||
};
|
||||
|
||||
|
||||
class AccelerometerEvent : public InputEvent
|
||||
{
|
||||
public:
|
||||
AccelerometerEvent(const cocos2d::Acceleration& event);
|
||||
virtual void execute();
|
||||
|
||||
private:
|
||||
cocos2d::Acceleration m_event;
|
||||
};
|
||||
|
||||
class PointerEvent : public InputEvent
|
||||
{
|
||||
public:
|
||||
PointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
|
||||
virtual void execute(Cocos2dRenderer ^ renderer);
|
||||
virtual void execute();
|
||||
|
||||
|
||||
private:
|
||||
|
@ -73,12 +82,12 @@ class KeyboardEvent : public InputEvent
|
|||
|
||||
{
|
||||
public:
|
||||
KeyboardEvent(Cocos2dKeyEvent type);
|
||||
KeyboardEvent(Cocos2dKeyEvent type, Platform::String^ text);
|
||||
virtual void execute(Cocos2dRenderer ^ renderer);
|
||||
KeyboardEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent type);
|
||||
KeyboardEvent(PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent type, Platform::String^ text);
|
||||
virtual void execute();
|
||||
|
||||
private:
|
||||
Cocos2dKeyEvent m_type;
|
||||
PhoneDirect3DXamlAppComponent::Cocos2dKeyEvent m_type;
|
||||
Platform::Agile<Platform::String> m_text;
|
||||
};
|
||||
|
||||
|
@ -86,11 +95,10 @@ class BackButtonEvent : public InputEvent
|
|||
{
|
||||
public:
|
||||
BackButtonEvent();
|
||||
virtual void execute(Cocos2dRenderer ^ renderer);
|
||||
virtual void execute();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
#endif // #ifndef __INPUT_EVENT__
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* Copyright (C) 1996-2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
* Original code by Paul Vixie. "curlified" by Gisle Vanem.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) Microsoft Open Technologies, Inc. */
|
||||
|
||||
/*modifications by Microsoft Open Technologies, Inc. to implement missing inet_ntop() from Windows Phone 8 SDK */
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if defined(_DEBUG)
|
||||
#define DEBUGASSERT(x) assert(x)
|
||||
#else
|
||||
#define DEBUGASSERT(x)
|
||||
#endif
|
||||
|
||||
#define ERRNO ((int)GetLastError())
|
||||
#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
|
||||
|
||||
|
||||
#define ENABLE_IPV6
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define _MPRINTF_REPLACE /* use our functions only */
|
||||
#include <curl/mprintf.h>
|
||||
#endif // 0
|
||||
|
||||
|
||||
//#include "inet_ntop.h"
|
||||
|
||||
#define IN6ADDRSZ 16
|
||||
#define INADDRSZ 4
|
||||
#define INT16SZ 2
|
||||
|
||||
/*
|
||||
* Format an IPv4 address, more or less like inet_ntoa().
|
||||
*
|
||||
* Returns `dst' (as a const)
|
||||
* Note:
|
||||
* - uses no statics
|
||||
* - takes a unsigned char* not an in_addr as input
|
||||
*/
|
||||
static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
|
||||
{
|
||||
char tmp[sizeof "255.255.255.255"];
|
||||
size_t len;
|
||||
|
||||
DEBUGASSERT(size >= 16);
|
||||
|
||||
tmp[0] = '\0';
|
||||
(void)snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
|
||||
((int)((unsigned char)src[0])) & 0xff,
|
||||
((int)((unsigned char)src[1])) & 0xff,
|
||||
((int)((unsigned char)src[2])) & 0xff,
|
||||
((int)((unsigned char)src[3])) & 0xff);
|
||||
|
||||
len = strlen(tmp);
|
||||
if(len == 0 || len >= size) {
|
||||
SET_ERRNO(ENOSPC);
|
||||
return (NULL);
|
||||
}
|
||||
strcpy(dst, tmp);
|
||||
return dst;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
/*
|
||||
* Convert IPv6 binary address into presentation (printable) format.
|
||||
*/
|
||||
static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
char *tp;
|
||||
struct {
|
||||
long base;
|
||||
long len;
|
||||
} best, cur;
|
||||
unsigned long words[IN6ADDRSZ / INT16SZ];
|
||||
int i;
|
||||
|
||||
/* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof(words));
|
||||
for(i = 0; i < IN6ADDRSZ; i++)
|
||||
words[i/2] |= (src[i] << ((1 - (i % 2)) << 3));
|
||||
|
||||
best.base = -1;
|
||||
cur.base = -1;
|
||||
best.len = 0;
|
||||
cur.len = 0;
|
||||
|
||||
for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
|
||||
if(words[i] == 0) {
|
||||
if(cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
}
|
||||
else if(cur.base != -1) {
|
||||
if(best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
if((cur.base != -1) && (best.base == -1 || cur.len > best.len))
|
||||
best = cur;
|
||||
if(best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
/* Format the result. */
|
||||
tp = tmp;
|
||||
for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if(best.base != -1 && i >= best.base && i < (best.base + best.len)) {
|
||||
if(i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Are we following an initial run of 0x00s or any real hex?
|
||||
*/
|
||||
if(i != 0)
|
||||
*tp++ = ':';
|
||||
|
||||
/* Is this address an encapsulated IPv4?
|
||||
*/
|
||||
if(i == 6 && best.base == 0 &&
|
||||
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
|
||||
if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) {
|
||||
SET_ERRNO(ENOSPC);
|
||||
return (NULL);
|
||||
}
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
tp += snprintf(tp, 5, "%lx", words[i]);
|
||||
}
|
||||
|
||||
/* Was it a trailing run of 0x00's?
|
||||
*/
|
||||
if(best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ))
|
||||
*tp++ = ':';
|
||||
*tp++ = '\0';
|
||||
|
||||
/* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
if((size_t)(tp - tmp) > size) {
|
||||
SET_ERRNO(ENOSPC);
|
||||
return (NULL);
|
||||
}
|
||||
strcpy(dst, tmp);
|
||||
return dst;
|
||||
}
|
||||
#endif /* ENABLE_IPV6 */
|
||||
|
||||
/*
|
||||
* Convert a network format address to presentation format.
|
||||
*
|
||||
* Returns pointer to presentation format address (`buf').
|
||||
* Returns NULL on error and errno set with the specific
|
||||
* error, EAFNOSUPPORT or ENOSPC.
|
||||
*
|
||||
* On Windows we store the error in the thread errno, not
|
||||
* in the winsock error code. This is to avoid losing the
|
||||
* actual last winsock error. So use macro ERRNO to fetch the
|
||||
* errno this function sets when returning NULL, not SOCKERRNO.
|
||||
*/
|
||||
char *inet_ntop(int af, const void *src, char *buf, size_t size)
|
||||
{
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return inet_ntop4((const unsigned char*)src, buf, size);
|
||||
#ifdef ENABLE_IPV6
|
||||
case AF_INET6:
|
||||
return inet_ntop6((const unsigned char*)src, buf, size);
|
||||
#endif
|
||||
default:
|
||||
SET_ERRNO(EAFNOSUPPORT);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_INET_NTOP */
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef HEADER_CURL_INET_NTOP_H
|
||||
#define HEADER_CURL_INET_NTOP_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) Microsoft Open Technologies, Inc.
|
||||
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
char *inet_ntop(int af, const void *addr, char *buf, size_t size);
|
||||
|
||||
|
||||
#endif /* HEADER_CURL_INET_NTOP_H */
|
||||
|
|
@ -99,15 +99,6 @@ IAsyncAction^ Cocos2dRenderer::OnSuspending()
|
|||
}
|
||||
|
||||
|
||||
// user pressed the Back Key on the phone
|
||||
void Cocos2dRenderer::OnBackKeyPress()
|
||||
{
|
||||
// handle the backkey in your app here.
|
||||
// call Cocos2dEvent::TerminateApp if it is time to exit your app.
|
||||
// ie. the user is on your first page and wishes to exit your app.
|
||||
m_delegate->Invoke(Cocos2dEvent::TerminateApp);
|
||||
}
|
||||
|
||||
void Cocos2dRenderer::OnUpdateDevice()
|
||||
{
|
||||
GLView* glview = GLView::sharedOpenGLView();
|
||||
|
@ -132,21 +123,6 @@ bool Cocos2dRenderer::OnRender()
|
|||
return false;
|
||||
}
|
||||
|
||||
void Cocos2dRenderer::OnPointerPressed(PointerEventArgs^ args)
|
||||
{
|
||||
GLView::sharedOpenGLView()->OnPointerPressed(args);
|
||||
}
|
||||
|
||||
void Cocos2dRenderer::OnPointerMoved(PointerEventArgs^ args)
|
||||
{
|
||||
GLView::sharedOpenGLView()->OnPointerMoved(args);
|
||||
}
|
||||
|
||||
void Cocos2dRenderer::OnPointerReleased(PointerEventArgs^ args)
|
||||
{
|
||||
GLView::sharedOpenGLView()->OnPointerReleased(args);
|
||||
}
|
||||
|
||||
void Cocos2dRenderer::OnKeyPressed(Platform::String^ text)
|
||||
{
|
||||
char szUtf8[8] = {0};
|
||||
|
@ -154,7 +130,6 @@ void Cocos2dRenderer::OnKeyPressed(Platform::String^ text)
|
|||
IMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen);
|
||||
}
|
||||
|
||||
|
||||
void Cocos2dRenderer::OnCocos2dKeyEvent(Cocos2dKeyEvent event)
|
||||
{
|
||||
switch(event)
|
||||
|
|
|
@ -46,11 +46,7 @@ public:
|
|||
void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate);
|
||||
void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate);
|
||||
|
||||
void OnPointerPressed(Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerMoved(Windows::UI::Core::PointerEventArgs^ args);
|
||||
void OnPointerReleased(Windows::UI::Core::PointerEventArgs^ args);
|
||||
Windows::Foundation::IAsyncAction^ OnSuspending();
|
||||
void OnBackKeyPress();
|
||||
void Connect();
|
||||
void Disconnect();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
|||
#include "Direct3DInterop.h"
|
||||
#include "Direct3DContentProvider.h"
|
||||
#include "EditBoxEvent.h"
|
||||
#include "cocos2d.h"
|
||||
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Core;
|
||||
|
@ -91,69 +92,46 @@ IAsyncAction^ Direct3DInterop::OnSuspending()
|
|||
|
||||
void Direct3DInterop::OnBackKeyPress()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<BackButtonEvent> e(new BackButtonEvent());
|
||||
mInputEvents.push(e);
|
||||
cocos2d::GLView::sharedOpenGLView()->QueueBackKeyPress();
|
||||
}
|
||||
|
||||
// Pointer Event Handlers. We need to queue up pointer events to pass them to the drawing thread
|
||||
void Direct3DInterop::OnPointerPressed(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
AddPointerEvent(PointerEventType::PointerPressed, args);
|
||||
cocos2d::GLView::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerPressed, args);
|
||||
}
|
||||
|
||||
|
||||
void Direct3DInterop::OnPointerMoved(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
AddPointerEvent(PointerEventType::PointerMoved, args);
|
||||
cocos2d::GLView::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerMoved, args);
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnPointerReleased(DrawingSurfaceManipulationHost^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
AddPointerEvent(PointerEventType::PointerReleased, args);
|
||||
cocos2d::GLView::sharedOpenGLView()->QueuePointerEvent(cocos2d::PointerEventType::PointerReleased, args);
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnCocos2dKeyEvent(Cocos2dKeyEvent key)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<KeyboardEvent> e(new KeyboardEvent(key));
|
||||
mInputEvents.push(e);
|
||||
std::shared_ptr<cocos2d::InputEvent> e(new cocos2d::KeyboardEvent(key));
|
||||
cocos2d::GLView::sharedOpenGLView()->QueueEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void Direct3DInterop::OnCocos2dKeyEvent(Cocos2dKeyEvent key, Platform::String^ text)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<KeyboardEvent> e(new KeyboardEvent(key,text));
|
||||
mInputEvents.push(e);
|
||||
std::shared_ptr<cocos2d::InputEvent> e(new cocos2d::KeyboardEvent(key,text));
|
||||
cocos2d::GLView::sharedOpenGLView()->QueueEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void Direct3DInterop::AddPointerEvent(PointerEventType type, PointerEventArgs^ args)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<PointerEvent> e(new PointerEvent(type, args));
|
||||
mInputEvents.push(e);
|
||||
}
|
||||
|
||||
void Direct3DInterop::OnCocos2dEditboxEvent(Object^ sender, Platform::String^ args, Windows::Foundation::EventHandler<Platform::String^>^ handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<EditBoxEvent> e(new EditBoxEvent(sender, args, handler));
|
||||
mInputEvents.push(e);
|
||||
std::shared_ptr<cocos2d::InputEvent> e(new EditBoxEvent(sender, args, handler));
|
||||
cocos2d::GLView::sharedOpenGLView()->QueueEvent(e);
|
||||
}
|
||||
|
||||
void Direct3DInterop::ProcessEvents()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
|
||||
while(!mInputEvents.empty())
|
||||
{
|
||||
InputEvent* e = mInputEvents.front().get();
|
||||
e->execute(m_renderer);
|
||||
mInputEvents.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HRESULT Direct3DInterop::PrepareResources(_In_ const LARGE_INTEGER* presentTargetTime, _Inout_ DrawingSurfaceSizeF* desiredRenderTargetSize)
|
||||
|
@ -176,7 +154,7 @@ HRESULT Direct3DInterop::Draw(_In_ ID3D11Device1* device, _In_ ID3D11DeviceConte
|
|||
}
|
||||
#endif // 0
|
||||
|
||||
ProcessEvents();
|
||||
cocos2d::GLView::sharedOpenGLView()->ProcessEvents();
|
||||
m_renderer->Render();
|
||||
RequestAdditionalFrame();
|
||||
return S_OK;
|
||||
|
|
|
@ -39,7 +39,6 @@ namespace PhoneDirect3DXamlAppComponent
|
|||
|
||||
public delegate void RequestAdditionalFrameHandler();
|
||||
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Direct3DInterop sealed : public Windows::Phone::Input::Interop::IDrawingSurfaceManipulationHandler
|
||||
{
|
||||
|
@ -60,7 +59,7 @@ public:
|
|||
void OnBackKeyPress();
|
||||
void OnCocos2dKeyEvent(Cocos2dKeyEvent key);
|
||||
void OnCocos2dKeyEvent(Cocos2dKeyEvent key, Platform::String^ text);
|
||||
void OnCocos2dEditboxEvent(Object^ sender, Platform::String^ args, Windows::Foundation::EventHandler<Platform::String^>^ handler);
|
||||
void OnCocos2dEditboxEvent(Platform::Object^ sender, Platform::String^ args, Windows::Foundation::EventHandler<Platform::String^>^ handler);
|
||||
|
||||
property Windows::Graphics::Display::DisplayOrientations WindowOrientation;
|
||||
property Windows::Foundation::Size WindowBounds;
|
||||
|
@ -84,13 +83,10 @@ internal:
|
|||
bool SendCocos2dEvent(Cocos2dEvent event);
|
||||
|
||||
private:
|
||||
void ProcessEvents();
|
||||
void AddPointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
|
||||
Cocos2dRenderer^ m_renderer;
|
||||
Windows::Graphics::Display::DisplayOrientations mCurrentOrientation;
|
||||
|
||||
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
||||
std::mutex mMutex;
|
||||
|
||||
std::mutex mRenderingMutex;
|
||||
|
||||
Cocos2dEventDelegate^ m_delegate;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace PhoneDirect3DXamlAppComponent
|
|||
|
||||
}
|
||||
|
||||
void EditBoxEvent::execute( Cocos2dRenderer ^ renderer )
|
||||
void EditBoxEvent::execute()
|
||||
{
|
||||
if(m_handler.Get())
|
||||
{
|
||||
|
|
|
@ -25,18 +25,18 @@ THE SOFTWARE.
|
|||
#ifndef __EditBoxEVENT_H__
|
||||
#define __EditBoxEVENT_H__
|
||||
|
||||
#include "platform/wp8-xaml/cpp/InputEvent.h"
|
||||
#include "InputEvent.h"
|
||||
#include <agile.h>
|
||||
|
||||
|
||||
namespace PhoneDirect3DXamlAppComponent
|
||||
{
|
||||
class EditBoxEvent : public InputEvent
|
||||
class EditBoxEvent : public cocos2d::InputEvent
|
||||
{
|
||||
public:
|
||||
EditBoxEvent(Platform::Object^ sender, Platform::String^ arg, Windows::Foundation::EventHandler<Platform::String^>^ handle);
|
||||
|
||||
virtual void execute(Cocos2dRenderer ^ renderer);
|
||||
virtual void execute();
|
||||
|
||||
private:
|
||||
Platform::Agile<Platform::Object^> m_sender;
|
||||
|
|
|
@ -173,6 +173,14 @@ void GLView::OnResuming(Platform::Object^ sender, Platform::Object^ args)
|
|||
{
|
||||
}
|
||||
|
||||
// user pressed the Back Key on the phone
|
||||
void GLView::OnBackKeyPress()
|
||||
{
|
||||
if(m_delegate)
|
||||
{
|
||||
m_delegate->Invoke(Cocos2dEvent::TerminateApp);
|
||||
}
|
||||
}
|
||||
|
||||
void GLView::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
|
||||
{
|
||||
|
@ -504,5 +512,36 @@ void GLView::setScissorInPoints(float x , float y , float w , float h)
|
|||
}
|
||||
}
|
||||
|
||||
void GLView::QueueBackKeyPress()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<BackButtonEvent> e(new BackButtonEvent());
|
||||
mInputEvents.push(e);
|
||||
}
|
||||
|
||||
void GLView::QueuePointerEvent(PointerEventType type, PointerEventArgs^ args)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
std::shared_ptr<PointerEvent> e(new PointerEvent(type, args));
|
||||
mInputEvents.push(e);
|
||||
}
|
||||
|
||||
void GLView::QueueEvent(std::shared_ptr<InputEvent>& event)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
mInputEvents.push(event);
|
||||
}
|
||||
|
||||
void GLView::ProcessEvents()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mMutex);
|
||||
|
||||
while (!mInputEvents.empty())
|
||||
{
|
||||
InputEvent* e = mInputEvents.front().get();
|
||||
e->execute();
|
||||
mInputEvents.pop();
|
||||
}
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -30,15 +30,19 @@ THE SOFTWARE.
|
|||
#include "platform/CCCommon.h"
|
||||
#include "CCGeometry.h"
|
||||
#include "platform/CCGLViewProtocol.h"
|
||||
#include "InputEvent.h"
|
||||
|
||||
|
||||
#include <agile.h>
|
||||
|
||||
#include <wrl/client.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include <agile.h>
|
||||
#include <DirectXMath.h>
|
||||
#include "kazmath/mat4.h"
|
||||
#include "../wp8-xaml/cpp/InputEvent.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
@ -83,7 +87,12 @@ public:
|
|||
void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
|
||||
void OnResuming(Platform::Object^ sender, Platform::Object^ args);
|
||||
void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
|
||||
|
||||
void OnBackKeyPress();
|
||||
|
||||
void QueueBackKeyPress();
|
||||
void QueuePointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
|
||||
void GLView::QueueEvent(std::shared_ptr<InputEvent>& event);
|
||||
|
||||
void SetXamlEventDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ delegate) { m_delegate = delegate; };
|
||||
void SetXamlMessageBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ delegate) { m_messageBoxDelegate = delegate; };
|
||||
void SetXamlEditBoxDelegate(PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ delegate) { m_editBoxDelegate = delegate; };
|
||||
|
@ -108,6 +117,11 @@ public:
|
|||
*/
|
||||
static GLView* sharedOpenGLView();
|
||||
|
||||
void ProcessEvents();
|
||||
void AddPointerEvent(PointerEventType type, Windows::UI::Core::PointerEventArgs^ args);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
GLView();
|
||||
virtual ~GLView();
|
||||
|
@ -165,6 +179,10 @@ private:
|
|||
PhoneDirect3DXamlAppComponent::Cocos2dEventDelegate^ m_delegate;
|
||||
PhoneDirect3DXamlAppComponent::Cocos2dMessageBoxDelegate^ m_messageBoxDelegate;
|
||||
PhoneDirect3DXamlAppComponent::Cocos2dEditBoxDelegate^ m_editBoxDelegate;
|
||||
|
||||
std::queue<std::shared_ptr<InputEvent>> mInputEvents;
|
||||
std::mutex mMutex;
|
||||
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -1 +1 @@
|
|||
675c891edfee81289823d47b2dac3c1b9e48e835
|
||||
50ec12724990929d67cc08d297011bcd7e3ebe7c
|
|
@ -43,7 +43,7 @@
|
|||
NS_CC_BEGIN
|
||||
|
||||
// helper
|
||||
bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
static bool compareRenderCommand(RenderCommand* a, RenderCommand* b)
|
||||
{
|
||||
return a->getGlobalOrder() < b->getGlobalOrder();
|
||||
}
|
||||
|
|
|
@ -18,42 +18,42 @@ public:
|
|||
void Close();
|
||||
|
||||
/**
|
||||
@brief 播放声音文件
|
||||
@param pFileName 播放的声音文件名称,需要包含文件的路径
|
||||
@param nTimes 播放声音文件的循环次数,默认值为 1,即播放一次
|
||||
@brief Play sound file
|
||||
@param pFileName Sound's file name,include the file path.
|
||||
@param nTimes Play mode£¬default value is 1,paly once
|
||||
*/
|
||||
void Open(const char* pFileName, UINT uId);
|
||||
|
||||
void Play(UINT uTimes = 1);
|
||||
|
||||
/**
|
||||
@brief 暂停播放声音
|
||||
@brief Pause play
|
||||
*/
|
||||
void Pause();
|
||||
|
||||
/**
|
||||
@brief 继续播放声音
|
||||
@brief Resume play
|
||||
*/
|
||||
void Resume();
|
||||
|
||||
/**
|
||||
@brief 停止播放声音
|
||||
@brief Stop play
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
/**
|
||||
@brief 重新播放
|
||||
@brief Replay
|
||||
*/
|
||||
void Rewind();
|
||||
|
||||
/**
|
||||
@brief 获取播放器当前是否正在播放中
|
||||
@brief Is Playing
|
||||
*/
|
||||
bool IsPlaying();
|
||||
|
||||
/**
|
||||
@brief 获取当前播放的音效 ID
|
||||
@return 当前播放的音效ID
|
||||
@brief Get playing sound's ID
|
||||
@return Sound's ID
|
||||
*/
|
||||
UINT GetSoundID();
|
||||
|
||||
|
|
|
@ -40,7 +40,10 @@
|
|||
#include <WS2tcpip.h>
|
||||
#include <Winsock2.h>
|
||||
#define bzero(a, b) memset(a, 0, b);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
#include "inet_ntop_winrt.h"
|
||||
#include "CCWinRTUtils.h"
|
||||
#endif
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
|
@ -107,7 +110,7 @@ static bool isFloat( std::string myString ) {
|
|||
return iss.eof() && !iss.fail();
|
||||
}
|
||||
|
||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT && CC_TARGET_PLATFORM != CC_PLATFORM_WP8
|
||||
#if CC_TARGET_PLATFORM != CC_PLATFORM_WINRT
|
||||
|
||||
// helper free functions
|
||||
|
||||
|
@ -220,13 +223,14 @@ static void _log(const char *format, va_list args)
|
|||
OutputDebugStringW(wszBuf);
|
||||
WideCharToMultiByte(CP_ACP, 0, wszBuf, -1, buf, sizeof(buf), NULL, FALSE);
|
||||
printf("%s", buf);
|
||||
fflush(stdout);
|
||||
#else
|
||||
// Linux, Mac, iOS, etc
|
||||
fprintf(stdout, "cocos2d: %s", buf);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
Director::getInstance()->getConsole()->log(buf);
|
||||
#endif
|
||||
|
||||
|
@ -249,7 +253,7 @@ void log(const char * format, ...)
|
|||
va_end(args);
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
|
||||
//
|
||||
// Console code
|
||||
|
@ -320,9 +324,13 @@ bool Console::listenOnTCP(int port)
|
|||
hints.ai_family = AF_INET; // AF_UNSPEC: Do we need IPv6 ?
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
WSADATA wsaData;
|
||||
n = WSAStartup(MAKEWORD(2, 2),&wsaData);
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
CCLogIPAddresses();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if ( (n = getaddrinfo(NULL, serv, &hints, &res)) != 0) {
|
||||
|
@ -342,7 +350,7 @@ bool Console::listenOnTCP(int port)
|
|||
break; /* success */
|
||||
|
||||
/* bind error, close and try next one */
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
closesocket(listenfd);
|
||||
#else
|
||||
close(listenfd);
|
||||
|
@ -429,7 +437,7 @@ void Console::commandExit(int fd, const std::string &args)
|
|||
{
|
||||
FD_CLR(fd, &_read_set);
|
||||
_fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end());
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
|
@ -845,8 +853,7 @@ void Console::commandUpload(int fd)
|
|||
|
||||
ssize_t Console::readBytes(int fd, char* buffer, size_t maxlen, bool* more)
|
||||
{
|
||||
size_t n;
|
||||
int rc;
|
||||
size_t n, rc;
|
||||
char c, *ptr = buffer;
|
||||
*more = false;
|
||||
for( n = 0; n < maxlen; n++ ) {
|
||||
|
@ -956,8 +963,7 @@ bool Console::parseCommand(int fd)
|
|||
|
||||
ssize_t Console::readline(int fd, char* ptr, size_t maxlen)
|
||||
{
|
||||
size_t n;
|
||||
int rc;
|
||||
size_t n, rc;
|
||||
char c;
|
||||
|
||||
for( n = 0; n < maxlen - 1; n++ ) {
|
||||
|
@ -1064,7 +1070,7 @@ void Console::loop()
|
|||
//receive a SIGPIPE, which will cause linux system shutdown the sending process.
|
||||
//Add this ioctl code to check if the socket has been closed by peer.
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
u_long n = 0;
|
||||
ioctlsocket(fd, FIONREAD, &n);
|
||||
#else
|
||||
|
@ -1109,14 +1115,14 @@ void Console::loop()
|
|||
// clean up: ignore stdin, stdout and stderr
|
||||
for(const auto &fd: _fds )
|
||||
{
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
closesocket(fd);
|
||||
#else
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
|
||||
closesocket(_listenfd);
|
||||
WSACleanup();
|
||||
#else
|
||||
|
@ -1125,7 +1131,7 @@ void Console::loop()
|
|||
_running = false;
|
||||
}
|
||||
|
||||
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) */
|
||||
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) */
|
||||
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -71,7 +71,7 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
|
|||
```
|
||||
*/
|
||||
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
|
||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
|
||||
class CC_DLL Console
|
||||
{
|
||||
public:
|
||||
|
@ -146,7 +146,7 @@ private:
|
|||
CC_DISALLOW_COPY_AND_ASSIGN(Console);
|
||||
};
|
||||
|
||||
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) && (CC_TARGET_PLATFORM != CC_PLATFORM_WP8) */
|
||||
#endif /* #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT) */
|
||||
NS_CC_END
|
||||
|
||||
#endif /* defined(__CCCONSOLE_H__) */
|
||||
|
|
|
@ -0,0 +1,309 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2014 PlayFirst Inc.
|
||||
Copyright (c) 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 __CC_REF_PTR_H__
|
||||
#define __CC_REF_PTR_H__
|
||||
|
||||
#include "CCRef.h"
|
||||
#include <type_traits>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
/**
|
||||
* Utility/support macros. Defined to enable RefPtr<T> to contain types like 'const T' because we do not
|
||||
* regard retain()/release() as affecting mutability of state.
|
||||
*/
|
||||
#define CC_REF_PTR_SAFE_RETAIN(ptr)\
|
||||
\
|
||||
do\
|
||||
{\
|
||||
if (ptr)\
|
||||
{\
|
||||
const_cast<Ref*>(static_cast<const Ref*>(ptr))->retain();\
|
||||
}\
|
||||
\
|
||||
} while (0);
|
||||
|
||||
#define CC_REF_PTR_SAFE_RELEASE(ptr)\
|
||||
\
|
||||
do\
|
||||
{\
|
||||
if (ptr)\
|
||||
{\
|
||||
const_cast<Ref*>(static_cast<const Ref*>(ptr))->release();\
|
||||
}\
|
||||
\
|
||||
} while (0);
|
||||
|
||||
#define CC_REF_PTR_SAFE_RELEASE_NULL(ptr)\
|
||||
\
|
||||
do\
|
||||
{\
|
||||
if (ptr)\
|
||||
{\
|
||||
const_cast<Ref*>(static_cast<const Ref*>(ptr))->release();\
|
||||
ptr = nullptr;\
|
||||
}\
|
||||
\
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
* Wrapper class which maintains a strong reference to a cocos2dx cocos2d::Ref* type object.
|
||||
* Similar in concept to a boost smart pointer.
|
||||
*
|
||||
* Enables the use of the RAII idiom with Cocos2dx objects and helps automate some of the more
|
||||
* mundane tasks of pointer initialization and cleanup.
|
||||
*
|
||||
* The class itself is modelled on C++ 11 std::shared_ptr, and trys to keep some of the methods
|
||||
* and functionality consistent with std::shared_ptr.
|
||||
*/
|
||||
template <typename T> class RefPtr
|
||||
{
|
||||
public:
|
||||
|
||||
inline RefPtr()
|
||||
:
|
||||
_ptr(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline RefPtr(RefPtr<T> && other)
|
||||
{
|
||||
_ptr = other._ptr;
|
||||
other._ptr = nullptr;
|
||||
}
|
||||
|
||||
inline RefPtr(T * ptr)
|
||||
:
|
||||
_ptr(const_cast<typename std::remove_const<T>::type*>(ptr)) // Const cast allows RefPtr<T> to reference objects marked const too.
|
||||
{
|
||||
CC_REF_PTR_SAFE_RETAIN(_ptr);
|
||||
}
|
||||
|
||||
inline RefPtr(std::nullptr_t ptr)
|
||||
:
|
||||
_ptr(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
inline RefPtr(const RefPtr<T> & other)
|
||||
:
|
||||
_ptr(other._ptr)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RETAIN(_ptr);
|
||||
}
|
||||
|
||||
inline ~RefPtr()
|
||||
{
|
||||
CC_REF_PTR_SAFE_RELEASE_NULL(_ptr);
|
||||
}
|
||||
|
||||
inline RefPtr<T> & operator = (const RefPtr<T> & other)
|
||||
{
|
||||
if (other._ptr != _ptr)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RETAIN(other._ptr);
|
||||
CC_REF_PTR_SAFE_RELEASE(_ptr);
|
||||
_ptr = other._ptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RefPtr<T> & operator = (RefPtr<T> && other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RELEASE(_ptr);
|
||||
_ptr = other._ptr;
|
||||
other._ptr = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RefPtr<T> & operator = (T * other)
|
||||
{
|
||||
if (other != _ptr)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RETAIN(other);
|
||||
CC_REF_PTR_SAFE_RELEASE(_ptr);
|
||||
_ptr = const_cast<typename std::remove_const<T>::type*>(other); // Const cast allows RefPtr<T> to reference objects marked const too.
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline RefPtr<T> & operator = (std::nullptr_t other)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RELEASE_NULL(_ptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Note: using reinterpret_cast<> instead of static_cast<> here because it doesn't require type info.
|
||||
// Since we verify the correct type cast at compile time on construction/assign we don't need to know the type info
|
||||
// here. Not needing the type info here enables us to use these operations in inline functions in header files when
|
||||
// the type pointed to by this class is only forward referenced.
|
||||
|
||||
inline operator T * () const { return reinterpret_cast<T*>(_ptr); }
|
||||
|
||||
inline T & operator * () const
|
||||
{
|
||||
CCASSERT(_ptr, "Attempt to dereference a null pointer!");
|
||||
return reinterpret_cast<T&>(*_ptr);
|
||||
}
|
||||
|
||||
inline T * operator->() const
|
||||
{
|
||||
CCASSERT(_ptr, "Attempt to dereference a null pointer!");
|
||||
return reinterpret_cast<T*>(_ptr);
|
||||
}
|
||||
|
||||
inline T * get() const { return reinterpret_cast<T*>(_ptr); }
|
||||
|
||||
|
||||
inline bool operator == (const RefPtr<T> & other) const { return _ptr == other._ptr; }
|
||||
|
||||
inline bool operator == (const T * other) const { return _ptr == other; }
|
||||
|
||||
inline bool operator == (typename std::remove_const<T>::type * other) const { return _ptr == other; }
|
||||
|
||||
inline bool operator == (const std::nullptr_t other) const { return _ptr == other; }
|
||||
|
||||
|
||||
inline bool operator != (const RefPtr<T> & other) const { return _ptr != other._ptr; }
|
||||
|
||||
inline bool operator != (const T * other) const { return _ptr != other; }
|
||||
|
||||
inline bool operator != (typename std::remove_const<T>::type * other) const { return _ptr != other; }
|
||||
|
||||
inline bool operator != (const std::nullptr_t other) const { return _ptr != other; }
|
||||
|
||||
|
||||
inline bool operator > (const RefPtr<T> & other) const { return _ptr > other._ptr; }
|
||||
|
||||
inline bool operator > (const T * other) const { return _ptr > other; }
|
||||
|
||||
inline bool operator > (typename std::remove_const<T>::type * other) const { return _ptr > other; }
|
||||
|
||||
inline bool operator > (const std::nullptr_t other) const { return _ptr > other; }
|
||||
|
||||
|
||||
inline bool operator < (const RefPtr<T> & other) const { return _ptr < other._ptr; }
|
||||
|
||||
inline bool operator < (const T * other) const { return _ptr < other; }
|
||||
|
||||
inline bool operator < (typename std::remove_const<T>::type * other) const { return _ptr < other; }
|
||||
|
||||
inline bool operator < (const std::nullptr_t other) const { return _ptr < other; }
|
||||
|
||||
|
||||
inline bool operator >= (const RefPtr<T> & other) const { return _ptr >= other._ptr; }
|
||||
|
||||
inline bool operator >= (const T * other) const { return _ptr >= other; }
|
||||
|
||||
inline bool operator >= (typename std::remove_const<T>::type * other) const { return _ptr >= other; }
|
||||
|
||||
inline bool operator >= (const std::nullptr_t other) const { return _ptr >= other; }
|
||||
|
||||
|
||||
inline bool operator <= (const RefPtr<T> & other) const { return _ptr <= other._ptr; }
|
||||
|
||||
inline bool operator <= (const T * other) const { return _ptr <= other; }
|
||||
|
||||
inline bool operator <= (typename std::remove_const<T>::type * other) const { return _ptr <= other; }
|
||||
|
||||
inline bool operator <= (const std::nullptr_t other) const { return _ptr <= other; }
|
||||
|
||||
|
||||
inline operator bool() const { return _ptr != nullptr; }
|
||||
|
||||
inline void reset()
|
||||
{
|
||||
CC_REF_PTR_SAFE_RELEASE_NULL(_ptr);
|
||||
}
|
||||
|
||||
inline void swap(RefPtr<T> & other)
|
||||
{
|
||||
if (&other != this)
|
||||
{
|
||||
Ref * tmp = _ptr;
|
||||
_ptr = other._ptr;
|
||||
other._ptr = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function assigns to this RefPtr<T> but does not increase the reference count of the object pointed to.
|
||||
* Useful for assigning an object created through the 'new' operator to a RefPtr<T>. Basically used in scenarios
|
||||
* where the RefPtr<T> has the initial ownership of the object.
|
||||
*
|
||||
* E.G:
|
||||
* RefPtr<cocos2d::Image> image;
|
||||
* image.weakAssign(new cocos2d::Image());
|
||||
*
|
||||
* Instead of:
|
||||
* RefPtr<cocos2d::Image> image;
|
||||
* image = new cocos2d::Image();
|
||||
* image->release(); // Required because new'd object already has a reference count of '1'.
|
||||
*/
|
||||
inline void weakAssign(const RefPtr<T> & other)
|
||||
{
|
||||
CC_REF_PTR_SAFE_RELEASE(_ptr);
|
||||
_ptr = other._ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
Ref * _ptr;
|
||||
};
|
||||
|
||||
/**
|
||||
* Cast between RefPtr types statically.
|
||||
*/
|
||||
template<class T, class U> RefPtr<T> static_pointer_cast(const RefPtr<U> & r)
|
||||
{
|
||||
return RefPtr<T>(static_cast<T*>(r.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast between RefPtr types dynamically.
|
||||
*/
|
||||
template<class T, class U> RefPtr<T> dynamic_pointer_cast(const RefPtr<U> & r)
|
||||
{
|
||||
return RefPtr<T>(dynamic_cast<T*>(r.get()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Done with these macros.
|
||||
*/
|
||||
#undef CC_REF_PTR_SAFE_RETAIN
|
||||
#undef CC_REF_PTR_SAFE_RELEASE
|
||||
#undef CC_REF_PTR_SAFE_RELEASE_NULL
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif // __CC_REF_PTR_H__
|
|
@ -1109,6 +1109,14 @@ Widget* WidgetPropertiesReader0300::widgetFromJsonDictionary(const rapidjson::Va
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!dynamic_cast<Layout*>(widget))
|
||||
{
|
||||
if (child->getPositionType() == cocos2d::ui::POSITION_PERCENT)
|
||||
{
|
||||
child->setPositionPercent(Point(child->getPositionPercent().x + 0.5f, child->getPositionPercent().y + 0.5f));
|
||||
}
|
||||
child->setPosition(Point(child->getPositionX() + widget->getSize().width / 2.0f, child->getPositionY() + widget->getSize().height / 2.0f));
|
||||
}
|
||||
widget->addChild(child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -502,10 +502,15 @@ void HttpClient::dispatchResponseCallbacks()
|
|||
if (response)
|
||||
{
|
||||
HttpRequest *request = response->getHttpRequest();
|
||||
const ccHttpRequestCallback& callback = request->getCallback();
|
||||
Ref* pTarget = request->getTarget();
|
||||
SEL_HttpResponse pSelector = request->getSelector();
|
||||
|
||||
if (pTarget && pSelector)
|
||||
if (callback != nullptr)
|
||||
{
|
||||
callback(this, response);
|
||||
}
|
||||
else if (pTarget && pSelector)
|
||||
{
|
||||
(pTarget->*pSelector)(this, response);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace network {
|
|||
class HttpClient;
|
||||
class HttpResponse;
|
||||
|
||||
typedef std::function<void(HttpClient* client, HttpResponse* response)> ccHttpRequestCallback;
|
||||
typedef void (cocos2d::Ref::*SEL_HttpResponse)(HttpClient* client, HttpResponse* response);
|
||||
#define httpresponse_selector(_SELECTOR) (cocos2d::network::SEL_HttpResponse)(&_SELECTOR)
|
||||
|
||||
|
@ -78,9 +79,10 @@ public:
|
|||
_url.clear();
|
||||
_requestData.clear();
|
||||
_tag.clear();
|
||||
_pTarget = NULL;
|
||||
_pSelector = NULL;
|
||||
_pUserData = NULL;
|
||||
_pTarget = nullptr;
|
||||
_pSelector = nullptr;
|
||||
_pCallback = nullptr;
|
||||
_pUserData = nullptr;
|
||||
};
|
||||
|
||||
/** Destructor */
|
||||
|
@ -183,7 +185,7 @@ public:
|
|||
setResponseCallback(pTarget, (SEL_HttpResponse) pSelector);
|
||||
}
|
||||
|
||||
inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
|
||||
CC_DEPRECATED_ATTRIBUTE inline void setResponseCallback(Ref* pTarget, SEL_HttpResponse pSelector)
|
||||
{
|
||||
_pTarget = pTarget;
|
||||
_pSelector = pSelector;
|
||||
|
@ -192,7 +194,13 @@ public:
|
|||
{
|
||||
_pTarget->retain();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void setResponseCallback(const ccHttpRequestCallback& callback)
|
||||
{
|
||||
_pCallback = callback;
|
||||
}
|
||||
|
||||
/** Get the target of callback selector funtion, mainly used by HttpClient */
|
||||
inline Ref* getTarget()
|
||||
{
|
||||
|
@ -218,6 +226,11 @@ public:
|
|||
return _prxy(_pSelector);
|
||||
}
|
||||
|
||||
inline const ccHttpRequestCallback& getCallback()
|
||||
{
|
||||
return _pCallback;
|
||||
}
|
||||
|
||||
/** Set any custom headers **/
|
||||
inline void setHeaders(std::vector<std::string> pHeaders)
|
||||
{
|
||||
|
@ -238,6 +251,7 @@ protected:
|
|||
std::string _tag; /// user defined tag, to identify different requests in response callback
|
||||
Ref* _pTarget; /// callback target of pSelector function
|
||||
SEL_HttpResponse _pSelector; /// callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)
|
||||
ccHttpRequestCallback _pCallback; /// C++11 style callbacks
|
||||
void* _pUserData; /// You can add your customed data here
|
||||
std::vector<std::string> _headers; /// custom http headers
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "chipmunk.h"
|
||||
|
||||
#include "CCNode.h"
|
||||
#include "CCLayer.h"
|
||||
|
||||
#include "CCPhysicsShape.h"
|
||||
#include "CCPhysicsJoint.h"
|
||||
|
@ -347,18 +347,12 @@ void PhysicsBody::setGravityEnable(bool enable)
|
|||
|
||||
void PhysicsBody::setPosition(Point position)
|
||||
{
|
||||
if (!_positionResetTag)
|
||||
{
|
||||
cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position + _positionOffset));
|
||||
}
|
||||
cpBodySetPos(_info->getBody(), PhysicsHelper::point2cpv(position + _positionOffset));
|
||||
}
|
||||
|
||||
void PhysicsBody::setRotation(float rotation)
|
||||
{
|
||||
if (!_rotationResetTag)
|
||||
{
|
||||
cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f)));
|
||||
}
|
||||
cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f)));
|
||||
}
|
||||
|
||||
Point PhysicsBody::getPosition() const
|
||||
|
@ -770,12 +764,19 @@ void PhysicsBody::update(float delta)
|
|||
if (_node != nullptr)
|
||||
{
|
||||
Node* parent = _node->getParent();
|
||||
Layer* layer = &_world->getLayer();
|
||||
|
||||
Point position = parent != layer ? parent->convertToNodeSpace(layer->convertToWorldSpace(getPosition())) : getPosition();
|
||||
float rotation = getRotation();
|
||||
for (; parent != layer; parent = parent->getParent())
|
||||
{
|
||||
rotation -= parent->getRotation();
|
||||
}
|
||||
|
||||
Point position = parent != nullptr ? parent->convertToNodeSpace(getPosition()) : getPosition();
|
||||
_positionResetTag = true;
|
||||
_rotationResetTag = true;
|
||||
_node->setPosition(position);
|
||||
_node->setRotation(getRotation());
|
||||
_node->setRotation(rotation);
|
||||
_positionResetTag = false;
|
||||
_rotationResetTag = false;
|
||||
|
||||
|
|
|
@ -349,6 +349,7 @@ protected:
|
|||
friend class PhysicsShape;
|
||||
friend class PhysicsJoint;
|
||||
friend class Node;
|
||||
friend class Layer;
|
||||
friend class ProtectedNode;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "chipmunk/CCPhysicsHelper_chipmunk.h"
|
||||
|
||||
#include "CCDrawNode.h"
|
||||
#include "CCScene.h"
|
||||
#include "CCLayer.h"
|
||||
#include "CCDirector.h"
|
||||
#include "CCEventDispatcher.h"
|
||||
#include "CCEventCustom.h"
|
||||
|
@ -289,7 +289,7 @@ int PhysicsWorld::collisionBeginCallback(PhysicsContact& contact)
|
|||
{
|
||||
contact.setEventCode(PhysicsContact::EventCode::BEGIN);
|
||||
contact.setWorld(this);
|
||||
_scene->getEventDispatcher()->dispatchEvent(&contact);
|
||||
_layer->getEventDispatcher()->dispatchEvent(&contact);
|
||||
}
|
||||
|
||||
return ret ? contact.resetResult() : false;
|
||||
|
@ -305,7 +305,7 @@ int PhysicsWorld::collisionPreSolveCallback(PhysicsContact& contact)
|
|||
|
||||
contact.setEventCode(PhysicsContact::EventCode::PRESOLVE);
|
||||
contact.setWorld(this);
|
||||
_scene->getEventDispatcher()->dispatchEvent(&contact);
|
||||
_layer->getEventDispatcher()->dispatchEvent(&contact);
|
||||
|
||||
return contact.resetResult();
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ void PhysicsWorld::collisionPostSolveCallback(PhysicsContact& contact)
|
|||
|
||||
contact.setEventCode(PhysicsContact::EventCode::POSTSOLVE);
|
||||
contact.setWorld(this);
|
||||
_scene->getEventDispatcher()->dispatchEvent(&contact);
|
||||
_layer->getEventDispatcher()->dispatchEvent(&contact);
|
||||
}
|
||||
|
||||
void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
|
||||
|
@ -331,7 +331,7 @@ void PhysicsWorld::collisionSeparateCallback(PhysicsContact& contact)
|
|||
|
||||
contact.setEventCode(PhysicsContact::EventCode::SEPERATE);
|
||||
contact.setWorld(this);
|
||||
_scene->getEventDispatcher()->dispatchEvent(&contact);
|
||||
_layer->getEventDispatcher()->dispatchEvent(&contact);
|
||||
}
|
||||
|
||||
void PhysicsWorld::rayCast(PhysicsRayCastCallbackFunc func, const Point& point1, const Point& point2, void* data)
|
||||
|
@ -416,10 +416,10 @@ PhysicsShape* PhysicsWorld::getShape(const Point& point) const
|
|||
return shape == nullptr ? nullptr : PhysicsShapeInfo::getMap().find(shape)->second->getShape();
|
||||
}
|
||||
|
||||
PhysicsWorld* PhysicsWorld::construct(Scene& scene)
|
||||
PhysicsWorld* PhysicsWorld::construct(Layer& layer)
|
||||
{
|
||||
PhysicsWorld * world = new PhysicsWorld();
|
||||
if(world && world->init(scene))
|
||||
if(world && world->init(layer))
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
@ -428,14 +428,14 @@ PhysicsWorld* PhysicsWorld::construct(Scene& scene)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
bool PhysicsWorld::init(Scene& scene)
|
||||
bool PhysicsWorld::init(Layer& layer)
|
||||
{
|
||||
do
|
||||
{
|
||||
_info = new PhysicsWorldInfo();
|
||||
CC_BREAK_IF(_info == nullptr);
|
||||
|
||||
_scene = &scene;
|
||||
_layer = &layer;
|
||||
|
||||
_info->setGravity(_gravity);
|
||||
|
||||
|
@ -867,8 +867,7 @@ void PhysicsWorld::setGravity(const Vect& gravity)
|
|||
// reset gravity for body
|
||||
if (!body->isGravityEnabled())
|
||||
{
|
||||
body->applyForce(_gravity * body->getMass());
|
||||
body->applyForce(- gravity * body->getMass());
|
||||
body->applyForce((_gravity - gravity) * body->getMass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -912,7 +911,7 @@ PhysicsWorld::PhysicsWorld()
|
|||
, _updateRateCount(0)
|
||||
, _updateTime(0.0f)
|
||||
, _info(nullptr)
|
||||
, _scene(nullptr)
|
||||
, _layer(nullptr)
|
||||
, _delayDirty(false)
|
||||
, _debugDraw(nullptr)
|
||||
, _debugDrawMask(DEBUGDRAW_NONE)
|
||||
|
@ -933,7 +932,7 @@ PhysicsDebugDraw::PhysicsDebugDraw(PhysicsWorld& world)
|
|||
, _world(world)
|
||||
{
|
||||
_drawNode = DrawNode::create();
|
||||
_world.getScene().addChild(_drawNode);
|
||||
_world.getLayer().addChild(_drawNode);
|
||||
}
|
||||
|
||||
PhysicsDebugDraw::~PhysicsDebugDraw()
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef Point Vect;
|
|||
|
||||
class Node;
|
||||
class Sprite;
|
||||
class Scene;
|
||||
class Layer;
|
||||
class DrawNode;
|
||||
class PhysicsDebugDraw;
|
||||
|
||||
|
@ -119,8 +119,8 @@ public:
|
|||
/** Get body by tag */
|
||||
PhysicsBody* getBody(int tag) const;
|
||||
|
||||
/** Get scene contain this physics world */
|
||||
inline Scene& getScene() const { return *_scene; }
|
||||
/** Get layer contain this physics world */
|
||||
inline Layer& getLayer() const { return *_layer; }
|
||||
/** get the gravity value */
|
||||
inline Vect getGravity() const { return _gravity; }
|
||||
/** set the gravity value */
|
||||
|
@ -144,8 +144,8 @@ public:
|
|||
inline int getDebugDrawMask() { return _debugDrawMask; }
|
||||
|
||||
protected:
|
||||
static PhysicsWorld* construct(Scene& scene);
|
||||
bool init(Scene& scene);
|
||||
static PhysicsWorld* construct(Layer& layer);
|
||||
bool init(Layer& layer);
|
||||
|
||||
virtual void addBody(PhysicsBody* body);
|
||||
virtual void addShape(PhysicsShape* shape);
|
||||
|
@ -180,7 +180,7 @@ protected:
|
|||
|
||||
Vector<PhysicsBody*> _bodies;
|
||||
std::list<PhysicsJoint*> _joints;
|
||||
Scene* _scene;
|
||||
Layer* _layer;
|
||||
|
||||
bool _delayDirty;
|
||||
PhysicsDebugDraw* _debugDraw;
|
||||
|
@ -198,7 +198,7 @@ protected:
|
|||
|
||||
friend class Node;
|
||||
friend class Sprite;
|
||||
friend class Scene;
|
||||
friend class Layer;
|
||||
friend class PhysicsBody;
|
||||
friend class PhysicsShape;
|
||||
friend class PhysicsJoint;
|
||||
|
|
|
@ -137,11 +137,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -153,7 +148,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Button] getContentSize
|
||||
-- @function [parent=#Button] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -73,11 +73,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -89,7 +84,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#CheckBox] getContentSize
|
||||
-- @function [parent=#CheckBox] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -50,11 +50,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -66,7 +61,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ImageView] getContentSize
|
||||
-- @function [parent=#ImageView] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -137,12 +137,6 @@
|
|||
-- @param self
|
||||
-- @return color3B_table#color3B_table ret (return value: color3B_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Layout] hitTest
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Layout] setBackGroundImageScale9Enabled
|
||||
-- @param self
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#LoadingBar] getContentSize
|
||||
-- @function [parent=#LoadingBar] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
-- @param self
|
||||
-- @param #ccui.RichElement richelement
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] formatText
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] ignoreContentAdaptWithSize
|
||||
-- @param self
|
||||
|
@ -34,9 +30,8 @@
|
|||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] getContentSize
|
||||
-- @function [parent=#RichText] formatText
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- overload function: removeElement(ccui.RichElement)
|
||||
|
@ -57,6 +52,11 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] RichText
|
||||
-- @param self
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Slider] getContentSize
|
||||
-- @function [parent=#Slider] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -95,11 +95,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -111,7 +106,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Text] getContentSize
|
||||
-- @function [parent=#Text] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] adaptRenderers
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] setStringValue
|
||||
-- @param self
|
||||
|
@ -41,11 +45,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -57,7 +56,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextAtlas] getContentSize
|
||||
-- @function [parent=#TextAtlas] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -50,7 +45,7 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextBMFont] getContentSize
|
||||
-- @function [parent=#TextBMFont] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -184,11 +184,6 @@
|
|||
-- @param self
|
||||
-- @return Ref#Ref ret (return value: cc.Ref)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] setAnchorPoint
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] getVirtualRenderer
|
||||
-- @param self
|
||||
|
@ -205,7 +200,7 @@
|
|||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextField] getContentSize
|
||||
-- @function [parent=#TextField] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
|
|
|
@ -63,11 +63,6 @@
|
|||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getActionTag
|
||||
-- @param self
|
||||
-- @return int#int ret (return value: int)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getLayoutParameter
|
||||
-- @param self
|
||||
|
@ -100,15 +95,20 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getVirtualRendererSize
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isTouchEnabled
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getContentSize
|
||||
-- @function [parent=#Widget] getActionTag
|
||||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
-- @return int#int ret (return value: int)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getWorldPosition
|
||||
|
|
|
@ -1 +1 @@
|
|||
877f92ef1788ddee60729373e99035e25a6cdb5c
|
||||
b3b8c850b5895cbdb53da07310323c031c8b66c0
|
|
@ -1 +1 @@
|
|||
a1f2ceee65fe7b4bdae2cd2c32ff84fa332a6b50
|
||||
088e9951d4f001122370379060141d0e98b5a4d8
|
|
@ -365,7 +365,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // __cocos2dx_ui_h__
|
||||
|
|
|
@ -1 +1 @@
|
|||
468c9e8472db4be2923ca63484bc72ba2a30ae88
|
||||
c6021dd4f0d5fbfab61453c2a5f045f4f789a18d
|
|
@ -74,7 +74,7 @@ tolua_lerror:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
||||
int lua_cocos2dx_physics_PhysicsWorld_getLayer(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::PhysicsWorld* cobj = nullptr;
|
||||
|
@ -93,7 +93,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'", NULL);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_getLayer'", NULL);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -103,7 +103,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cocos2d::Scene& ret = cobj->getScene();
|
||||
cocos2d::Layer& ret = cobj->getLayer();
|
||||
do {
|
||||
|
||||
std::string hashName = typeid(ret).name();
|
||||
|
@ -112,7 +112,7 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
if(iter != g_luaType.end()){
|
||||
className = iter->second.c_str();
|
||||
} else {
|
||||
className = "cc.Scene";
|
||||
className = "cc.Layer";
|
||||
}
|
||||
|
||||
int ID = (int)(ret._ID);
|
||||
|
@ -122,12 +122,12 @@ int lua_cocos2dx_physics_PhysicsWorld_getScene(lua_State* tolua_S)
|
|||
}while (0);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getScene",argc, 0);
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getLayer",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getScene'.",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_getLayer'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -1573,8 +1573,8 @@ int register_all_cocos2dx_physics_manual(lua_State* tolua_S)
|
|||
lua_rawget(tolua_S, LUA_REGISTRYINDEX);
|
||||
if (lua_istable(tolua_S,-1))
|
||||
{
|
||||
lua_pushstring(tolua_S,"getScene");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_getScene );
|
||||
lua_pushstring(tolua_S,"getLayer");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_getLayer );
|
||||
lua_rawset(tolua_S,-3);
|
||||
lua_pushstring(tolua_S,"queryPoint");
|
||||
lua_pushcfunction(tolua_S, lua_cocos2dx_physics_PhysicsWorld_queryPoint );
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
--Encapsulate SimpleAudioEngine to AudioEngine,Play music and sound effects.
|
||||
local M = {}
|
||||
local audioEngineInstance = cc.SimpleAudioEngine:getInstance()
|
||||
|
||||
function M.stopAllEffects()
|
||||
audioEngineInstance:stopAllEffects()
|
||||
cc.SimpleAudioEngine:getInstance():stopAllEffects()
|
||||
end
|
||||
|
||||
function M.getMusicVolume()
|
||||
return audioEngineInstance:getMusicVolume()
|
||||
return cc.SimpleAudioEngine:getInstance():getMusicVolume()
|
||||
end
|
||||
|
||||
function M.isMusicPlaying()
|
||||
return audioEngineInstance:isMusicPlaying()
|
||||
return cc.SimpleAudioEngine:getInstance():isMusicPlaying()
|
||||
end
|
||||
|
||||
function M.getEffectsVolume()
|
||||
return audioEngineInstance:getEffectsVolume()
|
||||
return cc.SimpleAudioEngine:getInstance():getEffectsVolume()
|
||||
end
|
||||
|
||||
function M.setMusicVolume(volume)
|
||||
audioEngineInstance:setMusicVolume(volume)
|
||||
cc.SimpleAudioEngine:getInstance():setMusicVolume(volume)
|
||||
end
|
||||
|
||||
function M.stopEffect(handle)
|
||||
audioEngineInstance:stopEffect(handle)
|
||||
cc.SimpleAudioEngine:getInstance():stopEffect(handle)
|
||||
end
|
||||
|
||||
function M.stopMusic(isReleaseData)
|
||||
|
@ -31,7 +30,7 @@ function M.stopMusic(isReleaseData)
|
|||
if nil ~= isReleaseData then
|
||||
releaseDataValue = isReleaseData
|
||||
end
|
||||
audioEngineInstance:stopMusic(releaseDataValue)
|
||||
cc.SimpleAudioEngine:getInstance():stopMusic(releaseDataValue)
|
||||
end
|
||||
|
||||
function M.playMusic(filename, isLoop)
|
||||
|
@ -39,19 +38,19 @@ function M.playMusic(filename, isLoop)
|
|||
if nil ~= isLoop then
|
||||
loopValue = isLoop
|
||||
end
|
||||
audioEngineInstance:playMusic(filename, loopValue)
|
||||
cc.SimpleAudioEngine:getInstance():playMusic(filename, loopValue)
|
||||
end
|
||||
|
||||
function M.pauseAllEffects()
|
||||
audioEngineInstance:pauseAllEffects()
|
||||
cc.SimpleAudioEngine:getInstance():pauseAllEffects()
|
||||
end
|
||||
|
||||
function M.preloadMusic(filename)
|
||||
audioEngineInstance:preloadMusic(filename)
|
||||
cc.SimpleAudioEngine:getInstance():preloadMusic(filename)
|
||||
end
|
||||
|
||||
function M.resumeMusic()
|
||||
audioEngineInstance:resumeMusic()
|
||||
cc.SimpleAudioEngine:getInstance():resumeMusic()
|
||||
end
|
||||
|
||||
function M.playEffect(filename, isLoop)
|
||||
|
@ -59,43 +58,51 @@ function M.playEffect(filename, isLoop)
|
|||
if nil ~= isLoop then
|
||||
loopValue = isLoop
|
||||
end
|
||||
return audioEngineInstance:playEffect(filename, loopValue)
|
||||
return cc.SimpleAudioEngine:getInstance():playEffect(filename, loopValue)
|
||||
end
|
||||
|
||||
function M.rewindMusic()
|
||||
audioEngineInstance:rewindMusic()
|
||||
cc.SimpleAudioEngine:getInstance():rewindMusic()
|
||||
end
|
||||
|
||||
function M.willPlayMusic()
|
||||
return audioEngineInstance:willPlayMusic()
|
||||
return cc.SimpleAudioEngine:getInstance():willPlayMusic()
|
||||
end
|
||||
|
||||
function M.unloadEffect(filename)
|
||||
audioEngineInstance:unloadEffect(filename)
|
||||
cc.SimpleAudioEngine:getInstance():unloadEffect(filename)
|
||||
end
|
||||
|
||||
function M.preloadEffect(filename)
|
||||
audioEngineInstance:preloadEffect(filename)
|
||||
cc.SimpleAudioEngine:getInstance():preloadEffect(filename)
|
||||
end
|
||||
|
||||
function M.setEffectsVolume(volume)
|
||||
audioEngineInstance:setEffectsVolume(volume)
|
||||
cc.SimpleAudioEngine:getInstance():setEffectsVolume(volume)
|
||||
end
|
||||
|
||||
function M.pauseEffect(handle)
|
||||
audioEngineInstance:pauseEffect(handle)
|
||||
cc.SimpleAudioEngine:getInstance():pauseEffect(handle)
|
||||
end
|
||||
|
||||
function M.resumeAllEffects(handle)
|
||||
audioEngineInstance:resumeAllEffects()
|
||||
cc.SimpleAudioEngine:getInstance():resumeAllEffects()
|
||||
end
|
||||
|
||||
function M.pauseMusic()
|
||||
audioEngineInstance:pauseMusic()
|
||||
cc.SimpleAudioEngine:getInstance():pauseMusic()
|
||||
end
|
||||
|
||||
function M.resumeEffect(handle)
|
||||
audioEngineInstance:resumeEffect(handle)
|
||||
cc.SimpleAudioEngine:getInstance():resumeEffect(handle)
|
||||
end
|
||||
|
||||
function M.getInstance()
|
||||
return cc.SimpleAudioEngine:getInstance()
|
||||
end
|
||||
|
||||
function M.destroyInstance()
|
||||
return cc.SimpleAudioEngine:destroyInstance()
|
||||
end
|
||||
|
||||
local modename = "AudioEngine"
|
||||
|
|
|
@ -414,8 +414,8 @@ _G.BRIGHT_HIGHLIGHT = ccui.BrightStyle.highlight
|
|||
_G.WidgetTypeWidget = ccui.WidgetType.widget
|
||||
_G.WidgetTypeContainer = ccui.WidgetType.container
|
||||
|
||||
_G.UI_TEX_TYPE_LOCAL = ccui.TextureResType.UI_TEX_TYPE_LOCAL
|
||||
_G.UI_TEX_TYPE_PLIST = ccui.TextureResType.UI_TEX_TYPE_PLIST
|
||||
_G.UI_TEX_TYPE_LOCAL = ccui.TextureResType.localType
|
||||
_G.UI_TEX_TYPE_PLIST = ccui.TextureResType.plistType
|
||||
|
||||
_G.TOUCH_EVENT_BEGAN = ccui.TouchEventType.began
|
||||
_G.TOUCH_EVENT_MOVED = ccui.TouchEventType.moved
|
||||
|
@ -449,15 +449,15 @@ _G.SCROLLVIEW_DIR_VERTICAL = ccui.ScrollViewDir.vertical
|
|||
_G.SCROLLVIEW_DIR_HORIZONTAL = ccui.ScrollViewDir.horizontal
|
||||
_G.SCROLLVIEW_DIR_BOTH = ccui.ScrollViewDir.both
|
||||
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.SCROLL_TO_TOP
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.SCROLL_TO_BOTTOM
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.SCROLL_TO_LEFT
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.SCROLL_TO_RIGHT
|
||||
_G.SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.SCROLLING
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.BOUNCE_TOP
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.BOUNCE_BOTTOM
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.BOUNCE_LEFT
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.BOUNCE_RIGHT
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_TOP = ccui.ScrollviewEventType.scrollToTop
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM = ccui.ScrollviewEventType.scrollToBottom
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_LEFT = ccui.ScrollviewEventType.scrollToLeft
|
||||
_G.SCROLLVIEW_EVENT_SCROLL_TO_RIGHT = ccui.ScrollviewEventType.scrollToRight
|
||||
_G.SCROLLVIEW_EVENT_SCROLLING = ccui.ScrollviewEventType.scrolling
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_TOP = ccui.ScrollviewEventType.bounceTop
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_BOTTOM = ccui.ScrollviewEventType.bounceBottom
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_LEFT = ccui.ScrollviewEventType.bounceLeft
|
||||
_G.SCROLLVIEW_EVENT_BOUNCE_RIGHT = ccui.ScrollviewEventType.bounceRight
|
||||
|
||||
_G.PAGEVIEW_EVENT_TURNING = ccui.PageViewEventType.turning
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#if CC_USE_PHYSICS
|
||||
#include "CCPhysicsBody.h"
|
||||
#endif
|
||||
#include "CCScene.h"
|
||||
#include "CCLayer.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -95,27 +95,24 @@ void ProtectedNode::addProtectedChild(Node *child, int zOrder, int tag)
|
|||
|
||||
this->insertProtectedChild(child, zOrder);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
if (child->getPhysicsBody() != nullptr)
|
||||
{
|
||||
child->getPhysicsBody()->setPosition(this->convertToWorldSpace(child->getPosition()));
|
||||
}
|
||||
|
||||
for (Node* node = this->getParent(); node != nullptr; node = node->getParent())
|
||||
{
|
||||
if (dynamic_cast<Scene*>(node) != nullptr)
|
||||
{
|
||||
(dynamic_cast<Scene*>(node))->addChildToPhysicsWorld(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
child->setTag(tag);
|
||||
|
||||
child->setParent(this);
|
||||
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
// Recursive add children with which have physics body.
|
||||
for (Node* node = this; node != nullptr; node = node->getParent())
|
||||
{
|
||||
Layer* layer = dynamic_cast<Layer*>(node);
|
||||
if (layer != nullptr && layer->getPhysicsWorld() != nullptr)
|
||||
{
|
||||
layer->addChildToPhysicsWorld(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( _running )
|
||||
{
|
||||
child->onEnter();
|
||||
|
|
|
@ -63,7 +63,10 @@ _pressedTextureScaleXInSize(1.0f),
|
|||
_pressedTextureScaleYInSize(1.0f),
|
||||
_normalTextureLoaded(false),
|
||||
_pressedTextureLoaded(false),
|
||||
_disabledTextureLoaded(false)
|
||||
_disabledTextureLoaded(false),
|
||||
_normalTextureAdaptDirty(true),
|
||||
_pressedTextureAdaptDirty(true),
|
||||
_disabledTextureAdaptDirty(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -253,12 +256,12 @@ void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
|
|||
}
|
||||
}
|
||||
_normalTextureSize = _buttonNormalRenderer->getContentSize();
|
||||
normalTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonNormalRenderer);
|
||||
updateContentSizeWithTextureSize(_normalTextureSize);
|
||||
_normalTextureLoaded = true;
|
||||
_normalTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::loadTexturePressed(const std::string& selected,TextureResType texType)
|
||||
|
@ -301,12 +304,11 @@ void Button::loadTexturePressed(const std::string& selected,TextureResType texTy
|
|||
}
|
||||
}
|
||||
_pressedTextureSize = _buttonClickedRenderer->getContentSize();
|
||||
pressedTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonDisableRenderer);
|
||||
_pressedTextureLoaded = true;
|
||||
_pressedTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType)
|
||||
|
@ -349,12 +351,11 @@ void Button::loadTextureDisabled(const std::string& disabled,TextureResType texT
|
|||
}
|
||||
}
|
||||
_disabledTextureSize = _buttonDisableRenderer->getContentSize();
|
||||
disabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_buttonDisableRenderer);
|
||||
_disabledTextureLoaded = true;
|
||||
_disabledTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::setCapInsets(const Rect &capInsets)
|
||||
|
@ -516,25 +517,41 @@ void Button::updateFlippedY()
|
|||
static_cast<Sprite*>(_buttonDisableRenderer)->setFlippedY(_flippedY);
|
||||
}
|
||||
}
|
||||
|
||||
void Button::setAnchorPoint(const Point &pt)
|
||||
|
||||
void Button::updateTitleLocation()
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_buttonNormalRenderer->setAnchorPoint(pt);
|
||||
_buttonClickedRenderer->setAnchorPoint(pt);
|
||||
_buttonDisableRenderer->setAnchorPoint(pt);
|
||||
_titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
|
||||
_titleRenderer->setPosition(Point(_contentSize.width * 0.5f, _contentSize.height * 0.5f));
|
||||
}
|
||||
|
||||
void Button::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
normalTextureScaleChangedWithSize();
|
||||
pressedTextureScaleChangedWithSize();
|
||||
disabledTextureScaleChangedWithSize();
|
||||
updateTitleLocation();
|
||||
_normalTextureAdaptDirty = true;
|
||||
_pressedTextureAdaptDirty = true;
|
||||
_disabledTextureAdaptDirty = true;
|
||||
}
|
||||
|
||||
void Button::adaptRenderers()
|
||||
{
|
||||
if (_normalTextureAdaptDirty)
|
||||
{
|
||||
normalTextureScaleChangedWithSize();
|
||||
_normalTextureAdaptDirty = false;
|
||||
}
|
||||
if (_pressedTextureAdaptDirty)
|
||||
{
|
||||
pressedTextureScaleChangedWithSize();
|
||||
_pressedTextureAdaptDirty = false;
|
||||
}
|
||||
if (_disabledTextureAdaptDirty)
|
||||
{
|
||||
disabledTextureScaleChangedWithSize();
|
||||
_disabledTextureAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& Button::getContentSize() const
|
||||
const Size& Button::getVirtualRendererSize() const
|
||||
{
|
||||
return _normalTextureSize;
|
||||
}
|
||||
|
@ -567,7 +584,6 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
{
|
||||
_buttonNormalRenderer->setScale(1.0f);
|
||||
_normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f;
|
||||
_size = _normalTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -593,6 +609,7 @@ void Button::normalTextureScaleChangedWithSize()
|
|||
_normalTextureScaleYInSize = scaleY;
|
||||
}
|
||||
}
|
||||
_buttonNormalRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::pressedTextureScaleChangedWithSize()
|
||||
|
@ -628,6 +645,7 @@ void Button::pressedTextureScaleChangedWithSize()
|
|||
_pressedTextureScaleYInSize = scaleY;
|
||||
}
|
||||
}
|
||||
_buttonClickedRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::disabledTextureScaleChangedWithSize()
|
||||
|
@ -659,6 +677,7 @@ void Button::disabledTextureScaleChangedWithSize()
|
|||
_buttonDisableRenderer->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
_buttonDisableRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void Button::setPressedActionEnabled(bool enabled)
|
||||
|
|
|
@ -146,9 +146,6 @@ public:
|
|||
|
||||
const Rect& getCapInsetsDisabledRenderer();
|
||||
|
||||
//override "setAnchorPoint" of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Sets if button is using scale9 renderer.
|
||||
*
|
||||
|
@ -168,8 +165,8 @@ public:
|
|||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -212,6 +209,8 @@ protected:
|
|||
void disabledTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
void updateTitleLocation();
|
||||
protected:
|
||||
Node* _buttonNormalRenderer;
|
||||
Node* _buttonClickedRenderer;
|
||||
|
@ -240,6 +239,9 @@ protected:
|
|||
bool _normalTextureLoaded;
|
||||
bool _pressedTextureLoaded;
|
||||
bool _disabledTextureLoaded;
|
||||
bool _normalTextureAdaptDirty;
|
||||
bool _pressedTextureAdaptDirty;
|
||||
bool _disabledTextureAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,12 @@ _backGroundFileName(""),
|
|||
_backGroundSelectedFileName(""),
|
||||
_frontCrossFileName(""),
|
||||
_backGroundDisabledFileName(""),
|
||||
_frontCrossDisabledFileName("")
|
||||
_frontCrossDisabledFileName(""),
|
||||
_backGroundBoxRendererAdaptDirty(true),
|
||||
_backGroundSelectedBoxRendererAdaptDirty(true),
|
||||
_frontCrossRendererAdaptDirty(true),
|
||||
_backGroundBoxDisabledRendererAdaptDirty(true),
|
||||
_frontCrossDisabledRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -178,11 +183,11 @@ void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResTyp
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundBoxRenderer);
|
||||
updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize());
|
||||
_backGroundBoxRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
|
||||
|
@ -204,11 +209,10 @@ void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelect
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
|
||||
_backGroundSelectedBoxRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType)
|
||||
|
@ -230,11 +234,10 @@ void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType tex
|
|||
default:
|
||||
break;
|
||||
}
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_frontCrossRenderer);
|
||||
_frontCrossRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType)
|
||||
|
@ -256,11 +259,10 @@ void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabl
|
|||
default:
|
||||
break;
|
||||
}
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_backGroundBoxDisabledRenderer);
|
||||
_backGroundBoxDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
|
||||
|
@ -282,11 +284,10 @@ void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabl
|
|||
default:
|
||||
break;
|
||||
}
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_frontCrossDisabledRenderer);
|
||||
_frontCrossDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::onTouchEnded(Touch *touch, Event *unusedEvent)
|
||||
|
@ -396,27 +397,46 @@ void CheckBox::updateFlippedY()
|
|||
_frontCrossDisabledRenderer->setFlippedY(_flippedY);
|
||||
}
|
||||
|
||||
void CheckBox::setAnchorPoint(const Point &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_backGroundBoxRenderer->setAnchorPoint(pt);
|
||||
_backGroundSelectedBoxRenderer->setAnchorPoint(pt);
|
||||
_backGroundBoxDisabledRenderer->setAnchorPoint(pt);
|
||||
_frontCrossRenderer->setAnchorPoint(pt);
|
||||
_frontCrossDisabledRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void CheckBox::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
_backGroundBoxRendererAdaptDirty = true;
|
||||
_backGroundSelectedBoxRendererAdaptDirty = true;
|
||||
_frontCrossRendererAdaptDirty = true;
|
||||
_backGroundBoxDisabledRendererAdaptDirty = true;
|
||||
_frontCrossDisabledRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void CheckBox::adaptRenderers()
|
||||
{
|
||||
if (_backGroundBoxRendererAdaptDirty)
|
||||
{
|
||||
backGroundTextureScaleChangedWithSize();
|
||||
_backGroundBoxRendererAdaptDirty = false;
|
||||
}
|
||||
if (_backGroundSelectedBoxRendererAdaptDirty)
|
||||
{
|
||||
backGroundSelectedTextureScaleChangedWithSize();
|
||||
_backGroundSelectedBoxRendererAdaptDirty = false;
|
||||
}
|
||||
if (_frontCrossRendererAdaptDirty)
|
||||
{
|
||||
frontCrossTextureScaleChangedWithSize();
|
||||
_frontCrossRendererAdaptDirty = false;
|
||||
}
|
||||
if (_backGroundBoxDisabledRendererAdaptDirty)
|
||||
{
|
||||
backGroundDisabledTextureScaleChangedWithSize();
|
||||
_backGroundBoxDisabledRendererAdaptDirty = false;
|
||||
}
|
||||
if (_frontCrossDisabledRendererAdaptDirty)
|
||||
{
|
||||
frontCrossDisabledTextureScaleChangedWithSize();
|
||||
_frontCrossDisabledRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& CheckBox::getContentSize() const
|
||||
const Size& CheckBox::getVirtualRendererSize() const
|
||||
{
|
||||
return _backGroundBoxRenderer->getContentSize();
|
||||
}
|
||||
|
@ -431,7 +451,6 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
|
|||
if (_ignoreSize)
|
||||
{
|
||||
_backGroundBoxRenderer->setScale(1.0f);
|
||||
_size = _backGroundBoxRenderer->getContentSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -446,6 +465,7 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
|
|||
_backGroundBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
|
||||
|
@ -467,6 +487,7 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
|
|||
_backGroundSelectedBoxRenderer->setScaleX(scaleX);
|
||||
_backGroundSelectedBoxRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundSelectedBoxRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::frontCrossTextureScaleChangedWithSize()
|
||||
|
@ -488,6 +509,7 @@ void CheckBox::frontCrossTextureScaleChangedWithSize()
|
|||
_frontCrossRenderer->setScaleX(scaleX);
|
||||
_frontCrossRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_frontCrossRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
|
||||
|
@ -509,6 +531,7 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
|
|||
_backGroundBoxDisabledRenderer->setScaleX(scaleX);
|
||||
_backGroundBoxDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_backGroundBoxDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
|
||||
|
@ -530,6 +553,7 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
|
|||
_frontCrossDisabledRenderer->setScaleX(scaleX);
|
||||
_frontCrossDisabledRenderer->setScaleY(scaleY);
|
||||
}
|
||||
_frontCrossDisabledRenderer->setPosition(Point(_contentSize.width / 2, _contentSize.height / 2));
|
||||
}
|
||||
|
||||
std::string CheckBox::getDescription() const
|
||||
|
|
|
@ -164,8 +164,6 @@ public:
|
|||
*/
|
||||
bool getSelectedState();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
//add a call back function would called when checkbox is selected or unselected.
|
||||
void addEventListenerCheckBox(Ref* target,SEL_SelectedStateEvent selector);
|
||||
|
@ -173,8 +171,8 @@ public:
|
|||
//override "onTouchEnded" method of widget.
|
||||
virtual void onTouchEnded(Touch *touch, Event *unusedEvent);
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -213,6 +211,7 @@ protected:
|
|||
void frontCrossDisabledTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
Sprite* _backGroundBoxRenderer;
|
||||
Sprite* _backGroundSelectedBoxRenderer;
|
||||
|
@ -235,6 +234,12 @@ protected:
|
|||
std::string _frontCrossFileName;
|
||||
std::string _backGroundDisabledFileName;
|
||||
std::string _frontCrossDisabledFileName;
|
||||
|
||||
bool _backGroundBoxRendererAdaptDirty;
|
||||
bool _backGroundSelectedBoxRendererAdaptDirty;
|
||||
bool _frontCrossRendererAdaptDirty;
|
||||
bool _backGroundBoxDisabledRendererAdaptDirty;
|
||||
bool _frontCrossDisabledRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ _capInsets(Rect::ZERO),
|
|||
_imageRenderer(nullptr),
|
||||
_textureFile(""),
|
||||
_imageTexType(UI_TEX_TYPE_LOCAL),
|
||||
_imageTextureSize(_size)
|
||||
_imageTextureSize(_size),
|
||||
_imageRendererAdaptDirty(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -150,11 +151,11 @@ void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
|
|||
break;
|
||||
}
|
||||
_imageTextureSize = _imageRenderer->getContentSize();
|
||||
imageTextureScaleChangedWithSize();
|
||||
updateAnchorPoint();
|
||||
updateFlippedX();
|
||||
updateFlippedY();
|
||||
updateRGBAToRenderer(_imageRenderer);
|
||||
updateContentSizeWithTextureSize(_imageTextureSize);
|
||||
_imageRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void ImageView::setTextureRect(const Rect &rect)
|
||||
|
@ -257,20 +258,23 @@ const Rect& ImageView::getCapInsets()
|
|||
{
|
||||
return _capInsets;
|
||||
}
|
||||
|
||||
void ImageView::setAnchorPoint(const Point &pt)
|
||||
{
|
||||
Widget::setAnchorPoint(pt);
|
||||
_imageRenderer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
void ImageView::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
imageTextureScaleChangedWithSize();
|
||||
_imageRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void ImageView::adaptRenderers()
|
||||
{
|
||||
if (_imageRendererAdaptDirty)
|
||||
{
|
||||
imageTextureScaleChangedWithSize();
|
||||
_imageRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
const Size& ImageView::getContentSize() const
|
||||
const Size& ImageView::getVirtualRendererSize() const
|
||||
{
|
||||
return _imageTextureSize;
|
||||
}
|
||||
|
@ -287,7 +291,6 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
if (!_scale9Enabled)
|
||||
{
|
||||
_imageRenderer->setScale(1.0f);
|
||||
_size = _imageTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -310,6 +313,7 @@ void ImageView::imageTextureScaleChangedWithSize()
|
|||
_imageRenderer->setScaleY(scaleY);
|
||||
}
|
||||
}
|
||||
_imageRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
std::string ImageView::getDescription() const
|
||||
|
|
|
@ -99,9 +99,6 @@ public:
|
|||
|
||||
const Rect& getCapInsets();
|
||||
|
||||
//override "setAnchorPoint" method of widget.
|
||||
virtual void setAnchorPoint(const Point &pt) override;
|
||||
|
||||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
|
@ -110,7 +107,7 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
virtual const Size& getContentSize() const override;
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
|
@ -129,6 +126,7 @@ protected:
|
|||
void imageTextureScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
bool _scale9Enabled;
|
||||
bool _prevIgnoreSize;
|
||||
|
@ -137,6 +135,7 @@ protected:
|
|||
std::string _textureFile;
|
||||
TextureResType _imageTexType;
|
||||
Size _imageTextureSize;
|
||||
bool _imageRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -700,24 +700,14 @@ bool Layout::isClippingEnabled()
|
|||
{
|
||||
return _clippingEnabled;
|
||||
}
|
||||
|
||||
bool Layout::hitTest(const Point &pt)
|
||||
{
|
||||
Point nsp = convertToNodeSpace(pt);
|
||||
Rect bb = Rect(0.0f, 0.0f, _size.width, _size.height);
|
||||
if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Layout::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
|
||||
{
|
||||
if (!_enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
adaptRenderers();
|
||||
if (_clippingEnabled)
|
||||
{
|
||||
switch (_clippingType)
|
||||
|
@ -1075,7 +1065,6 @@ const Rect& Layout::getClippingRect()
|
|||
void Layout::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
setContentSize(_size);
|
||||
setStencilClippingSize(_size);
|
||||
_doLayoutDirty = true;
|
||||
_clippingRectDirty = true;
|
||||
|
|
|
@ -265,9 +265,7 @@ public:
|
|||
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
|
||||
virtual bool hitTest(const Point &pt);
|
||||
|
||||
|
||||
CC_CONSTRUCTOR_ACCESS:
|
||||
//override "init" method of widget.
|
||||
virtual bool init() override;
|
||||
|
|
|
@ -43,7 +43,8 @@ _barRendererTextureSize(Size::ZERO),
|
|||
_scale9Enabled(false),
|
||||
_prevIgnoreSize(true),
|
||||
_capInsets(Rect::ZERO),
|
||||
_textureFile("")
|
||||
_textureFile(""),
|
||||
_barRendererAdaptDirty(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -175,7 +176,9 @@ int LoadingBar::getDirection()
|
|||
}
|
||||
break;
|
||||
}
|
||||
barRendererScaleChangedWithSize();
|
||||
// barRendererScaleChangedWithSize();
|
||||
updateContentSizeWithTextureSize(_barRendererTextureSize);
|
||||
_barRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void LoadingBar::setScale9Enabled(bool enabled)
|
||||
|
@ -265,7 +268,16 @@ int LoadingBar::getPercent()
|
|||
void LoadingBar::onSizeChanged()
|
||||
{
|
||||
Widget::onSizeChanged();
|
||||
barRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
void LoadingBar::adaptRenderers()
|
||||
{
|
||||
if (_barRendererAdaptDirty)
|
||||
{
|
||||
barRendererScaleChangedWithSize();
|
||||
_barRendererAdaptDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadingBar::ignoreContentAdaptWithSize(bool ignore)
|
||||
|
@ -277,7 +289,7 @@ void LoadingBar::ignoreContentAdaptWithSize(bool ignore)
|
|||
}
|
||||
}
|
||||
|
||||
const Size& LoadingBar::getContentSize() const
|
||||
const Size& LoadingBar::getVirtualRendererSize() const
|
||||
{
|
||||
return _barRendererTextureSize;
|
||||
}
|
||||
|
@ -295,7 +307,6 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
{
|
||||
_totalLength = _barRendererTextureSize.width;
|
||||
_barRenderer->setScale(1.0f);
|
||||
_size = _barRendererTextureSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -323,10 +334,10 @@ void LoadingBar::barRendererScaleChangedWithSize()
|
|||
switch (_barType)
|
||||
{
|
||||
case LoadingBarTypeLeft:
|
||||
_barRenderer->setPosition(Point(-_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Point(0.0f, _contentSize.height / 2.0f));
|
||||
break;
|
||||
case LoadingBarTypeRight:
|
||||
_barRenderer->setPosition(Point(_totalLength * 0.5f, 0.0f));
|
||||
_barRenderer->setPosition(Point(_totalLength, _contentSize.height / 2.0f));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -128,8 +128,8 @@ public:
|
|||
//override "ignoreContentAdaptWithSize" method of widget.
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore) override;
|
||||
|
||||
//override "getContentSize" method of widget.
|
||||
virtual const Size& getContentSize() const override;
|
||||
//override "getVirtualRendererSize" method of widget.
|
||||
virtual const Size& getVirtualRendererSize() const override;
|
||||
|
||||
//override "getVirtualRenderer" method of widget.
|
||||
virtual Node* getVirtualRenderer() override;
|
||||
|
@ -148,6 +148,7 @@ protected:
|
|||
void barRendererScaleChangedWithSize();
|
||||
virtual Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
virtual void adaptRenderers() override;
|
||||
protected:
|
||||
LoadingBarType _barType;
|
||||
int _percent;
|
||||
|
@ -159,6 +160,7 @@ protected:
|
|||
bool _prevIgnoreSize;
|
||||
Rect _capInsets;
|
||||
std::string _textureFile;
|
||||
bool _barRendererAdaptDirty;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -211,12 +211,11 @@ void RichText::formatText()
|
|||
if (FileUtils::getInstance()->isFileExist(elmtText->_fontName))
|
||||
{
|
||||
elementRenderer = Label::createWithTTF(elmtText->_text.c_str(), elmtText->_fontName, elmtText->_fontSize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
elementRenderer = Label::createWithSystemFont(elmtText->_text.c_str(), elmtText->_fontName, elmtText->_fontSize);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case RICH_IMAGE:
|
||||
|
@ -428,13 +427,15 @@ void RichText::formarRenderers()
|
|||
|
||||
if (_ignoreSize)
|
||||
{
|
||||
Size s = getContentSize();
|
||||
Size s = getVirtualRendererSize();
|
||||
_size = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
_size = _customSize;
|
||||
}
|
||||
updateContentSizeWithTextureSize(_size);
|
||||
_elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||
}
|
||||
|
||||
void RichText::pushToContainer(cocos2d::Node *renderer)
|
||||
|
@ -466,7 +467,7 @@ void RichText::setAnchorPoint(const Point &pt)
|
|||
_elementRenderersContainer->setAnchorPoint(pt);
|
||||
}
|
||||
|
||||
const Size& RichText::getContentSize() const
|
||||
const Size& RichText::getVirtualRendererSize() const
|
||||
{
|
||||
return _elementRenderersContainer->getContentSize();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue