Merge branch 'develop' into develop_nutty_modify_framework_fixedupdatebugs

This commit is contained in:
CaiWenzhi 2014-01-14 14:52:29 +08:00
commit 9ecc1309d9
42 changed files with 675 additions and 449 deletions

View File

@ -33,6 +33,12 @@ NS_CC_BEGIN
//
// CameraAction
//
ActionCamera::ActionCamera()
{
kmVec3Fill(&_center, 0, 0, 0);
kmVec3Fill(&_eye, 0, 0, FLT_EPSILON);
kmVec3Fill(&_up, 0, 1, 0);
}
void ActionCamera::startWithTarget(Node *target)
{
ActionInterval::startWithTarget(target);
@ -54,53 +60,39 @@ ActionCamera * ActionCamera::reverse() const
void ActionCamera::restore()
{
_eyeX = _eyeY = 0.0f;
_eyeZ = FLT_EPSILON;
kmVec3Fill(&_center, 0, 0, 0);
kmVec3Fill(&_eye, 0, 0, FLT_EPSILON);
kmVec3Fill(&_up, 0, 1, 0);
}
_centerX = _centerY = _centerZ = 0.0f;
_upX = 0.0f;
_upY = 1.0f;
_upZ = 0.0f;
void ActionCamera::setEye(const kmVec3& eye)
{
_eye = eye;
updateTransform();
}
void ActionCamera::setEye(float x, float y, float z)
{
_eyeX = x;
_eyeY = y;
_eyeZ = z;
kmVec3Fill(&_eye, x, y, z);
updateTransform();
}
void ActionCamera::setCenter(float centerX, float centerY, float centerZ)
void ActionCamera::setCenter(const kmVec3& center)
{
_centerX = centerX;
_centerY = centerY;
_centerZ = centerZ;
_center = center;
updateTransform();
}
void ActionCamera::setUp(float upX, float upY, float upZ)
void ActionCamera::setUp(const kmVec3& up)
{
_upX = upX;
_upY = upY;
_upZ = upZ;
_up = up;
updateTransform();
}
void ActionCamera::updateTransform()
{
kmVec3 eye, center, up;
kmVec3Fill(&eye, _eyeX, _eyeY , _eyeZ);
kmVec3Fill(&center, _centerX, _centerY, _centerZ);
kmVec3Fill(&up, _upX, _upY, _upZ);
kmMat4 lookupMatrix;
kmMat4LookAt(&lookupMatrix, &eye, &center, &up);
kmMat4LookAt(&lookupMatrix, &_eye, &_center, &_up);
Point anchorPoint = _target->getAnchorPointInPoints();
@ -199,9 +191,9 @@ void OrbitCamera::update(float dt)
float za = _radZ + _radDeltaZ * dt;
float xa = _radX + _radDeltaX * dt;
float i = sinf(za) * cosf(xa) * r + _centerX;
float j = sinf(za) * sinf(xa) * r + _centerY;
float k = cosf(za) * r + _centerZ;
float i = sinf(za) * cosf(xa) * r + _center.x;
float j = sinf(za) * sinf(xa) * r + _center.y;
float k = cosf(za) * r + _center.z;
setEye(i,j,k);
}
@ -211,9 +203,9 @@ void OrbitCamera::sphericalRadius(float *newRadius, float *zenith, float *azimut
float r; // radius
float s;
float x = _eyeX - _centerX;
float y = _eyeY - _centerY;
float z = _eyeZ - _centerZ;
float x = _eye.x - _center.x;
float y = _eye.y - _center.y;
float z = _eye.z - _center.z;
r = sqrtf( powf(x,2) + powf(y,2) + powf(z,2));
s = sqrtf( powf(x,2) + powf(y,2));

View File

@ -50,17 +50,7 @@ public:
/**
* @js ctor
*/
ActionCamera()
:_centerX(0)
,_centerY(0)
,_centerZ(0)
,_eyeX(0)
,_eyeY(0)
,_eyeZ(FLT_EPSILON)
,_upX(0)
,_upY(1)
,_upZ(0)
{}
ActionCamera();
/**
* @js NA
* @lua NA
@ -72,23 +62,28 @@ public:
virtual ActionCamera * reverse() const override;
virtual ActionCamera *clone() const override;
/* sets the Eye value of the Camera */
void setEye(const kmVec3 &eye);
void setEye(float x, float y, float z);
/* returns the Eye value of the Camera */
const kmVec3& getEye() const { return _eye; }
/* sets the Center value of the Camera */
void setCenter(const kmVec3 &center);
/* returns the Center value of the Camera */
const kmVec3& getCenter() const { return _center; }
/* sets the Up value of the Camera */
void setUp(const kmVec3 &up);
/* Returns the Up value of the Camera */
const kmVec3& getUp() const { return _up; }
protected:
void restore();
void setEye(float x, float y, float z);
void setCenter(float x, float y, float z);
void setUp(float x, float y, float z);
void updateTransform();
float _centerX;
float _centerY;
float _centerZ;
float _eyeX;
float _eyeY;
float _eyeZ;
float _upX;
float _upY;
float _upZ;
kmVec3 _center;
kmVec3 _eye;
kmVec3 _up;
};
/**

View File

@ -61,6 +61,7 @@ THE SOFTWARE.
#include "CCEventCustom.h"
#include "CCFontFreeType.h"
#include "CCRenderer.h"
#include "CCConsole.h"
#include "renderer/CCFrustum.h"
/**
Position of the FPS
@ -116,9 +117,6 @@ bool Director::init(void)
_scenesStack.reserve(15);
// projection delegate if "Custom" projection is used
_projectionDelegate = nullptr;
// FPS
_accumDt = 0.0f;
_frameRate = 0.0f;
@ -163,8 +161,8 @@ bool Director::init(void)
//init TextureCache
initTextureCache();
// Renderer
_renderer = new Renderer;
_console = new Console;
// create autorelease pool
PoolManager::sharedPoolManager()->push();
@ -192,6 +190,7 @@ Director::~Director(void)
delete _eventProjectionChanged;
delete _renderer;
delete _console;
// pop the autorelease pool
PoolManager::sharedPoolManager()->pop();
@ -483,9 +482,8 @@ void Director::setProjection(Projection projection)
}
case Projection::CUSTOM:
if (_projectionDelegate)
_projectionDelegate->updateProjection();
// Projection Delegate is no longer needed
// since the event "PROJECTION CHANGED" is emitted
break;
default:
@ -973,11 +971,6 @@ void Director::createStatsLabel()
_FPSLabel->setPosition(CC_DIRECTOR_STATS_POSITION);
}
float Director::getContentScaleFactor() const
{
return _contentScaleFactor;
}
void Director::setContentScaleFactor(float scaleFactor)
{
if (scaleFactor != _contentScaleFactor)
@ -987,11 +980,6 @@ void Director::setContentScaleFactor(float scaleFactor)
}
}
Node* Director::getNotificationNode()
{
return _notificationNode;
}
void Director::setNotificationNode(Node *node)
{
CC_SAFE_RELEASE(_notificationNode);
@ -999,16 +987,6 @@ void Director::setNotificationNode(Node *node)
CC_SAFE_RETAIN(_notificationNode);
}
DirectorDelegate* Director::getDelegate() const
{
return _projectionDelegate;
}
void Director::setDelegate(DirectorDelegate* delegate)
{
_projectionDelegate = delegate;
}
void Director::setScheduler(Scheduler* scheduler)
{
if (_scheduler != scheduler)
@ -1019,11 +997,6 @@ void Director::setScheduler(Scheduler* scheduler)
}
}
Scheduler* Director::getScheduler() const
{
return _scheduler;
}
void Director::setActionManager(ActionManager* actionManager)
{
if (_actionManager != actionManager)
@ -1034,16 +1007,6 @@ void Director::setActionManager(ActionManager* actionManager)
}
}
ActionManager* Director::getActionManager() const
{
return _actionManager;
}
EventDispatcher* Director::getEventDispatcher() const
{
return _eventDispatcher;
}
void Director::setEventDispatcher(EventDispatcher* dispatcher)
{
if (_eventDispatcher != dispatcher)
@ -1054,12 +1017,6 @@ void Director::setEventDispatcher(EventDispatcher* dispatcher)
}
}
Renderer* Director::getRenderer() const
{
return _renderer;
}
/***************************************************
* implementation of DisplayLinkDirector
**************************************************/

View File

@ -60,6 +60,7 @@ class EventListenerCustom;
class TextureCache;
class Frustum;
class Renderer;
class Console;
/**
@brief Class that creates and handles the main Window and manages how
@ -186,21 +187,9 @@ public:
Useful to hook a notification object, like Notifications (http://github.com/manucorporat/CCNotifications)
@since v0.99.5
*/
Node* getNotificationNode();
Node* getNotificationNode() const { return _notificationNode; }
void setNotificationNode(Node *node);
/** Director delegate. It shall implement the DirectorDelegate protocol
@since v0.99.5
* @js NA
* @lua NA
*/
DirectorDelegate* getDelegate() const;
/**
* @js NA
* @lua NA
*/
void setDelegate(DirectorDelegate* delegate);
// window size
/** returns the size of the OpenGL view in points.
@ -340,7 +329,7 @@ public:
@since v0.99.4
*/
void setContentScaleFactor(float scaleFactor);
float getContentScaleFactor() const;
float getContentScaleFactor() const { return _contentScaleFactor; }
/**
Get the Culling Frustum
@ -351,7 +340,7 @@ public:
/** Gets the Scheduler associated with this director
@since v2.0
*/
Scheduler* getScheduler() const;
Scheduler* getScheduler() const { return _scheduler; }
/** Sets the Scheduler associated with this director
@since v2.0
@ -361,7 +350,7 @@ public:
/** Gets the ActionManager associated with this director
@since v2.0
*/
ActionManager* getActionManager() const;
ActionManager* getActionManager() const { return _actionManager; }
/** Sets the ActionManager associated with this director
@since v2.0
@ -371,7 +360,7 @@ public:
/** Gets the EventDispatcher associated with this director
@since v3.0
*/
EventDispatcher* getEventDispatcher() const;
EventDispatcher* getEventDispatcher() const { return _eventDispatcher; }
/** Sets the EventDispatcher associated with this director
@since v3.0
@ -381,7 +370,12 @@ public:
/** Returns the Renderer
@since v3.0
*/
Renderer* getRenderer() const;
Renderer* getRenderer() const { return _renderer; }
/** Returns the Console
@since v3.0
*/
Console* getConsole() const { return _console; }
/* Gets delta time since last tick to main loop */
float getDeltaTime() const;
@ -492,11 +486,12 @@ protected:
/* This object will be visited after the scene. Useful to hook a notification node */
Node *_notificationNode;
/* Projection protocol delegate */
DirectorDelegate *_projectionDelegate;
/* Renderer for the Director */
Renderer *_renderer;
/* Console for the director */
Console *_console;
// EGLViewProtocol will recreate stats labels to fit visible rect
friend class EGLViewProtocol;
};

View File

@ -569,16 +569,11 @@ void LayerColor::draw()
_customCommand.func = CC_CALLBACK_0(LayerColor::onDraw, this);
Director::getInstance()->getRenderer()->addCommand(&_customCommand);
kmMat4 p, mvp;
kmGLGetMatrix(KM_GL_PROJECTION, &p);
kmGLGetMatrix(KM_GL_MODELVIEW, &mvp);
kmMat4Multiply(&mvp, &p, &mvp);
for(int i = 0; i < 4; ++i)
{
kmVec3 pos;
pos.x = _squareVertices[i].x; pos.y = _squareVertices[i].y; pos.z = _vertexZ;
kmVec3TransformCoord(&pos, &pos, &mvp);
kmVec3TransformCoord(&pos, &pos, &_modelViewTransform);
_noMVPVertices[i] = Vertex3F(pos.x,pos.y,pos.z);
}

View File

@ -103,7 +103,7 @@ Node::Node(void)
, _anchorPointInPoints(Point::ZERO)
, _anchorPoint(Point::ZERO)
, _contentSize(Size::ZERO)
, _additionalTransformDirty(false)
, _useAdditionalTransform(false)
, _transformDirty(true)
, _inverseDirty(true)
// children (lazy allocs)
@ -1189,10 +1189,9 @@ const kmMat4& Node::getNodeToParentTransform() const
// vertex Z
_transform.mat[14] = _vertexZ;
if (_additionalTransformDirty)
if (_useAdditionalTransform)
{
kmMat4Multiply(&_transform, &_transform, &_additionalTransform);
_additionalTransformDirty = false;
}
_transformDirty = false;
@ -1211,14 +1210,14 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
{
CGAffineToGL(additionalTransform, _additionalTransform.mat);
_transformDirty = true;
_additionalTransformDirty = true;
_useAdditionalTransform = true;
}
void Node::setAdditionalTransform(const kmMat4& additionalTransform)
{
_additionalTransform = additionalTransform;
_transformDirty = true;
_additionalTransformDirty = true;
_useAdditionalTransform = true;
}

View File

@ -1266,7 +1266,9 @@ public:
Point convertTouchToNodeSpaceAR(Touch * touch) const;
/**
* Sets the additional transform.
* Sets an additional transform matrix to the node.
*
* In order to remove it, set the Identity Matrix to the additional transform.
*
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
@ -1289,7 +1291,7 @@ public:
spriteA->setPosition(Point(200, 200));
// Gets the spriteA's transform.
AffineTransform t = spriteA->getNodeToParentTransform();
auto t = spriteA->getNodeToParentTransform();
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
spriteB->setAdditionalTransform(t);
@ -1421,12 +1423,13 @@ protected:
Size _contentSize; ///< untransformed size of the node
kmMat4 _modelViewTransform; ///< ModelView transform of the Node.
// "cache" variables are allowed to be mutable
mutable kmMat4 _additionalTransform; ///< transform
mutable kmMat4 _transform; ///< transform
mutable kmMat4 _inverse; ///< inverse transform
kmMat4 _modelViewTransform; ///< ModelView transform of the Node.
mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty
bool _useAdditionalTransform; ///< The flag to check whether the additional transform is dirty
mutable bool _transformDirty; ///< transform dirty flag
mutable bool _inverseDirty; ///< inverse transform dirty flag

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#define _USE_MATH_DEFINES
#endif
#include "platform/CCCommon.h"
#include "CCConsole.h"
#include "CCStdC.h"
#ifndef CCASSERT

View File

@ -25,6 +25,7 @@
#include "ccUTF8.h"
#include "platform/CCCommon.h"
#include "CCConsole.h"
NS_CC_BEGIN

View File

@ -35,14 +35,6 @@ NS_CC_BEGIN
* @{
*/
/// The max length of CCLog message.
static const int kMaxLogLen = 16*1024;
/**
@brief Output Debug message.
*/
void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
/**
* lua can not deal with ...
*/

View File

@ -33,28 +33,6 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
va_list args;
va_start(args, pszFormat);
__android_log_vprint(ANDROID_LOG_DEBUG, "cocos2d-x debug info", pszFormat, args);
va_end(args);
}
void log(const char * pszFormat, ...)
{
char buf[MAX_LEN];
va_list args;
va_start(args, pszFormat);
vsnprintf(buf, MAX_LEN, pszFormat, args);
va_end(args);
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
}
void MessageBox(const char * pszMsg, const char * pszTitle)
{
showDialogJNI(pszMsg, pszTitle);

View File

@ -29,34 +29,11 @@
#include <stdio.h>
#import <UIKit/UIAlert.h>
#include "CCDirector.h"
#include "CCConsole.h"
NS_CC_BEGIN
// XXX deprecated
void CCLog(const char * format, ...)
{
printf("cocos2d: ");
char buf[kMaxLogLen+1] = {0};
va_list ap;
va_start(ap, format);
vsnprintf(buf, kMaxLogLen, format, ap);
va_end(ap);
printf("%s", buf);
printf("\n");
}
void log(const char * format, ...)
{
printf("cocos2d: ");
char buf[kMaxLogLen+1] = {0};
va_list ap;
va_start(ap, format);
vsnprintf(buf, kMaxLogLen, format, ap);
va_end(ap);
printf("%s", buf);
printf("\n");
}
// ios no MessageBox, use log instead
void MessageBox(const char * msg, const char * title)
{

View File

@ -24,60 +24,18 @@ THE SOFTWARE.
****************************************************************************/
#include "platform/CCCommon.h"
#include "CCStdC.h"
#include "CCConsole.h"
NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
void MessageBox(const char * msg, const char * title)
{
char szBuf[MAX_LEN];
va_list ap;
va_start(ap, pszFormat);
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
log("%s: %s", title, msg);
}
void log(const char * pszFormat, ...)
void LuaLog(const char * format)
{
char szBuf[MAX_LEN];
va_list ap;
va_start(ap, pszFormat);
vsnprintf(szBuf, MAX_LEN, pszFormat, ap);
va_end(ap);
// Strip any trailing newlines from log message.
size_t len = strlen(szBuf);
while (len && szBuf[len-1] == '\n')
{
szBuf[len-1] = '\0';
len--;
}
fprintf(stderr, "cocos2d-x debug info [%s]\n", szBuf);
}
void MessageBox(const char * pszMsg, const char * pszTitle)
{
log("%s: %s", pszTitle, pszMsg);
}
void LuaLog(const char * pszFormat)
{
puts(pszFormat);
puts(format);
}
NS_CC_END

View File

@ -33,36 +33,6 @@ THE SOFTWARE.
NS_CC_BEGIN
// XXX deprecated
void CCLog(const char * format, ...)
{
printf("Cocos2d: ");
char buf[kMaxLogLen];
va_list ap;
va_start(ap, format);
vsnprintf(buf, kMaxLogLen, format, ap);
va_end(ap);
printf("%s", buf);
printf("\n");
fflush(stdout);
}
void log(const char * format, ...)
{
printf("Cocos2d: ");
char buf[kMaxLogLen];
va_list ap;
va_start(ap, format);
vsnprintf(buf, kMaxLogLen, format, ap);
va_end(ap);
printf("%s", buf);
printf("\n");
fflush(stdout);
}
void LuaLog(const char * format)
{
puts(format);

View File

@ -29,43 +29,6 @@ NS_CC_BEGIN
#define MAX_LEN (cocos2d::kMaxLogLen + 1)
// XXX deprecated
void CCLog(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
va_list ap;
va_start(ap, pszFormat);
vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap);
va_end(ap);
WCHAR wszBuf[MAX_LEN] = {0};
MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf));
OutputDebugStringW(wszBuf);
OutputDebugStringA("\n");
WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE);
printf("%s\n", szBuf);
}
void log(const char * pszFormat, ...)
{
char szBuf[MAX_LEN];
va_list ap;
va_start(ap, pszFormat);
vsnprintf_s(szBuf, MAX_LEN, MAX_LEN, pszFormat, ap);
va_end(ap);
WCHAR wszBuf[MAX_LEN] = {0};
MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf));
OutputDebugStringW(wszBuf);
OutputDebugStringA("\n");
WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE);
printf("%s\n", szBuf);
}
void MessageBox(const char * pszMsg, const char * pszTitle)
{
MessageBoxA(NULL, pszMsg, pszTitle, MB_OK);

View File

@ -23,7 +23,7 @@
****************************************************************************/
#include "CCFrustum.h"
#include "platform/CCCommon.h"
#include "CCConsole.h"
#include <stdlib.h>

View File

@ -49,6 +49,7 @@
#include "CCDirector.h"
#include "CCScheduler.h"
#include "CCScene.h"
#include "CCPlatformConfig.h"
NS_CC_BEGIN
@ -108,43 +109,94 @@ static const char* inet_ntop(int af, const void* src, char* dst, int cnt)
}
#endif
//
// Free functions to log
//
// XXX: Deprecated
void CCLog(const char * format, ...)
{
va_list args;
va_start(args, format);
log(format, args);
va_end(args);
}
void log(const char * format, ...)
{
va_list args;
va_start(args, format);
log(format, args);
va_end(args);
}
void log(const char *format, va_list args)
{
char buf[MAX_LOG_LENGTH];
vsnprintf(buf, MAX_LOG_LENGTH-3, format, args);
strcat(buf, "\n");
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "%s", buf);
#elif CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
WCHAR wszBuf[MAX_LOG_LENGTH] = {0};
MultiByteToWideChar(CP_UTF8, 0, szBuf, -1, wszBuf, sizeof(wszBuf));
OutputDebugStringW(wszBuf);
OutputDebugStringA("\n");
WideCharToMultiByte(CP_ACP, 0, wszBuf, sizeof(wszBuf), szBuf, sizeof(szBuf), NULL, FALSE);
printf("%s\n", szBuf);
#else
// Linux, Mac, iOS, etc
fprintf(stdout, "cocos2d: %s", buf);
fflush(stdout);
#endif
Director::getInstance()->getConsole()->log(buf);
}
//
// Console code
//
Console* Console::create()
{
auto ret = new Console;
ret->autorelease();
return ret;
}
Console::Console()
: _listenfd(-1)
, _running(false)
, _endThread(false)
, _maxCommands(5)
, _userCommands(nullptr)
, _maxUserCommands(0)
, _sendDebugStrings(false)
{
// VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'.
Command commands[] = {
{ "fps on", [](int fd, const char* command) {
Director *dir = Director::getInstance();
Scheduler *sched = dir->getScheduler();
sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true));
} },
{ "fps off", [](int fd, const char* command) {
Director *dir = Director::getInstance();
Scheduler *sched = dir->getScheduler();
sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false));
} },
{ "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) },
{ "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) },
{ "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) } };
{ "debug msg on", [&](int fd, const char* command) {
_sendDebugStrings = true;
} },
{ "debug msg off", [&](int fd, const char* command) {
_sendDebugStrings = false;
} },
{ "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) },
{ "fps on", [](int fd, const char* command) {
Director *dir = Director::getInstance();
Scheduler *sched = dir->getScheduler();
sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true));
} },
{ "fps off", [](int fd, const char* command) {
Director *dir = Director::getInstance();
Scheduler *sched = dir->getScheduler();
sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false));
} },
{ "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) },
{ "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) },
};
for (size_t i = 0; i < sizeof(commands)/sizeof(commands[0]) && i < sizeof(_commands)/sizeof(_commands[0]); ++i)
_maxCommands = sizeof(commands)/sizeof(commands[0]);
for (int i = 0; i < _maxCommands; ++i)
{
_commands[i] = commands[i];
}
@ -152,7 +204,7 @@ Console::Console()
Console::~Console()
{
cancel();
stop();
}
bool Console::listenOnTCP(int port)
@ -206,14 +258,14 @@ bool Console::listenOnTCP(int port)
char buf[INET_ADDRSTRLEN] = "";
struct sockaddr_in *sin = (struct sockaddr_in*) res->ai_addr;
if( inet_ntop(res->ai_family, &sin->sin_addr, buf, sizeof(buf)) != NULL )
log("Console: listening on %s : %d", buf, ntohs(sin->sin_port));
cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin_port));
else
perror("inet_ntop");
} else if (res->ai_family == AF_INET6) {
char buf[INET6_ADDRSTRLEN] = "";
struct sockaddr_in6 *sin = (struct sockaddr_in6*) res->ai_addr;
if( inet_ntop(res->ai_family, &sin->sin6_addr, buf, sizeof(buf)) != NULL )
log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port));
cocos2d::log("Console: listening on %s : %d", buf, ntohs(sin->sin6_port));
else
perror("inet_ntop");
}
@ -226,14 +278,18 @@ bool Console::listenOnTCP(int port)
bool Console::listenOnFileDescriptor(int fd)
{
CCASSERT(!_running, "already running");
if(_running) {
cocos2d::log("Console already started. 'stop' it before calling 'listen' again");
return false;
}
_listenfd = fd;
_thread = std::thread( std::bind( &Console::loop, this) );
return true;
}
void Console::cancel()
void Console::stop()
{
if( _running ) {
_endThread = true;
@ -312,7 +368,7 @@ bool Console::parseCommand(int fd)
}
}
if(!found) {
if(!found && strcmp(_buffer, "\r\n")!=0) {
const char err[] = "Unknown command. Type 'help' for options\n";
write(fd, err, sizeof(err));
}
@ -376,6 +432,15 @@ void Console::addClient()
}
}
void Console::log(const char* buf)
{
if( _sendDebugStrings ) {
_DebugStringsMutex.lock();
_DebugStrings.push_back(buf);
_DebugStringsMutex.unlock();
}
}
//
// Main Loop
//
@ -402,40 +467,55 @@ void Console::loop()
timeout_copy = timeout;
int nready = select(_maxfd+1, &copy_set, NULL, NULL, &timeout_copy);
if( nready == -1 ) {
/* error ?*/
if( nready == -1 )
{
/* error */
if(errno != EINTR)
log("Abnormal error in select()\n");
continue;
} else if( nready == 0 ) {
/* timeout ? */
continue;
}
// new client
if(FD_ISSET(_listenfd, &copy_set)) {
addClient();
if(--nready <= 0)
continue;
else if( nready == 0 )
{
/* timeout. do somethig ? */
}
// data from client
std::vector<int> to_remove;
for(const auto &fd: _fds) {
if(FD_ISSET(fd,&copy_set)) {
if( ! parseCommand(fd) ) {
to_remove.push_back(fd);
}
else
{
/* new client */
if(FD_ISSET(_listenfd, &copy_set)) {
addClient();
if(--nready <= 0)
break;
continue;
}
/* data from client */
std::vector<int> to_remove;
for(const auto &fd: _fds) {
if(FD_ISSET(fd,&copy_set)) {
if( ! parseCommand(fd) ) {
to_remove.push_back(fd);
}
if(--nready <= 0)
break;
}
}
/* remove closed conections */
for(int fd: to_remove) {
FD_CLR(fd, &_read_set);
_fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end());
}
}
// remove closed conections
for(int fd: to_remove) {
FD_CLR(fd, &_read_set);
_fds.erase(std::remove(_fds.begin(), _fds.end(), fd), _fds.end());
/* Any message for the remote console ? send it! */
if( !_DebugStrings.empty() ) {
_DebugStringsMutex.lock();
for(const auto &str : _DebugStrings) {
for(const auto &fd : _fds) {
write(fd, str.c_str(), str.length());
}
}
_DebugStrings.clear();
_DebugStringsMutex.unlock();
}
}

View File

@ -28,6 +28,7 @@
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <BaseTsd.h>
#include <WinSock2.h>
//typedef SSIZE_T ssize_t;
// ssize_t was redefined as int in libwebsockets.h.
// Therefore, to avoid conflict, we needs the same definition.
@ -39,13 +40,26 @@ typedef int ssize_t;
#include <thread>
#include <vector>
#include <functional>
#include <string>
#include <mutex>
#include <stdarg.h>
#include "ccMacros.h"
#include "CCObject.h"
#include "CCPlatformMacros.h"
NS_CC_BEGIN
/// The max length of CCLog message.
static const int MAX_LOG_LENGTH = 16*1024;
/**
@brief Output Debug message.
*/
void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
void CC_DLL log(const char * format, va_list args);
/** Console is helper class that lets the developer control the game from TCP connection.
Console will spawn a new thread that will listen to a specified TCP port.
Console has a basic token parser. Each token is associated with an std::function<void(int)>.
@ -55,17 +69,19 @@ NS_CC_BEGIN
scheduler->performFunctionInCocosThread( ... );
```
*/
class CC_DLL Console : public Object
class CC_DLL Console
{
public:
struct Command {
const char *name;
std::function<void(int, const char*)> callback;
};
/** creates a new instnace of the Console */
static Console* create();
/** Constructor */
Console();
/** Destructor */
virtual ~Console();
/** starts listening to specifed TCP port */
bool listenOnTCP(int port);
@ -73,18 +89,17 @@ public:
/** starts listening to specifed file descriptor */
bool listenOnFileDescriptor(int fd);
/** cancels the Console. Cancel will be called at destruction time as well */
void cancel();
/** stops the Console. 'stop' will be called at destruction time as well */
void stop();
/** sets user tokens */
void setUserCommands( Command* commands, int numberOfCommands);
/** log something in the console */
void log(const char *buf);
protected:
Console();
virtual ~Console();
void loop();
ssize_t readline(int fd);
bool parseCommand(int fd);
void sendPrompt(int fd);
@ -108,11 +123,17 @@ protected:
char _buffer[512];
struct Command _commands[15];
struct Command _commands[64];
int _maxCommands;
struct Command *_userCommands;
int _maxUserCommands;
// strings generated by cocos2d sent to the remote console
bool _sendDebugStrings;
std::mutex _DebugStringsMutex;
std::vector<std::string> _DebugStrings;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Console);
};

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#include "CCDataVisitor.h"
#include "ccMacros.h"
#include "CCConsole.h"
#ifdef EMSCRIPTEN
#include <GLES2/gl2.h>

@ -1 +1 @@
Subproject commit f893f6202c6f249f52660876278a1742ba12aefa
Subproject commit f41186e7ef4209597d8c81952c3535b02305a79c

View File

@ -200,12 +200,12 @@ void js_log(const char *format, ...) {
if (_js_log_buf == NULL)
{
_js_log_buf = (char *)calloc(sizeof(char), kMaxLogLen+1);
_js_log_buf[kMaxLogLen] = '\0';
_js_log_buf = (char *)calloc(sizeof(char), MAX_LOG_LENGTH+1);
_js_log_buf[MAX_LOG_LENGTH] = '\0';
}
va_list vl;
va_start(vl, format);
int len = vsnprintf(_js_log_buf, kMaxLogLen, format, vl);
int len = vsnprintf(_js_log_buf, MAX_LOG_LENGTH, format, vl);
va_end(vl);
if (len > 0)
{

View File

@ -19,10 +19,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
#include "CCPhysicsSprite.h"
#if defined(CC_ENABLE_CHIPMUNK_INTEGRATION) && defined(CC_ENABLE_BOX2D_INTEGRATION)
#if (CC_ENABLE_CHIPMUNK_INTEGRATION && CC_ENABLE_BOX2D_INTEGRATION)
#error "Either Chipmunk or Box2d should be enabled, but not both at the same time"
#endif
@ -406,3 +407,4 @@ const kmMat4& PhysicsSprite::getNodeToParentTransform() const
}
NS_CC_EXT_END
#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)

View File

@ -19,6 +19,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#if (CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)
#ifndef __PHYSICSNODES_CCPHYSICSSPRITE_H__
#define __PHYSICSNODES_CCPHYSICSSPRITE_H__
@ -132,3 +134,4 @@ protected:
NS_CC_EXT_END
#endif // __PHYSICSNODES_CCPHYSICSSPRITE_H__
#endif //(CC_ENABLE_CHIPMUNK_INTEGRATION || CC_ENABLE_BOX2D_INTEGRATION)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -82,6 +82,10 @@ bool AppDelegate::applicationDidFinishLaunching()
scene->addChild(layer);
director->runWithScene(scene);
// Enable Remote Console
auto console = director->getConsole();
console->listenOnTCP(5678);
return true;
}

View File

@ -133,13 +133,11 @@ void ConsoleTestScene::runThisTest()
ConsoleTCP::ConsoleTCP()
{
_console = Console::create();
_console->retain();
_console = Director::getInstance()->getConsole();
}
ConsoleTCP::~ConsoleTCP()
{
_console->release();
}
void ConsoleTCP::onEnter()
@ -167,8 +165,7 @@ std::string ConsoleTCP::subtitle() const
ConsoleCustomCommand::ConsoleCustomCommand()
{
_console = Console::create();
_console->retain();
_console = Director::getInstance()->getConsole();
static struct Console::Command commands[] = {
{"hello", [](int fd, const char* command) {
@ -183,7 +180,6 @@ ConsoleCustomCommand::ConsoleCustomCommand()
ConsoleCustomCommand::~ConsoleCustomCommand()
{
_console->release();
}
void ConsoleCustomCommand::onEnter()

View File

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

View File

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

View File

@ -1,3 +1,28 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "NodeTest.h"
#include "../testResource.h"
@ -1021,7 +1046,18 @@ CameraTest2::CameraTest2()
_sprite2->setPosition( Point(3*s.width/4, s.height/2) );
_sprite2->setScale(0.5);
scheduleUpdate();
kmVec3 eye, center, up;
kmVec3Fill(&eye, 150, 0, 200);
kmVec3Fill(&center, 0, 0, 0);
kmVec3Fill(&up, 0, 1, 0);
kmMat4 lookupMatrix;
kmMat4LookAt(&lookupMatrix, &eye, &center, &up);
_sprite1->setAdditionalTransform(lookupMatrix);
_sprite2->setAdditionalTransform(lookupMatrix);
}
std::string CameraTest2::title() const
@ -1034,22 +1070,6 @@ std::string CameraTest2::subtitle() const
return "Both images should look the same";
}
void CameraTest2::update(float dt)
{
kmVec3 eye, center, up;
kmVec3Fill(&eye, 150, 0, 200);
kmVec3Fill(&center, 0, 0, 0);
kmVec3Fill(&up, 0, 1, 0);
kmMat4 lookupMatrix;
kmMat4LookAt(&lookupMatrix, &eye, &center, &up);
_sprite1->setAdditionalTransform(lookupMatrix);
_sprite2->setAdditionalTransform(lookupMatrix);
}
///
/// main
///

View File

@ -1,3 +1,28 @@
/****************************************************************************
Copyright (c) 2012 cocos2d-x.org
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef _NODE_TEST_H_
#define _NODE_TEST_H_
@ -184,7 +209,6 @@ public:
virtual void onExit() override;
protected:
virtual void update(float dt) override;
CameraTest2();
Sprite *_sprite1;

View File

@ -1 +1 @@
e14a3c9f23fccd862ac2ffcba41ee7094ab54981
689b357d7acda141d13a3dfc4cb52aabb274f6cd

View File

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

View File

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

View File

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

View File

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

View File

@ -120,23 +120,23 @@ class TkCocosDialog(Frame):
self.rowconfigure(5, weight=1)
# project name frame
self.labName = Label(self, text="projectName:")
self.labName = Label(self, text="Project Name:")
self.strName = StringVar()
self.strName.set("MyGame")
self.editName = Entry(self, textvariable=self.strName)
self.labName.grid(sticky=W, pady=4, padx=5)
self.editName.grid(row=0, column=1, columnspan=3,padx=5, pady=2,sticky=E+W)
self.editName.grid(row=0, column=1, columnspan=4,padx=5, pady=2,sticky=E+W)
# package name frame
self.labPackage = Label(self, text="packageName:")
self.labPackage = Label(self, text="Package Name:")
self.strPackage=StringVar()
self.strPackage.set("com.MyCompany.AwesomeGame")
self.editPackage = Entry(self, textvariable=self.strPackage)
self.labPackage.grid(row=1, column=0,sticky=W, padx=5)
self.editPackage.grid(row=1, column=1, columnspan=3,padx=5, pady=2,sticky=E+W)
self.editPackage.grid(row=1, column=1, columnspan=4,padx=5, pady=2,sticky=E+W)
# project path frame
self.labPath = Label(self, text="projectPath:")
self.labPath = Label(self, text="Project Path:")
self.editPath = Entry(self)
self.btnPath = Button(self, text="...", width = 6, command = self.pathCallback)
self.labPath.grid(row=2, column=0,sticky=W, pady=4, padx=5)
@ -144,12 +144,12 @@ class TkCocosDialog(Frame):
self.btnPath.grid(row=2, column=4,)
# language frame
self.labLanguage = Label(self, text="language:")
self.labLanguage = Label(self, text="Language:")
self.var=IntVar()
self.var.set(1)
self.checkcpp = Radiobutton(self, text="cpp", variable=self.var, value=1)
self.checklua = Radiobutton(self, text="lua", variable=self.var, value=2)
self.checkjs = Radiobutton(self, text="javascript", variable=self.var, value=3)
self.checkcpp = Radiobutton(self, text="C++", variable=self.var, value=1)
self.checklua = Radiobutton(self, text="Lua", variable=self.var, value=2)
self.checkjs = Radiobutton(self, text="JavaScript", variable=self.var, value=3)
self.labLanguage.grid(row=3, column=0,sticky=W, padx=5)
self.checkcpp.grid(row=3, column=1,sticky=N+W)
self.checklua.grid(row=3, column=2,padx=5,sticky=N+W)
@ -158,12 +158,12 @@ class TkCocosDialog(Frame):
# show progress
self.progress = Scale(self, state= DISABLED, from_=0, to=100, orient=HORIZONTAL)
self.progress.set(0)
self.progress.grid(row=4, column=0, columnspan=4,padx=5, pady=2,sticky=E+W+S+N)
self.progress.grid(row=4, column=0, columnspan=5,padx=5, pady=2,sticky=E+W+S+N)
# msg text frame
self.text=Text(self,background = '#d9efff')
self.text.bind("<KeyPress>", lambda e : "break")
self.text.grid(row=5, column=0, columnspan=4, rowspan=1, padx=5, sticky=E+W+S+N)
self.text.grid(row=5, column=0, columnspan=5, rowspan=1, padx=5, sticky=E+W+S+N)
# new project button
self.btnCreate = Button(self, text="create", command = self.createBtnCallback)
@ -176,7 +176,7 @@ class TkCocosDialog(Frame):
scnHeight = self.parent.winfo_screenheight()
tmpcnf = '%dx%d+%d+%d'%(curWidth, curHeight, int((scnWidth-curWidth)/2), int((scnHeight-curHeight)/2))
self.parent.geometry(tmpcnf)
self.parent.title("CocosCreateProject")
self.parent.title("Cocos Project Creator")
#fix size
#self.parent.maxsize(curWidth, curHeight)