Merge pull request #7309 from mannewalis/v3

changes needed for swift bindings to work
This commit is contained in:
minggo 2014-07-06 17:10:26 +08:00
commit 5ff83d1a2b
6 changed files with 34 additions and 1 deletions

View File

@ -1305,6 +1305,9 @@ Mat4 Node::transform(const Mat4& parentTransform)
void Node::onEnter()
{
if (_onEnterCallback)
_onEnterCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1332,6 +1335,9 @@ void Node::onEnter()
void Node::onEnterTransitionDidFinish()
{
if (_onEnterTransitionDidFinishCallback)
_onEnterTransitionDidFinishCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1354,6 +1360,9 @@ void Node::onEnterTransitionDidFinish()
void Node::onExitTransitionDidStart()
{
if (_onExitTransitionDidStartCallback)
_onExitTransitionDidStartCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1375,6 +1384,9 @@ void Node::onExitTransitionDidStart()
void Node::onExit()
{
if (_onExitCallback)
_onExitCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{

View File

@ -1466,7 +1466,16 @@ public:
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
virtual bool isOpacityModifyRGB() const { return false; };
void setOnEnterCallback(const std::function<void()>& callback) { _onEnterCallback = callback; }
const std::function<void()>& getOnEnterCallback() const { return _onEnterCallback; }
void setOnExitCallback(const std::function<void()>& callback) { _onExitCallback = callback; }
const std::function<void()>& getOnExitCallback() const { return _onExitCallback; }
void setonEnterTransitionDidFinishCallback(const std::function<void()>& callback) { _onEnterTransitionDidFinishCallback = callback; }
const std::function<void()>& getonEnterTransitionDidFinishCallback() const { return _onEnterTransitionDidFinishCallback; }
void setonExitTransitionDidStartCallback(const std::function<void()>& callback) { _onExitTransitionDidStartCallback = callback; }
const std::function<void()>& getonExitTransitionDidStartCallback() const { return _onExitTransitionDidStartCallback; }
CC_CONSTRUCTOR_ACCESS:
// Nodes should be created using create();
Node();
@ -1605,6 +1614,11 @@ protected:
static int s_globalOrderOfArrival;
std::function<void()> _onEnterCallback;
std::function<void()> _onExitCallback;
std::function<void()> _onEnterTransitionDidFinishCallback;
std::function<void()> _onExitTransitionDidStartCallback;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Node);

View File

@ -47,6 +47,7 @@ typedef SSIZE_T ssize_t;
#include <mutex>
#include <stdarg.h>
#include "base/CCRef.h"
#include "base/ccMacros.h"
#include "base/CCPlatformMacros.h"
@ -73,6 +74,7 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
class CC_DLL Console
: public Ref
{
public:
struct Command {

View File

@ -46,6 +46,7 @@ Ref::Ref()
static unsigned int uObjectCount = 0;
_luaID = 0;
_ID = ++uObjectCount;
_scriptObject = nullptr;
#endif
#if CC_USE_MEM_LEAK_DETECTION

View File

@ -142,6 +142,8 @@ public:
unsigned int _ID;
/// Lua reference id
int _luaID;
/// scriptObject, support for swift
void* _scriptObject;
#endif
// Memory leak diagnostic data (only included when CC_USE_MEM_LEAK_DETECTION is defined and its value isn't zero)

View File

@ -33,6 +33,7 @@ THE SOFTWARE.
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "CCGL.h"
#include "CCRef.h"
NS_CC_BEGIN
@ -484,6 +485,7 @@ public:
@brief The device accelerometer reports values for each axis in units of g-force
*/
class Acceleration
: public Ref
{
public:
double x;