diff --git a/CocosDenshion/android/Android.mk b/CocosDenshion/android/Android.mk index 2d59a7e79b..2704964c93 100644 --- a/CocosDenshion/android/Android.mk +++ b/CocosDenshion/android/Android.mk @@ -16,7 +16,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ $(LOCAL_PATH)/../../cocos2dx \ $(LOCAL_PATH)/../../cocos2dx/include \ $(LOCAL_PATH)/../../cocos2dx/kazmath/include \ - $(LOCAL_PATH)/../../cocos2dx/platform/android + $(LOCAL_PATH)/../../cocos2dx/platform/android LOCAL_CFLAGS += -Wno-psabi LOCAL_EXPORT_CFLAGS += -Wno-psabi diff --git a/CocosDenshion/proj.win32/CocosDenshion.vcxproj b/CocosDenshion/proj.win32/CocosDenshion.vcxproj index c5738cf5a2..7a91634027 100644 --- a/CocosDenshion/proj.win32/CocosDenshion.vcxproj +++ b/CocosDenshion/proj.win32/CocosDenshion.vcxproj @@ -65,7 +65,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;"$(ProjectDir)..\..\cocos2dx";"$(ProjectDir)..\..\cocos2dx\include";"$(ProjectDir)..\..\cocos2dx\kazmath\include";"$(ProjectDir)..\..\cocos2dx\platform\win32";"$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES";%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;..\Include;$(ProjectDir)..\..\cocos2dx;$(ProjectDir)..\..\cocos2dx\include;$(ProjectDir)..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks diff --git a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index b299b031e3..1e9cc1e16a 100644 --- a/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -fad913317d2e64eb308c7066f450f3a351ee0aab \ No newline at end of file +29c3c2dfd8b683a800709d085839444c3a304a0d \ No newline at end of file diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 0c54f17697..0033dd4975 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -96,6 +96,21 @@ particle_nodes/CCParticleBatchNode.cpp \ particle_nodes/CCParticleExamples.cpp \ particle_nodes/CCParticleSystem.cpp \ particle_nodes/CCParticleSystemQuad.cpp \ +physics/CCPhysicsBody.cpp \ +physics/CCPhysicsContact.cpp \ +physics/CCPhysicsJoint.cpp \ +physics/CCPhysicsShape.cpp \ +physics/CCPhysicsWorld.cpp \ +physics/Box2D/CCPhysicsBodyInfo.cpp \ +physics/Box2D/CCPhysicsContactInfo.cpp \ +physics/Box2D/CCPhysicsJointInfo.cpp \ +physics/Box2D/CCPhysicsShapeInfo.cpp \ +physics/Box2D/CCPhysicsWorldInfo.cpp \ +physics/chipmunk/CCPhysicsBodyInfo.cpp \ +physics/chipmunk/CCPhysicsContactInfo.cpp \ +physics/chipmunk/CCPhysicsJointInfo.cpp \ +physics/chipmunk/CCPhysicsShapeInfo.cpp \ +physics/chipmunk/CCPhysicsWorldInfo.cpp \ platform/CCEGLViewProtocol.cpp \ platform/CCFileUtils.cpp \ platform/CCSAXParser.cpp \ @@ -149,7 +164,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/platform/third_party/common/etc \ $(LOCAL_PATH)/platform/third_party/common/s3tc \ - $(LOCAL_PATH)/platform/third_party/common/atitc + $(LOCAL_PATH)/platform/third_party/common/atitc \ + $(LOCAL_PATH)/../external/chipmunk/include/chipmunk LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ @@ -157,7 +173,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/platform/android \ $(LOCAL_PATH)/platform/third_party/common/etc \ $(LOCAL_PATH)/platform/third_party/common/s3tc \ - $(LOCAL_PATH)/platform/third_party/common/atitc + $(LOCAL_PATH)/platform/third_party/common/atitc \ + $(LOCAL_PATH)/../external/chipmunk/include/chipmunk LOCAL_LDLIBS := -lGLESv2 \ @@ -176,6 +193,7 @@ LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libwebp_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_freetype2_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static # define the macro to compile through support/zip_support/ioapi.c LOCAL_CFLAGS := -Wno-psabi -DUSE_FILE32API @@ -188,3 +206,4 @@ $(call import-module,libpng) $(call import-module,libtiff) $(call import-module,libwebp) $(call import-module,libfreetype2) +$(call import-module,external/chipmunk) diff --git a/cocos2dx/event_dispatcher/CCEventDispatcher.cpp b/cocos2dx/event_dispatcher/CCEventDispatcher.cpp index cb796bb0a7..c9b6f8718f 100644 --- a/cocos2dx/event_dispatcher/CCEventDispatcher.cpp +++ b/cocos2dx/event_dispatcher/CCEventDispatcher.cpp @@ -58,11 +58,17 @@ private: NS_CC_BEGIN +EventDispatcher::EventListenerItem::~EventListenerItem() +{ + CC_SAFE_RELEASE(this->node); +} + EventDispatcher::EventDispatcher() : _inDispatch(0) , _listeners(nullptr) , _isEnabled(true) { + _toAddedListeners.reserve(50); } EventDispatcher::~EventDispatcher() @@ -82,25 +88,33 @@ void EventDispatcher::addEventListenerWithItem(EventListenerItem* item) _listeners = new std::map*>(); } - std::vector* listenerList = nullptr; - - auto itr = _listeners->find(item->listener->type); - if (itr == _listeners->end()) + if (_inDispatch == 0) { - listenerList = new std::vector(); - listenerList->reserve(100); - _listeners->insert(std::make_pair(item->listener->type, listenerList)); + std::vector* listenerList = nullptr; + + auto itr = _listeners->find(item->listener->type); + if (itr == _listeners->end()) + { + listenerList = new std::vector(); + listenerList->reserve(100); + _listeners->insert(std::make_pair(item->listener->type, listenerList)); + } + else + { + listenerList = itr->second; + } + + listenerList->insert(listenerList->begin(), item); } else { - listenerList = itr->second; + _toAddedListeners.push_back(item); } - - listenerList->insert(listenerList->begin(), item); } void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node) { + CCASSERT(listener && node, "Invalid parameters."); CCASSERT(!listener->_isRegistered, "The listener has been registered."); if (!listener->checkAvaiable()) @@ -108,6 +122,7 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list auto item = new EventListenerItem(); item->node = node; + item->node->retain(); item->fixedPriority = 0; item->listener = listener; item->listener->retain(); @@ -120,6 +135,7 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority) { + CCASSERT(listener, "Invalid parameters."); CCASSERT(!listener->_isRegistered, "The listener has been registered."); CCASSERT(fixedPriority != 0, "0 priority is forbidden for fixed priority since it's used for scene graph based priority."); @@ -141,6 +157,8 @@ void EventDispatcher::removeEventListener(EventListener* listener) if (_listeners == nullptr || listener == nullptr) return; + bool isFound = false; + for (auto iter = _listeners->begin(); iter != _listeners->end();) { for (auto itemIter = iter->second->begin(); itemIter != iter->second->end(); ++itemIter) @@ -158,6 +176,7 @@ void EventDispatcher::removeEventListener(EventListener* listener) (*itemIter)->listener = nullptr; } + isFound = true; break; } } @@ -172,6 +191,9 @@ void EventDispatcher::removeEventListener(EventListener* listener) { ++iter; } + + if (isFound) + break; } if (_listeners->empty()) @@ -193,6 +215,9 @@ void EventDispatcher::setPriorityWithSceneGraph(EventListener* listener, Node* n if (item->listener == listener) { item->fixedPriority = 0; + + CC_SAFE_RETAIN(node); + CC_SAFE_RELEASE(item->node); item->node = node; return; } @@ -216,7 +241,7 @@ void EventDispatcher::setPriorityWithFixedValue(EventListener* listener, int fix if (item->node != nullptr) { item->node->dissociateEventListener(listener); - item->node = nullptr; + CC_SAFE_RELEASE_NULL(item->node); } return; } @@ -259,7 +284,7 @@ void EventDispatcher::dispatchEvent(Event* event, bool toSortListeners) } } - removeUnregisteredListeners(); + updateListenerItems(); } void EventDispatcher::dispatchTouchEvent(TouchEvent* event) @@ -331,7 +356,7 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event) if (touchEventListener->onTouchBegan) { isClaimed = touchEventListener->onTouchBegan(*touchesIter, event); - if (isClaimed) + if (isClaimed && item->listener) { touchEventListener->_claimedTouches.push_back(*touchesIter); } @@ -355,14 +380,20 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event) { touchEventListener->onTouchEnded(*touchesIter, event); } - touchEventListener->_claimedTouches.erase(removedIter); + if (item->listener) + { + touchEventListener->_claimedTouches.erase(removedIter); + } break; case TouchEvent::EventCode::CANCELLED: if (touchEventListener->onTouchCancelled) { touchEventListener->onTouchCancelled(*touchesIter, event); } - touchEventListener->_claimedTouches.erase(removedIter); + if (item->listener) + { + touchEventListener->_claimedTouches.erase(removedIter); + } break; default: CCASSERT(false, "The eventcode is invalid."); @@ -373,13 +404,13 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event) // If the event was stopped, return directly. if (event->isStopped()) { - removeUnregisteredListeners(); + updateListenerItems(); return; } CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(), ""); - if (isClaimed && touchEventListener->_needSwallow) + if (isClaimed && item->listener && touchEventListener->_needSwallow) { if (isNeedsMutableSet) { @@ -444,16 +475,16 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event) // If the event was stopped, return directly. if (event->isStopped()) { - removeUnregisteredListeners(); + updateListenerItems(); return; } } } - removeUnregisteredListeners(); + updateListenerItems(); } -void EventDispatcher::removeUnregisteredListeners() +void EventDispatcher::updateListenerItems() { if (!_listeners) return; @@ -461,17 +492,19 @@ void EventDispatcher::removeUnregisteredListeners() auto listenerItemIter = _listeners->begin(); while (listenerItemIter != _listeners->end()) { - auto removeIterBegin = std::remove_if(listenerItemIter->second->begin(), listenerItemIter->second->end(), [](const EventListenerItem* item){ - return item->listener == nullptr; - }); - - for (auto iter = removeIterBegin; iter != listenerItemIter->second->end(); ++iter) + for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end();) { - delete (*iter); + if ((*iter)->listener == nullptr) + { + delete (*iter); + iter = listenerItemIter->second->erase(iter); + } + else + { + ++iter; + } } - listenerItemIter->second->erase(removeIterBegin, listenerItemIter->second->end()); - if (listenerItemIter->second->empty()) { delete listenerItemIter->second; @@ -483,6 +516,29 @@ void EventDispatcher::removeUnregisteredListeners() } } + if (!_toAddedListeners.empty()) + { + std::vector* listenerList = nullptr; + + for (auto& item : _toAddedListeners) + { + auto itr = _listeners->find(item->listener->type); + if (itr == _listeners->end()) + { + listenerList = new std::vector(); + listenerList->reserve(100); + _listeners->insert(std::make_pair(item->listener->type, listenerList)); + } + else + { + listenerList = itr->second; + } + + listenerList->push_back(item); + } + _toAddedListeners.clear(); + } + if (_listeners->empty()) { delete _listeners; @@ -563,14 +619,22 @@ void EventDispatcher::removeListenersForEventType(const std::string& eventType) for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter) { (*iter)->listener->release(); - delete (*iter); + if (_inDispatch) + { + (*iter)->listener = nullptr; + } + else + { + delete (*iter); + } } - listenerItemIter->second->clear(); - - delete listenerItemIter->second; - - _listeners->erase(listenerItemIter); + if (!_inDispatch) + { + listenerItemIter->second->clear(); + delete listenerItemIter->second; + _listeners->erase(listenerItemIter); + } } } @@ -584,16 +648,28 @@ void EventDispatcher::removeAllListeners() for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter) { (*iter)->listener->release(); - delete (*iter); + if (_inDispatch) + { + (*iter)->listener = nullptr; + } + else + { + delete (*iter); + } } - listenerItemIter->second->clear(); - - delete listenerItemIter->second; + if (!_inDispatch) + { + listenerItemIter->second->clear(); + delete listenerItemIter->second; + } } - delete _listeners; - _listeners = nullptr; + if (!_inDispatch) + { + delete _listeners; + _listeners = nullptr; + } } void EventDispatcher::setEnabled(bool isEnabled) diff --git a/cocos2dx/event_dispatcher/CCEventDispatcher.h b/cocos2dx/event_dispatcher/CCEventDispatcher.h index 621262272b..51aff99973 100644 --- a/cocos2dx/event_dispatcher/CCEventDispatcher.h +++ b/cocos2dx/event_dispatcher/CCEventDispatcher.h @@ -110,6 +110,7 @@ private: int fixedPriority; // The higher the number, the higher the priority Node* node; // Weak reference. EventListener* listener; + ~EventListenerItem(); }; /** Constructor of EventDispatcher */ @@ -127,15 +128,19 @@ private: /** Sorts the listeners of specified type by priority */ void sortAllEventListenerItemsForType(const std::string& eventType); - /** Removes all listeners that have been unregistered. */ - void removeUnregisteredListeners(); + /** Updates all listener items + * 1) Removes all listener items that have been marked as 'removed' when dispatching event. + * 2) Adds all listener items that have been marked as 'added' when dispatching event. + */ + void updateListenerItems(); private: /** * Listeners map. */ std::map*>* _listeners; - + std::vector _toAddedListeners; + int _inDispatch; bool _isEnabled; }; diff --git a/cocos2dx/include/CCDeprecated.h b/cocos2dx/include/CCDeprecated.h index 28aae5f779..0e201a9668 100644 --- a/cocos2dx/include/CCDeprecated.h +++ b/cocos2dx/include/CCDeprecated.h @@ -909,7 +909,6 @@ CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType; #define kCCLabelAutomaticWidth kLabelAutomaticWidth -CC_DEPRECATED_ATTRIBUTE const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY; CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateWaiting = Menu::State::WAITING; CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH; diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 1e4c40d404..2abb121ad7 100644 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -120,6 +120,13 @@ THE SOFTWARE. #include "particle_nodes/CCParticleExamples.h" #include "particle_nodes/CCParticleSystemQuad.h" +// physics +#include "physics/CCPhysicsBody.h" +#include "physics/CCPhysicsContact.h" +#include "physics/CCPhysicsShape.h" +#include "physics/CCPhysicsJoint.h" +#include "physics/CCPhysicsWorld.h" + // platform #include "platform/CCDevice.h" #include "platform/CCCommon.h" diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index fc8dd27d63..564e627c42 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -42,6 +42,7 @@ THE SOFTWARE. #include "event_dispatcher/CCAccelerationEvent.h" #include "event_dispatcher/CCAccelerationEventListener.h" #include "platform/CCDevice.h" +#include "CCScene.h" NS_CC_BEGIN @@ -98,8 +99,13 @@ Layer *Layer::create() /// Touch and Accelerometer related -void Layer::onRegisterTouchListener() -{ +void Layer::addTouchListener() +{ + if (_touchListener != nullptr) + return; + + auto dispatcher = EventDispatcher::getInstance(); + if( _touchMode == Touch::DispatchMode::ALL_AT_ONCE ) { // Register Touch Event @@ -110,7 +116,7 @@ void Layer::onRegisterTouchListener() listener->onTouchesEnded = CC_CALLBACK_2(Layer::onTouchesEnded, this); listener->onTouchesCancelled = CC_CALLBACK_2(Layer::onTouchesCancelled, this); - EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); + dispatcher->addEventListenerWithSceneGraphPriority(listener, this); _touchListener = listener; } else @@ -124,7 +130,7 @@ void Layer::onRegisterTouchListener() listener->onTouchEnded = CC_CALLBACK_2(Layer::onTouchEnded, this); listener->onTouchCancelled = CC_CALLBACK_2(Layer::onTouchCancelled, this); - EventDispatcher::getInstance()->addEventListenerWithSceneGraphPriority(listener, this); + dispatcher->addEventListenerWithSceneGraphPriority(listener, this); _touchListener = listener; } } @@ -170,7 +176,7 @@ void Layer::setTouchEnabled(bool enabled) { if (enabled) { - this->onRegisterTouchListener(); + this->addTouchListener(); } else { @@ -309,7 +315,7 @@ void Layer::onEnter() // since events are propagated in reverse order if (_touchEnabled) { - this->onRegisterTouchListener(); + this->addTouchListener(); } // then iterate over all the children @@ -348,6 +354,7 @@ void Layer::onEnterTransitionDidFinish() if (_accelerometerEnabled) { auto dispatcher = EventDispatcher::getInstance(); + dispatcher->removeEventListener(_accelerationListener); _accelerationListener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this); } @@ -452,6 +459,30 @@ void Layer::onTouchesCancelled(const std::vector& pTouches, Event *pEven CC_UNUSED_PARAM(pEvent); } + +#ifdef CC_USE_PHYSICS +void Layer::addChild(Node* child) +{ + Node::addChild(child); +} + +void Layer::addChild(Node* child, int zOrder) +{ + Node::addChild(child, zOrder); +} + +void Layer::addChild(Node* child, int zOrder, int tag) +{ + Node::addChild(child, zOrder, tag); + + if (this->getParent() && + dynamic_cast(this->getParent()) != nullptr) + { + dynamic_cast(this->getParent())->addChildToPhysicsWorld(child); + } +} +#endif + // LayerRGBA LayerRGBA::LayerRGBA() : _displayedOpacity(255) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index ca75eb3dd0..a6a2296725 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -33,6 +33,7 @@ THE SOFTWARE. #ifdef EMSCRIPTEN #include "base_nodes/CCGLBufferedNode.h" #endif // EMSCRIPTEN +#include "physics/CCPhysicsSetting.h" #include "event_dispatcher/CCKeyboardEvent.h" @@ -113,7 +114,6 @@ public: @since v0.8.0 */ CC_DEPRECATED_ATTRIBUTE virtual void registerWithTouchDispatcher() final {}; - virtual void onRegisterTouchListener(); /** whether or not it will receive Touch events. You can enable / disable touch events with this property. @@ -178,8 +178,16 @@ public: * @lua NA */ virtual void onEnterTransitionDidFinish() override; + +#ifdef CC_USE_PHYSICS + virtual void addChild(Node* child) override; + virtual void addChild(Node* child, int zOrder) override; + virtual void addChild(Node* child, int zOrder, int tag) override; +#endif // CC_USE_PHYSICS protected: + void addTouchListener(); + bool _touchEnabled; bool _accelerometerEnabled; bool _keyboardEnabled; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index 4a144f9b80..36f2947dc6 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -26,10 +26,16 @@ THE SOFTWARE. #include "CCScene.h" #include "CCDirector.h" +#include "CCLayer.h" +#include "sprite_nodes/CCSprite.h" +#include "physics/CCPhysicsWorld.h" NS_CC_BEGIN Scene::Scene() +#ifdef _physicsWorld +: _physicsWorld(nullptr) +#endif { _ignoreAnchorPointForPosition = true; setAnchorPoint(Point(0.5f, 0.5f)); @@ -68,4 +74,95 @@ Scene *Scene::create() } } +#ifdef CC_USE_PHYSICS +Scene *Scene::createWithPhysics() +{ + Scene *pRet = new Scene(); + if (pRet && pRet->initWithPhysics()) + { + pRet->autorelease(); + return pRet; + } + else + { + CC_SAFE_DELETE(pRet); + return NULL; + } +} + +bool Scene::initWithPhysics() +{ + bool bRet = false; + do + { + Director * pDirector; + CC_BREAK_IF( ! (pDirector = Director::getInstance()) ); + this->setContentSize(pDirector->getWinSize()); + CC_BREAK_IF(! (_physicsWorld = PhysicsWorld::create())); + _physicsWorld->setScene(this); + + this->scheduleUpdate(); + // success + bRet = true; + } while (0); + return bRet; +} + +void Scene::addChild(Node* child) +{ + Node::addChild(child); +} + +void Scene::addChild(Node* child, int zOrder) +{ + Node::addChild(child, zOrder); +} + +void Scene::addChild(Node* child, int zOrder, int tag) +{ + Node::addChild(child, zOrder, tag); + + addChildToPhysicsWorld(child); +} + +void Scene::addChildToPhysicsWorld(Node* child) +{ + if (_physicsWorld) + { + auto addToPhysicsWorldFunc = [this](Object* node) -> void + { + if (dynamic_cast(node) != nullptr) + { + Sprite* sp = dynamic_cast(node); + + if (sp->getPhysicsBody()) + { + _physicsWorld->addChild(sp->getPhysicsBody()); + } + } + }; + + if(dynamic_cast(child) != nullptr) + { + Object* subChild = nullptr; + CCARRAY_FOREACH(child->getChildren(), subChild) + { + addToPhysicsWorldFunc(subChild); + } + }else + { + addToPhysicsWorldFunc(child); + } + } +} + +void Scene::update(float delta) +{ + Node::update(delta); + + _physicsWorld->update(delta); +} +#endif + + NS_CC_END diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index f5c46f61ea..24d4b25843 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __CCSCENE_H__ #include "base_nodes/CCNode.h" +#include "physics/CCPhysicsWorld.h" NS_CC_BEGIN @@ -50,7 +51,10 @@ class CC_DLL Scene : public Node { public: /** creates a new Scene object */ - static Scene *create(void); + static Scene *create(); +#ifdef CC_USE_PHYSICS + static Scene *createWithPhysics(); +#endif Scene(); /** @@ -60,7 +64,30 @@ public: virtual ~Scene(); bool init(); - + +#ifdef CC_USE_PHYSICS +public: + bool initWithPhysics(); + + virtual void addChild(Node* child) override; + virtual void addChild(Node* child, int zOrder) override; + virtual void addChild(Node* child, int zOrder, int tag) override; + + /* + * Update method will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" + */ + virtual void update(float delta) override; + + inline PhysicsWorld* getPhysicsWorld() { return _physicsWorld; } + +protected: + virtual void addChildToPhysicsWorld(Node* child); + +protected: + PhysicsWorld* _physicsWorld; +#endif // CC_USE_PHYSICS + + friend class Layer; }; // end of scene group diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 3fc1781baa..966d5ad4f6 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -50,11 +50,6 @@ NS_CC_BEGIN class CC_DLL Menu : public LayerRGBA { public: - enum - { - HANDLER_PRIORITY = -128, - }; - enum class State { WAITING, diff --git a/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.cpp b/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.cpp new file mode 100644 index 0000000000..bfa20b616a --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsBodyInfo.h" + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) +NS_CC_BEGIN + +PhysicsBodyInfo::PhysicsBodyInfo() +{ +} + +PhysicsBodyInfo::~PhysicsBodyInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.h b/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.h new file mode 100644 index 0000000000..730837ed9d --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsBodyInfo.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_BODY_INFO_H__ +#define __CCPHYSICS_BODY_INFO_H__ +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsBodyInfo +{ +public: + PhysicsBodyInfo(); + ~PhysicsBodyInfo(); +}; + +NS_CC_END +#endif // __CCPHYSICS_BODY_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsContactInfo.cpp b/cocos2dx/physics/Box2D/CCPhysicsContactInfo.cpp new file mode 100644 index 0000000000..41eaa4f831 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsContactInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsContactInfo.h" + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) +NS_CC_BEGIN + +PhysicsContactInfo::PhysicsContactInfo() +{ +} + +PhysicsContactInfo::~PhysicsContactInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsContactInfo.h b/cocos2dx/physics/Box2D/CCPhysicsContactInfo.h new file mode 100644 index 0000000000..b592caa0af --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsContactInfo.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_CONTACT_INFO_H__ +#define __CCPHYSICS_CONTACT_INFO_H__ +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsContactInfo +{ +public: + PhysicsContactInfo(); + ~PhysicsContactInfo(); +}; + +NS_CC_END +#endif // __CCPHYSICS_CONTACT_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsHelper.h b/cocos2dx/physics/Box2D/CCPhysicsHelper.h new file mode 100644 index 0000000000..86ef7d74ee --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsHelper.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_HELPER_H__ +#define __CCPHYSICS_HELPER_H__ + +#include "platform/CCPlatformMacros.h" +#include "cocoa/CCGeometry.h" + +NS_CC_BEGIN + +class PhysicsHelper +{ +}; + +NS_CC_END +#endif // __CCPHYSICS_HELPER_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsJointInfo.cpp b/cocos2dx/physics/Box2D/CCPhysicsJointInfo.cpp new file mode 100644 index 0000000000..753ba41534 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsJointInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsJointInfo.h" + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) +NS_CC_BEGIN + +PhysicsJointInfo::PhysicsJointInfo() +{ +} + +PhysicsJointInfo::~PhysicsJointInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsJointInfo.h b/cocos2dx/physics/Box2D/CCPhysicsJointInfo.h new file mode 100644 index 0000000000..abcf089387 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsJointInfo.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_JOINT_INFO_H__ +#define __CCPHYSICS_JOINT_INFO_H__ +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsJointInfo +{ +public: + PhysicsJointInfo(); + ~PhysicsJointInfo(); +}; + +NS_CC_END +#endif // __CCPHYSICS_JOINT_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.cpp b/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.cpp new file mode 100644 index 0000000000..a89ba7dae7 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsShapeInfo.h" + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) +NS_CC_BEGIN + +PhysicsShapeInfo::PhysicsShapeInfo() +{ +} + +PhysicsShapeInfo::~PhysicsShapeInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.h b/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.h new file mode 100644 index 0000000000..9091001887 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsShapeInfo.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_SHAPE_INFO_H__ +#define __CCPHYSICS_SHAPE_INFO_H__ +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsShapeInfo +{ +public: + PhysicsShapeInfo(); + ~PhysicsShapeInfo(); +}; + +NS_CC_END +#endif // __CCPHYSICS_SHAPE_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.cpp b/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.cpp new file mode 100644 index 0000000000..0de6c00d82 --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsWorldInfo.h" + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) +NS_CC_BEGIN + +PhysicsWorldInfo::PhysicsWorldInfo() +{ +} + +PhysicsWorldInfo::~PhysicsWorldInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.h b/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.h new file mode 100644 index 0000000000..bcc09124db --- /dev/null +++ b/cocos2dx/physics/Box2D/CCPhysicsWorldInfo.h @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#ifndef __CCPHYSICS_WORLD_INFO_H__ +#define __CCPHYSICS_WORLD_INFO_H__ +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsWorldInfo +{ +public: + PhysicsWorldInfo(); + ~PhysicsWorldInfo(); +}; + +NS_CC_END +#endif // __CCPHYSICS_WORLD_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D diff --git a/cocos2dx/physics/CCPhysicsBody.cpp b/cocos2dx/physics/CCPhysicsBody.cpp new file mode 100644 index 0000000000..3fb5d485b1 --- /dev/null +++ b/cocos2dx/physics/CCPhysicsBody.cpp @@ -0,0 +1,394 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "CCPhysicsBody.h" +#ifdef CC_USE_PHYSICS + +#include + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include "chipmunk.h" +#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) +#include "Box2D.h" +#endif + +#include "CCPhysicsShape.h" +#include "CCPhysicsJoint.h" +#include "CCPhysicsWorld.h" + +#include "chipmunk/CCPhysicsBodyInfo.h" +#include "Box2D/CCPhysicsBodyInfo.h" +#include "chipmunk/CCPhysicsJointInfo.h" +#include "Box2D/CCPhysicsJointInfo.h" +#include "chipmunk/CCPhysicsWorldInfo.h" +#include "Box2D/CCPhysicsWorldInfo.h" + +#include "chipmunk/CCPhysicsHelper.h" +#include "Box2D/CCPhysicsHelper.h" + +NS_CC_BEGIN + + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +namespace +{ + static const float MASS_DEFAULT = 1.0; + static const float DENSITY_DEFAULT = 1.0; + static const float ANGULARDAMPING_DEFAULT = 200; +} + +PhysicsBody::PhysicsBody() +: _owner(nullptr) +, _world(nullptr) +, _info(nullptr) +, _dynamic(false) +, _massDefault(true) +, _angularDampingDefault(true) +, _mass(MASS_DEFAULT) +, _area(0.0) +, _density(DENSITY_DEFAULT) +, _angularDamping(ANGULARDAMPING_DEFAULT) +{ +} + +PhysicsBody::~PhysicsBody() +{ + CC_SAFE_DELETE(_info); + + for (auto it = _shapes.begin(); it != _shapes.end(); ++it) + { + delete *it; + } + + for (auto it = _joints.begin(); it != _joints.end(); ++it) + { + PhysicsJoint* joint = *it; + PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyA() : joint->getBodyB(); + + other->_joints.erase(std::find(other->_joints.begin(), other->_joints.end(), joint)); + delete joint; + } +} + +PhysicsBody* PhysicsBody::createCircle(float radius) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->init()) + { + body->addCircle(radius); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + return nullptr; +} + +PhysicsBody* PhysicsBody::createBox(Size size) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->init()) + { + body->addBox(size); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + return nullptr; +} + +PhysicsBody* PhysicsBody::createPolygon(Point* points, int count) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->init()) + { + body->addPolygon(points, count); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + return nullptr; +} + +PhysicsBody* PhysicsBody::createEdgeSegment(Point a, Point b, float border/* = 1*/) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->initStatic()) + { + body->addEdgeSegment(a, b, border); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + return nullptr; +} + +PhysicsBody* PhysicsBody::createEdgeBox(Size size, float border/* = 1*/) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->initStatic()) + { + body->addEdgeBox(size, border); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + + return nullptr; +} + +PhysicsBody* PhysicsBody::createEdgePolygon(Point* points, int count, float border/* = 1*/) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->initStatic()) + { + body->addEdgePolygon(points, count, border); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + + return nullptr; +} + +PhysicsBody* PhysicsBody::createEdgeChain(Point* points, int count, float border/* = 1*/) +{ + PhysicsBody* body = new PhysicsBody(); + if (body && body->initStatic()) + { + body->addEdgeChain(points, count); + body->autorelease(); + return body; + } + + CC_SAFE_DELETE(body); + + return nullptr; +} + +PhysicsShapeCircle* PhysicsBody::addCircle(float radius, Point offset/* = Point(0, 0)*/) +{ + _area = PhysicsHelper::cpfloat2float(cpAreaForCircle(0, radius)); + setMass((_massDefault ? 0 : getMass()) + _area * _density); + + setAngularDamping((_angularDampingDefault ? 0 : getAngularDamping()) + + PhysicsHelper::cpfloat2float(cpMomentForCircle(getMass(), 0, radius, PhysicsHelper::point2cpv(offset)))); + + return PhysicsShapeCircle::create(this, radius, offset); +} + +PhysicsShapeBox* PhysicsBody::addBox(Size size, Point offset/* = Point(0, 0)*/) +{ + cpVect cpOffset = PhysicsHelper::size2cpv(size); + cpVect vec[4] = {}; + vec[0] = cpv(0, 0); + vec[1] = cpv(0, cpOffset.y); + vec[2] = cpv(cpOffset.x, cpOffset.y); + vec[3] = cpv(cpOffset.x, 0); + + _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(4, vec)); + setMass((_massDefault ? 0 : getMass()) + _area * _density); + + setAngularDamping((_angularDampingDefault ? 0 : getAngularDamping()) + + PhysicsHelper::cpfloat2float(cpMomentForBox(getMass(), PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)))); + + return PhysicsShapeBox::create(this, size, offset); +} + +PhysicsShapePolygon* PhysicsBody::addPolygon(Point* points, int count, Point offset/* = Point(0, 0)*/) +{ + cpVect* vec = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vec, count); + _area = PhysicsHelper::cpfloat2float(cpAreaForPoly(count, vec)); + + setAngularDamping((_angularDampingDefault ? 0 : getAngularDamping()) + + PhysicsHelper::cpfloat2float(cpMomentForPoly(getMass(), count, vec, PhysicsHelper::point2cpv(offset)))); + + delete[] vec; + + return PhysicsShapePolygon::create(this, points, count, offset); +} + +PhysicsShapeEdgeSegment* PhysicsBody::addEdgeSegment(Point a, Point b, float border/* = 1*/) +{ + return PhysicsShapeEdgeSegment::create(this, a, b, border); +} + +PhysicsShapeEdgeBox* PhysicsBody::addEdgeBox(Size size, float border/* = 1*/, Point offset/* = Point(0, 0)*/) +{ + return PhysicsShapeEdgeBox::create(this, size, border, offset); +} + +PhysicsShapeEdgePolygon* PhysicsBody::addEdgePolygon(Point* points, int count, float border/* = 1*/) +{ + return PhysicsShapeEdgePolygon::create(this, points, count); +} + +PhysicsShapeEdgeChain* PhysicsBody::addEdgeChain(Point* points, int count, float border/* = 1*/) +{ + return PhysicsShapeEdgeChain::create(this, points, count, border); +} + +bool PhysicsBody::init() +{ + do + { + _info = new PhysicsBodyInfo(); + CC_BREAK_IF(_info == nullptr); + + _info->body = cpBodyNew(PhysicsHelper::float2cpfloat(_mass), PhysicsHelper::float2cpfloat(_angularDamping)); + CC_BREAK_IF(_info->body == nullptr); + _dynamic = true; + + return true; + } while (false); + + return false; +} + +void PhysicsBody::setDynamic(bool dynamic) +{ + _dynamic = dynamic; + if (_world != nullptr && cpBodyIsStatic(_info->body) == (cpBool)_dynamic) + { + if (dynamic) + { + cpSpaceConvertBodyToDynamic(_world->_info->space, _info->body, _mass, _angularDamping); + }else + { + cpSpaceConvertBodyToStatic(_world->_info->space, _info->body); + } + } +} + +bool PhysicsBody::initStatic() +{ + do + { + _info = new PhysicsBodyInfo(); + CC_BREAK_IF(_info == nullptr); + + _info->body = cpBodyNewStatic(); + CC_BREAK_IF(_info->body == nullptr); + _dynamic = false; + + return true; + } while (false); + + return false; +} + +void PhysicsBody::setPosition(Point position) +{ + cpBodySetPos(_info->body, PhysicsHelper::point2cpv(position)); +} + +void PhysicsBody::setRotation(float rotation) +{ + cpBodySetAngle(_info->body, PhysicsHelper::float2cpfloat(rotation)); +} + +Point PhysicsBody::getPosition() const +{ + cpVect vec = cpBodyGetPos(_info->body); + return PhysicsHelper::cpv2point(vec); +} + +float PhysicsBody::getRotation() const +{ + return -PhysicsHelper::cpfloat2float(cpBodyGetAngle(_info->body) / 3.14f * 180.0f); +} + +void PhysicsBody::addShape(PhysicsShape* shape) +{ + if (shape == nullptr) return; + + _shapes.push_back(shape); + + if (_world != nullptr) _world->addShape(shape); +} + +void PhysicsBody::applyForce(Point force) +{ + applyForce(force, Point()); +} + +void PhysicsBody::applyForce(Point force, Point offset) +{ + cpBodyApplyForce(_info->body, PhysicsHelper::point2cpv(force), PhysicsHelper::point2cpv(offset)); +} + +void PhysicsBody::applyImpulse(Point impulse) +{ + applyImpulse(impulse, Point()); +} + +void PhysicsBody::applyImpulse(Point impulse, Point offset) +{ + cpBodyApplyImpulse(_info->body, PhysicsHelper::point2cpv(impulse), PhysicsHelper::point2cpv(offset)); +} + +void PhysicsBody::applyTorque(float torque) +{ + cpBodySetTorque(_info->body, PhysicsHelper::float2cpfloat(torque)); +} + +void PhysicsBody::setMass(float mass) +{ + _mass = mass; + _massDefault = false; + + cpBodySetMass(_info->body, PhysicsHelper::float2cpfloat(_mass)); +} + +void PhysicsBody::setAngularDamping(float angularDamping) +{ + _angularDamping = angularDamping; + _angularDampingDefault = false; + + cpBodySetMoment(_info->body, _angularDamping); +} + +//Clonable* PhysicsBody::clone() const +//{ +// PhysicsBody* body = new PhysicsBody(); +// +// body->autorelease(); +// +// return body; +//} + +#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + + +#endif + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsBody.h b/cocos2dx/physics/CCPhysicsBody.h new file mode 100644 index 0000000000..515366e64e --- /dev/null +++ b/cocos2dx/physics/CCPhysicsBody.h @@ -0,0 +1,259 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsSetting.h" +#ifdef CC_USE_PHYSICS + +#ifndef __CCPHYSICS_BODY_H__ +#define __CCPHYSICS_BODY_H__ + +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" +#include + +NS_CC_BEGIN +class Sprite; +class PhysicsWorld; +class PhysicsJoint; +class PhysicsShape; +class PhysicsShapeCircle; +class PhysicsShapeBox; +class PhysicsShapePolygon; +class PhysicsShapeEdgeSegment; +class PhysicsShapeEdgeBox; +class PhysicsShapeEdgePolygon; +class PhysicsShapeEdgeChain; + +class PhysicsBodyInfo; +/** + * A body affect by physics. + * it can attach one or more shapes. + */ +class PhysicsBody : public Object//, public Clonable +{ +public: + /** + * @brief Create a body contains a circle shape. + */ + static PhysicsBody* createCircle(float radius); + /** + * @brief Create a body contains a box shape. + */ + static PhysicsBody* createBox(Size size); + /** + * @brief Create a body contains a polygon shape. + * points is an array of Point structs defining a convex hull with a clockwise winding. + */ + static PhysicsBody* createPolygon(Point* points, int count); + + /** + * @brief Create a body contains a EdgeSegment shape. + */ + static PhysicsBody* createEdgeSegment(Point a, Point b, float border = 1); + /** + * @brief Create a body contains a EdgeBox shape. + */ + static PhysicsBody* createEdgeBox(Size size, float border = 1); + /** + * @brief Create a body contains a EdgePolygon shape. + */ + static PhysicsBody* createEdgePolygon(Point* points, int count, float border = 1); + /** + * @brief Create a body contains a EdgeChain shape. + */ + static PhysicsBody* createEdgeChain(Point* points, int count, float border = 1); + + /** + * @brief Attach a circle shape with body + */ + virtual PhysicsShapeCircle* addCircle(float radius, Point offset = Point(0, 0)); + /** + * @brief Attach a box shape with body + */ + virtual PhysicsShapeBox* addBox(Size size, Point offset = Point(0, 0)); + /** + * @brief Attach a polygon shape with body + */ + virtual PhysicsShapePolygon* addPolygon(Point* points, int count, Point offset = Point(0, 0)); + + /** + * @brief Attach a edge segment shape with body + */ + virtual PhysicsShapeEdgeSegment* addEdgeSegment(Point a, Point b, float border = 1); + /** + * @brief Attach a edge box shape with body + */ + virtual PhysicsShapeEdgeBox* addEdgeBox(Size size, float border = 1, Point offset = Point(0, 0)); + /** + * @brief Attach a edge polygon shape with body + * points is an array of Point structs defining a convex hull with a clockwise winding. + */ + virtual PhysicsShapeEdgePolygon* addEdgePolygon(Point* points, int count, float border = 1); + /** + * @brief Attach a edge chain shape with body + * points is an array of Point structs defining a convex hull with a clockwise winding. + */ + virtual PhysicsShapeEdgeChain* addEdgeChain(Point* points, int count, float border = 1); + + /** + * @brief Applies a immediate force to body. + */ + virtual void applyForce(Point force); + /** + * @brief Applies a immediate force to body. + */ + virtual void applyForce(Point force, Point offset); + /** + * @brief Applies a continuous force to body. + */ + virtual void applyImpulse(Point impulse); + /** + * @brief Applies a continuous force to body. + */ + virtual void applyImpulse(Point impulse, Point offset); + /** + * @brief Applies a torque force to body. + */ + virtual void applyTorque(float torque); + + /* + * @brief get the body shapes. + */ + inline std::vector& getShapes() { return _shapes; } + /* + * @brief get the first body shapes. + */ + inline PhysicsShape* getShape() { return _shapes.size() >= 1 ? _shapes.front() : nullptr; } + /* + * @brief remove a shape from body + */ + void removeShape(PhysicsShape* shape); + /* + * @brief remove all shapes + */ + void removeAllShapes(); + + /* + * @brief get the world body added to. + */ + inline PhysicsWorld* getWorld() const { return _world; } + /* + * @brief get all joints the body have + */ + inline const std::vector* getJoints() const { return &_joints; } + + /* + * @brief get the sprite the body set to. + */ + inline Sprite* getOwner() const { return _owner; } + + void setCategoryBitmask(int bitmask); + inline int getCategoryBitmask() const { return _categoryBitmask; } + void setContactTestBitmask(int bitmask); + inline int getContactTestBitmask() const { return _contactTestBitmask; } + void setCollisionBitmask(int bitmask); + inline int getCollisionBitmask() const { return _collisionBitmask; } + + /* + * @brief get the body position. + */ + Point getPosition() const; + /* + * @brief get the body rotation. + */ + float getRotation() const; + + /* + * @brief test the body is dynamic or not. + * a dynamic body will effect with gravity. + */ + inline bool isDynamic() { return _dynamic; } + /* + * @brief set dynamic to body. + * a dynamic body will effect with gravity. + */ + void setDynamic(bool dynamic); + + /* + * @brief set the body mass. + */ + void setMass(float mass); + /* + * @brief get the body mass. + */ + inline float getMass() { return _mass; } + + /* + * @brief set angular damping. + */ + void setAngularDamping(float angularDamping); + /* + * @brief get angular damping. + */ + inline float getAngularDamping() { return _angularDamping; } + + //virtual Clonable* clone() const override; + +protected: + + bool init(); + bool initStatic(); + + virtual void setPosition(Point position); + virtual void setRotation(float rotation); + virtual void addShape(PhysicsShape* shape); + +protected: + PhysicsBody(); + virtual ~PhysicsBody(); + +protected: + Sprite* _owner; + std::vector _joints; + std::vector _shapes; + PhysicsWorld* _world; + PhysicsBodyInfo* _info; + bool _dynamic; + bool _massDefault; + bool _angularDampingDefault; + float _mass; + float _area; + float _density; + float _angularDamping; + + int _categoryBitmask; + int _contactTestBitmask; + int _collisionBitmask; + + friend class PhysicsWorld; + friend class PhysicsShape; + friend class PhysicsJoint; + friend class Sprite; +}; + +NS_CC_END + +#endif // __CCPHYSICS_BODY_H__ + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsContact.cpp b/cocos2dx/physics/CCPhysicsContact.cpp new file mode 100644 index 0000000000..928c8c9e59 --- /dev/null +++ b/cocos2dx/physics/CCPhysicsContact.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +#include "CCPhysicsContact.h" +#ifdef CC_USE_PHYSICS + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include "chipmunk.h" +#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) +#include "Box2D.h" +#endif + +#include "chipmunk/CCPhysicsContactInfo.h" +#include "Box2D/CCPhysicsContactInfo.h" + +NS_CC_BEGIN + +PhysicsContact::PhysicsContact() +: _shapeA(nullptr) +, _shapeB(nullptr) +, _info(nullptr) +, _data(nullptr) +{ + +} + +PhysicsContact::~PhysicsContact() +{ + CC_SAFE_DELETE(_info); +} + +PhysicsContact* PhysicsContact::create(PhysicsShape* a, PhysicsShape* b) +{ + PhysicsContact * contact = new PhysicsContact(); + if(contact && contact->init(a, b)) + { + return contact; + } + + CC_SAFE_DELETE(contact); + return nullptr; +} + +bool PhysicsContact::init(PhysicsShape* a, PhysicsShape* b) +{ + do + { + CC_BREAK_IF(a == nullptr || b == nullptr); + + CC_BREAK_IF(!(_info = new PhysicsContactInfo(this))); + + _shapeA = a; + _shapeB = b; + + return true; + } while(false); + + return false; +} + +// PhysicsContactPreSolve implementation +PhysicsContactPreSolve::PhysicsContactPreSolve() +{ + +} + +PhysicsContactPreSolve::~PhysicsContactPreSolve() +{ + +} + +PhysicsContactPreSolve* PhysicsContactPreSolve::create() +{ + PhysicsContactPreSolve * solve = new PhysicsContactPreSolve(); + if(solve && solve->init()) + { + return solve; + } + + CC_SAFE_DELETE(solve); + return nullptr; +} + +bool PhysicsContactPreSolve::init() +{ + return true; +} + + +// PhysicsContactPostSolve implementation +PhysicsContactPostSolve::PhysicsContactPostSolve() +{ + +} + +PhysicsContactPostSolve::~PhysicsContactPostSolve() +{ + +} + +PhysicsContactPostSolve* PhysicsContactPostSolve::create() +{ + PhysicsContactPostSolve * solve = new PhysicsContactPostSolve(); + if(solve && solve->init()) + { + return solve; + } + + CC_SAFE_DELETE(solve); + return nullptr; +} + +bool PhysicsContactPostSolve::init() +{ + return true; +} + +PhysicsContactListener::PhysicsContactListener() +: onContactBegin(nullptr) +, onContactPreSolve(nullptr) +, onContactPostSolve(nullptr) +, onContactEnd(nullptr) +{ + +} + +PhysicsContactListener::~PhysicsContactListener() +{ + +} + +NS_CC_END +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsContact.h b/cocos2dx/physics/CCPhysicsContact.h new file mode 100644 index 0000000000..605a6dcf80 --- /dev/null +++ b/cocos2dx/physics/CCPhysicsContact.h @@ -0,0 +1,143 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsSetting.h" +#ifdef CC_USE_PHYSICS + +#ifndef __CCPHYSICS_CONTACT_H__ +#define __CCPHYSICS_CONTACT_H__ + +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" + +NS_CC_BEGIN + +class PhysicsShape; +class PhysicsWorld; + +class PhysicsContactInfo; + +/** + * @brief Contact infomation. it will created automatically when two shape contact with each other. and it will destoried automatically when two shape separated. + */ +class PhysicsContact +{ +public: + /* + * @brief get contact shape A. + */ + inline PhysicsShape* getShapeA() { return _shapeA; } + /* + * @brief get contact shape B. + */ + inline PhysicsShape* getShapeB() { return _shapeB; } + /* + * @brief get data. + */ + inline void* getData() { return _data; } + /* + * @brief set data to contact. you must manage the memory yourself, Generally you can set data at contact begin, and distory it at contact end. + */ + inline void setData(void* data) { _data = data; } + +private: + static PhysicsContact* create(PhysicsShape* a, PhysicsShape* b); + bool init(PhysicsShape* a, PhysicsShape* b); + +private: + PhysicsContact(); + ~PhysicsContact(); + +private: + PhysicsShape* _shapeA; + PhysicsShape* _shapeB; + PhysicsContactInfo* _info; + void* _data; + + friend class PhysicsWorld; +}; + +/* + * @brief presolve value generated when onContactPreSolve called. + */ +class PhysicsContactPreSolve +{ +private: + PhysicsContactPreSolve(); + ~PhysicsContactPreSolve(); + + static PhysicsContactPreSolve* create(); + bool init(); + + friend class PhysicsWorld; +}; + +/* + * @brief postsolve value generated when onContactPostSolve called. + */ +class PhysicsContactPostSolve +{ +private: + PhysicsContactPostSolve(); + ~PhysicsContactPostSolve(); + + static PhysicsContactPostSolve* create(); + bool init(); + + friend class PhysicsWorld; +}; + +/* + * @brief contact listener. + */ +class PhysicsContactListener +{ +public: + PhysicsContactListener(); + virtual ~PhysicsContactListener(); + +public: + /* + * @brief it will called at two shapes start to contact, and only call it once. + */ + std::function onContactBegin; + /* + * @brief Two shapes are touching during this step. Return false from the callback to make world ignore the collision this step or true to process it normally. Additionally, you may override collision values, elasticity, or surface velocity values. + */ + std::function onContactPreSolve; + /* + * @brief Two shapes are touching and their collision response has been processed. You can retrieve the collision impulse or kinetic energy at this time if you want to use it to calculate sound volumes or damage amounts. See cpArbiter for more info + */ + std::function onContactPostSolve; + /* + * @brief it will called at two shapes separated, and only call it once. + * onContactBegin and onContactEnd will called in pairs. + */ + std::function onContactEnd; +}; + +NS_CC_END +#endif //__CCPHYSICS_CONTACT_H__ + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsJoint.cpp b/cocos2dx/physics/CCPhysicsJoint.cpp new file mode 100644 index 0000000000..3e60d246ab --- /dev/null +++ b/cocos2dx/physics/CCPhysicsJoint.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsJoint.h" +#ifdef CC_USE_PHYSICS + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include "chipmunk.h" +#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) +#include "Box2D.h" +#endif + +#include "CCPhysicsBody.h" + +#include "chipmunk/CCPhysicsJointInfo.h" +#include "Box2D/CCPhysicsJointInfo.h" +#include "chipmunk/CCPhysicsBodyInfo.h" +#include "Box2D/CCPhysicsBodyInfo.h" +#include "chipmunk/CCPhysicsHelper.h" +#include "Box2D/CCPhysicsHelper.h" + +NS_CC_BEGIN + +PhysicsJoint::PhysicsJoint() +: _bodyA(nullptr) +, _bodyB(nullptr) +, _info(nullptr) +{ + +} + +PhysicsJoint::~PhysicsJoint() +{ + CC_SAFE_DELETE(_info); + + CC_SAFE_RELEASE(_bodyA); + CC_SAFE_RELEASE(_bodyB); +} + +bool PhysicsJoint::init(cocos2d::PhysicsBody *a, cocos2d::PhysicsBody *b) +{ + do + { + CC_BREAK_IF(a == nullptr || b == nullptr); + + CC_BREAK_IF(!(_info = new PhysicsJointInfo())); + + _bodyA = a; + _bodyA->retain(); + _bodyA->_joints.push_back(this); + _bodyB = b; + _bodyB->retain(); + _bodyB->_joints.push_back(this); + + return true; + } while (false); + + return false; +} + + +PhysicsJointPin::PhysicsJointPin() +{ + +} + +PhysicsJointPin::~PhysicsJointPin() +{ + +} + +PhysicsJointFixed::PhysicsJointFixed() +{ + +} + +PhysicsJointFixed::~PhysicsJointFixed() +{ + +} + +PhysicsJointSliding::PhysicsJointSliding() +{ + +} + +PhysicsJointSliding::~PhysicsJointSliding() +{ + +} + +PhysicsJointLimit::PhysicsJointLimit() +{ + +} + +PhysicsJointLimit::~PhysicsJointLimit() +{ + +} + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +PhysicsBodyInfo* PhysicsJoint::bodyInfo(PhysicsBody* body) const +{ + return body->_info; +} + + + +PhysicsJointFixed* PhysicsJointFixed::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr) +{ + PhysicsJointFixed* joint = new PhysicsJointFixed(); + + if (joint && joint->init(a, b, anchr)) + { + joint->autorelease(); + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointFixed::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + _info->joint = cpPivotJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + PhysicsHelper::point2cpv(anchr)); + + return true; + } while (false); + + return false; +} + +PhysicsJointPin* PhysicsJointPin::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2) +{ + PhysicsJointPin* joint = new PhysicsJointPin(); + + if (joint && joint->init(a, b, anchr1, anchr2)) + { + joint->autorelease(); + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointPin::init(PhysicsBody *a, PhysicsBody *b, const Point& anchr1, const Point& anchr2) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + _info->joint = cpPinJointNew(bodyInfo(a)->body, bodyInfo(b)->body, PhysicsHelper::point2cpv(anchr1), PhysicsHelper::point2cpv(anchr2)); + + return true; + } while (false); + + return false; +} + +PhysicsJointSliding* PhysicsJointSliding::create(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr) +{ + PhysicsJointSliding* joint = new PhysicsJointSliding(); + + if (joint && joint->init(a, b, grooveA, grooveB, anchr)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointSliding::init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + _info->joint = cpGrooveJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + PhysicsHelper::point2cpv(grooveA), + PhysicsHelper::point2cpv(grooveB), + PhysicsHelper::point2cpv(anchr)); + + return true; + } while (false); + + return false; +} + + +PhysicsJointLimit* PhysicsJointLimit::create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) +{ + PhysicsJointLimit* joint = new PhysicsJointLimit(); + + if (joint && joint->init(a, b, anchr1, anchr2, min, max)) + { + return joint; + } + + CC_SAFE_DELETE(joint); + return nullptr; +} + +bool PhysicsJointLimit::init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max) +{ + do + { + CC_BREAK_IF(!PhysicsJoint::init(a, b)); + + _info->joint = cpSlideJointNew(bodyInfo(a)->body, bodyInfo(b)->body, + PhysicsHelper::point2cpv(anchr1), + PhysicsHelper::point2cpv(anchr2), + PhysicsHelper::float2cpfloat(min), + PhysicsHelper::float2cpfloat(max)); + + return true; + } while (false); + + return false; +} + +#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#endif + +NS_CC_END +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsJoint.h b/cocos2dx/physics/CCPhysicsJoint.h new file mode 100644 index 0000000000..854963049d --- /dev/null +++ b/cocos2dx/physics/CCPhysicsJoint.h @@ -0,0 +1,153 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsSetting.h" +#ifdef CC_USE_PHYSICS + +#ifndef __CCPHYSICS_JOINT_H__ +#define __CCPHYSICS_JOINT_H__ + +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" + +NS_CC_BEGIN + +class PhysicsBody; +class PhysicsJointInfo; +class PhysicsBodyInfo; + +/* + * @brief An PhysicsJoint object connects two physics bodies together. + */ +class PhysicsJoint : public Object +{ +protected: + PhysicsJoint(); + virtual ~PhysicsJoint() = 0; + +public: + PhysicsBody* getBodyA() { return _bodyA; } + PhysicsBody* getBodyB() { return _bodyB; } + +protected: + bool init(PhysicsBody* a, PhysicsBody* b); + + /** + * PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. + */ + PhysicsBodyInfo* bodyInfo(PhysicsBody* body) const; + +protected: + PhysicsBody* _bodyA; + PhysicsBody* _bodyB; + PhysicsJointInfo* _info; + + friend class PhysicsBody; +}; + +/* + * @brief A fixed joint fuses the two bodies together at a reference point. Fixed joints are useful for creating complex shapes that can be broken apart later. + */ +class PhysicsJointFixed : public PhysicsJoint +{ +public: + PhysicsJointFixed* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr); + +protected: + PhysicsJointFixed(); + virtual ~PhysicsJointFixed(); +}; + +/* + * @brief A sliding joint allows the two bodies to slide along a chosen axis. + */ +class PhysicsJointSliding : public PhysicsJoint +{ +public: + PhysicsJointSliding* create(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& grooveA, const Point& grooveB, const Point& anchr); + +protected: + PhysicsJointSliding(); + virtual ~PhysicsJointSliding(); +}; + +/* + * @brief A spring joint connects the two bodies with a spring whose length is the initial distance between the two bodies. + */ +class PhysicsJointSpring : public PhysicsJoint +{ +public: + PhysicsJointSpring* create(); + +protected: + bool init(); + +protected: + PhysicsJointSpring(); + virtual ~PhysicsJointSpring(); +}; + +/* + * @brief A limit joint imposes a maximum distance between the two bodies, as if they were connected by a rope. + */ +class PhysicsJointLimit : public PhysicsJoint +{ +public: + PhysicsJointLimit* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2, float min, float max); + +protected: + PhysicsJointLimit(); + virtual ~PhysicsJointLimit(); +}; + +/* + * @brief A pin joint allows the two bodies to independently rotate around the anchor point as if pinned together. + */ +class PhysicsJointPin : public PhysicsJoint +{ +public: + static PhysicsJointPin* create(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + +protected: + bool init(PhysicsBody* a, PhysicsBody* b, const Point& anchr1, const Point& anchr2); + +protected: + PhysicsJointPin(); + virtual ~PhysicsJointPin(); +}; + +NS_CC_END + +#endif // __CCPHYSICS_JOINT_H__ + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsSetting.h b/cocos2dx/physics/CCPhysicsSetting.h new file mode 100644 index 0000000000..98b39f8f66 --- /dev/null +++ b/cocos2dx/physics/CCPhysicsSetting.h @@ -0,0 +1,46 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef __CCPHYSICS_SETTING_H__ +#define __CCPHYSICS_SETTING_H__ + +#define CC_PHYSICS_UNKNOWN 0 +#define CC_PHYSICS_BOX2D 1 +#define CC_PHYSICS_CHIPMUNK 2 + +#define CC_USE_CHIPMUNK + +#ifdef CC_USE_BOX2D +#define CC_PHYSICS_ENGINE CC_PHYSICS_BOX2D +#elif defined(CC_USE_CHIPMUNK) +#define CC_PHYSICS_ENGINE CC_PHYSICS_CHIPMUNK +#else +#define CC_PHYSICS_ENGINE CC_PHYSICS_UNKNOWN +#endif + +#if (CC_PHYSICS_ENGINE != CC_PHYSICS_UNKNOWN) +#define CC_USE_PHYSICS +#endif + +#endif // __CCPHYSICS_SETTING_H__ diff --git a/cocos2dx/physics/CCPhysicsShape.cpp b/cocos2dx/physics/CCPhysicsShape.cpp new file mode 100644 index 0000000000..e98dff0b5c --- /dev/null +++ b/cocos2dx/physics/CCPhysicsShape.cpp @@ -0,0 +1,432 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsShape.h" +#ifdef CC_USE_PHYSICS + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include "chipmunk.h" +#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) +#include "Box2D.h" +#endif + +#include "CCPhysicsBody.h" + +#include "chipmunk/CCPhysicsBodyInfo.h" +#include "Box2D/CCPhysicsBodyInfo.h" +#include "chipmunk/CCPhysicsShapeInfo.h" +#include "Box2D/CCPhysicsShapeInfo.h" +#include "chipmunk/CCPhysicsHelper.h" + +NS_CC_BEGIN + +PhysicsShape::PhysicsShape() +: _body(nullptr) +, _info(nullptr) +, _type(Type::UNKNOWN) +{ + +} + +PhysicsShape::~PhysicsShape() +{ + CC_SAFE_DELETE(_info); +} + +bool PhysicsShape::init(PhysicsBody* body, Type type) +{ + if (body == nullptr) return false; + + _body = body; + + _info = new PhysicsShapeInfo(this); + if (_info == nullptr) return false; + + _type = type; + + return true; +} + +void PhysicsShape::addToBody() +{ + if(_body != nullptr) _body->addShape(this); +} + +PhysicsBodyInfo* PhysicsShape::bodyInfo() const +{ + return _body->_info; +} + +PhysicsShapeCircle::PhysicsShapeCircle() +{ + +} + +PhysicsShapeCircle::~PhysicsShapeCircle() +{ + +} + +PhysicsShapeBox::PhysicsShapeBox() +{ + +} + +PhysicsShapeBox::~PhysicsShapeBox() +{ + +} + +PhysicsShapePolygon::PhysicsShapePolygon() +{ + +} + +PhysicsShapePolygon::~PhysicsShapePolygon() +{ + +} + +PhysicsShapeEdgeBox::PhysicsShapeEdgeBox() +{ + +} + +PhysicsShapeEdgeBox::~PhysicsShapeEdgeBox() +{ + +} + +PhysicsShapeEdgeChain::PhysicsShapeEdgeChain() +{ + +} + +PhysicsShapeEdgeChain::~PhysicsShapeEdgeChain() +{ + +} + +PhysicsShapeEdgePolygon::PhysicsShapeEdgePolygon() +{ + +} + +PhysicsShapeEdgePolygon::~PhysicsShapeEdgePolygon() +{ + +} + +PhysicsShapeEdgeSegment::PhysicsShapeEdgeSegment() +{ + +} + +PhysicsShapeEdgeSegment::~PhysicsShapeEdgeSegment() +{ + +} + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +// PhysicsShapeCircle +PhysicsShapeCircle* PhysicsShapeCircle::create(PhysicsBody* body, float radius, Point offset/* = Point(0, 0)*/) +{ + PhysicsShapeCircle* shape = new PhysicsShapeCircle(); + if (shape && shape->init(body, radius, offset)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeCircle::init(PhysicsBody* body, float radius, Point offset /*= Point(0, 0)*/) +{ + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::CIRCLE)); + + cpShape* shape = cpCircleShapeNew(bodyInfo()->body, radius, PhysicsHelper::point2cpv(offset)); + + CC_BREAK_IF(shape == nullptr); + + _info->add(shape); + addToBody(); + + return true; + } while (false); + + return false; +} + +// PhysicsShapeEdgeSegment +PhysicsShapeEdgeSegment* PhysicsShapeEdgeSegment::create(PhysicsBody* body, Point a, Point b, float border/* = 1*/) +{ + PhysicsShapeEdgeSegment* shape = new PhysicsShapeEdgeSegment(); + if (shape && shape->init(body, a, b, border)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeEdgeSegment::init(PhysicsBody* body, Point a, Point b, float border/* = 1*/) +{ + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::EDGESEGMENT)); + + cpShape* shape = cpSegmentShapeNew(bodyInfo()->body, + PhysicsHelper::point2cpv(a), + PhysicsHelper::point2cpv(b), + PhysicsHelper::float2cpfloat(border)); + + CC_BREAK_IF(shape == nullptr); + + _info->add(shape); + addToBody(); + + return true; + } while (false); + + return false; +} + +// PhysicsShapeBox +PhysicsShapeBox* PhysicsShapeBox::create(PhysicsBody* body, Size size, Point offset/* = Point(0, 0)*/) +{ + PhysicsShapeBox* shape = new PhysicsShapeBox(); + if (shape && shape->init(body, size, offset)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeBox::init(PhysicsBody* body, Size size, Point offset /*= Point(0, 0)*/) +{ + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::BOX)); + + cpShape* shape = cpBoxShapeNew(bodyInfo()->body, PhysicsHelper::float2cpfloat(size.width), PhysicsHelper::float2cpfloat(size.height)); + + CC_BREAK_IF(shape == nullptr); + + _info->add(shape); + addToBody(); + + return true; + } while (false); + + return false; +} + +// PhysicsShapeCircle +PhysicsShapePolygon* PhysicsShapePolygon::create(PhysicsBody* body, Point* points, int count, Point offset/* = Point(0, 0)*/) +{ + PhysicsShapePolygon* shape = new PhysicsShapePolygon(); + if (shape && shape->init(body, points, count, offset)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapePolygon::init(PhysicsBody* body, Point* points, int count, Point offset /*= Point(0, 0)*/) +{ + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::POLYGEN)); + + cpVect* vecs = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vecs, count); + cpShape* shape = cpPolyShapeNew(bodyInfo()->body, count, vecs, PhysicsHelper::point2cpv(offset)); + + CC_BREAK_IF(shape == nullptr); + + _info->add(shape); + addToBody(); + + return true; + } while (false); + + return false; +} + +// PhysicsShapeEdgeBox +PhysicsShapeEdgeBox* PhysicsShapeEdgeBox::create(PhysicsBody* body, Size size, float border/* = 1*/, Point offset/* = Point(0, 0)*/) +{ + PhysicsShapeEdgeBox* shape = new PhysicsShapeEdgeBox(); + if (shape && shape->init(body, size, border, offset)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeEdgeBox::init(PhysicsBody* body, Size size, float border/* = 1*/, Point offset/*= Point(0, 0)*/) +{ + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::EDGEBOX)); + + Point bodyPos = body->getPosition(); + + cpVect vec[4] = {}; + vec[0] = PhysicsHelper::point2cpv(Point(bodyPos.x-size.width/2+offset.x, bodyPos.y-size.height/2+offset.y)); + vec[1] = PhysicsHelper::point2cpv(Point(bodyPos.x+size.width/2+offset.x, bodyPos.y-size.height/2+offset.y)); + vec[2] = PhysicsHelper::point2cpv(Point(bodyPos.x+size.width/2+offset.x, bodyPos.y+size.height/2+offset.y)); + vec[3] = PhysicsHelper::point2cpv(Point(bodyPos.x-size.width/2+offset.x, bodyPos.y+size.height/2+offset.y)); + + int i = 0; + for (; i < 4; ++i) + { + cpShape* shape = cpSegmentShapeNew(bodyInfo()->body, vec[i], vec[(i+1)%4], + PhysicsHelper::float2cpfloat(border)); + CC_BREAK_IF(shape == nullptr); + cpShapeSetElasticity(shape, 1.0f); + cpShapeSetFriction(shape, 1.0f); + _info->add(shape); + } + CC_BREAK_IF(i < 4); + + addToBody(); + + return true; + } while (false); + + return false; +} + +// PhysicsShapeEdgeBox +PhysicsShapeEdgePolygon* PhysicsShapeEdgePolygon::create(PhysicsBody* body, Point* points, int count, float border/* = 1*/) +{ + PhysicsShapeEdgePolygon* shape = new PhysicsShapeEdgePolygon(); + if (shape && shape->init(body, points, count, border)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeEdgePolygon::init(PhysicsBody* body, Point* points, int count, float border/* = 1*/) +{ + cpVect* vec = nullptr; + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::EDGEPOLYGEN)); + + vec = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vec, count); + + int i = 0; + for (; i < count; ++i) + { + cpShape* shape = cpSegmentShapeNew(bodyInfo()->body, vec[i], vec[(i+1)%count], + PhysicsHelper::float2cpfloat(border)); + CC_BREAK_IF(shape == nullptr); + cpShapeSetElasticity(shape, 1.0f); + cpShapeSetFriction(shape, 1.0f); + _info->add(shape); + } + CC_BREAK_IF(i < count); + + addToBody(); + + if (vec != nullptr) delete[] vec; + return true; + } while (false); + + if (vec != nullptr) delete[] vec; + + return false; +} + +// PhysicsShapeEdgeChain +PhysicsShapeEdgeChain* PhysicsShapeEdgeChain::create(PhysicsBody* body, Point* points, int count, float border/* = 1*/) +{ + PhysicsShapeEdgeChain* shape = new PhysicsShapeEdgeChain(); + if (shape && shape->init(body, points, count, border)) + { + return shape; + } + + CC_SAFE_DELETE(shape); + return nullptr; +} + +bool PhysicsShapeEdgeChain::init(PhysicsBody* body, Point* points, int count, float border/* = 1*/) +{ + cpVect* vec = nullptr; + do + { + CC_BREAK_IF(!PhysicsShape::init(body, Type::EDGECHAIN)); + + vec = new cpVect[count]; + PhysicsHelper::points2cpvs(points, vec, count); + + int i = 0; + for (; i < count - 1; ++i) + { + cpShape* shape = cpSegmentShapeNew(bodyInfo()->body, vec[i], vec[i+1], + PhysicsHelper::float2cpfloat(border)); + CC_BREAK_IF(shape == nullptr); + cpShapeSetElasticity(shape, 1.0f); + cpShapeSetFriction(shape, 1.0f); + _info->add(shape); + } + CC_BREAK_IF(i < count); + + addToBody(); + + if (vec != nullptr) delete[] vec; + return true; + } while (false); + + if (vec != nullptr) delete[] vec; + + return false; +} + + +#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#endif + +NS_CC_END + +#endif // CC_USE_PHYSICS \ No newline at end of file diff --git a/cocos2dx/physics/CCPhysicsShape.h b/cocos2dx/physics/CCPhysicsShape.h new file mode 100644 index 0000000000..79cda68e6d --- /dev/null +++ b/cocos2dx/physics/CCPhysicsShape.h @@ -0,0 +1,192 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsSetting.h" +#ifdef CC_USE_PHYSICS + +#ifndef __CCPHYSICS_SHAPE_H__ +#define __CCPHYSICS_SHAPE_H__ + +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" + +NS_CC_BEGIN + +class PhysicsShapeInfo; +class PhysicsBody; +class PhysicsBodyInfo; + +/** + * @brief A shape for body. You do not create PhysicsWorld objects directly, instead, you can view PhysicsBody to see how to create it. + */ +class PhysicsShape : public Object +{ +public: + enum class Type + { + UNKNOWN, + CIRCLE, + BOX, + POLYGEN, + EDGESEGMENT, + EDGEBOX, + EDGEPOLYGEN, + EDGECHAIN, + }; + +public: + inline PhysicsBody* getBody(){ return _body; } + inline Type getType() { return _type; } + +protected: + bool init(PhysicsBody* body, Type type); + + /** + * @brief PhysicsShape is PhysicsBody's friend class, but all the subclasses isn't. so this method is use for subclasses to catch the bodyInfo from PhysicsBody. + */ + PhysicsBodyInfo* bodyInfo() const; + + void addToBody(); + +protected: + PhysicsShape(); + virtual ~PhysicsShape() = 0; + +protected: + PhysicsBody* _body; + PhysicsShapeInfo* _info; + Type _type; + + friend class PhysicsWorld; + friend class PhysicsBody; +}; + +/** A circle shape */ +class PhysicsShapeCircle : public PhysicsShape +{ +protected: + static PhysicsShapeCircle* create(PhysicsBody* body, float radius, Point offset = Point(0, 0)); + bool init(PhysicsBody* body, float radius, Point offset = Point(0, 0)); + +protected: + PhysicsShapeCircle(); + virtual ~PhysicsShapeCircle(); + + friend class PhysicsBody; +}; + +/** A box shape */ +class PhysicsShapeBox : public PhysicsShape +{ +protected: + static PhysicsShapeBox* create(PhysicsBody* body, Size size, Point offset = Point(0, 0)); + bool init(PhysicsBody* body, Size size, Point offset = Point(0, 0)); + +protected: + PhysicsShapeBox(); + virtual ~PhysicsShapeBox(); + + friend class PhysicsBody; +}; + +/** A polygon shape */ +class PhysicsShapePolygon : public PhysicsShape +{ +protected: + static PhysicsShapePolygon* create(PhysicsBody* body, Point* points, int count, Point offset = Point(0, 0)); + bool init(PhysicsBody* body, Point* points, int count, Point offset = Point(0, 0)); + +protected: + PhysicsShapePolygon(); + virtual ~PhysicsShapePolygon(); + + friend class PhysicsBody; +}; + +/** A segment shape */ +class PhysicsShapeEdgeSegment : public PhysicsShape +{ +protected: + static PhysicsShapeEdgeSegment* create(PhysicsBody* body, Point a, Point b, float border = 1); + bool init(PhysicsBody* body, Point a, Point b, float border = 1); + +protected: + PhysicsShapeEdgeSegment(); + virtual ~PhysicsShapeEdgeSegment(); + + friend class PhysicsBody; +}; + +/** An edge box shape */ +class PhysicsShapeEdgeBox : public PhysicsShape +{ +public: + static PhysicsShapeEdgeBox* create(PhysicsBody* body, Size size, float border = 0, Point offset = Point(0, 0)); + +protected: + bool init(PhysicsBody* body, Size size, float border = 1, Point offset = Point(0, 0)); + +protected: + PhysicsShapeEdgeBox(); + virtual ~PhysicsShapeEdgeBox(); + + friend class PhysicsBody; +}; + +/** An edge polygon shape */ +class PhysicsShapeEdgePolygon : public PhysicsShape +{ +public: + static PhysicsShapeEdgePolygon* create(PhysicsBody* body, Point* points, int count, float border = 1); + +protected: + bool init(PhysicsBody* body, Point* points, int count, float border = 1); + +protected: + PhysicsShapeEdgePolygon(); + virtual ~PhysicsShapeEdgePolygon(); + + friend class PhysicsBody; +}; + +/** a chain shape */ +class PhysicsShapeEdgeChain : public PhysicsShape +{ +public: + static PhysicsShapeEdgeChain* create(PhysicsBody* body, Point* points, int count, float border = 1); + +protected: + bool init(PhysicsBody* body, Point* points, int count, float border = 1); + +protected: + PhysicsShapeEdgeChain(); + virtual ~PhysicsShapeEdgeChain(); + + friend class PhysicsBody; +}; + +NS_CC_END +#endif // __CCPHYSICS_FIXTURE_H__ + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsWorld.cpp b/cocos2dx/physics/CCPhysicsWorld.cpp new file mode 100644 index 0000000000..08857de24b --- /dev/null +++ b/cocos2dx/physics/CCPhysicsWorld.cpp @@ -0,0 +1,330 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsWorld.h" +#ifdef CC_USE_PHYSICS + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include "chipmunk.h" +#elif (CC_PHYSICS_ENGINE == CCPHYSICS_BOX2D) +#include "Box2D.h" +#endif + +#include "CCPhysicsBody.h" +#include "CCPhysicsShape.h" +#include "CCPhysicsContact.h" + +#include "chipmunk/CCPhysicsWorldInfo.h" +#include "Box2D/CCPhysicsWorldInfo.h" +#include "chipmunk/CCPhysicsBodyInfo.h" +#include "Box2D/CCPhysicsBodyInfo.h" +#include "chipmunk/CCPhysicsShapeInfo.h" +#include "Box2D/CCPhysicsShapeInfo.h" +#include "chipmunk/CCPhysicsContactInfo.h" +#include "Box2D/CCPhysicsContactInfo.h" +#include "chipmunk/CCPhysicsHelper.h" + +#include "draw_nodes/CCDrawNode.h" +#include "cocoa/CCArray.h" +#include "layers_scenes_transitions_nodes/CCScene.h" +#include "CCDirector.h" + +NS_CC_BEGIN + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +int PhysicsWorld::collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data) +{ + PhysicsWorld* world = static_cast(data); + + CP_ARBITER_GET_SHAPES(arb, a, b); + + auto ita = PhysicsShapeInfo::map.find(a); + auto itb = PhysicsShapeInfo::map.find(b); + CC_ASSERT(ita != PhysicsShapeInfo::map.end() && itb != PhysicsShapeInfo::map.end()); + + PhysicsContact* contact = PhysicsContact::create(ita->second->shape, itb->second->shape); + arb->data = contact; + + return world->collisionBeginCallback(*static_cast(arb->data)); +} + +int PhysicsWorld::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +{ + PhysicsWorld* world = static_cast(data); + return world->collisionPreSolveCallback(*static_cast(arb->data), + PhysicsContactPreSolve()); +} + +void PhysicsWorld::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +{ + PhysicsWorld* world = static_cast(data); + world->collisionPostSolveCallback(*static_cast(arb->data), + PhysicsContactPostSolve()); +} + +void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data) +{ + PhysicsWorld* world = static_cast(data); + PhysicsContact* contact = static_cast(arb->data); + + world->collisionSeparateCallback(*contact); + + delete contact; +} + +bool PhysicsWorld::init() +{ + _info = new PhysicsWorldInfo(); + + cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(_gravity)); + + cpSpaceSetDefaultCollisionHandler(_info->space, + PhysicsWorld::collisionBeginCallbackFunc, + PhysicsWorld::collisionPreSolveCallbackFunc, + PhysicsWorld::collisionPostSolveCallbackFunc, + PhysicsWorld::collisionSeparateCallbackFunc, + this); + + return true; +} + +void PhysicsWorld::addShape(PhysicsShape* shape) +{ + for (auto it = shape->_info->shapes.begin(); it != shape->_info->shapes.end(); it++) + { + if (cpBodyIsStatic(shape->getBody()->_info->body)) + { + cpSpaceAddStaticShape(_info->space, *it); + }else + { + cpSpaceAddShape(_info->space, *it); + } + } +} + +void PhysicsWorld::addChild(PhysicsBody* body) +{ + auto shapes = body->getShapes(); + + // add body to space + if (body->isDynamic()) + { + cpSpaceAddBody(_info->space, body->_info->body); + } + + // add shapes to space + for (auto it = shapes.begin(); it != shapes.end(); it++) + { + addShape(*it); + } + + if (_bodys == nullptr) + { + _bodys = Array::create(body, NULL); + _bodys->retain(); + }else + { + _bodys->addObject(body); + } +} + +void PhysicsWorld::update(float delta) +{ + cpSpaceStep(_info->space, delta); + + if (_drawNode) + { + _drawNode->removeFromParent(); + _drawNode = nullptr; + } + + if (_debugDraw) + { + debugDraw(); + } +} + +void PhysicsWorld::debugDraw() +{ + if (_debugDraw && _bodys != nullptr) + { + _drawNode= DrawNode::create(); + + Object* child = nullptr; + CCARRAY_FOREACH(_bodys, child) + { + PhysicsBody* body = dynamic_cast(child); + + std::vector shapes = body->getShapes(); + + for (auto it = shapes.begin(); it != shapes.end(); ++it) + { + drawWithShape(_drawNode, *it); + } + } + + if (_scene) + { + _scene->addChild(_drawNode); + } + } +} + +void PhysicsWorld::setScene(Scene *scene) +{ + _scene = scene; + scene->retain(); +} + +void PhysicsWorld::drawWithShape(DrawNode* node, PhysicsShape* shape) +{ + for (auto it = shape->_info->shapes.begin(); it != shape->_info->shapes.end(); ++it) + { + cpShape *shape = *it; + + switch ((*it)->klass_private->type) + { + case CP_CIRCLE_SHAPE: + { + float radius = PhysicsHelper::cpfloat2float(cpCircleShapeGetRadius(shape)); + Point centre = PhysicsHelper::cpv2point(cpBodyGetPos(cpShapeGetBody(shape))) + + PhysicsHelper::cpv2point(cpCircleShapeGetOffset(shape)); + + Point seg[4] = {}; + seg[0] = Point(centre.x - radius, centre.y - radius); + seg[1] = Point(centre.x - radius, centre.y + radius); + seg[2] = Point(centre.x + radius, centre.y + radius); + seg[3] = Point(centre.x + radius, centre.y - radius); + node->drawPolygon(seg, 4, Color4F(), 1, Color4F(1, 0, 0, 1)); + break; + } + case CP_SEGMENT_SHAPE: + { + cpSegmentShape *seg = (cpSegmentShape *)shape; + node->drawSegment(PhysicsHelper::cpv2point(seg->ta), + PhysicsHelper::cpv2point(seg->tb), + PhysicsHelper::cpfloat2float(seg->r==0 ? 1 : seg->r), Color4F(1, 0, 0, 1)); + break; + } + case CP_POLY_SHAPE: + { + cpPolyShape* poly = (cpPolyShape*)shape; + int num = poly->numVerts; + Point* seg = new Point[num]; + + PhysicsHelper::cpvs2points(poly->tVerts, seg, num); + + node->drawPolygon(seg, num, Color4F(1, 0, 0, 0.3), 1, Color4F(1, 0, 0, 1)); + + delete[] seg; + break; + } + default: + break; + } + } +} + +int PhysicsWorld::collisionBeginCallback(const PhysicsContact& contact) +{ + if (_listener && _listener->onContactBegin) + { + return _listener->onContactBegin(contact); + } + + return true; +} + +int PhysicsWorld::collisionPreSolveCallback(const PhysicsContact& contact, const PhysicsContactPreSolve& solve) +{ + if (_listener && _listener->onContactPreSolve) + { + return _listener->onContactPreSolve(contact, solve); + } + + return true; +} + +void PhysicsWorld::collisionPostSolveCallback(const PhysicsContact& contact, const PhysicsContactPostSolve& solve) +{ + if (_listener && _listener->onContactPreSolve) + { + _listener->onContactPostSolve(contact, solve); + } +} + +void PhysicsWorld::collisionSeparateCallback(const PhysicsContact& contact) +{ + if (_listener && _listener->onContactEnd) + { + _listener->onContactEnd(contact); + } +} + +void PhysicsWorld::setGravity(Point gravity) +{ + _gravity = gravity; + cpSpaceSetGravity(_info->space, PhysicsHelper::point2cpv(_gravity)); +} + +#elif (CC_PHYSICS_ENGINE == CC_PHYSICS_BOX2D) + +#endif + +PhysicsWorld* PhysicsWorld::create() +{ + PhysicsWorld * world = new PhysicsWorld(); + if(world && world->init()) + { + return world; + } + + CC_SAFE_DELETE(world); + return nullptr; +} + +PhysicsWorld::PhysicsWorld() +: _gravity(Point(0.0f, -98.0f)) +, _speed(1.0f) +, _info(nullptr) +, _listener(nullptr) +, _bodys(nullptr) +, _scene(nullptr) +, _debugDraw(false) +, _drawNode(nullptr) +{ + +} + +PhysicsWorld::~PhysicsWorld() +{ + CC_SAFE_DELETE(_info); + CC_SAFE_RELEASE(_bodys); + CC_SAFE_RELEASE(_scene); +} + +NS_CC_END + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/CCPhysicsWorld.h b/cocos2dx/physics/CCPhysicsWorld.h new file mode 100644 index 0000000000..bd06fdf661 --- /dev/null +++ b/cocos2dx/physics/CCPhysicsWorld.h @@ -0,0 +1,141 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsSetting.h" +#ifdef CC_USE_PHYSICS + +#ifndef __CCPHYSICS_WORLD_H__ +#define __CCPHYSICS_WORLD_H__ + +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" + + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +typedef struct cpArbiter cpArbiter; +typedef struct cpSpace cpSpace; +#endif + +NS_CC_BEGIN + +class PhysicsBody; +class PhysicsJoint; +class PhysicsWorldInfo; +class PhysicsShape; +class PhysicsContact; +class PhysicsContactPreSolve; +class PhysicsContactPostSolve; +class PhysicsContactListener; +class Array; + +class Sprite; +class Scene; +class DrawNode; + +/** + * @brief An PhysicsWorld object simulates collisions and other physical properties. You do not create PhysicsWorld objects directly; instead, you can get it from an Scene object. + */ +class PhysicsWorld +{ +public: + /** Adds a joint to the physics world.*/ + void addJoint(PhysicsJoint* joint); + /** Removes a joint from the physics world.*/ + void removeJoint(PhysicsJoint* joint); + /** Remove all joints from the physics world.*/ + void removeAllJoints(); + + Array* getBodysAlongRay(Point start, Point end) const; + Array* getBodysAtPoint(Point point) const; + Array* getBodysInRect(Rect rect) const; + Array* getAllBody() const; + + /** Register a listener to receive contact callbacks*/ + inline void registerContactListener(PhysicsContactListener* delegate) { _listener = delegate; } + /** Unregister a listener. */ + inline void unregisterContactListener() { _listener = nullptr; } + + /** get the gravity value */ + inline Point getGravity() { return _gravity; } + /** set the gravity value */ + void setGravity(Point gravity); + + /** test the debug draw is enabled */ + inline bool isDebugDraw() { return _debugDraw; } + /** set the debug draw */ + inline void setDebugDraw(bool debugDraw) { _debugDraw = debugDraw; } + +protected: + static PhysicsWorld* create(); + bool init(); + + void setScene(Scene* scene); + + virtual void addChild(PhysicsBody* body); + virtual void addShape(PhysicsShape* shape); + virtual void update(float delta); + + virtual void debugDraw(); + virtual void drawWithShape(DrawNode* node, PhysicsShape* shape); + + + virtual int collisionBeginCallback(const PhysicsContact& contact); + virtual int collisionPreSolveCallback(const PhysicsContact& contact, const PhysicsContactPreSolve& solve); + virtual void collisionPostSolveCallback(const PhysicsContact& contact, const PhysicsContactPostSolve& solve); + virtual void collisionSeparateCallback(const PhysicsContact& contact); + +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + static int collisionBeginCallbackFunc(cpArbiter *arb, struct cpSpace *space, void *data); + static int collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); + static void collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); + static void collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data); +#endif + +protected: + Point _gravity; + float _speed; + PhysicsWorldInfo* _info; + PhysicsContactListener* _listener; + + + Array* _bodys; + Scene* _scene; + + bool _debugDraw; + DrawNode* _drawNode; + +protected: + PhysicsWorld(); + virtual ~PhysicsWorld(); + + friend class Sprite; + friend class Scene; + friend class PhysicsBody; +}; + +NS_CC_END + +#endif // __CCPHYSICS_WORLD_H__ + +#endif // CC_USE_PHYSICS diff --git a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp new file mode 100644 index 0000000000..5fd8ceb171 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsBodyInfo.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +NS_CC_BEGIN + +PhysicsBodyInfo::PhysicsBodyInfo() +: body(nullptr) +{ +} + +PhysicsBodyInfo::~PhysicsBodyInfo() +{ + if (body) cpBodyFree(body); +} + +Clonable* PhysicsBodyInfo::clone() const +{ + return nullptr; +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h new file mode 100644 index 0000000000..0faef2eb49 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsBodyInfo.h @@ -0,0 +1,53 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_BODY_INFO_H__ +#define __CCPHYSICS_BODY_INFO_H__ +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" +#include "cocoa/CCObject.h" + +NS_CC_BEGIN + +class PhysicsBodyInfo : public Clonable +{ +public: + cpBody* body; + +private: + PhysicsBodyInfo(); + ~PhysicsBodyInfo(); + + Clonable* clone() const override; + + friend class PhysicsBody; +}; + +NS_CC_END +#endif // __CCPHYSICS_BODY_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.cpp new file mode 100644 index 0000000000..53b4f29b14 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsContactInfo.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +NS_CC_BEGIN + +PhysicsContactInfo::PhysicsContactInfo(PhysicsContact* contact) +: contact(contact) +{ +} + +PhysicsContactInfo::~PhysicsContactInfo() +{ +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.h new file mode 100644 index 0000000000..5033a2181d --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsContactInfo.h @@ -0,0 +1,50 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_CONTACT_INFO_H__ +#define __CCPHYSICS_CONTACT_INFO_H__ +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsContact; +class PhysicsContactInfo +{ +public: + PhysicsContact* contact; + +private: + PhysicsContactInfo(PhysicsContact* contact); + ~PhysicsContactInfo(); + + friend class PhysicsContact; +}; + +NS_CC_END +#endif // __CCPHYSICS_WORLD_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsHelper.h b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h new file mode 100644 index 0000000000..a026d632b7 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsHelper.h @@ -0,0 +1,69 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_HELPER_H__ +#define __CCPHYSICS_HELPER_H__ + +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" +#include "cocoa/CCGeometry.h" + +NS_CC_BEGIN + +class PhysicsHelper +{ +public: + static Point cpv2point(const cpVect& vec) { return Point(vec.x, vec.y); } + static cpVect point2cpv(const Point& point) { return cpv(point.x, point.y); } + static Size cpv2size(const cpVect& vec) { return Size(vec.x, vec.y); } + static cpVect size2cpv(const Size& size) { return cpv(size.width, size.height); } + static float cpfloat2float(cpFloat f) { return f; } + static cpFloat float2cpfloat(float f) { return f; } + + static void cpvs2points(const cpVect* cpvs, Point* points, int count) + { + for (int i = 0; i < count; ++i) + { + points[i] = cpv2point(cpvs[i]); + } + } + + static cpVect* points2cpvs(const Point* points, cpVect* cpvs, int count) + { + for (int i = 0; i < count; ++i) + { + cpvs[i] = point2cpv(points[i]); + } + + return cpvs; + } +}; + +NS_CC_END +#endif // __CCPHYSICS_HELPER_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp new file mode 100644 index 0000000000..aca28aa0fb --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsJointInfo.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +NS_CC_BEGIN + +PhysicsJointInfo::PhysicsJointInfo() +: joint(nullptr) +{ +} + +PhysicsJointInfo::~PhysicsJointInfo() +{ + if (joint) + { + cpConstraintFree(joint); + } +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h new file mode 100644 index 0000000000..47b1fc6141 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsJointInfo.h @@ -0,0 +1,49 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_JOINT_INFO_H__ +#define __CCPHYSICS_JOINT_INFO_H__ +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsJointInfo +{ +public: + cpConstraint* joint; + +private: + PhysicsJointInfo(); + ~PhysicsJointInfo(); + + friend class PhysicsJoint; +}; + +NS_CC_END +#endif // __CCPHYSICS_SHAPE_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp new file mode 100644 index 0000000000..0734bf6e49 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsShapeInfo.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +#include +NS_CC_BEGIN + +std::map PhysicsShapeInfo::map; + +PhysicsShapeInfo::PhysicsShapeInfo(PhysicsShape* shape) +: shape(shape) +{ +} + +PhysicsShapeInfo::~PhysicsShapeInfo() +{ + for (auto it = shapes.begin(); it != shapes.end(); it++) + { + cpShapeFree(*it); + + auto mit = map.find(*it); + if (mit != map.end()) map.erase(*it); + } +} + +void PhysicsShapeInfo::add(cpShape* shape) +{ + if (shape == nullptr) return; + + shapes.push_back(shape); + map.insert(std::pair(shape, this)); +} + +void PhysicsShapeInfo::remove(cpShape* shape) +{ + if (shape == nullptr) return; + + auto it = std::find(shapes.begin(), shapes.end(), shape); + if (it != shapes.end()) + { + shapes.erase(it); + + auto mit = map.find(shape); + if (mit != map.end()) map.erase(mit); + } +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h new file mode 100644 index 0000000000..7e0be63747 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsShapeInfo.h @@ -0,0 +1,62 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_SHAPE_INFO_H__ +#define __CCPHYSICS_SHAPE_INFO_H__ + +#include +#include +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" + +NS_CC_BEGIN + +class PhysicsShape; + +class PhysicsShapeInfo +{ +public: + void add(cpShape* shape); + void remove(cpShape* shape); + void removeall(); + +public: + std::vector shapes; + static std::map map; + PhysicsShape* shape; + +private: + PhysicsShapeInfo(PhysicsShape* shape); + ~PhysicsShapeInfo(); + + friend class PhysicsShape; +}; + +NS_CC_END +#endif // __CCPHYSICS_SHAPE_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.cpp b/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.cpp new file mode 100644 index 0000000000..57f601ead7 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCPhysicsWorldInfo.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) +NS_CC_BEGIN + +PhysicsWorldInfo::PhysicsWorldInfo() +{ + space = cpSpaceNew(); +} + +PhysicsWorldInfo::~PhysicsWorldInfo() +{ + cpSpaceFree(space); +} + +NS_CC_END +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.h b/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.h new file mode 100644 index 0000000000..3bc0cf2bc4 --- /dev/null +++ b/cocos2dx/physics/chipmunk/CCPhysicsWorldInfo.h @@ -0,0 +1,49 @@ +/**************************************************************************** + Copyright (c) 2013 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "../CCPhysicsSetting.h" +#if (CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK) + +#ifndef __CCPHYSICS_WORLD_INFO_H__ +#define __CCPHYSICS_WORLD_INFO_H__ +#include "chipmunk.h" +#include "platform/CCPlatformMacros.h" +NS_CC_BEGIN + +class PhysicsWorldInfo +{ +public: + cpSpace* space; + +private: + PhysicsWorldInfo(); + ~PhysicsWorldInfo(); + + friend class PhysicsWorld; +}; + +NS_CC_END +#endif // __CCPHYSICS_WORLD_INFO_H__ + +#endif // CC_PHYSICS_ENGINE == CC_PHYSICS_CHIPMUNK diff --git a/cocos2dx/platform/CCAccelerometerDelegate.h b/cocos2dx/platform/CCAccelerometerDelegate.h deleted file mode 100644 index 2cb0dafac9..0000000000 --- a/cocos2dx/platform/CCAccelerometerDelegate.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CCACCELEROMETER_DELEGATE_H__ -#define __CCACCELEROMETER_DELEGATE_H__ - -#include "platform/CCCommon.h" - -NS_CC_BEGIN -/** -@brief The device accelerometer reports values for each axis in units of g-force -*/ -class Acceleration -{ -public: - double x; - double y; - double z; - - double timestamp; - /** - * @js NA - * @lua NA - */ - Acceleration(): x(0), y(0), z(0), timestamp(0) {} -}; - -NS_CC_END - -#endif diff --git a/cocos2dx/platform/android/CCAccelerometer.h b/cocos2dx/platform/android/CCAccelerometer.h deleted file mode 100644 index df6569cb3b..0000000000 --- a/cocos2dx/platform/android/CCAccelerometer.h +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_ANDROID_CCACCELEROMETER_H__ -#define __PLATFORM_ANDROID_CCACCELEROMETER_H__ - -#include "platform/CCCommon.h" -#include "platform/CCAccelerometerDelegate.h" -#include - -namespace cocos2d { - -class Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(); - /** - * @js NA - * @lua NA - */ - ~Accelerometer(); - - void setDelegate(std::function function); - void setAccelerometerInterval(float interval); - void update(float x, float y, float z, long sensorTimeStamp); - -private: - std::function _function; - Acceleration _accelerationValue; -}; - -}//namespace cocos2d - -#endif diff --git a/cocos2dx/platform/emscripten/CCAccelerometer.h b/cocos2dx/platform/emscripten/CCAccelerometer.h deleted file mode 100644 index 576b496590..0000000000 --- a/cocos2dx/platform/emscripten/CCAccelerometer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Accelerometer.h - * - * Created on: Aug 9, 2011 - * Author: laschweinski - */ - -#ifndef CCACCELEROMETER_H_ -#define CCACCELEROMETER_H_ - -#include "platform/CCAccelerometerDelegate.h" -#include - -namespace cocos2d { - -class Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(){} - /** - * @js NA - * @lua NA - */ - ~Accelerometer(){} - - static Accelerometer* sharedAccelerometer() { return NULL; }; - - void removeDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void addDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);}; -}; - -}//namespace cocos2d - -#endif /* CCACCELEROMETER_H_ */ diff --git a/cocos2dx/platform/ios/CCAccelerometer.h b/cocos2dx/platform/ios/CCAccelerometer.h deleted file mode 100644 index f218da6d36..0000000000 --- a/cocos2dx/platform/ios/CCAccelerometer.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__ -#define __PLATFORM_IPHONE_CCACCELEROMETER_H__ - -#include -#include "platform/CCAccelerometerDelegate.h" - -NS_CC_BEGIN - -class Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(); - /** - * @js NA - * @lua NA - */ - ~Accelerometer(); - - void setDelegate(std::function function); - void setAccelerometerInterval(float interval); -}; - -NS_CC_END - -#endif diff --git a/cocos2dx/platform/linux/CCAccelerometer.h b/cocos2dx/platform/linux/CCAccelerometer.h deleted file mode 100644 index 576b496590..0000000000 --- a/cocos2dx/platform/linux/CCAccelerometer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Accelerometer.h - * - * Created on: Aug 9, 2011 - * Author: laschweinski - */ - -#ifndef CCACCELEROMETER_H_ -#define CCACCELEROMETER_H_ - -#include "platform/CCAccelerometerDelegate.h" -#include - -namespace cocos2d { - -class Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(){} - /** - * @js NA - * @lua NA - */ - ~Accelerometer(){} - - static Accelerometer* sharedAccelerometer() { return NULL; }; - - void removeDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void addDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);}; -}; - -}//namespace cocos2d - -#endif /* CCACCELEROMETER_H_ */ diff --git a/cocos2dx/platform/mac/CCAccelerometer.h b/cocos2dx/platform/mac/CCAccelerometer.h deleted file mode 100644 index cf3f9ca945..0000000000 --- a/cocos2dx/platform/mac/CCAccelerometer.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_MAC_CCACCELEROMETER_H__ -#define __PLATFORM_MAC_CCACCELEROMETER_H__ - -#include -#include "platform/CCAccelerometerDelegate.h" - -NS_CC_BEGIN - -class CC_DLL Accelerometer -{ -public: - Accelerometer() {} - /** - * @js NA - * @lua NA - */ - ~Accelerometer() {} - - void setDelegate(std::function function) { CC_UNUSED_PARAM(function); } - void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);}; -}; - -NS_CC_END - -#endif diff --git a/cocos2dx/platform/nacl/CCAccelerometer.h b/cocos2dx/platform/nacl/CCAccelerometer.h deleted file mode 100644 index a56075c8e3..0000000000 --- a/cocos2dx/platform/nacl/CCAccelerometer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013 The Chromium Authors - -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 __CCACCELEROMETER_H__ -#define __CCACCELEROMETER_H__ - -#include "platform/CCAccelerometerDelegate.h" -#include - -namespace cocos2d { - -class Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(){} - /** - * @js NA - * @lua NA - */ - ~Accelerometer(){} - - static Accelerometer* sharedAccelerometer() { return NULL; }; - - void removeDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void addDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setDelegate(std::function function) {CC_UNUSED_PARAM(function);}; - void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);}; -}; - -} - -#endif /* __CCACCELEROMETER_H__ */ diff --git a/cocos2dx/platform/win32/CCAccelerometer.h b/cocos2dx/platform/win32/CCAccelerometer.h deleted file mode 100644 index babb2c284d..0000000000 --- a/cocos2dx/platform/win32/CCAccelerometer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __PLATFORM_WIN32_UIACCELEROMETER_H__ -#define __PLATFORM_WIN32_UIACCELEROMETER_H__ - -#include "platform/CCAccelerometerDelegate.h" -#include - -NS_CC_BEGIN - -class CC_DLL Accelerometer -{ -public: - /** - * @js ctor - */ - Accelerometer(); - /** - * @js NA - * @lua NA - */ - ~Accelerometer(); - - void setDelegate(std::function function); - void setAccelerometerInterval(float interval); - void update( double x,double y,double z,double timestamp ); -private: - Acceleration _accelerationValue; - std::function _function; -}; - -NS_CC_END - -#endif diff --git a/cocos2dx/proj.linux/Makefile b/cocos2dx/proj.linux/Makefile index 951e1e87c8..a1234a9f90 100644 --- a/cocos2dx/proj.linux/Makefile +++ b/cocos2dx/proj.linux/Makefile @@ -81,6 +81,11 @@ SOURCES = ../actions/CCAction.cpp \ ../particle_nodes/CCParticleSystem.cpp \ ../particle_nodes/CCParticleSystemQuad.cpp \ ../particle_nodes/CCParticleBatchNode.cpp \ +../physics/CCPhysicsBody.cpp \ +../physics/CCPhysicsContactDelegate.cpp \ +../physics/CCPhysicsFixture.cpp \ +../physics/CCPhysicsJoint.cpp \ +../physics/CCPhysicsWorld.cpp \ ../platform/CCSAXParser.cpp \ ../platform/CCThread.cpp \ ../platform/CCEGLViewProtocol.cpp \ diff --git a/cocos2dx/proj.linux/cocos2dx.mk b/cocos2dx/proj.linux/cocos2dx.mk index 29c1f8f3fd..061b5b9a5d 100644 --- a/cocos2dx/proj.linux/cocos2dx.mk +++ b/cocos2dx/proj.linux/cocos2dx.mk @@ -59,7 +59,8 @@ INCLUDES += \ -I$(COCOS_SRC)/platform/linux \ -I$(COCOS_SRC)/platform/third_party/linux/libjpeg \ -I$(COCOS_SRC)/platform/third_party/linux/libtiff \ - -I$(COCOS_SRC)/platform/third_party/linux/libwebp + -I$(COCOS_SRC)/platform/third_party/linux/libwebp \ + -I$(COCOS_ROOT/external/chipmunk/include/chipmunk LBITS := $(shell getconf LONG_BIT) ifeq ($(LBITS),64) diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj b/cocos2dx/proj.win32/cocos2d.vcxproj index d6efeb7168..a37adf2788 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj +++ b/cocos2dx/proj.win32/cocos2d.vcxproj @@ -69,7 +69,7 @@ Disabled - $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\libfreetype2;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;$(ProjectDir)..\platform\third_party\common\etc;%(AdditionalIncludeDirectories) + $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(ProjectDir)..;$(ProjectDir)..\platform\win32;$(ProjectDir)..\platform\third_party\win32\iconv;$(ProjectDir)..\platform\third_party\win32\zlib;$(ProjectDir)..\platform\third_party\win32\libpng;$(ProjectDir)..\platform\third_party\win32\libjpeg;$(ProjectDir)..\platform\third_party\win32\libtiff;$(ProjectDir)..\platform\third_party\win32\libwebp;$(ProjectDir)..\platform\third_party\win32\libfreetype2;$(ProjectDir)..\platform\third_party\win32\OGLES;..\include;$(ProjectDir)..\kazmath\include;$(ProjectDir)..\platform\third_party\common\etc;$(ProjectDir)..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -211,6 +211,21 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + + + + + + + + + + + + + + + @@ -365,6 +380,24 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir + + + + + + + + + + + + + + + + + + diff --git a/cocos2dx/proj.win32/cocos2d.vcxproj.filters b/cocos2dx/proj.win32/cocos2d.vcxproj.filters index dcd9961e74..81e2e2a3d0 100644 --- a/cocos2dx/proj.win32/cocos2d.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d.vcxproj.filters @@ -103,6 +103,15 @@ {3ff2746c-a91b-4b86-93b7-43a9ec14825b} + + {08593631-5bf5-46aa-9436-62595c4f7bf6} + + + {aeadfa95-9c89-4212-98ae-89ad57db596a} + + + {b9880458-36e5-4f28-a34b-d01d9512a395} + @@ -512,6 +521,51 @@ event_dispatcher + + physics + + + physics + + + physics + + + physics + + + physics + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + @@ -1035,5 +1089,59 @@ event_dispatcher + + physics + + + physics + + + physics + + + physics + + + physics + + + physics + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\chipmunk + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + + + physics\Box2D + \ No newline at end of file diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index ef36444240..741a1e1683 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -295,13 +295,19 @@ Sprite* Sprite::initWithCGImage(CGImageRef pImage, const char *pszKey) Sprite::Sprite(void) : _shouldBeHidden(false) -, _texture(NULL) +, _texture(nullptr) +#ifdef CC_USE_PHYSICS +, _physicsBody(nullptr) +#endif { } Sprite::~Sprite(void) { CC_SAFE_RELEASE(_texture); +#ifdef CC_USE_PHYSICS + CC_SAFE_RELEASE(_physicsBody); +#endif } void Sprite::setTextureRect(const Rect& rect) @@ -784,12 +790,27 @@ void Sprite::setPosition(const Point& pos) { Node::setPosition(pos); SET_DIRTY_RECURSIVELY(); + +#ifdef CC_USE_PHYSICS + if (_physicsBody) + { + _physicsBody->setPosition(pos); + } +#endif } -void Sprite::setRotation(float fRotation) +void Sprite::setRotation(float rotation) { - Node::setRotation(fRotation); + Node::setRotation(rotation); + SET_DIRTY_RECURSIVELY(); + +#ifdef CC_USE_PHYSICS + if (_physicsBody) + { + _physicsBody->setRotation(rotation); + } +#endif } void Sprite::setRotationX(float fRotationX) @@ -886,6 +907,33 @@ bool Sprite::isFlippedY(void) const return _flippedY; } +#ifdef CC_USE_PHYSICS +void Sprite::setPhysicsBody(PhysicsBody* body) +{ + _physicsBody = body; + _physicsBody->retain(); + _physicsBody->setPosition(getPosition()); + _physicsBody->setRotation(getRotation()); +} + +PhysicsBody* Sprite::getPhysicsBody() const +{ + return _physicsBody; +} + +void Sprite::visit() +{ + if (_physicsBody) + { + Node::setPosition(_physicsBody->getPosition()); + Node::setRotation(_physicsBody->getRotation()); + SET_DIRTY_RECURSIVELY(); + } + + Node::visit(); +} +#endif //CC_USE_PHYSICS + // // RGBA protocol // diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 0778541a7c..815cd67614 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -36,6 +36,7 @@ THE SOFTWARE. #ifdef EMSCRIPTEN #include "base_nodes/CCGLBufferedNode.h" #endif // EMSCRIPTEN +#include "physics/CCPhysicsBody.h" NS_CC_BEGIN @@ -460,6 +461,20 @@ public: */ void setFlippedY(bool flippedY); +#ifdef CC_USE_PHYSICS + /** + * set the PhysicsBody that let the sprite effect with physics + */ + virtual void setPhysicsBody(PhysicsBody* body); + + /** + * get the PhysicsBody the sprite have + */ + PhysicsBody* getPhysicsBody() const; + + virtual void visit() override; +#endif + /// @} End of Sprite properties getter/setters /** @deprecated Use isFlippedY() instead */ @@ -575,6 +590,10 @@ protected: // image is flipped bool _flippedX; /// Whether the sprite is flipped horizaontally or not. bool _flippedY; /// Whether the sprite is flipped vertically or not. + +#ifdef CC_USE_PHYSICS + PhysicsBody* _physicsBody; ///< the physicsBody the node have +#endif }; diff --git a/extensions/CocoStudio/GUI/Layouts/Layout.cpp b/extensions/CocoStudio/GUI/Layouts/Layout.cpp index 779ff73616..17e90a2108 100644 --- a/extensions/CocoStudio/GUI/Layouts/Layout.cpp +++ b/extensions/CocoStudio/GUI/Layouts/Layout.cpp @@ -462,7 +462,7 @@ bool RectClippingNode::init() rect[2] = Point(_clippingSize.width, _clippingSize.height); rect[3] = Point(0, _clippingSize.height); - Color4F green = {0, 1, 0, 1}; + Color4F green(0, 1, 0, 1); m_pInnerStencil->drawPolygon(rect, 4, green, 0, green); if (CCClippingNode::init(m_pInnerStencil)) { @@ -480,7 +480,7 @@ void RectClippingNode::setClippingSize(const Size &size) rect[1] = Point(_clippingSize.width, 0); rect[2] = Point(_clippingSize.width, _clippingSize.height); rect[3] = Point(0, _clippingSize.height); - Color4F green = {0, 1, 0, 1}; + Color4F green(0, 1, 0, 1); m_pInnerStencil->clear(); m_pInnerStencil->drawPolygon(rect, 4, green, 0, green); } diff --git a/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk b/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk index 5ffbbfbf2f..a85ad02ade 100644 --- a/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk +++ b/samples/Cpp/AssetsManagerTest/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj index 616d9f442d..2e747d142d 100644 --- a/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj +++ b/samples/Cpp/HelloCpp/proj.win32/HelloCpp.vcxproj @@ -67,7 +67,7 @@ Disabled - $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks @@ -84,7 +84,7 @@ true Windows MachineX86 - libcocos2d.lib;%(AdditionalDependencies) + libcocos2d.lib;libchipmunk.lib;%(AdditionalDependencies) diff --git a/samples/Cpp/TestCpp/Android.mk b/samples/Cpp/TestCpp/Android.mk index 8e8f270da7..87d662be3a 100644 --- a/samples/Cpp/TestCpp/Android.mk +++ b/samples/Cpp/TestCpp/Android.mk @@ -118,6 +118,7 @@ Classes/PerformanceTest/PerformanceSpriteTest.cpp \ Classes/PerformanceTest/PerformanceTest.cpp \ Classes/PerformanceTest/PerformanceTextureTest.cpp \ Classes/PerformanceTest/PerformanceTouchesTest.cpp \ +Classes/PhysicsTest/PhysicsTest.cpp \ Classes/RenderTextureTest/RenderTextureTest.cpp \ Classes/RotateWorldTest/RotateWorldTest.cpp \ Classes/SceneTest/SceneTest.cpp \ diff --git a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp index b35b38048e..d99f5e6f3c 100644 --- a/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp +++ b/samples/Cpp/TestCpp/Classes/Box2DTestBed/Box2dView.cpp @@ -53,6 +53,7 @@ bool MenuLayer::initWithEntryID(int entryId) m_entryID = entryId; setTouchEnabled( true ); + setTouchMode(Touch::DispatchMode::ONE_BY_ONE); Box2DView* view = Box2DView::viewWithEntryID( entryId ); addChild(view, 0, kTagBox2DNode); @@ -90,7 +91,7 @@ bool MenuLayer::initWithEntryID(int entryId) listener->onTouchBegan = CC_CALLBACK_2(MenuLayer::onTouchBegan, this); listener->onTouchMoved = CC_CALLBACK_2(MenuLayer::onTouchMoved, this); - EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 0); + EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 1); _touchListener = listener; return true; } @@ -185,6 +186,7 @@ bool Box2DView::initWithEntryID(int entryId) m_entry = g_testEntries + entryId; m_test = m_entry->createFcn(); + setTouchMode(Touch::DispatchMode::ONE_BY_ONE); // Removes Touch Event Listener EventDispatcher::getInstance()->removeEventListener(_touchListener); @@ -197,7 +199,7 @@ bool Box2DView::initWithEntryID(int entryId) listener->onTouchMoved = CC_CALLBACK_2(Box2DView::onTouchMoved, this); listener->onTouchEnded = CC_CALLBACK_2(Box2DView::onTouchEnded, this); - EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 10); + EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, -10); _touchListener = listener; return true; @@ -268,8 +270,6 @@ void Box2DView::onTouchEnded(Touch* touch, Event* event) log("Box2DView::onTouchEnded, pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y); m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y)); - -// EventDispatcher::getInstance()->setPriorityWithFixedValue(_touchEventId, -1); } // void Box2DView::accelerometer(UIAccelerometer* accelerometer, Acceleration* acceleration) diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp index 8b0e698c47..e8081a2563 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.cpp @@ -573,19 +573,16 @@ RemoveMenuItemWhenMove::RemoveMenuItemWhenMove() setTouchEnabled(true); setTouchMode(Touch::DispatchMode::ONE_BY_ONE); -} - -void RemoveMenuItemWhenMove::onRegisterTouchListener() -{ + // Register Touch Event - auto listener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); - listener->setSwallowTouches(false); + _touchListener = TouchEventListener::create(Touch::DispatchMode::ONE_BY_ONE); + _touchListener->setSwallowTouches(false); - listener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this); - listener->onTouchMoved = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchMoved, this); + _touchListener->onTouchBegan = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchBegan, this); + _touchListener->onTouchMoved = CC_CALLBACK_2(RemoveMenuItemWhenMove::onTouchMoved, this); + + EventDispatcher::getInstance()->addEventListenerWithFixedPriority(_touchListener, -100); - EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, -100); - _touchListener = listener; } void RemoveMenuItemWhenMove::goBack(Object *pSender) diff --git a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h index af97bf66aa..a6384d0195 100644 --- a/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h +++ b/samples/Cpp/TestCpp/Classes/MenuTest/MenuTest.h @@ -107,8 +107,6 @@ public: RemoveMenuItemWhenMove(); ~RemoveMenuItemWhenMove(); - virtual void onRegisterTouchListener() override; -// virtual void registerWithTouchDispatcher(void); virtual bool onTouchBegan(Touch *touch, Event *event); virtual void onTouchMoved(Touch *touch, Event *event); diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp new file mode 100644 index 0000000000..94f63e7f59 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.cpp @@ -0,0 +1,164 @@ +#include "PhysicsTest.h" +#include "../testResource.h" +USING_NS_CC; + +PhysicsTestLayer::PhysicsTestLayer() +: _spriteTexture(nullptr) +, _scene(nullptr) +{ +#ifdef CC_USE_PHYSICS + setTouchEnabled(true); + setAccelerometerEnabled(true); + + // title + auto label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36); + label->setPosition(Point( VisibleRect::center().x, VisibleRect::top().y - 30)); + this->addChild(label, -1); + + // menu for debug layer + MenuItemFont::setFontSize(18); + auto item = MenuItemFont::create("Toggle debug", CC_CALLBACK_1(PhysicsTestLayer::toggleDebugCallback, this)); + + auto menu = Menu::create(item, NULL); + this->addChild(menu); + menu->setPosition(Point(VisibleRect::right().x-100, VisibleRect::top().y-60)); + + auto sp = Sprite::create(); + auto body = PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size); + sp->setPhysicsBody(body); + this->addChild(sp); + sp->setPosition(VisibleRect::center()); + + auto parent = SpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); + _spriteTexture = parent->getTexture(); + + addNewSpriteAtPosition(VisibleRect::center()); + + createResetButton(); + +#else + auto label = LabelTTF::create("Should define CC_USE_BOX2D or CC_USE_CHIPMUNK\n to run this test case", + "Arial", + 18); + auto size = Director::getInstance()->getWinSize(); + label->setPosition(Point(size.width/2, size.height/2)); + + addChild(label); +#endif +} + +void PhysicsTestLayer::toggleDebugCallback(Object* sender) +{ +#ifdef CC_USE_PHYSICS + if (_scene != nullptr) + { + _scene->getPhysicsWorld()->setDebugDraw(!_scene->getPhysicsWorld()->isDebugDraw()); + } +#endif +} + +PhysicsTestLayer::~PhysicsTestLayer() +{ +} + +void PhysicsTestLayer::createResetButton() +{ + auto reset = MenuItemImage::create("Images/r1.png", "Images/r2.png", [](Object *sender) { + auto s = new PhysicsTestScene(); + s->initTest(); + auto child = new PhysicsTestLayer(); + child->setScene(s); + s->addChild(child); + child->release(); + Director::getInstance()->replaceScene(s); + s->release(); + }); + + auto menu = Menu::create(reset, NULL); + + menu->setPosition(Point(VisibleRect::bottom().x, VisibleRect::bottom().y + 30)); + this->addChild(menu, -1); + +} + +void PhysicsTestLayer::onTouchesEnded(const std::vector& touches, Event* event) +{ + //Add a new body/atlas sprite at the touched location + + for( auto &touch: touches) + { + auto location = touch->getLocation(); + + addNewSpriteAtPosition( location ); + } +} + + +void PhysicsTestLayer::onAcceleration(Acceleration* acc, Event* event) +{ +#ifdef CC_USE_PHYSICS + static float prevX=0, prevY=0; + +#define kFilterFactor 0.05f + + float accelX = (float) acc->x * kFilterFactor + (1- kFilterFactor)*prevX; + float accelY = (float) acc->y * kFilterFactor + (1- kFilterFactor)*prevY; + + prevX = accelX; + prevY = accelY; + + auto v = Point( accelX, accelY); + v = v * 200; + + if(_scene != nullptr) + { + _scene->getPhysicsWorld()->setGravity(v); + } +#endif +} + +void PhysicsTestLayer::addNewSpriteAtPosition(Point p) +{ +#ifdef CC_USE_PHYSICS + CCLOG("Add sprite %0.2f x %02.f",p.x,p.y); + + int posx, posy; + + posx = CCRANDOM_0_1() * 200.0f; + posy = CCRANDOM_0_1() * 200.0f; + + posx = (posx % 4) * 85; + posy = (posy % 3) * 121; + + auto sp = Sprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121)); + auto body = PhysicsBody::createBox(Size(48, 108)); + sp->setPhysicsBody(body); + sp->setPosition(p); + this->addChild(sp); +#endif +} + +bool PhysicsTestScene::initTest() +{ +#ifdef CC_USE_PHYSICS + if (TestScene::initWithPhysics()) + { + this->getPhysicsWorld()->setDebugDraw(true); + return true; + } +#else + return TestScene::init(); +#endif + + return false; +} + +void PhysicsTestScene::runThisTest() +{ + auto layer = new PhysicsTestLayer(); + layer->setScene(this); + addChild(layer); + layer->release(); + + Director::getInstance()->replaceScene(this); +} diff --git a/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h new file mode 100644 index 0000000000..3c95ed90c8 --- /dev/null +++ b/samples/Cpp/TestCpp/Classes/PhysicsTest/PhysicsTest.h @@ -0,0 +1,32 @@ +#ifndef _PHYSICS_TEST_H_ +#define _PHYSICS_TEST_H_ + +#include "cocos2d.h" +#include "../testBasic.h" + +class PhysicsTestLayer : public Layer +{ + Texture2D* _spriteTexture; // weak ref + Scene* _scene; + +public: + PhysicsTestLayer(); + ~PhysicsTestLayer(); + + void createResetButton(); + + inline void setScene(Scene* scene) { _scene = scene; } + void toggleDebugCallback(Object* sender); + void addNewSpriteAtPosition(Point p); + virtual void onTouchesEnded(const std::vector& touches, Event* event) override; + virtual void onAcceleration(Acceleration* acc, Event* event) override; +} ; + +class PhysicsTestScene : public TestScene +{ +public: + virtual bool initTest() override; + virtual void runThisTest(); +}; + +#endif diff --git a/samples/Cpp/TestCpp/Classes/controller.cpp b/samples/Cpp/TestCpp/Classes/controller.cpp index f3ad2162a7..fc58fcda60 100644 --- a/samples/Cpp/TestCpp/Classes/controller.cpp +++ b/samples/Cpp/TestCpp/Classes/controller.cpp @@ -66,6 +66,7 @@ struct { { "ParallaxTest", [](){return new ParallaxTestScene(); } }, { "ParticleTest", [](){return new ParticleTestScene(); } }, { "PerformanceTest", []() { return new PerformanceTestScene(); } }, + { "PhysicsTest", []() { return new PhysicsTestScene(); } }, { "RenderTextureTest", [](){return new RenderTextureScene(); } }, { "RotateWorldTest", [](){return new RotateWorldTestScene(); } }, { "SceneTest", [](){return new SceneTestScene();} }, @@ -152,7 +153,7 @@ void TestController::menuCallback(Object * sender) // create the test scene and run it auto scene = g_aTestNames[idx].callback(); - if (scene) + if (scene && scene->initTest()) { scene->runThisTest(); scene->release(); diff --git a/samples/Cpp/TestCpp/Classes/testBasic.cpp b/samples/Cpp/TestCpp/Classes/testBasic.cpp index c1c7b22bad..9600d3b067 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.cpp +++ b/samples/Cpp/TestCpp/Classes/testBasic.cpp @@ -3,8 +3,11 @@ TestScene::TestScene(bool bPortrait) { - - Scene::init(); +} + +bool TestScene::initTest() +{ + return Scene::init(); } void TestScene::onEnter() diff --git a/samples/Cpp/TestCpp/Classes/testBasic.h b/samples/Cpp/TestCpp/Classes/testBasic.h index f4be332a7d..7bc95ab05c 100644 --- a/samples/Cpp/TestCpp/Classes/testBasic.h +++ b/samples/Cpp/TestCpp/Classes/testBasic.h @@ -11,6 +11,7 @@ class TestScene : public Scene { public: TestScene(bool bPortrait = false); + virtual bool initTest(); virtual void onEnter(); virtual void runThisTest() = 0; diff --git a/samples/Cpp/TestCpp/Classes/tests.h b/samples/Cpp/TestCpp/Classes/tests.h index 724f95276f..4268bdbb45 100644 --- a/samples/Cpp/TestCpp/Classes/tests.h +++ b/samples/Cpp/TestCpp/Classes/tests.h @@ -65,5 +65,6 @@ #include "TexturePackerEncryptionTest/TextureAtlasEncryptionTest.h" #include "DataVisitorTest/DataVisitorTest.h" #include "ConfigurationTest/ConfigurationTest.h" +#include "PhysicsTest/PhysicsTest.h" #endif diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/Hello.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/Hello.png.REMOVED.git-id new file mode 100644 index 0000000000..f02d84fd8f --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/Hello.png.REMOVED.git-id @@ -0,0 +1 @@ +5fe89fb5bd58cedf13b0363f97b20e3ea7ff255d \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/UITest/background.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/UITest/background.png.REMOVED.git-id new file mode 100644 index 0000000000..746e4e19e9 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/UITest/background.png.REMOVED.git-id @@ -0,0 +1 @@ +500d95937f3fd81659da66d2099b6c80d988a6b5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/b11.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/b11.png.REMOVED.git-id new file mode 100644 index 0000000000..0b4502562c --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/b11.png.REMOVED.git-id @@ -0,0 +1 @@ +39179659c7b94b213b6ab7b24372c96378f61062 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/bitmapFontTest2.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/bitmapFontTest2.png.REMOVED.git-id new file mode 100644 index 0000000000..d025022480 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/bitmapFontTest2.png.REMOVED.git-id @@ -0,0 +1 @@ +9975e4961272d5bda6d5f3bbd61ea0fc02222199 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/examples/examples.json.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/examples/examples.json.REMOVED.git-id new file mode 100644 index 0000000000..f28818a9af --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/examples/examples.json.REMOVED.git-id @@ -0,0 +1 @@ +0a4ce85782909e964aa0e95e89bab8272d0c3d4e \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id new file mode 100644 index 0000000000..596d52b27c --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id @@ -0,0 +1 @@ +0a77108d377ceb5f084f1aab1877159df9499428 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id new file mode 100644 index 0000000000..6f99243a26 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id @@ -0,0 +1 @@ +39d29cbeb700598c3e4ad6d3ee0ac273a3385fcd \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id new file mode 100644 index 0000000000..746e4e19e9 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id @@ -0,0 +1 @@ +500d95937f3fd81659da66d2099b6c80d988a6b5 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/Hello.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/Hello.png.REMOVED.git-id new file mode 100644 index 0000000000..bf03af4205 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/Hello.png.REMOVED.git-id @@ -0,0 +1 @@ +a6e5d948d0c85ecc42b7a2ebf5751e3990002bac \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/UITest/background.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/UITest/background.png.REMOVED.git-id new file mode 100644 index 0000000000..1f73829609 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/UITest/background.png.REMOVED.git-id @@ -0,0 +1 @@ +eff519b0334eaeb486f302ec2581771950b7cca2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/b11.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/b11.png.REMOVED.git-id new file mode 100644 index 0000000000..7ad21adacb --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/b11.png.REMOVED.git-id @@ -0,0 +1 @@ +021493cabd2489bf2c20c657e5523e24608df86c \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/bitmapFontTest2.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/bitmapFontTest2.png.REMOVED.git-id new file mode 100644 index 0000000000..d025022480 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/bitmapFontTest2.png.REMOVED.git-id @@ -0,0 +1 @@ +9975e4961272d5bda6d5f3bbd61ea0fc02222199 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/examples/examples.json.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/examples/examples.json.REMOVED.git-id new file mode 100644 index 0000000000..f28818a9af --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/examples/examples.json.REMOVED.git-id @@ -0,0 +1 @@ +0a4ce85782909e964aa0e95e89bab8272d0c3d4e \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id new file mode 100644 index 0000000000..596d52b27c --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/equip_1/equip_1.json.REMOVED.git-id @@ -0,0 +1 @@ +0a77108d377ceb5f084f1aab1877159df9499428 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id new file mode 100644 index 0000000000..7e87ef6cb4 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/map_1/map_pve.png.REMOVED.git-id @@ -0,0 +1 @@ +1a6a5a2f571c692a962e9159fca8ea5d6879a748 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id new file mode 100644 index 0000000000..1f73829609 --- /dev/null +++ b/samples/Cpp/TestCpp/Resources/hd/cocosgui/gui_examples/page_1/background.png.REMOVED.git-id @@ -0,0 +1 @@ +eff519b0334eaeb486f302ec2581771950b7cca2 \ No newline at end of file diff --git a/samples/Cpp/TestCpp/proj.android/jni/Android.mk b/samples/Cpp/TestCpp/proj.android/jni/Android.mk index 210fef8fa1..98de0c8956 100644 --- a/samples/Cpp/TestCpp/proj.android/jni/Android.mk +++ b/samples/Cpp/TestCpp/proj.android/jni/Android.mk @@ -14,7 +14,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos_testcpp_common LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -26,5 +25,4 @@ $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) $(call import-module,CocosDenshion/android) $(call import-module,extensions) $(call import-module,external/Box2D) -$(call import-module,external/chipmunk) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Cpp/TestCpp/proj.emscripten/Makefile b/samples/Cpp/TestCpp/proj.emscripten/Makefile index ee891075ee..67b18155c0 100644 --- a/samples/Cpp/TestCpp/proj.emscripten/Makefile +++ b/samples/Cpp/TestCpp/proj.emscripten/Makefile @@ -77,6 +77,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/PerformanceTest/PerformanceTest.cpp \ ../Classes/PerformanceTest/PerformanceTextureTest.cpp \ ../Classes/PerformanceTest/PerformanceTouchesTest.cpp \ + ../Classes/PhysicsTest/PhysicsTest.cpp \ ../Classes/RenderTextureTest/RenderTextureTest.cpp \ ../Classes/RotateWorldTest/RotateWorldTest.cpp \ ../Classes/SceneTest/SceneTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.linux/Makefile b/samples/Cpp/TestCpp/proj.linux/Makefile index 4cf8a35a44..b066e6606f 100644 --- a/samples/Cpp/TestCpp/proj.linux/Makefile +++ b/samples/Cpp/TestCpp/proj.linux/Makefile @@ -102,6 +102,7 @@ SOURCES = ../Classes/AccelerometerTest/AccelerometerTest.cpp \ ../Classes/PerformanceTest/PerformanceTest.cpp \ ../Classes/PerformanceTest/PerformanceTextureTest.cpp \ ../Classes/PerformanceTest/PerformanceTouchesTest.cpp \ + ../Classes/PhysicsTest/PhysicsTest.cpp \ ../Classes/RenderTextureTest/RenderTextureTest.cpp \ ../Classes/RotateWorldTest/RotateWorldTest.cpp \ ../Classes/SceneTest/SceneTest.cpp \ diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj index e38cc2fe68..13c9116bad 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj @@ -146,6 +146,26 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + + + + + + + + + + + + + + + + + + + + @@ -160,6 +180,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + @@ -260,6 +281,26 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + + + + + + + + + + + + + + + + + + + + @@ -273,6 +314,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O + diff --git a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters index f6dac52c63..10a96be084 100644 --- a/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters +++ b/samples/Cpp/TestCpp/proj.win32/TestCpp.vcxproj.filters @@ -240,6 +240,62 @@ {0b414789-7971-4a4c-86e3-40cc00936684} + + + {a83cb042-e3d6-4d3b-a4f6-30a4b3fcb3e9} + + {9daecd38-37c6-4216-a999-86077af83beb} + + + {493fcd85-c749-482d-9404-905e99aa0103} + + + {5c1960de-24ba-4b72-be18-cc160dd2a50d} + + + {175b363b-a41a-4b1d-bde1-970e77e64cff} + + + {2e08949f-bf73-4fdc-85e8-34b8c69aa978} + + + {c57c0453-a096-44d7-830b-1cf24c712cfd} + + + {c4dbbfb3-0e91-492f-bbbf-f03fb26f3f54} + + + {01097388-e538-4081-8e16-d1ff3a86292a} + + + {160da6f0-a0f1-4a53-8e5e-cf0a63ee82a3} + + + {fadff96e-c19a-41f5-a755-547cf1f8a5fb} + + + {73c268e8-3872-49d6-9204-1e679ff72a42} + + + {6e7f1d2a-c8c1-4f48-826f-930bc8a0556e} + + + {305e1c54-9321-49f7-8672-46d1286dbe83} + + + {df6e9468-93f7-472d-be1d-d274d7de677e} + + + {dedcabba-959c-40e3-9959-7ccf4e31c792} + + + {cfc87c30-a7b4-4b6f-bc5d-da45360466b6} + + + {5caf2179-ae22-4040-8bac-17e9f22efbf7} + + + {24f044ee-09a6-406b-98d7-8d5d759e5bb1} @@ -570,6 +626,68 @@ Classes\NewEventDispatcherTest + + + Classes\PhysicsTest + + Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest + + + Classes\ExtensionsTest\CocoStudioGUITest + + + Classes\ExtensionsTest\CocoStudioGUITest + + + Classes\ExtensionsTest\CocoStudioGUITest @@ -1077,6 +1195,68 @@ Classes\NewEventDispatcherTest + + + Classes\PhysicsTest + + Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest + + + Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest + + + Classes\ExtensionsTest\CocoStudioGUITest + + + Classes\ExtensionsTest\CocoStudioGUITest + + + Classes\ExtensionsTest\CocoStudioGUITest \ No newline at end of file diff --git a/samples/Javascript/CocosDragonJS/proj.android/jni/Android.mk b/samples/Javascript/CocosDragonJS/proj.android/jni/Android.mk index d2615a756b..0ab251941c 100644 --- a/samples/Javascript/CocosDragonJS/proj.android/jni/Android.mk +++ b/samples/Javascript/CocosDragonJS/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Javascript/CrystalCraze/proj.android/jni/Android.mk b/samples/Javascript/CrystalCraze/proj.android/jni/Android.mk index de9f96689d..12575cad7a 100644 --- a/samples/Javascript/CrystalCraze/proj.android/jni/Android.mk +++ b/samples/Javascript/CrystalCraze/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Javascript/MoonWarriors/proj.android/jni/Android.mk b/samples/Javascript/MoonWarriors/proj.android/jni/Android.mk index 5567a3879c..1cdcb62cd6 100644 --- a/samples/Javascript/MoonWarriors/proj.android/jni/Android.mk +++ b/samples/Javascript/MoonWarriors/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Javascript/TestJavascript/proj.android/jni/Android.mk b/samples/Javascript/TestJavascript/proj.android/jni/Android.mk index a5e5f60ec0..88ce0ac197 100644 --- a/samples/Javascript/TestJavascript/proj.android/jni/Android.mk +++ b/samples/Javascript/TestJavascript/proj.android/jni/Android.mk @@ -14,7 +14,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -25,7 +24,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,extensions) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) diff --git a/samples/Javascript/WatermelonWithMe/proj.android/jni/Android.mk b/samples/Javascript/WatermelonWithMe/proj.android/jni/Android.mk index 33fdf59cf3..76b8e7fd1e 100644 --- a/samples/Javascript/WatermelonWithMe/proj.android/jni/Android.mk +++ b/samples/Javascript/WatermelonWithMe/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj index 7ab70c4ea1..b8fd26308f 100644 --- a/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj +++ b/samples/Lua/HelloLua/proj.win32/HelloLua.vcxproj @@ -77,7 +77,7 @@ Disabled - $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\..\extensions;%(AdditionalIncludeDirectories) + $(ProjectDir)..\Classes;$(ProjectDir)..\..\..\..\scripting\auto-generated\lua-bindings;$(ProjectDir)..\..\..\..\scripting\lua\cocos2dx_support;$(ProjectDir)..\..\..\..\scripting\lua\lua;$(ProjectDir)..\..\..\..\scripting\lua\tolua;$(ProjectDir)..\..\..\..\scripting\lua\src;$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\..\extensions;$(ProjectDir)..\..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -95,7 +95,7 @@ $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;websockets.lib;%(AdditionalDependencies) + libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;websockets.lib;libchipmunk.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows diff --git a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua index 781a8824e6..ee13a9c390 100644 --- a/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/ClickAndMoveTest/ClickAndMoveTest.lua @@ -59,9 +59,9 @@ function ClickAndMoveTest() layer = cc.Layer:create() initWithLayer() - - scene:addChild(CreateBackMenuItem()) scene:addChild(layer) + scene:addChild(CreateBackMenuItem()) + return scene end diff --git a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua index 0e8d723b25..25588d87eb 100644 --- a/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/MenuTest/MenuTest.lua @@ -23,7 +23,6 @@ local function MenuLayerMainMenu() local ret = cc.Layer:create() ret:setTouchEnabled(true) - ret:setTouchPriority(cc.MENU_HANDLER_PRIORITY + 1) ret:setTouchMode(cc.TOUCHES_ONE_BY_ONE ) -- Font Item diff --git a/samples/Lua/TestLua/proj.android/jni/Android.mk b/samples/Lua/TestLua/proj.android/jni/Android.mk index 306ca7e320..189dd81468 100644 --- a/samples/Lua/TestLua/proj.android/jni/Android.mk +++ b/samples/Lua/TestLua/proj.android/jni/Android.mk @@ -18,7 +18,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -30,5 +29,4 @@ $(call import-module,scripting/lua/proj.android) $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) $(call import-module,extensions) $(call import-module,external/Box2D) -$(call import-module,external/chipmunk) $(call import-module,cocos2dx/platform/android) diff --git a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id index 3206968761..2d04786b13 100644 --- a/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/samples/samples.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -0859c6e193e305efaec33c21d373b65637f5544e \ No newline at end of file +febc64c0af18af645de925396d73473973a0b37e \ No newline at end of file diff --git a/scripting/auto-generated b/scripting/auto-generated index f0a368c0f8..558b0d0b08 160000 --- a/scripting/auto-generated +++ b/scripting/auto-generated @@ -1 +1 @@ -Subproject commit f0a368c0f8f9f460ff1ad3d7d876fa6ad29213a0 +Subproject commit 558b0d0b086fc2b5011b49237fa5f49b6d6537f4 diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp index adc06cea35..1914d3a930 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.cpp @@ -1328,25 +1328,3 @@ void dictionary_to_luaval(lua_State* L, Dictionary* dict) } } } - -void std_vector_to_luaval(lua_State* L,const std::vector& inValue) -{ - lua_newtable(L); - - if (inValue.empty()) - return; - - auto iter = inValue.begin(); - int indexTable = 1; - for (; iter != inValue.end(); ++iter) - { - if (nullptr == *iter) - continue; - - lua_pushnumber(L, (lua_Number)indexTable); - toluafix_pushusertype_ccobject(L, (*iter)->_ID, &((*iter)->_luaID), (void*)(*iter),"Sprite"); - lua_rawset(L, -3); - (*iter)->retain(); - ++indexTable; - } -} diff --git a/scripting/lua/cocos2dx_support/LuaBasicConversions.h b/scripting/lua/cocos2dx_support/LuaBasicConversions.h index ace2f0643e..20167170df 100644 --- a/scripting/lua/cocos2dx_support/LuaBasicConversions.h +++ b/scripting/lua/cocos2dx_support/LuaBasicConversions.h @@ -55,5 +55,4 @@ extern void affinetransform_to_luaval(lua_State* L,const AffineTransform& inValu extern void fontdefinition_to_luaval(lua_State* L,const FontDefinition& inValue); extern void array_to_luaval(lua_State* L,Array* inValue); extern void dictionary_to_luaval(lua_State* L, Dictionary* dict); -extern void std_vector_to_luaval(lua_State* L,const std::vector& inValue); #endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__ diff --git a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp index 14dab59467..cb3ab58888 100644 --- a/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp +++ b/scripting/lua/cocos2dx_support/lua_cocos2dx_manual.cpp @@ -2286,6 +2286,70 @@ tolua_lerror: #endif } +static int tolua_cocos2dx_SpriteBatchNode_getDescendants(lua_State* tolua_S) +{ + if (NULL == tolua_S) + return 0; + + int argc = 0; + cocos2d::SpriteBatchNode* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"SpriteBatchNode",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::SpriteBatchNode*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'tolua_cocos2dx_SpriteBatchNode_getDescendants'", NULL); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + return 0; + std::vector ret = cobj->getDescendants(); + + lua_newtable(tolua_S); + + if (ret.empty()) + return 1; + + auto iter = ret.begin(); + int indexTable = 1; + for (; iter != ret.end(); ++iter) + { + if (nullptr == *iter) + continue; + + lua_pushnumber(tolua_S, (lua_Number)indexTable); + toluafix_pushusertype_ccobject(tolua_S, (*iter)->_ID, &((*iter)->_luaID), (void*)(*iter),"Sprite"); + lua_rawset(tolua_S, -3); + (*iter)->retain(); + ++indexTable; + } + + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getDescendants",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_SpriteBatchNode_getDescendants'.",&tolua_err); +#endif + return 0; +} + static void extendTexture2D(lua_State* tolua_S) { lua_pushstring(tolua_S, "Texture2D"); @@ -2657,6 +2721,18 @@ static void extendUserDefault(lua_State* tolua_S) } } +static void extendSpriteBatchNode(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "SpriteBatchNode"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + lua_pushstring(tolua_S,"getDescendants"); + lua_pushcfunction(tolua_S,tolua_cocos2dx_SpriteBatchNode_getDescendants ); + lua_rawset(tolua_S,-3); + } +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { @@ -2691,6 +2767,6 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendUserDefault(tolua_S); extendGLProgram(tolua_S); extendTexture2D(tolua_S); - + extendSpriteBatchNode(tolua_S); return 0; } \ No newline at end of file diff --git a/scripting/lua/proj.win32/liblua.vcxproj b/scripting/lua/proj.win32/liblua.vcxproj index cc6539600d..1c646b774c 100644 --- a/scripting/lua/proj.win32/liblua.vcxproj +++ b/scripting/lua/proj.win32/liblua.vcxproj @@ -62,7 +62,7 @@ Disabled - $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;%(AdditionalIncludeDirectories) + $(ProjectDir)..\..\..\cocos2dx;$(ProjectDir)..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\OGLES;$(ProjectDir)..\..\..\cocos2dx\platform\third_party\win32\pthread;$(ProjectDir)..\..\..\CocosDenshion\include;$(ProjectDir)..\..\..\extensions;$(ProjectDir)..\..\..\extensions\network;$(ProjectDir)..\..\..\external\libwebsockets\win32\include;$(ProjectDir)..\tolua;$(ProjectDir)..\luajit\include;$(ProjectDir)..\..\auto-generated\lua-bindings;$(ProjectDir)..\cocos2dx_support;$(ProjectDir)..\..\..\external\chipmunk\include\chipmunk;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks diff --git a/scripting/lua/script/Deprecated.lua b/scripting/lua/script/Deprecated.lua index a2d6ac9878..82be56c5c6 100644 --- a/scripting/lua/script/Deprecated.lua +++ b/scripting/lua/script/Deprecated.lua @@ -28,6 +28,12 @@ function CCTextureCacheDeprecated.purgeSharedTextureCache() return cc.TextureCache:destroyInstance() end rawset(CCTextureCache,"purgeSharedTextureCache",CCTextureCacheDeprecated.purgeSharedTextureCache) + +function CCTextureCacheDeprecated.addUIImage(self, image, key) + deprecatedTip("CCTextureCache:addUIImage","CCTextureCache:addImage") + return self:addImage(image,key) +end +rawset(CCTextureCache,"addUIImage",CCTextureCacheDeprecated.addUIImage) --functions of CCTextureCache will be deprecated end --functions of CCAnimation will be deprecated begin diff --git a/template/multi-platform-cpp/proj.android/jni/Android.mk b/template/multi-platform-cpp/proj.android/jni/Android.mk index 329ebc0e4f..5430a288ba 100644 --- a/template/multi-platform-cpp/proj.android/jni/Android.mk +++ b/template/multi-platform-cpp/proj.android/jni/Android.mk @@ -15,7 +15,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -26,5 +25,4 @@ $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) $(call import-module,CocosDenshion/android) $(call import-module,extensions) $(call import-module,external/Box2D) -$(call import-module,external/chipmunk) $(call import-module,cocos2dx/platform/android) diff --git a/template/multi-platform-js/proj.android/jni/Android.mk b/template/multi-platform-js/proj.android/jni/Android.mk index 2b70298a7c..09cabaea59 100644 --- a/template/multi-platform-js/proj.android/jni/Android.mk +++ b/template/multi-platform-js/proj.android/jni/Android.mk @@ -13,7 +13,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += spidermonkey_static LOCAL_WHOLE_STATIC_LIBRARIES += scriptingcore-spidermonkey LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -24,7 +23,6 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,external/chipmunk) $(call import-module,scripting/javascript/spidermonkey-android) $(call import-module,scripting/javascript/bindings) $(call import-module,cocos2dx/platform/android) diff --git a/template/multi-platform-lua/proj.android/jni/Android.mk b/template/multi-platform-lua/proj.android/jni/Android.mk index 3cab251681..05362699b5 100644 --- a/template/multi-platform-lua/proj.android/jni/Android.mk +++ b/template/multi-platform-lua/proj.android/jni/Android.mk @@ -19,7 +19,6 @@ LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dxandroid_static @@ -31,5 +30,4 @@ $(call import-module,scripting/lua/proj.android) $(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) $(call import-module,extensions) $(call import-module,external/Box2D) -$(call import-module,external/chipmunk) $(call import-module,cocos2dx/platform/android) diff --git a/tools/bindings-generator b/tools/bindings-generator index 9d98b45fcd..2ee36ff842 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit 9d98b45fcdebff58bfe4372266f883cd1a6ce476 +Subproject commit 2ee36ff8423fb0a30817c5278891e4d1667ec68f diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 84d3d8ebc9..87551f1c09 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common diff --git a/tools/tojs/cocos2dx_extension.ini b/tools/tojs/cocos2dx_extension.ini index d0554f5314..41ecc9e5a6 100644 --- a/tools/tojs/cocos2dx_extension.ini +++ b/tools/tojs/cocos2dx_extension.ini @@ -13,7 +13,7 @@ android_flags = -D_SIZE_T_DEFINED_ clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include clang_flags = -nostdinc -x c++ -std=c++11 -cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions +cocos_headers = -I%(cocosdir)s/cocos2dx/include -I%(cocosdir)s/cocos2dx/platform -I%(cocosdir)s/cocos2dx/platform/android -I%(cocosdir)s/cocos2dx -I%(cocosdir)s/cocos2dx/kazmath/include -I%(cocosdir)s/extensions cocos_flags = -DANDROID -DCOCOS2D_JAVASCRIPT cxxgenerator_headers = -I%(cxxgeneratordir)s/targets/spidermonkey/common diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg deleted file mode 100644 index 043e16809d..0000000000 --- a/tools/tolua++/CCAction.pkg +++ /dev/null @@ -1,298 +0,0 @@ - -enum { - kCCActionTagInvalid = -1, -}; - -class CCAction : public CCObject -{ - bool isDone(void); - CCNode* getTarget(void); - // void setTarget(CCNode *pTarget); - CCNode* getOriginalTarget(void); - // void setOriginalTarget(CCNode *pOriginalTarget); - int getTag(void); - void setTag(int nTag); - CCAction* clone(); - CCObject* copy(); -}; - -class CCFiniteTimeAction : public CCAction -{ - float getDuration(void); - void setDuration(float duration); - CCFiniteTimeAction* reverse(void); -}; - -class CCActionInterval : public CCFiniteTimeAction -{ - float getElapsed(void); - bool isDone(void); - void setAmplitudeRate(float amp); - float getAmplitudeRate(void); - CCActionInterval* reverse(void); -}; - -// CCActionInterval -class CCSpeed : public CCAction -{ - float getSpeed(void); - void setSpeed(float fSpeed); - CCActionInterval* reverse(void); - bool isDone(void); - - static CCSpeed* create(CCActionInterval *pAction, float fRate); -}; - -class CCFollow : public CCAction -{ - bool isBoundarySet(void); - void setBoudarySet(bool bValue); - bool isDone(void); - - static CCFollow* create(CCNode *pFollowedNode, CCRect rect); - static CCFollow* create(CCNode *pFollowedNode); -}; - -class CCSequence : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCSequence* createWithTwoActions(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); - static CCSequence* create(CCArray *actions); -}; - -class CCRepeat : public CCActionInterval -{ - bool isDone(void); - CCActionInterval* reverse(void); - - static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times); -}; - -class CCRepeatForever : public CCActionInterval -{ - bool isDone(void); - CCActionInterval* reverse(void); - - static CCRepeatForever* create(CCActionInterval *pAction); -}; - -class CCSpawn : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCSpawn* createWithTwoActions(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); - static CCSpawn* create(CCArray *actions); -}; - -class CCRotateTo : public CCActionInterval -{ - - static CCRotateTo* create(float duration, float fDeltaAngle); -}; - -class CCRotateBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCRotateBy* create(float duration, float fDeltaAngle); - static CCRotateBy* create(float duration, float fDeltaAngleX, float DeltaAngleY); -}; - -class CCMoveTo : public CCActionInterval -{ - - static CCMoveTo* create(float duration, CCPoint position); -}; - -class CCMoveBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCMoveBy* create(float duration, CCPoint deltaPosition); -}; - -class CCSkewTo : public CCActionInterval -{ - - static CCSkewTo* create(float t, float sx, float sy); -}; - -class CCSkewBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); -}; - -class CCJumpBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCJumpBy* create(float duration, CCPoint position, float height, int jumps); -}; - -class CCJumpTo : public CCActionInterval -{ - - static CCJumpTo* create(float duration, CCPoint position, float height, int jumps); -}; - -/* - There's a bug in tolua++ - Can't use struct in lua after binding struct - So use class instead. -*/ -class ccBezierConfig { - ccBezierConfig(void); - CCPoint endPosition; - CCPoint controlPoint_1; - CCPoint controlPoint_2; -}; - -class CCBezierBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCBezierBy* create(float t, ccBezierConfig c); -}; - -class CCBezierTo : public CCActionInterval -{ - - static CCBezierTo* create(float t, ccBezierConfig c); -}; - -class CCScaleTo : public CCActionInterval -{ - - static CCScaleTo* create(float duration, float sx, float sy); - static CCScaleTo* create(float duration, float s); -}; - -class CCScaleBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCScaleBy* create(float duration, float s); - static CCScaleBy* create(float duration, float sx, float sy); -}; - -class CCBlink : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCBlink* create(float duration, unsigned int uBlinks); -}; - -class CCFadeIn : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCFadeIn* create(float d); -}; - -class CCFadeOut : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCFadeOut* create(float d); -}; - -class CCFadeTo : public CCActionInterval -{ - - static CCFadeTo* create(float duration, GLubyte opacity); -}; - -class CCTintTo : public CCActionInterval -{ - - static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); -}; - -class CCTintBy : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); -}; - -class CCDelayTime : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCDelayTime* create(float d); -}; - -class CCReverseTime : public CCActionInterval -{ - CCActionInterval* reverse(void); - - static CCReverseTime* create(CCFiniteTimeAction *pAction); -}; - -class CCAnimate : public CCActionInterval -{ - CCActionInterval* reverse(void); - - CCAnimation* getAnimation(void); - void setAnimation(CCAnimation *pAnimation); - - static CCAnimate* create(CCAnimation *pAnimation); -}; - -class CCTargetedAction : public CCActionInterval -{ - CCNode* getForcedTarget(void); - void setForcedTarget(CCNode* target); - - static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction); -}; - - -// CCActionInstant -class CCActionInstant : public CCFiniteTimeAction -{ - CCFiniteTimeAction* reverse(void); - bool isDone(void); -}; - -class CCShow : public CCActionInstant -{ - CCFiniteTimeAction* reverse(void); - - static CCShow* create(); -}; - -class CCHide : public CCActionInstant -{ - CCFiniteTimeAction* reverse(void); - - static CCHide* create(); -}; - -class CCToggleVisibility : public CCActionInstant -{ - - static CCToggleVisibility* create(); -}; - -class CCFlipX : public CCActionInstant -{ - CCFiniteTimeAction* reverse(void); - - static CCFlipX* create(bool x); -}; - -class CCFlipY : public CCActionInstant -{ - CCFiniteTimeAction* reverse(void); - - static CCFlipY* create(bool y); -}; - -class CCPlace : public CCActionInstant // -{ - static CCPlace* create(CCPoint pos); -}; diff --git a/tools/tolua++/CCActionCamera.pkg b/tools/tolua++/CCActionCamera.pkg deleted file mode 100644 index 0063c75a73..0000000000 --- a/tools/tolua++/CCActionCamera.pkg +++ /dev/null @@ -1,13 +0,0 @@ - -class CCActionCamera : public CCActionInterval -{ - void startWithTarget(CCNode *pTarget); - CCActionInterval* reverse(); -}; - -class CCOrbitCamera : public CCActionCamera -{ - void sphericalRadius(float *r, float *zenith, float *azimuth); - - static CCOrbitCamera * create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); -}; diff --git a/tools/tolua++/CCActionCatmullRom.pkg b/tools/tolua++/CCActionCatmullRom.pkg deleted file mode 100644 index d26651c2a1..0000000000 --- a/tools/tolua++/CCActionCatmullRom.pkg +++ /dev/null @@ -1,44 +0,0 @@ - -class CCPointArray : public CCNode -{ - bool initWithCapacity(unsigned int capacity); - void addControlPoint(CCPoint controlPoint); - void insertControlPoint(CCPoint &controlPoint, unsigned int index); - void replaceControlPoint(CCPoint &controlPoint, unsigned int index); - CCPoint getControlPointAtIndex(unsigned int index); - void removeControlPointAtIndex(unsigned int index); - unsigned int count(); - CCPointArray* reverse(); - void reverseInline(); - const std::vector* getControlPoints(); - void setControlPoints(std::vector *controlPoints); - - static CCPointArray* create(unsigned int capacity); -}; - -class CCCardinalSplineTo : public CCActionInterval -{ - CCActionInterval* reverse(); - CCPointArray* getPoints(); - void setPoints(CCPointArray* points); - - static CCCardinalSplineTo* create(float duration, CCPointArray* points, float tension); -}; - - -class CCCardinalSplineBy : public CCCardinalSplineTo -{ - CCActionInterval* reverse(); - - static CCCardinalSplineBy* create(float duration, CCPointArray* points, float tension); -}; - -class CCCatmullRomTo : public CCCardinalSplineTo -{ - static CCCatmullRomTo* create(float dt, CCPointArray* points); -}; - -class CCCatmullRomBy : public CCCardinalSplineBy -{ - static CCCatmullRomBy* create(float dt, CCPointArray* points); -}; diff --git a/tools/tolua++/CCActionEase.pkg b/tools/tolua++/CCActionEase.pkg deleted file mode 100644 index 00409506a1..0000000000 --- a/tools/tolua++/CCActionEase.pkg +++ /dev/null @@ -1,149 +0,0 @@ - -class CCActionEase : public CCActionInterval -{ - CCActionInterval* reverse(void); -}; - -class CCEaseRateAction : public CCActionEase -{ - CCActionInterval* reverse(void); -}; - -class CCEaseIn : public CCEaseRateAction -{ - CCActionInterval* reverse(void); - - static CCEaseIn* create(CCActionInterval* pAction, float fRate); -}; - -class CCEaseOut : public CCEaseRateAction -{ - CCActionInterval* reverse(void); - - static CCEaseOut* create(CCActionInterval* pAction, float fRate); -}; - -class CCEaseInOut : public CCEaseRateAction -{ - CCActionInterval* reverse(void); - - static CCEaseInOut* create(CCActionInterval* pAction, float fRate); -}; - -class CCEaseExponentialIn : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseExponentialIn* create(CCActionInterval* pAction); -}; - -class CCEaseExponentialOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseExponentialOut* create(CCActionInterval* pAction); -}; - -class CCEaseExponentialInOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseExponentialInOut* create(CCActionInterval* pAction); -}; - -class CCEaseSineIn : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseSineIn* create(CCActionInterval* pAction); -}; - -class CCEaseSineOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseSineOut* create(CCActionInterval* pAction); -}; - -class CCEaseSineInOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseSineInOut* create(CCActionInterval* pAction); -}; - -class CCEaseElastic : public CCActionEase -{ - CCActionInterval* reverse(void); - - float getPeriod(void); - void setPeriod(float fPeriod); -}; - -class CCEaseElasticIn : public CCEaseElastic -{ - CCActionInterval* reverse(void); - - static CCEaseElasticIn* create(CCActionInterval *pAction, float fPeriod = 0.3); -}; - -class CCEaseElasticOut : public CCEaseElastic -{ - CCActionInterval* reverse(void); - - static CCEaseElasticOut* create(CCActionInterval *pAction, float fPeriod = 0.3); -}; - -class CCEaseElasticInOut : public CCEaseElastic -{ - CCActionInterval* reverse(void); - - static CCEaseElasticInOut* create(CCActionInterval *pAction, float fPeriod = 0.3); -}; - -class CCEaseBounce : public CCActionEase -{ - CCActionInterval* reverse(void); -}; - -class CCEaseBounceIn : public CCEaseBounce -{ - CCActionInterval* reverse(void); - - static CCEaseBounceIn* create(CCActionInterval* pAction); -}; - -class CCEaseBounceOut : public CCEaseBounce -{ - CCActionInterval* reverse(void); - - static CCEaseBounceOut* create(CCActionInterval* pAction); -}; - -class CCEaseBounceInOut : public CCEaseBounce -{ - CCActionInterval* reverse(void); - - static CCEaseBounceInOut* create(CCActionInterval* pAction); -}; - -class CCEaseBackIn : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseBackIn* create(CCActionInterval* pAction); -}; - -class CCEaseBackOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseBackOut* create(CCActionInterval* pAction); -}; - -class CCEaseBackInOut : public CCActionEase -{ - CCActionInterval* reverse(void); - - static CCEaseBackInOut* create(CCActionInterval* pAction); -}; diff --git a/tools/tolua++/CCActionGrid.pkg b/tools/tolua++/CCActionGrid.pkg deleted file mode 100644 index bcd89597b5..0000000000 --- a/tools/tolua++/CCActionGrid.pkg +++ /dev/null @@ -1,65 +0,0 @@ - -class CCGridAction : public CCActionInterval -{ - CCActionInterval* reverse(void); - - CCGridBase* getGrid(void); -}; - -class CCAccelDeccelAmplitude : public CCActionInterval -{ - CCActionInterval* reverse(void); - - float getRate(void); - void setRate(float fRate); - - static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); -}; - -class CCGrid3DAction : public CCGridAction -{ - virtual CCGridBase* getGrid(void); - void setVertex(const CCPoint& pos, const Vertex3F& vertex); - Vertex3F getVertex(const CCPoint& position); - Vertex3F getOriginalVertex(const CCPoint& position); -}; - -class CCTiledGrid3DAction : public CCGridAction -{ - void setTile(CCPoint pos, Quad3 coords); - CCGridBase* getGrid(void); - Quad3 getTile(const CCPoint& position); - Quad3 getOriginalTile(const CCPoint& position); - - //static CCTiledGrid3DAction* create(float duration, const CCSize& gridSize); -}; - -class CCAccelAmplitude : public CCActionInterval -{ - CCActionInterval* reverse(void); - - float getRate(void); - void setRate(float fRate); - - static CCAccelAmplitude* create(CCAction *pAction, float duration); -}; - -class CCDeccelAmplitude : public CCActionInterval -{ - CCActionInterval* reverse(void); - - float getRate(void); - void setRate(float fRate); - - static CCDeccelAmplitude* create(CCAction *pAction, float duration); -}; - -class CCStopGrid : public CCActionInstant -{ - static CCStopGrid* create(void); -}; - -class CCReuseGrid : public CCActionInstant -{ - static CCReuseGrid* create(int times); -}; diff --git a/tools/tolua++/CCActionGrid3D.pkg b/tools/tolua++/CCActionGrid3D.pkg deleted file mode 100644 index 99cf5e6c6d..0000000000 --- a/tools/tolua++/CCActionGrid3D.pkg +++ /dev/null @@ -1,79 +0,0 @@ - -class CCWaves3D : public CCGrid3DAction -{ - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCWaves3D* create(float duration, CCSize gridSize, unsigned int waves, float amplitude); -}; - -class CCFlipX3D : public CCGrid3DAction -{ - static CCFlipX3D* create(float duration); -}; - -class CCFlipY3D : public CCFlipX3D -{ - static CCFlipY3D* create(float duration); -}; - -class CCLens3D : public CCGrid3DAction -{ - float getLensEffect(void); - void setLensEffect(float fLensEffect); - CCPoint getPosition(void); - void setPosition(CCPoint position); - - static CCLens3D* create(float duration, CCSize gridSize, CCPoint position, float radius); -}; - -class CCRipple3D : public CCGrid3DAction -{ - CCPoint getPosition(void); - void setPosition(CCPoint position); - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCRipple3D* create(float duration, CCSize gridSize, CCPoint position, float radius, unsigned int waves, float amplitude); -}; - -class CCShaky3D : public CCGrid3DAction -{ - static CCShaky3D* create(float duration, CCSize gridSize, int range, bool shakeZ); -}; - -class CCLiquid : public CCGrid3DAction -{ - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCLiquid* create(float duration, CCSize gridSize, unsigned int waves, float amplitude); -}; - -class CCWaves : public CCGrid3DAction -{ - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCWaves* create(float duration, CCSize gridSize, unsigned int waves, float amplitude, bool horizontal, bool vertical); -}; - -class CCTwirl : public CCGrid3DAction -{ - CCPoint getPosition(void); - void setPosition(CCPoint position); - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCTwirl* create(float duration, CCSize gridSize, CCPoint position, unsigned int twirls, float amplitude); -}; diff --git a/tools/tolua++/CCActionManager.pkg b/tools/tolua++/CCActionManager.pkg deleted file mode 100644 index 8eb3890da9..0000000000 --- a/tools/tolua++/CCActionManager.pkg +++ /dev/null @@ -1,25 +0,0 @@ - -class CCActionManager : public CCObject -{ - void addAction(CCAction *pAction, CCNode *pTarget, bool paused); - - void removeAllActions(void); - - void removeAllActionsFromTarget(CCObject *pTarget); - - void removeAction(CCAction *pAction); - - void removeActionByTag(unsigned int tag, CCObject *pTarget); - - CCAction* getActionByTag(unsigned int tag, CCObject *pTarget); - - unsigned int getNumberOfRunningActionsInTarget(CCObject *pTarget); - - void pauseTarget(CCObject *pTarget); - - void resumeTarget(CCObject *pTarget); - - CCSet* pauseAllRunningActions(); - - void resumeTargets(CCSet* targetsToResume); -}; diff --git a/tools/tolua++/CCActionPageTurn3D.pkg b/tools/tolua++/CCActionPageTurn3D.pkg deleted file mode 100644 index 40e5b2eb3d..0000000000 --- a/tools/tolua++/CCActionPageTurn3D.pkg +++ /dev/null @@ -1,5 +0,0 @@ - -class CCPageTurn3D : public CCGrid3DAction -{ - static CCPageTurn3D* create(float duration, CCSize gridSize); -}; diff --git a/tools/tolua++/CCActionProgressTimer.pkg b/tools/tolua++/CCActionProgressTimer.pkg deleted file mode 100644 index 6e3c911fd8..0000000000 --- a/tools/tolua++/CCActionProgressTimer.pkg +++ /dev/null @@ -1,10 +0,0 @@ - -class CCProgressTo : public CCActionInterval -{ - static CCProgressTo* create(float duration, float fPercent); -}; - -class CCProgressFromTo : public CCActionInterval -{ - static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); -}; diff --git a/tools/tolua++/CCActionTiledGrid.pkg b/tools/tolua++/CCActionTiledGrid.pkg deleted file mode 100644 index 6baa15906d..0000000000 --- a/tools/tolua++/CCActionTiledGrid.pkg +++ /dev/null @@ -1,85 +0,0 @@ - -class CCShakyTiles3D : public CCTiledGrid3DAction -{ - static CCShakyTiles3D* create(float duration, CCSize gridSize, int nRange, bool bShakeZ); -}; - -class CCShatteredTiles3D : public CCTiledGrid3DAction -{ - static CCShatteredTiles3D* create(float duration, CCSize gridSize, int nRange, bool bShatterZ); -}; - -class CCShuffleTiles : public CCTiledGrid3DAction -{ - void shuffle(unsigned int *pArray, int nLen); - CCSize getDelta(CCSize pos); - void placeTile(CCPoint pos, Tile *t); - - static CCShuffleTiles* create(float duration, CCSize gridSize, unsigned int seed); -}; - -class CCFadeOutTRTiles : public CCTiledGrid3DAction -{ - void turnOnTile(CCPoint pos); - void turnOffTile(CCPoint pos); - void transformTile(CCPoint pos, float distance); - - static CCFadeOutTRTiles* create(float duration, CCSize gridSize); -}; - -class CCFadeOutBLTiles : public CCFadeOutTRTiles -{ - static CCFadeOutBLTiles* create(float duration, CCSize gridSize); -}; - -class CCFadeOutUpTiles : public CCFadeOutTRTiles -{ - void transformTile(CCPoint pos, float distance); - - static CCFadeOutUpTiles* create(float duration, CCSize gridSize); -}; - -class CCFadeOutDownTiles : public CCFadeOutUpTiles -{ - static CCFadeOutDownTiles* create(float duration, CCSize gridSize); -}; - -class CCTurnOffTiles : public CCTiledGrid3DAction -{ - void shuffle(unsigned int *pArray, int nLen); - void turnOnTile(CCPoint pos); - void turnOffTile(CCPoint pos); - - static CCTurnOffTiles* create(float duration, CCSize gridSize); - static CCTurnOffTiles* create(float duration, CCSize gridSize, unsigned int seed); -}; - -class CCWavesTiles3D : public CCTiledGrid3DAction -{ - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCWavesTiles3D* create(float duration, CCSize gridSize, unsigned int waves, float amplitude); -}; - -class CCJumpTiles3D : public CCTiledGrid3DAction -{ - float getAmplitude(void); - void setAmplitude(float fAmplitude); - float getAmplitudeRate(void); - void setAmplitudeRate(float fAmplitudeRate); - - static CCJumpTiles3D* create(float duration, CCSize gridSize, unsigned int numberOfJumps, float amplitude); -}; - -class CCSplitRows : public CCTiledGrid3DAction -{ - static CCSplitRows* create(float duration, unsigned int nRows); -}; - -class CCSplitCols : public CCTiledGrid3DAction -{ - static CCSplitCols* create(float duration, unsigned int nCols); -}; diff --git a/tools/tolua++/CCAffineTransform.pkg b/tools/tolua++/CCAffineTransform.pkg deleted file mode 100644 index b7a98840c6..0000000000 --- a/tools/tolua++/CCAffineTransform.pkg +++ /dev/null @@ -1,24 +0,0 @@ - -class CCAffineTransform { - float a, b, c, d; - float tx, ty; -}; - -CCAffineTransform __CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); -CCAffineTransform CCAffineTransformMake(float a, float b, float c, float d, float tx, float ty); - -CCPoint __CCPointApplyAffineTransform(CCPoint point, CCAffineTransform t); -CCPoint CCPointApplyAffineTransform(CCPoint point, CCAffineTransform t); - -CCSize CCSizeApplyAffineTransform(CCSize size, CCAffineTransform t); -CCSize __CCSizeApplyAffineTransform(CCSize size, CCAffineTransform t); - -CCAffineTransform CCAffineTransformMakeIdentity(); -CCRect CCRectApplyAffineTransform(CCRect rect, CCAffineTransform anAffineTransform); - -CCAffineTransform CCAffineTransformTranslate(CCAffineTransform t, float tx, float ty); -CCAffineTransform CCAffineTransformRotate(CCAffineTransform aTransform, float anAngle); -CCAffineTransform CCAffineTransformScale(CCAffineTransform t, float sx, float sy); -CCAffineTransform CCAffineTransformConcat(CCAffineTransform t1,CCAffineTransform t2); -bool CCAffineTransformEqualToTransform(CCAffineTransform t1,CCAffineTransform t2); -CCAffineTransform CCAffineTransformInvert(CCAffineTransform t); diff --git a/tools/tolua++/CCAnimation.pkg b/tools/tolua++/CCAnimation.pkg deleted file mode 100644 index 83a7d82071..0000000000 --- a/tools/tolua++/CCAnimation.pkg +++ /dev/null @@ -1,50 +0,0 @@ - -class CCAnimationFrame : public CCObject -{ - CCAnimationFrame(); - ~CCAnimationFrame(); - - bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, float delayUnits, CCDictionary* userInfo); - - CCSpriteFrame* getSpriteFrame(); - void setSpriteFrame(CCSpriteFrame* pSpFrame); - - float getDelayUnits(); - void setDelayUnits(float fDelayUnits); - - CCDictionary* getUserInfo(); - void setUserInfo(CCDictionary* pDict); -}; - - -class CCAnimation : public CCObject -{ - static CCAnimation* create(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); - static CCAnimation* create(void); - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); - - void addSpriteFrame(CCSpriteFrame *pFrame); - void addSpriteFrameWithFileName(const char *pszFileName); - void addSpriteFrameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); - - float getTotalDelayUnits(); - - float getDelayPerUnit(); - void setDelayPerUnit(float fDelayPerUnits); - - float getDuration(); - - CCAnimation* clone(); - CCObject* copy(); - - CCArray* getFrames(); - void setFrames(CCArray* pFrames); - - - bool getRestoreOriginalFrame(); - void setRestoreOriginalFrame(bool bRestoreFrame); - - unsigned int getLoops(); - void setLoops(unsigned int uLoops); -}; diff --git a/tools/tolua++/CCAnimationCache.pkg b/tools/tolua++/CCAnimationCache.pkg deleted file mode 100644 index c4da10ccd9..0000000000 --- a/tools/tolua++/CCAnimationCache.pkg +++ /dev/null @@ -1,13 +0,0 @@ - -class CCAnimationCache : public CCObject -{ - void addAnimation(CCAnimation *animation, const char * name); - void removeAnimationByName(const char* name); - CCAnimation* animationByName(const char* name); - - static CCAnimationCache* getInstance(); - static void destroyInstance(); - - void addAnimationsWithDictionary(CCDictionary* dictionary); - void addAnimationsWithFile(const char* plist); -}; diff --git a/tools/tolua++/CCApplication.pkg b/tools/tolua++/CCApplication.pkg deleted file mode 100644 index 8bf80c8895..0000000000 --- a/tools/tolua++/CCApplication.pkg +++ /dev/null @@ -1,35 +0,0 @@ -typedef enum LanguageType -{ - kLanguageEnglish = 0, - kLanguageChinese, - kLanguageFrench, - kLanguageItalian, - kLanguageGerman, - kLanguageSpanish, - kLanguageRussian, - kLanguageKorean, - kLanguageJapanese, - kLanguageHungarian, - kLanguagePortuguese, - kLanguageArabic -} ccLanguageType; - -enum TargetPlatform -{ - kTargetWindows, - kTargetLinux, - kTargetMacOS, - kTargetAndroid, - kTargetIphone, - kTargetIpad, - kTargetBlackBerry, -}; - -class CCApplication -{ - ~CCApplication(); - - static CCApplication* getInstance(); - ccLanguageType getCurrentLanguage(); - TargetPlatform getTargetPlatform(); -}; diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg deleted file mode 100644 index 194f5e932f..0000000000 --- a/tools/tolua++/CCArray.pkg +++ /dev/null @@ -1,56 +0,0 @@ -class CCArray : public CCObject -{ - static CCArray* create(); - - static CCArray* createWithObject(CCObject* pObject); - static CCArray* createWithArray(CCArray* otherArray); - static CCArray* createWithCapacity(unsigned int capacity); - static CCArray* createWithContentsOfFile(const char* pFileName); - - unsigned int count(); - - unsigned int capacity(); - - unsigned int indexOfObject(CCObject* object); - - CCObject* objectAtIndex(unsigned int index); - - CCObject* lastObject(); - - CCObject* randomObject(); - - bool isEqualToArray(CCArray* pOtherArray); - - bool containsObject(CCObject* object); - - void addObject(CCObject* object); - - void addObjectsFromArray(CCArray* otherArray); - - void insertObject(CCObject* object, unsigned int index); - - void removeLastObject(bool bReleaseObj = true); - - void removeObject(CCObject* object, bool bReleaseObj = true); - - void removeObjectAtIndex(unsigned int index, bool bReleaseObj = true); - - void removeObjectsInArray(CCArray* otherArray); - - void removeAllObjects(); - - void fastRemoveObject(CCObject* object); - - void fastRemoveObjectAtIndex(unsigned int index); - - void exchangeObject(CCObject* object1, CCObject* object2); - - void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); - - void reverseObjects(); - - void reduceMemoryFootprint(); - - void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); - -}; diff --git a/tools/tolua++/CCAtlasNode.pkg b/tools/tolua++/CCAtlasNode.pkg deleted file mode 100644 index ff5d3a1e6d..0000000000 --- a/tools/tolua++/CCAtlasNode.pkg +++ /dev/null @@ -1,24 +0,0 @@ - -class CCAtlasNode : public CCNodeRGBA -{ - CCTextureAtlas* getTextureAtlas(); - void setTextureAtlas(CCTextureAtlas* atlas); - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D *texture); - - Color3B getColor(); - void setColor(Color3B color); - - unsigned int getQuadsToDraw(); - void setQuadsToDraw(unsigned int quadsToDraw); - - GLubyte getOpacity(); - void setOpacity(GLubyte opacity); - - void updateAtlasValues(); - bool isOpacityModifyRGB(); - void setOpacityModifyRGB(bool isOpacityModifyRGB); - - static CCAtlasNode * create(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); -}; diff --git a/tools/tolua++/CCCamera.pkg b/tools/tolua++/CCCamera.pkg deleted file mode 100644 index 5d69c3b860..0000000000 --- a/tools/tolua++/CCCamera.pkg +++ /dev/null @@ -1,22 +0,0 @@ - -class CCCamera : public CCObject -{ - CCCamera(void); - - void init(void); - char * description(void); - - void setDirty(bool bValue); - bool isDirty(void); - void restore(void); - void locate(void); - void setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ); - void setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ); - void setUpXYZ(float fUpX, float fUpY, float fUpZ); - - void getEyeXYZ(float *pEyeX, float *pEyeY, float *pEyeZ); - void getCenterXYZ(float *pCenterX, float *pCenterY, float *pCenterZ); - void getUpXYZ(float *pUpX, float *pUpY, float *pUpZ); - - static float getZEye(); -}; diff --git a/tools/tolua++/CCCommon.pkg b/tools/tolua++/CCCommon.pkg deleted file mode 100644 index 5f01e967be..0000000000 --- a/tools/tolua++/CCCommon.pkg +++ /dev/null @@ -1,3 +0,0 @@ - -void CCLuaLog(const char * pszFormat); -void CCMessageBox(const char * pszMsg, const char * pszTitle); diff --git a/tools/tolua++/CCControl.pkg b/tools/tolua++/CCControl.pkg deleted file mode 100644 index bb749d8334..0000000000 --- a/tools/tolua++/CCControl.pkg +++ /dev/null @@ -1,62 +0,0 @@ -enum CCControlEvent -{ - CCControlEventTouchDown = 1 << 0, - CCControlEventTouchDragInside = 1 << 1, - CCControlEventTouchDragOutside = 1 << 2, - CCControlEventTouchDragEnter = 1 << 3, - CCControlEventTouchDragExit = 1 << 4, - CCControlEventTouchUpInside = 1 << 5, - CCControlEventTouchUpOutside = 1 << 6, - CCControlEventTouchCancel = 1 << 7, - CCControlEventValueChanged = 1 << 8 -}; - -typedef unsigned int CCControlEvent; - -enum CCControlState -{ - CCControlStateNormal = 1 << 0, - CCControlStateHighlighted = 1 << 1, - CCControlStateDisabled = 1 << 2, - CCControlStateSelected = 1 << 3 -}; - -typedef unsigned int CCControlState; - -class CCControl:public CCLayerRGBA -{ - virtual CCControlState getState() const; - - virtual void setEnabled(bool bEnabled); - virtual bool isEnabled(); - - virtual void setSelected(bool bSelected); - virtual bool isSelected(); - - virtual void setHighlighted(bool bHighlighted); - virtual bool isHighlighted(); - bool hasVisibleParents(); - - virtual void needsLayout(); - - virtual bool isOpacityModifyRGB(); - virtual void setOpacityModifyRGB(bool bOpacityModifyRGB); - - CCControl(); - virtual bool init(void); - virtual ~CCControl(); - - - virtual void onEnter(); - virtual void onExit(); - virtual void registerWithTouchDispatcher(); - - virtual void sendActionsForControlEvents(CCControlEvent controlEvents); - - virtual void addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents); - - virtual void removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents); - - virtual CCPoint getTouchLocation(CCTouch* touch); - virtual bool isTouchInside(CCTouch * touch); -}; diff --git a/tools/tolua++/CCControlButton.pkg b/tools/tolua++/CCControlButton.pkg deleted file mode 100644 index 849e28b9d8..0000000000 --- a/tools/tolua++/CCControlButton.pkg +++ /dev/null @@ -1,111 +0,0 @@ - -#define CCControlButtonMarginLR 8 - -#define CCControlButtonMarginTB 2 - -class CCControlButton : public CCControl -{ - CCControlButton(); - virtual ~CCControlButton(); - virtual void needsLayout(void); - - virtual void setEnabled(bool enabled); - virtual void setSelected(bool enabled); - virtual void setHighlighted(bool enabled); - - virtual CCString* getCurrentTitle(); - virtual const Color3B& getCurrentTitleColor() const; - - bool doesAdjustBackgroundImage(); - void setAdjustBackgroundImage(bool adjustBackgroundImage); - - virtual CCNode* getTitleLabel(); - virtual void setTitleLabel(CCNode* var); - - virtual CCScale9Sprite* getBackgroundSprite(); - virtual void setBackgroundSprite(CCScale9Sprite* var); - - virtual CCSize getPreferredSize(); - virtual void setPreferredSize(CCSize var); - - virtual bool getZoomOnTouchDown(); - virtual void setZoomOnTouchDown(bool var); - - virtual CCPoint getLabelAnchorPoint(); - virtual void setLabelAnchorPoint(CCPoint var); - - virtual GLubyte getOpacity(void); - virtual void setOpacity(GLubyte var); - - bool isPushed(); - - virtual CCDictionary* getTitleDispatchTable(); - virtual void setTitleDispatchTable(CCDictionary* var); - - virtual CCDictionary* getTitleColorDispatchTable(); - virtual void setTitleColorDispatchTable(CCDictionary* var); - - virtual CCDictionary* getTitleLabelDispatchTable(); - virtual void setTitleLabelDispatchTable(CCDictionary* var); - - virtual CCDictionary* getBackgroundSpriteDispatchTable(); - virtual void setBackgroundSpriteDispatchTable(CCDictionary* var); - - virtual int getVerticalMargin() const; - virtual int getHorizontalOrigin() const; - - virtual void setMargins(int marginH, int marginV); - - virtual bool init(); - virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); - - static CCControlButton* create(CCNode* label, CCScale9Sprite* backgroundSprite); - - virtual bool initWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); - - static CCControlButton* create(std::string title, const char * fontName, float fontSize); - - virtual bool initWithBackgroundSprite(CCScale9Sprite* sprite); - - static CCControlButton* create(CCScale9Sprite* sprite); - - virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); - - virtual CCString* getTitleForState(CCControlState state); - - virtual void setTitleForState(CCString* title, CCControlState state); - - - virtual const Color3B getTitleColorForState(CCControlState state); - - - virtual void setTitleColorForState(Color3B color, CCControlState state); - - - virtual CCNode* getTitleLabelForState(CCControlState state); - - virtual void setTitleLabelForState(CCNode* label, CCControlState state); - - virtual void setTitleTTFForState(const char * fntFile, CCControlState state); - virtual const char * getTitleTTFForState(CCControlState state); - - virtual void setTitleTTFSizeForState(float size, CCControlState state); - virtual float getTitleTTFSizeForState(CCControlState state); - - virtual void setTitleBMFontForState(const char * fntFile, CCControlState state); - virtual const char * getTitleBMFontForState(CCControlState state); - - virtual CCScale9Sprite* getBackgroundSpriteForState(CCControlState state); - - - virtual void setBackgroundSpriteForState(CCScale9Sprite* sprite, CCControlState state); - - - virtual void setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFrame, CCControlState state); - - static CCControlButton* create(); - -}; diff --git a/tools/tolua++/CCControlColourPicker.pkg b/tools/tolua++/CCControlColourPicker.pkg deleted file mode 100644 index bbe40ba62d..0000000000 --- a/tools/tolua++/CCControlColourPicker.pkg +++ /dev/null @@ -1,23 +0,0 @@ -class CCControlColourPicker : public CCControl -{ - CCControlColourPicker(); - virtual ~CCControlColourPicker(); - virtual void setColor(const Color3B& colorValue); - virtual void setEnabled(bool bEnabled); - - virtual CCControlSaturationBrightnessPicker* getcolourPicker() const; - virtual void setcolourPicker(CCControlSaturationBrightnessPicker* var); - - virtual CCControlHuePicker* getHuePicker() const; - virtual void setHuePicker(CCControlHuePicker* var); - - virtual CCSprite* getBackground() const; - virtual void setBackground(CCSprite* var); - - static CCControlColourPicker* create(); - - virtual bool init(); - - void hueSliderValueChanged(CCObject * sender, CCControlEvent controlEvent); - void colourSliderValueChanged(CCObject * sender, CCControlEvent controlEvent); -}; diff --git a/tools/tolua++/CCControlPotentiometer.pkg b/tools/tolua++/CCControlPotentiometer.pkg deleted file mode 100644 index 85f83cf056..0000000000 --- a/tools/tolua++/CCControlPotentiometer.pkg +++ /dev/null @@ -1,42 +0,0 @@ -class CCControlPotentiometer : public CCControl -{ - CCControlPotentiometer(); - virtual ~CCControlPotentiometer(); - - static CCControlPotentiometer* create(const char* backgroundFile, const char* progressFile, const char* thumbFile); - - bool initWithTrackSprite_ProgressTimer_ThumbSprite(CCSprite* trackSprite, CCProgressTimer* progressTimer, CCSprite* thumbSprite); - void setValue(float value); - float getValue(); - - void setMinimumValue(float minimumValue); - float getMinimumValue(); - - void setMaximumValue(float maximumValue); - float getMaximumValue(); - - void setEnabled(bool enabled); - - virtual bool isTouchInside(CCTouch * touch); - - virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); - - virtual CCSprite* getThumbSprite() const; - virtual void setThumbSprite(CCSprite* var); - - virtual CCProgressTimer* getProgressTimer() const; - virtual void setProgressTimer(CCProgressTimer* var); - - virtual CCPoint getPreviousLocation() const; - virtual void setPreviousLocation(CCPoint var); - - void potentiometerBegan(CCPoint location); - void potentiometerMoved(CCPoint location); - void potentiometerEnded(CCPoint location); - - float distanceBetweenPointAndPoint(CCPoint point1, CCPoint point2); - - float angleInDegreesBetweenLineFromPoint_toPoint_toLineFromPoint_toPoint(CCPoint beginLineA, CCPoint endLineA,CCPoint beginLineB,CCPoint endLineB); -}; diff --git a/tools/tolua++/CCControlSlider.pkg b/tools/tolua++/CCControlSlider.pkg deleted file mode 100644 index ee17566768..0000000000 --- a/tools/tolua++/CCControlSlider.pkg +++ /dev/null @@ -1,39 +0,0 @@ -class CCControlSlider : public CCControl -{ - virtual float getValue() const; - virtual void setValue(float val); - - virtual float getMinimumValue() const; - virtual void setMinimumValue(float val); - - virtual float getMaximumValue() const; - virtual void setMaximumValue(float val); - - virtual void setMaximumValue(float val); - virtual void setEnabled(bool enabled); - virtual bool isTouchInside(CCTouch * touch); - CCPoint locationFromTouch(CCTouch* touch); - - virtual float getMinimumAllowedValue() const; - virtual void setMinimumAllowedValue(float val); - - virtual float getMaximumAllowedValue() const; - virtual void setMaximumAllowedValue(float val); - - virtual CCSprite* getThumbSprite() const; - virtual void setThumbSprite(CCSprite* val); - - virtual CCSprite* getProgressSprite() const; - virtual void setProgressSprite(CCSprite* val); - - virtual CCSprite* getBackgroundSprite() const; - virtual void setBackgroundSprite(CCSprite* val); - - CCControlSlider(); - virtual ~CCControlSlider(); - - virtual bool initWithSprites(CCSprite * backgroundSprite, CCSprite* progressSprite, CCSprite* thumbSprite); - static CCControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile); - static CCControlSlider* create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCSprite* thumbSprite); - virtual void needsLayout(); -}; diff --git a/tools/tolua++/CCControlStepper.pkg b/tools/tolua++/CCControlStepper.pkg deleted file mode 100644 index 66fcc45cb0..0000000000 --- a/tools/tolua++/CCControlStepper.pkg +++ /dev/null @@ -1,47 +0,0 @@ -enum CCControlStepperPart -{ - kCCControlStepperPartMinus, - kCCControlStepperPartPlus, - kCCControlStepperPartNone, -}; - - -class CCControlStepper : public CCControl -{ - CCControlStepper(); - virtual ~CCControlStepper(); - - bool initWithMinusSpriteAndPlusSprite(CCSprite *minusSprite, CCSprite *plusSprite); - static CCControlStepper* create(CCSprite *minusSprite, CCSprite *plusSprite); - virtual void setWraps(bool wraps); - virtual void setMinimumValue(double minimumValue); - virtual void setMaximumValue(double maximumValue); - virtual void setValue(double value); - virtual double getValue(); - virtual void setStepValue(double stepValue); - virtual void setValueWithSendingEvent(double value, bool send); - virtual bool isContinuous(); - void update(float dt); - - virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); - - virtual CCSprite* getMinusSprite() const; - virtual void setMinusSprite(CCSprite* var); - - virtual CCSprite* getPlusSprite() const; - virtual void setPlusSprite(CCSprite* var); - - virtual CCLabelTTF* getMinusLabel() const; - virtual void setMinusLabel(CCLabelTTF* var); - - virtual CCLabelTTF* getPlusLabel() const; - virtual void setPlusLabel(CCLabelTTF* var); - - void updateLayoutUsingTouchLocation(CCPoint location); - - void startAutorepeat(); - - void stopAutorepeat(); -}; diff --git a/tools/tolua++/CCControlSwitch.pkg b/tools/tolua++/CCControlSwitch.pkg deleted file mode 100644 index a73dd5ca77..0000000000 --- a/tools/tolua++/CCControlSwitch.pkg +++ /dev/null @@ -1,26 +0,0 @@ -class CCControlSwitch : public CCControl -{ - CCControlSwitch(); - virtual ~CCControlSwitch(); - - bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); - - static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); - - bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); - - static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); - - void setOn(bool isOn, bool animated); - void setOn(bool isOn); - bool isOn(void) { return m_bOn; } - bool hasMoved() { return m_bMoved; } - virtual void setEnabled(bool enabled); - - CCPoint locationFromTouch(CCTouch* touch); - - virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); - virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); -}; diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg deleted file mode 100644 index 3c87553265..0000000000 --- a/tools/tolua++/CCDictionary.pkg +++ /dev/null @@ -1,26 +0,0 @@ -class CCDictionary : public CCObject -{ - unsigned int count(); - CCArray* allKeys(); - CCArray* allKeysForObject(CCObject* object); - - CCObject* objectForKey(const std::string& key); - CCObject* objectForKey(int key); - const CCString* valueForKey(const std::string& key); - const CCString* valueForKey(int key); - - - void setObject(CCObject* pObject, const std::string& key); - void setObject(CCObject* pObject, int key); - - void removeObjectForKey(const std::string& key); - void removeObjectForKey(int key); - void removeObjectsForKeys(CCArray* pKeyArray); - void removeAllObjects(); - - static CCDictionary* create(); - static CCDictionary* createWithDictionary(CCDictionary* srcDict); - static CCDictionary* createWithContentsOfFile(const char *pFileName); - -}; - diff --git a/tools/tolua++/CCDirector.pkg b/tools/tolua++/CCDirector.pkg deleted file mode 100644 index e63fda7c94..0000000000 --- a/tools/tolua++/CCDirector.pkg +++ /dev/null @@ -1,61 +0,0 @@ - -typedef enum { - kCCDirectorProjection2D, - kCCDirectorProjection3D, - kCCDirectorProjectionCustom, - kCCDirectorProjectionDefault = kCCDirectorProjection3D, -} ccDirectorProjection; - -class CCDirector : public CCObject -{ - CCScene* getRunningScene(void); - - double getAnimationInterval(void); - - bool isDisplayStats(void); - void setDisplayStats(bool bDisplayStats); - - bool isPaused(void); - unsigned int getTotalFrames(void); - - CCEGLViewProtocol* getOpenGLView(void); - - CCSize getWinSize(void); - CCSize getWinSizeInPixels(void); - - CCPoint convertToGL(CCPoint obPoint); - CCPoint convertToUI(CCPoint obPoint); - - void pause(); - void resume(); - void purgeCachedData(void); - - void runWithScene(CCScene *pScene); - void pushScene(CCScene *pScene); - void popScene(void); - void popToRootScene(); - void replaceScene(CCScene *pScene); - void end @ endToLua (); - - float getContentScaleFactor(void); - void setContentScaleFactor(float scaleFactor); - - CCScheduler* getScheduler(); - CCActionManager* getActionManager(); - CCTouchDispatcher* getTouchDispatcher(); - // CCKeypadDispatcher* getKeypadDispatcher(); - // CCAccelerometer* getAccelerometer(); - - void setDepthTest(bool var); - void setProjection(ccDirectorProjection kProjection); - ccDirectorProjection getProjection(void); - - CCNode* getNotificationNode(); - void setNotificationNode(CCNode *node); - - float getZEye(void); - CCSize getVisibleSize(); - CCPoint getVisibleOrigin(); - - static CCDirector* getInstance(); -}; diff --git a/tools/tolua++/CCDrawNode.pkg b/tools/tolua++/CCDrawNode.pkg deleted file mode 100644 index f8a28cef5e..0000000000 --- a/tools/tolua++/CCDrawNode.pkg +++ /dev/null @@ -1,22 +0,0 @@ -class CCDrawNode : public CCNode -{ - static CCDrawNode* create(); - - CCDrawNode(); - - virtual ~CCDrawNode(); - - virtual bool init(); - - void drawDot(const CCPoint &pos, float radius, const Color4F &color); - - void drawSegment(const CCPoint &from, const CCPoint &to, float radius, const Color4F &color); - - void clear(); - - const BlendFunc& getBlendFunc() const; - - void setBlendFunc(const BlendFunc &blendFunc); - - virtual void draw(); -}; diff --git a/tools/tolua++/CCEGLViewProtocol.pkg b/tools/tolua++/CCEGLViewProtocol.pkg deleted file mode 100644 index ff01580f8b..0000000000 --- a/tools/tolua++/CCEGLViewProtocol.pkg +++ /dev/null @@ -1,91 +0,0 @@ - -enum ResolutionPolicy -{ - // The entire application is visible in the specified area without trying to preserve the original aspect ratio. - // Distortion can occur, and the application may appear stretched or compressed. - kResolutionExactFit, - // The entire application fills the specified area, without distortion but possibly with some cropping, - // while maintaining the original aspect ratio of the application. - kResolutionNoBorder, - // The entire application is visible in the specified area without distortion while maintaining the original - // aspect ratio of the application. Borders can appear on two sides of the application. - kResolutionShowAll, - - kResolutionUnKnown, -}; - -class CCEGLViewProtocol -{ - /** - * Get the frame size of EGL view. - * In general, it returns the screen size since the EGL view is a fullscreen view. - */ - const CCSize& getFrameSize() const; - - /** - * Set the frame size of EGL view. - */ - void setFrameSize(float width, float height); - - /** - * Get the visible area size of opengl viewport. - */ - CCSize getVisibleSize() const; - - /** - * Get the visible origin point of opengl viewport. - */ - CCPoint getVisibleOrigin() const; - - /** - * Set the design resolutin size. - * You can't use it with enableRetina together. - * @param width Design resolution width. - * @param height Design resolution height. - * @param resolutionPolicy The resolution policy you need, there are: - * [1] kResolutionExactFit Fill screen, if the design resolution ratio of width and height is different from the screen resolution ratio, your game view will be stretched. - * [2] kResolutionNoBorder Full screen without black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two areas of your game view will be cut. - * [3] kResolutionShowAll Full screen with black border, if the design resolution ratio of width and height is different from the screen resolution ratio, two black border will be shown on the screen; - */ - void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy); - - /** Get design resolution size. - * Default resolution size is the same as 'getFrameSize'. - */ - virtual const CCSize& getDesignResolutionSize() const; - - /** Set touch delegate */ - void setTouchDelegate(EGLTouchDelegate * pDelegate); - - /** - * Set opengl view port rectangle with points. - */ - void setViewPortInPoints(float x , float y , float w , float h); - - /** - * Set Scissor rectangle with points. - */ - void setScissorInPoints(float x , float y , float w , float h); - - /** - * Get opengl view port rectangle. - */ - const CCRect& getViewPortRect() const; - - /** - * Get the scale factor of horizontal direction. - * - */ - float getScaleX() const; - - /** - * Get the scale factor of vertical direction. - */ - float getScaleY() const; -}; - -class CCEGLView : public CCEGLViewProtocol -{ - static CCEGLView* getInstance(); -}; - diff --git a/tools/tolua++/CCEditBox.pkg b/tools/tolua++/CCEditBox.pkg deleted file mode 100644 index bbb9b33626..0000000000 --- a/tools/tolua++/CCEditBox.pkg +++ /dev/null @@ -1,103 +0,0 @@ -enum KeyboardReturnType { - kKeyboardReturnTypeDefault = 0, - kKeyboardReturnTypeDone, - kKeyboardReturnTypeSend, - kKeyboardReturnTypeSearch, - kKeyboardReturnTypeGo -}; - -enum EditBoxInputMode -{ - kEditBoxInputModeAny = 0, - - kEditBoxInputModeEmailAddr, - - kEditBoxInputModeNumeric, - - kEditBoxInputModePhoneNumber, - - kEditBoxInputModeUrl, - - kEditBoxInputModeDecimal, - - kEditBoxInputModeSingleLine -}; - -enum EditBoxInputFlag -{ - - kEditBoxInputFlagPassword = 0, - - kEditBoxInputFlagSensitive, - - kEditBoxInputFlagInitialCapsWord, - - kEditBoxInputFlagInitialCapsSentence, - - kEditBoxInputFlagInitialCapsAllCharacters -}; - -class CCEditBox: public CCControlButton -{ -public: - - CCEditBox(void); - - - virtual ~CCEditBox(void); - - - static CCEditBox* create(const CCSize& size, CCScale9Sprite* pNormal9SpriteBg, CCScale9Sprite* pPressed9SpriteBg = NULL, CCScale9Sprite* pDisabled9SpriteBg = NULL); - - bool initWithSizeAndBackgroundSprite(const CCSize& size, CCScale9Sprite* pNormal9SpriteBg); - - void registerScriptEditBoxHandler(LUA_FUNCTION handler); - - void unregisterScriptEditBoxHandler(void); - - int getScriptEditBoxHandler(void); - - void setText(const char* pText); - - const char* getText(void); - - void setFont(const char* pFontName, int fontSize); - - void setFontName(const char* pFontName); - - void setFontSize(int fontSize); - - void setFontColor(const Color3B& color); - - void setPlaceholderFont(const char* pFontName, int fontSize); - - void setPlaceholderFontName(const char* pFontName); - - void setPlaceholderFontSize(int fontSize); - - void setPlaceholderFontColor(const Color3B& color); - - void setPlaceHolder(const char* pText); - - const char* getPlaceHolder(void); - - void setInputMode(EditBoxInputMode inputMode); - - void setMaxLength(int maxLength); - - int getMaxLength(); - - void setInputFlag(EditBoxInputFlag inputFlag); - - void setReturnType(KeyboardReturnType returnType); - - virtual void setPosition(const CCPoint& pos); - virtual void setVisible(bool visible); - virtual void setContentSize(const CCSize& size); - virtual void setAnchorPoint(const CCPoint& anchorPoint); - virtual void visit(void); - virtual void onEnter(void); - virtual void onExit(void); - - void touchDownAction(CCObject *sender, CCControlEvent controlEvent); -}; diff --git a/tools/tolua++/CCFileUtils.pkg b/tools/tolua++/CCFileUtils.pkg deleted file mode 100644 index 558bbc3394..0000000000 --- a/tools/tolua++/CCFileUtils.pkg +++ /dev/null @@ -1,19 +0,0 @@ - -class CCFileUtils -{ - static CCFileUtils* getInstance(); - static void destroyInstance(); - - void purgeCachedEntries(); - - std::string fullPathForFilename(const char *pszFileName); - void loadFilenameLookupDictionaryFromFile(const char* filename); - const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); - void addSearchResolutionsOrder(const char* order); - void addSearchPath(const char* path); - - std::string getWritablePath(); - - void setPopupNotify(bool bNotify); - bool isPopupNotify(); -}; diff --git a/tools/tolua++/CCGeometry.pkg b/tools/tolua++/CCGeometry.pkg deleted file mode 100644 index 917f83079a..0000000000 --- a/tools/tolua++/CCGeometry.pkg +++ /dev/null @@ -1,63 +0,0 @@ - -class CCPoint -{ - float x; - float y; - CCPoint(); - CCPoint(float x, float y); - CCPoint(const CCSize& size); - CCPoint operator-(const CCPoint& right) const; - CCPoint operator+(const CCPoint& right) const; - CCPoint operator*(float a) const; - CCPoint getMidpoint(const CCPoint& other) const; - float dot(const CCPoint& other) const; - float cross(const CCPoint& other) const; - CCPoint getPerp() const; - CCPoint getRPerp() const; - CCPoint project(const CCPoint& other) const; - CCPoint rotate(const CCPoint& other) const; - CCPoint unrotate(const CCPoint& other) const; - float getLengthSq() const; - float getLength() const; - float getDistance(const CCPoint& other) const; - CCPoint normalize() const; - float getAngle() const; - CCPoint getClampPoint(const CCPoint& min_inclusive, const CCPoint& max_inclusive) const; - CCPoint lerp(const CCPoint& other, float alpha) const; - bool fuzzyEquals(const CCPoint& target, float variance) const; - CCPoint rotateByAngle(const CCPoint& pivot, float angle) const; - - bool equals(const CCPoint & target) const ; - static bool isLineIntersect(const CCPoint& A, const CCPoint& B,const CCPoint& C, const CCPoint& D,float* S, float* T); - static bool isSegmentIntersect(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D); - static CCPoint getIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D); - static CCPoint forAngle(const float a); -}; - -class CCSize -{ - float width; - float height; - CCSize(); - CCSize(float width, float height); - - bool equals(const CCSize & target) const; -}; - -class CCRect -{ - CCPoint origin; - CCSize size; - CCRect(); - CCRect(float x, float y, float width, float height); - - float getMinX(); - float getMidX(); - float getMaxX(); - float getMinY(); - float getMidY(); - float getMaxY(); - bool equals(const CCRect & rect) const; - bool containsPoint(const CCPoint & point) const; - bool intersectsRect(const CCRect & rect) const; -}; diff --git a/tools/tolua++/CCImage.pkg b/tools/tolua++/CCImage.pkg deleted file mode 100644 index 87638721a9..0000000000 --- a/tools/tolua++/CCImage.pkg +++ /dev/null @@ -1,60 +0,0 @@ -class CCImage : public CCObject -{ - CCImage(); - ~CCImage(); - -/* - typedef enum - { - kFmtJpg = 0, - kFmtPng, - kFmtTiff, - kFmtWebp, - kFmtRawData, - kFmtUnKnown - }EImageFormat; - - typedef enum - { - kAlignCenter = 0x33, ///< Horizontal center and vertical center. - kAlignTop = 0x13, ///< Horizontal center and vertical top. - kAlignTopRight = 0x12, ///< Horizontal right and vertical top. - kAlignRight = 0x32, ///< Horizontal right and vertical center. - kAlignBottomRight = 0x22, ///< Horizontal right and vertical bottom. - kAlignBottom = 0x23, ///< Horizontal center and vertical bottom. - kAlignBottomLeft = 0x21, ///< Horizontal left and vertical bottom. - kAlignLeft = 0x31, ///< Horizontal left and vertical center. - kAlignTopLeft = 0x11, ///< Horizontal left and vertical top. - }ETextAlign; - - typedef enum - { - kColorGray = 0, - kColorRGB, - }EColorType; - - bool initWithImageFile(const char * strPath); - bool initWithImageData(void * pData, - int nDataLen, - int nWidth = 0, - int nHeight = 0, - int nBitsPerComponent = 8); - bool initWithString( - const char * pText, - int nWidth = 0, - int nHeight = 0, - ETextAlign eAlignMask = kAlignCenter, - const char * pFontName = 0, - int nSize = 0); - -*/ - unsigned char * getData(); - int getDataLen(); - - bool hasAlpha(); - bool isPremultipliedAlpha(); - bool saveToFile(const char *pszFilePath, bool bIsToRGB = true); - int getWidth(); - int getHeight(); - int getBitPerPixel(); -}; diff --git a/tools/tolua++/CCInteger.pkg b/tools/tolua++/CCInteger.pkg deleted file mode 100644 index c506637fb4..0000000000 --- a/tools/tolua++/CCInteger.pkg +++ /dev/null @@ -1,7 +0,0 @@ -class CCInteger : public CCObject -{ - CCInteger(int v); - int getValue() const; - - static CCInteger* create(int v); -}; diff --git a/tools/tolua++/CCKeypadDispatcher.pkg b/tools/tolua++/CCKeypadDispatcher.pkg deleted file mode 100644 index 868e390bec..0000000000 --- a/tools/tolua++/CCKeypadDispatcher.pkg +++ /dev/null @@ -1,6 +0,0 @@ - -typedef enum { - // the back key clicked msg - kTypeBackClicked = 1, - kTypeMenuClicked, -} ccKeypadMSGType; diff --git a/tools/tolua++/CCLabelAtlas.pkg b/tools/tolua++/CCLabelAtlas.pkg deleted file mode 100644 index f14d41c84e..0000000000 --- a/tools/tolua++/CCLabelAtlas.pkg +++ /dev/null @@ -1,14 +0,0 @@ - -class CCLabelAtlas : public CCAtlasNode -{ - void updateAtlasValues(); - - void setString(const char *label); - const char* getString(void) const; - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D *texture); - - static CCLabelAtlas* create(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - static CCLabelAtlas* create(const char *sring, const char *fntFile); -}; diff --git a/tools/tolua++/CCLabelBMFont.pkg b/tools/tolua++/CCLabelBMFont.pkg deleted file mode 100644 index 358f2fdab4..0000000000 --- a/tools/tolua++/CCLabelBMFont.pkg +++ /dev/null @@ -1,39 +0,0 @@ - -enum { - kCCLabelAutomaticWidth = -1, -}; - -class CCLabelBMFont : public CCSpriteBatchNode -{ - CCLabelBMFont(); - ~CCLabelBMFont(); - bool init(); - void setString(const char *label); - void setString(const char *label, bool fromUpdate); - void setCString(const char *label); - const char* getString(void) const; - - void setAnchorPoint(const CCPoint & var); - void setAlignment(CCTextAlignment alignment); - void setWidth(float width); - void setLineBreakWithoutSpace(bool breakWithoutSpace); - void setScale(float scale); - void setScaleX(float scaleX); - void setScaleY(float scaleY); - - void setFntFile(const char* fntFile); - const char* getFntFile(); - - void setColor(const Color3B& color); - const Color3B& getColor(void) const; - - GLubyte getOpacity(void) const; - void setOpacity(GLubyte opacity); - - bool isOpacityModifyRGB() const; - void setOpacityModifyRGB(bool isOpacityModifyRGB); - - static void purgeCachedData(); - static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointMake(0, 0)); - static CCLabelBMFont * create(); -}; diff --git a/tools/tolua++/CCLabelTTF.pkg b/tools/tolua++/CCLabelTTF.pkg deleted file mode 100644 index 5fe337dbe5..0000000000 --- a/tools/tolua++/CCLabelTTF.pkg +++ /dev/null @@ -1,29 +0,0 @@ - -class CCLabelTTF : public CCSprite -{ - CCLabelTTF(); - ~CCLabelTTF(); - bool init(); - void setString(const char *label); - const char* getString(void) const; - - CCTextAlignment getHorizontalAlignment() const; - void setHorizontalAlignment(CCTextAlignment alignment); - - CCVerticalTextAlignment getVerticalAlignment() const; - void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment); - - CCSize getDimensions() const; - void setDimensions(CCSize &dim); - - float getFontSize() const; - void setFontSize(float fontSize); - - const char* getFontName() const; - void setFontName(const char *fontName); - - static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment); - static CCLabelTTF * create(const char *str, const char *fontName, float fontSize, const CCSize& dimensions, CCTextAlignment hAlignment); - static CCLabelTTF * create(const char *str, const char *fontName, float fontSize); - static CCLabelTTF * create(); -}; diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg deleted file mode 100644 index 5d7f85ddf7..0000000000 --- a/tools/tolua++/CCLayer.pkg +++ /dev/null @@ -1,104 +0,0 @@ -typedef enum { - kCCTouchesAllAtOnce, - kCCTouchesOneByOne, -} ccTouchesMode; - -class CCLayer : public CCNode -{ - void setTouchEnabled(bool bValue); - bool isTouchEnabled() const; - - void setAccelerometerEnabled(bool bValue); - bool isAccelerometerEnabled() const; - - void setKeypadEnabled(bool bValue); - bool isKeypadEnabled() const; - - virtual void setTouchMode(ccTouchesMode mode); - virtual int getTouchMode() const; - virtual void setTouchPriority(int priority); - virtual int getTouchPriority() const; - virtual void setSwallowsTouches(bool swallowsTouches); - virtual bool isSwallowsTouches() const; - - static CCLayer *create(void); -}; - -class CCLayerRGBA : public CCLayer, public CCRGBAProtocol -{ - static CCLayerRGBA* create(); - - CCLayerRGBA(); - virtual ~CCLayerRGBA(); - - virtual bool init(); - - virtual GLubyte getOpacity() const; - virtual GLubyte getDisplayedOpacity() const; - virtual void setOpacity(GLubyte opacity); - virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled() const; - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - - virtual const Color3B& getColor() const; - virtual const Color3B& getDisplayedColor() const; - virtual void setColor(const Color3B& color); - virtual void updateDisplayedColor(const Color3B& parentColor); - virtual bool isCascadeColorEnabled() const; - virtual void setCascadeColorEnabled(bool cascadeColorEnabled); - - virtual void setOpacityModifyRGB(bool bValue); - virtual bool isOpacityModifyRGB() const; -}; - -class CCLayerColor : public CCLayerRGBA -{ - void changeWidth(GLfloat w); - void changeHeight(GLfloat h); - void changeWidthAndHeight(GLfloat w ,GLfloat h); - - void setContentSize(const CCSize & var); - - void setOpacity(GLubyte var); - void setColor(Color3B Value); - void setBlendFunc(BlendFunc Value); - BlendFunc getBlendFunc(void) const; - - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void) const; - - static CCLayerColor * create(Color4B color, GLfloat width, GLfloat height); - static CCLayerColor * create(Color4B color); -}; - -class CCLayerGradient : public CCLayerColor -{ - void setStartColor(Color3B colors); - Color3B getStartColor() const; - void setEndColor(Color3B Value); - Color3B getEndColor(void) const; - void setStartOpacity(GLubyte Value); - GLubyte getStartOpacity(void); - void setEndOpacity(GLubyte Value); - GLubyte getEndOpacity(void); - void setVector(CCPoint Value); - CCPoint getVector(void); - - void setCompressedInterpolation(bool Value); - bool isCompressedInterpolation(void) const; - - static CCLayerGradient* create(Color4B start, Color4B end, CCPoint v); - static CCLayerGradient* create(Color4B start, Color4B end); - static CCLayerGradient* create(); -}; - -class CCLayerMultiplex : public CCLayer -{ - void addLayer(CCLayer* layer); - void switchTo(unsigned int n); - void switchToAndReleaseMe(unsigned int n); - - static CCLayerMultiplex* createWithArray(CCArray* arrayOfLayers); - static CCLayerMultiplex * create(); - static CCLayerMultiplex * createWithLayer(CCLayer* layer); -}; diff --git a/tools/tolua++/CCMenu.pkg b/tools/tolua++/CCMenu.pkg deleted file mode 100644 index efc9b6daaa..0000000000 --- a/tools/tolua++/CCMenu.pkg +++ /dev/null @@ -1,38 +0,0 @@ -enum -{ - kCCMenuStateWaiting, - kCCMenuStateTrackingTouch -}; - -enum { - kCCMenuHandlerPriority = -128 -}; - -class CCMenu : public CCLayerRGBA -{ - void alignItemsVertically(); - void alignItemsVerticallyWithPadding(float padding); - void alignItemsHorizontally(); - void alignItemsHorizontallyWithPadding(float padding); - void alignItemsInColumnsWithArray(CCArray* rows); - void alignItemsInRowsWithArray(CCArray* columns); - - void setHandlerPriority(int newPriority); - - void addChild(CCMenuItem* child, int zOrder = 0, int tag = -1); - - void setOpacity(GLubyte opacity); - GLubyte getOpacity(void); - void setColor(Color3B color); - Color3B getColor(void); - - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - - bool isEnabled(); - void setEnabled(bool value); - - static CCMenu* create(); - static CCMenu* createWithItem(CCMenuItem* item); - static CCMenu* createWithArray(CCArray* pArrayOfItems); -}; diff --git a/tools/tolua++/CCMenuItem.pkg b/tools/tolua++/CCMenuItem.pkg deleted file mode 100644 index 7f0dd8414a..0000000000 --- a/tools/tolua++/CCMenuItem.pkg +++ /dev/null @@ -1,130 +0,0 @@ - -class CCMenuItem : public CCNodeRGBA -{ - CCRect rect(); - void activate(); - void selected(); - void unselected(); - void setEnabled(bool enabled); - bool isEnabled() const; - bool isSelected() const; -}; - -class CCMenuItemLabel : public CCMenuItem -{ - void setString(const char* label); - - void setOpacity(GLubyte opacity); - GLubyte getOpacity(); - void setColor(Color3B color); - Color3B getColor(); - void setDisabledColor(const Color3B & color); - const Color3B & getDisabledColor(); - void setLabel(CCNode* pLabel); - CCNode* getLabel(); - - void activate(); - void selected(); - void unselected(); - void setEnabled(bool enabled); - - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - - static CCMenuItemLabel* create(CCNode* label); -}; - -class CCMenuItemAtlasFont : public CCMenuItemLabel -{ - static CCMenuItemAtlasFont* create(const char* value, - const char* charMapFile, - int itemWidth, - int itemHeight, - char startCharMap); -}; - -class CCMenuItemFont : public CCMenuItemLabel -{ - static void setFontSize(int s); - static unsigned int getFontSize(); - static void setFontName(const char* name); - static const char* getFontName(); - void setFontSizeObj(unsigned int s); - unsigned int getFontSizeObj(); - void setFontNameObj(const char* name); - const char* getFontNameObj() const; - - static CCMenuItemFont * create(const char* value); -}; - -class CCMenuItemSprite : public CCMenuItem -{ - void setColor(Color3B color); - Color3B getColor(); - void setOpacity(GLubyte opacity); - GLubyte getOpacity(); - - void setNormalImage(CCNode* pImage); - CCNode* getNormalImage(); - void setSelectedImage(CCNode* pImage); - CCNode* getSelectedImage(); - void setDisabledImage(CCNode* pImage); - CCNode* getDisabledImage(); - - void selected(); - void unselected(); - void setEnabled(bool bEnabled); - - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - - static CCMenuItemSprite * create(CCNode* normalSprite, - CCNode* selectedSprite, - CCNode* disabledSprite); - static CCMenuItemSprite * create(CCNode* normalSprite, - CCNode* selectedSprite); -}; - -class CCMenuItemImage : public CCMenuItemSprite -{ - void setColor(Color3B color); - Color3B getColor(); - void setOpacity(GLubyte opacity); - GLubyte getOpacity(); - - void setNormalSpriteFrame(CCSpriteFrame* frame); - void setSelectedSpriteFrame(CCSpriteFrame* frame); - void setDisabledSpriteFrame(CCSpriteFrame* frame); - - static CCMenuItemImage* create(const char* normalImage, - const char* selectedImage, - const char* disabledImage); - static CCMenuItemImage* create(const char* normalImage, - const char* selectedImage); - static CCMenuItemImage* create(); -}; - -class CCMenuItemToggle : public CCMenuItem -{ - void setColor(Color3B color); - Color3B getColor(); - void setOpacity(GLubyte opacity); - GLubyte getOpacity(); - void setSelectedIndex(unsigned int index); - unsigned int getSelectedIndex(); - void setSubItems(CCArray* pArrayOfItems); - CCArray* getSubItems(); - - void addSubItem(CCMenuItem *item); - CCMenuItem* getSelectedItem(); - - void activate(); - void selected(); - void unselected(); - void setEnabled(bool var); - - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - - static CCMenuItemToggle* create(CCMenuItem *item); -}; diff --git a/tools/tolua++/CCMotionStreak.pkg b/tools/tolua++/CCMotionStreak.pkg deleted file mode 100644 index 2945d3d18e..0000000000 --- a/tools/tolua++/CCMotionStreak.pkg +++ /dev/null @@ -1,25 +0,0 @@ -class CCMotionStreak : public CCNodeRGBA -{ - static CCMotionStreak* create(float fade, float minSeg, float stroke, Color3B color, const char* path); - static CCMotionStreak* create(float fade, float minSeg, float stroke, Color3B color, CCTexture2D* texture); - - void tintWithColor(Color3B colors); - void reset(); - - void setPosition(CCPoint& position); - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D *texture); - void setBlendFunc(BlendFunc blendFunc); - BlendFunc getBlendFunc(void); - void setColor(const Color3B& color); - const Color3B& getColor(void); - GLubyte getOpacity(void); - void setOpacity(GLubyte opacity); - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - bool isFastMode(); - void setFastMode(bool bFastMode); - bool isStartingPositionInitialized(); - void setStartingPositionInitialized(bool bStartingPositionInitialized); -}; diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg deleted file mode 100644 index 249461610f..0000000000 --- a/tools/tolua++/CCNode.pkg +++ /dev/null @@ -1,146 +0,0 @@ -enum { - kCCNodeTagInvalid = -1, -}; - -enum { - kCCNodeOnEnter, - kCCNodeOnExit -}; - -typedef enum { -// CC_GL_ALL = 0, -} ccGLServerState; - - -class CCNode : public CCObject -{ - int getZOrder() const; - float getVertexZ() const; - void setVertexZ(float var); - float getRotation() const; - float getRotationX() const; - float getRotationY() const; - void setRotation(float newRotation); - float getScale() const; - void setScale(float scale); - float getScaleX() const; - void setScaleX(float newScaleX); - float getScaleY() const; - void setScaleY(float newScaleY); - void getPosition(float* x = 0, float* y = 0) const; - float getPositionX() const; - float getPositionY() const; - void setPosition(float x, float y); - void setPosition(CCPoint pos); - void setPositionX(float x); - void setPositionY(float y); - float getSkewX() const; - void setSkewX(float skewX); - float getSkewY() const; - void setSkewY(float skewY); - bool isVisible() const; - void setVisible(bool var); - CCPoint getAnchorPoint() const; - void setAnchorPoint(CCPoint point); - CCSize getContentSize(); - void setContentSize(const CCSize & size); - int getTag(); - void setTag(int var); - - CCArray* getChildren(); - unsigned int getChildrenCount(void); - - CCCamera* getCamera(); - CCGridBase* getGrid(); - void setGrid(CCGridBase* pGrid); - CCPoint getAnchorPointInPoints(); - bool isRunning() const; - CCNode* getParent(); - void setParent(CCNode * var); - bool isIgnoreAnchorPointForPosition(); - void ignoreAnchorPointForPosition(bool newValue); - void* getUserData(); - void setUserData(void *var); - CCObject* getUserObject(); - void setUserObject(CCObject* pObject); - CCGLProgram* getShaderProgram(); - void setShaderProgram(CCGLProgram* pShaderProgram); - int getOrderOfArrival() const; - void setOrderOfArrival(int order); - ccGLServerState getGLServerState() const; - void setGLServerState(ccGLServerState state); - CCActionManager* getActionManager(); - void setActionManager(CCActionManager* pActionMgr); - ccGLServerState getGLServerState(void); - void setGLServerState(ccGLServerState state); - CCScheduler* getScheduler(); - void setScheduler(CCScheduler* pScheduler); - void addChild(CCNode * child); - void addChild(CCNode * child, int zOrder); - void addChild(CCNode * child, int zOrder, int tag); - void removeChild(CCNode* child, bool cleanup); - void removeAllChildrenWithCleanup(bool cleanup); - void reorderChild(CCNode * child, int zOrder); - void cleanup(void); - void draw(void); - void visit(void); - void transform(void); - void transformAncestors(void); - CCRect getBoundingBox(void) const; - - CCAction* runAction(CCAction* action); - void stopAllActions(void); - void stopAction(CCAction* action); - - void stopActionByTag(int tag); - CCAction* getActionByTag(int tag); - const char * description(void) const; - CCNode* getChildByTag(int tag); - - unsigned int getNumberOfRunningActions(void) const; - - CCAffineTransform nodeToParentTransform(void); - CCAffineTransform parentToNodeTransform(void); - CCAffineTransform nodeToWorldTransform(void); - CCAffineTransform worldToNodeTransform(void); - - CCPoint convertToNodeSpace(CCPoint worldPoint); - CCPoint convertToWorldSpace(CCPoint nodePoint); - CCPoint convertToNodeSpaceAR(CCPoint worldPoint); - CCPoint convertToWorldSpaceAR(CCPoint nodePoint); - CCPoint convertTouchToNodeSpace(CCTouch * touch); - CCPoint convertTouchToNodeSpaceAR(CCTouch * touch); - - void removeFromParentAndCleanup(bool cleanup); - void removeChildByTag(int tag, bool cleanup); - - void scheduleUpdateWithPriorityLua(LUA_FUNCTION nHandler, int priority); - void unscheduleUpdate(void); - - static CCNode * create(void); -}; - -class CCNodeRGBA : public CCNode, public CCRGBAProtocol -{ - CCNodeRGBA(); - virtual ~CCNodeRGBA(); - - virtual bool init(); - - virtual GLubyte getOpacity() const; - virtual GLubyte getDisplayedOpacity() const; - virtual void setOpacity(GLubyte opacity); - virtual void updateDisplayedOpacity(GLubyte parentOpacity); - virtual bool isCascadeOpacityEnabled() const; - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - - virtual const Color3B& getColor(void) const; - virtual const Color3B& getDisplayedColor() const; - virtual void setColor(const Color3B& color); - virtual void updateDisplayedColor(const Color3B& parentColor); - virtual bool isCascadeColorEnabled() const; - virtual void setCascadeColorEnabled(bool cascadeColorEnabled); - - virtual void setOpacityModifyRGB(bool bValue); - virtual bool isOpacityModifyRGB() const; -}; diff --git a/tools/tolua++/CCNotificationCenter.pkg b/tools/tolua++/CCNotificationCenter.pkg deleted file mode 100644 index d6598d1076..0000000000 --- a/tools/tolua++/CCNotificationCenter.pkg +++ /dev/null @@ -1,24 +0,0 @@ - -class CCNotificationCenter : public CCObject -{ - CCNotificationCenter(); - - ~CCNotificationCenter(); - - static CCNotificationCenter* getInstance(); - static void destroyInstance(); - - int removeAllObservers(CCObject *target); - - void registerScriptObserver(CCObject *target,LUA_FUNCTION funcID,const char* name); - - void unregisterScriptObserver(CCObject *target,const char* name); - - void postNotification(const char *name); - - void postNotification(const char *name, CCObject *object); - - int getScriptHandler(); - - int getObserverHandlerByName(const char* name); -}; diff --git a/tools/tolua++/CCObject.pkg b/tools/tolua++/CCObject.pkg deleted file mode 100644 index 12883a0b74..0000000000 --- a/tools/tolua++/CCObject.pkg +++ /dev/null @@ -1,10 +0,0 @@ - -class CCObject -{ - void release(void); - void retain(void); - bool isSingleReference(void); - unsigned int retainCount(void); - bool isEqual(const CCObject* pObject); - CCObject* autorelease(); -}; diff --git a/tools/tolua++/CCParallaxNode.pkg b/tools/tolua++/CCParallaxNode.pkg deleted file mode 100644 index 998fb6d4a1..0000000000 --- a/tools/tolua++/CCParallaxNode.pkg +++ /dev/null @@ -1,16 +0,0 @@ - -class CCParallaxNode : public CCNode -{ - // struct _ccArray* getParallaxArray(); - // void setParallaxArray(struct _ccArray * pval); - - void addChild(CCNode * child, unsigned int z, CCPoint parallaxRatio, CCPoint positionOffset); - void addChild(CCNode * child, unsigned int zOrder, int tag); - - void removeChild(CCNode* child, bool cleanup); - void removeAllChildrenWithCleanup(bool cleanup); - - void visit(void); - - static CCParallaxNode* create(); -}; diff --git a/tools/tolua++/CCParticleBatchNode.pkg b/tools/tolua++/CCParticleBatchNode.pkg deleted file mode 100644 index b76da61785..0000000000 --- a/tools/tolua++/CCParticleBatchNode.pkg +++ /dev/null @@ -1,23 +0,0 @@ -class CCParticleBatchNode : public CCNode, public CCTextureProtocol -{ -public: - void addChild(CCNode * child); - void addChild(CCNode * child, int zOrder); - void addChild(CCNode * child, int zOrder, int tag); - - void insertChild(CCParticleSystem* pSystem, unsigned int index); - - void removeChild(CCNode* child, bool cleanup); - void reorderChild(CCNode * child, int zOrder); - void removeChildAtIndex(unsigned int index, bool doCleanup); - void removeAllChildrenWithCleanup(bool doCleanup); - void disableParticle(unsigned int particleIndex); - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D *texture); - void setBlendFunc(const BlendFunc &blendFunc); - const BlendFunc& getBlendFunc(void); - - static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); - static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); -}; diff --git a/tools/tolua++/CCParticleExamples.pkg b/tools/tolua++/CCParticleExamples.pkg deleted file mode 100644 index 6b6571010b..0000000000 --- a/tools/tolua++/CCParticleExamples.pkg +++ /dev/null @@ -1,55 +0,0 @@ - -class CCParticleFire : public CCParticleSystemQuad -{ - static CCParticleFire * create(); -}; - -class CCParticleFireworks : public CCParticleSystemQuad -{ - static CCParticleFireworks * create(); -}; - -class CCParticleSun : public CCParticleSystemQuad -{ - static CCParticleSun * create(); -}; - -class CCParticleGalaxy : public CCParticleSystemQuad -{ - static CCParticleGalaxy * create(); -}; - -class CCParticleFlower : public CCParticleSystemQuad -{ - static CCParticleFlower * create(); -}; - -class CCParticleMeteor : public CCParticleSystemQuad -{ - static CCParticleMeteor * create(); -}; - -class CCParticleSpiral : public CCParticleSystemQuad -{ - static CCParticleSpiral * create(); -}; - -class CCParticleExplosion : public CCParticleSystemQuad -{ - static CCParticleExplosion * create(); -}; - -class CCParticleSmoke : public CCParticleSystemQuad -{ - static CCParticleSmoke * create(); -}; - -class CCParticleSnow : public CCParticleSystemQuad -{ - static CCParticleSnow * create(); -}; - -class CCParticleRain : public CCParticleSystemQuad -{ - static CCParticleRain * create(); -}; diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg deleted file mode 100644 index 66f7174530..0000000000 --- a/tools/tolua++/CCParticleSystem.pkg +++ /dev/null @@ -1,152 +0,0 @@ -enum { - kCCParticleDurationInfinity = -1, - kCCParticleStartSizeEqualToEndSize = -1, - kCCParticleStartRadiusEqualToEndRadius = -1, -}; - -enum { - kCCParticleModeGravity, - kCCParticleModeRadius, -}; - -typedef enum { - kCCPositionTypeFree, - kCCPositionTypeRelative, - kCCPositionTypeGrouped, -}tCCPositionType; - - -class CCParticleSystem : public CCNode -{ - // mode A - const CCPoint& getGravity(); - void setGravity(const CCPoint& g); - float getSpeed(); - void setSpeed(float speed); - float getSpeedVar(); - void setSpeedVar(float speed); - float getTangentialAccel(); - void setTangentialAccel(float t); - float getTangentialAccelVar(); - void setTangentialAccelVar(float t); - float getRadialAccel(); - void setRadialAccel(float t); - float getRadialAccelVar(); - void setRadialAccelVar(float t); - - // mode B - float getStartRadius(); - void setStartRadius(float startRadius); - float getStartRadiusVar(); - void setStartRadiusVar(float startRadiusVar); - float getEndRadius(); - void setEndRadius(float endRadius); - float getEndRadiusVar(); - void setEndRadiusVar(float endRadiusVar); - float getRotatePerSecond(); - void setRotatePerSecond(float degrees); - float getRotatePerSecondVar(); - void setRotatePerSecondVar(float degrees); - - bool addParticle(); - void initParticle(tCCParticle* particle); - void stopSystem(); - void resetSystem(); - bool isFull(); - void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition); - void postStep(); - - unsigned int getParticleCount(); - float getDuration(); - void setDuration(float d); - CCPoint getSourcePosition(); - void setSourcePosition(CCPoint pos); - CCPoint getPosVar(); - void setPosVar(CCPoint pos); - float getLife(); - void setLife(float life); - float getLifeVar(); - void setLifeVar(float lifeVar); - float getAngle(); - void setAngle(float angle); - float getAngleVar(); - void setAngleVar(float angle); - - float getStartSize(); - void setStartSize(float size); - float getStartSizeVar(); - void setStartSizeVar(float size); - float getEndSize(); - void setEndSize(float size); - float getEndSizeVar(); - void setEndSizeVar(float size); - - void setStartColor(const Color4F var); - const Color4F & getStartColor(); - void setStartColorVar(const Color4F var); - const Color4F & getStartColorVar(); - void setEndColor(const Color4F var); - const Color4F & getEndColor(); - void setEndColorVar(const Color4F var); - const Color4F & getEndColorVar(); - void setStartSpin(float var); - float getStartSpin(); - void setStartSpinVar(float var); - float getStartSpinVar(); - void setEndSpin(float var); - float getEndSpin(); - void setEndSpinVar(float var); - float getEndSpinVar(); - void setEmissionRate(float rate); - float getEmissionRate(); - unsigned int getTotalParticles(); - - bool isAutoRemoveOnFinish(); - void setAutoRemoveOnFinish(bool var); - int getEmitterMode(); - void setEmitterMode(int mode); - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D* var); - - BlendFunc getBlendFunc(void); - void setBlendFunc(BlendFunc var); - - void setScale(float s); - void setRotation(float newRotation); - void setScaleX(float newScaleX); - void setScaleY(float newScaleY); - - bool isActive(); - bool isBlendAdditive(); - void setBlendAdditive(bool value); - - CCParticleBatchNode* getBatchNode(void); - void setBatchNode(CCParticleBatchNode* node); - tCCPositionType getPositionType(void); - void setPositionType(tCCPositionType type); - - bool initWithFile(const char* plistFile); - bool initWithTotalParticles(unsigned int number); - - static CCParticleSystem * create(const char *plistFile); -}; - -class CCParticleSystemQuad : public CCParticleSystem -{ - CCParticleSystemQuad(void); - void postStep(); - void setDisplayFrame(CCSpriteFrame* spriteFrame); - void setTexture(CCTexture2D* texture); - void setTextureWithRect(CCTexture2D *texture, const CCRect& rect); - void setBatchNode(CCParticleBatchNode* batchNode); - void setTotalParticles(unsigned int tp); - - void updateQuadWithParticle(tCCParticle* particle, const CCPoint& newPosition); - void postStep(); - void setTotalParticles(unsigned int tp); - - static CCParticleSystemQuad * create(const char *plistFile); - static CCParticleSystemQuad * create(); -}; - diff --git a/tools/tolua++/CCPointExtension.pkg b/tools/tolua++/CCPointExtension.pkg deleted file mode 100644 index 1af9739089..0000000000 --- a/tools/tolua++/CCPointExtension.pkg +++ /dev/null @@ -1 +0,0 @@ -float clampf(float value, float min_inclusive, float max_inclusive); diff --git a/tools/tolua++/CCProgressTimer.pkg b/tools/tolua++/CCProgressTimer.pkg deleted file mode 100644 index 6eba68fd82..0000000000 --- a/tools/tolua++/CCProgressTimer.pkg +++ /dev/null @@ -1,36 +0,0 @@ -typedef enum { - kCCProgressTimerTypeRadial, - kCCProgressTimerTypeBar, -} CCProgressTimerType; - -class CCProgressTimer : public CCNodeRGBA -{ - CCProgressTimerType getType(void); - - float getPercentage(void); - - CCSprite* getSprite(void) { return m_pSprite; } - - void setPercentage(float fPercentage); - void setSprite(CCSprite *pSprite); - void setType(CCProgressTimerType type); - void setReverseProgress(bool reverse); - void setAnchorPoint(CCPoint anchorPoint); - - void setColor(const Color3B& color); - const Color3B& getColor(void); - GLubyte getOpacity(void); - void setOpacity(GLubyte opacity); - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void); - - static CCProgressTimer* create(CCSprite* sp); - - CCPoint getMidpoint(); - void setMidpoint(CCPoint pt); - CCPoint getBarChangeRate(); - void setBarChangeRate(CCPoint rate); - - bool isReverseDirection(); - void setReverseDirection(bool bReverseDir); -}; diff --git a/tools/tolua++/CCProtocols.pkg b/tools/tolua++/CCProtocols.pkg deleted file mode 100644 index 05d48bb5bc..0000000000 --- a/tools/tolua++/CCProtocols.pkg +++ /dev/null @@ -1,18 +0,0 @@ -class CCRGBAProtocol -{ -public: - virtual void setColor(const Color3B& color); - virtual const Color3B& getColor(void); - virtual const Color3B& getDisplayedColor(void); - virtual GLubyte getDisplayedOpacity(void); - virtual GLubyte getOpacity(void); - virtual void setOpacity(GLubyte opacity); - virtual void setOpacityModifyRGB(bool bValue); - virtual bool isOpacityModifyRGB(void); - virtual bool isCascadeColorEnabled(void); - virtual void setCascadeColorEnabled(bool cascadeColorEnabled); - virtual void updateDisplayedColor(const Color3B& color); - virtual bool isCascadeOpacityEnabled(void); - virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled); - virtual void updateDisplayedOpacity(GLubyte opacity); -}; diff --git a/tools/tolua++/CCRenderTexture.pkg b/tools/tolua++/CCRenderTexture.pkg deleted file mode 100644 index 2e038456ff..0000000000 --- a/tools/tolua++/CCRenderTexture.pkg +++ /dev/null @@ -1,30 +0,0 @@ -enum tCCImageFormat -{ - kCCImageFormatJPEG = 0, - kCCImageFormatPNG = 1, -}; - -class CCRenderTexture : public CCNode -{ - CCSprite* getSprite(); - void setSprite(CCSprite* psprite); - - void begin(); - void endToLua (); - void beginWithClear(float r, float g, float b, float a); - void beginWithClear(float r, float g, float b, float a, float depthValue); - void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); - - void clear(float r, float g, float b, float a); - void clearDepth(float depthValue); - void clearStencil(int stencilValue); - - CCImage* newCCImage(); - - bool saveToFile(const char *szFilePath); - bool saveToFile(const char *name, tCCImageFormat format); - - static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); - static CCRenderTexture * create(int w, int h, CCTexture2DPixelFormat eFormat); - static CCRenderTexture * create(int w, int h); -}; diff --git a/tools/tolua++/CCRibbon.pkg b/tools/tolua++/CCRibbon.pkg deleted file mode 100644 index e97e84598a..0000000000 --- a/tools/tolua++/CCRibbon.pkg +++ /dev/null @@ -1,20 +0,0 @@ - -class CCRibbon: public CCNode -{ - void setTexture(CCTexture2D* val); - CCTexture2D* getTexture(); - - void setTextureLength(float val); - float getTextureLength(); - - void setBlendFunc(BlendFunc val); - BlendFunc getBlendFunc(); - - void setColor(Color4B val); - Color4B getColor(); - - void addPointAt(CCPoint location, float width); - float sideOfLine(CCPoint p, CCPoint l1, CCPoint l2); - - static CCRibbon * create(float w, const char *path, float length, Color4B color, float fade); -}; diff --git a/tools/tolua++/CCScale9Sprite.pkg b/tools/tolua++/CCScale9Sprite.pkg deleted file mode 100644 index 2baeb3218c..0000000000 --- a/tools/tolua++/CCScale9Sprite.pkg +++ /dev/null @@ -1,92 +0,0 @@ - -class CCScale9Sprite : public CCNodeRGBA -{ - - CCScale9Sprite(); - virtual ~CCScale9Sprite(); - - CCSize getOriginalSize(void) const; - - CCSize getPreferredSize(); - void setPreferredSize(CCSize sz); - - CCRect getCapInsets(); - void setCapInsets(CCRect rt); - - float getInsetLeft(); - void setInsetLeft(float fLeft); - - float getInsetTop(); - void setInsetTop(float fTop); - - float getInsetRight(); - void setInsetRight(float fRight); - - float getInsetBottom(); - void setInsetBottom(float fBottom); - - virtual void setContentSize(const CCSize & size); - virtual void visit(); - - virtual bool init(); - - virtual bool initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets); - virtual bool initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); - - virtual bool initWithFile(const char* file, CCRect rect, CCRect capInsets); - - - static CCScale9Sprite* create(const char* file, CCRect rect, CCRect capInsets); - - - virtual bool initWithFile(const char* file, CCRect rect); - - - static CCScale9Sprite* create(const char* file, CCRect rect); - - - virtual bool initWithFile(CCRect capInsets, const char* file); - - - static CCScale9Sprite* create(CCRect capInsets, const char* file); - - virtual bool initWithFile(const char* file); - - static CCScale9Sprite* create(const char* file); - - virtual bool initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); - - static CCScale9Sprite* createWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); - - virtual bool initWithSpriteFrame(CCSpriteFrame* spriteFrame); - - - static CCScale9Sprite* createWithSpriteFrame(CCSpriteFrame* spriteFrame); - - - virtual bool initWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); - - - static CCScale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); - - - virtual bool initWithSpriteFrameName(const char*spriteFrameName); - - - static CCScale9Sprite* createWithSpriteFrameName(const char*spriteFrameName); - - - CCScale9Sprite* resizableSpriteWithCapInsets(CCRect capInsets); - - static CCScale9Sprite* create(); - - virtual void setOpacityModifyRGB(bool bValue); - - virtual bool isOpacityModifyRGB(void); - virtual void setOpacity(GLubyte opacity); - virtual void setColor(const Color3B& color); - - virtual bool updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, bool rotated, CCRect capInsets); - - virtual void setSpriteFrame(CCSpriteFrame * spriteFrame); -}; diff --git a/tools/tolua++/CCScene.pkg b/tools/tolua++/CCScene.pkg deleted file mode 100644 index 350672772d..0000000000 --- a/tools/tolua++/CCScene.pkg +++ /dev/null @@ -1,5 +0,0 @@ - -class CCScene : public CCNode -{ - static CCScene *create(void); -}; diff --git a/tools/tolua++/CCScheduler.pkg b/tools/tolua++/CCScheduler.pkg deleted file mode 100644 index 1bb53bb84f..0000000000 --- a/tools/tolua++/CCScheduler.pkg +++ /dev/null @@ -1,19 +0,0 @@ - -class CCTimer : public CCObject -{ - float getInterval(void); - void setInterval(float fInterval); - void update(float dt); - - static CCTimer* createWithScriptHandler(LUA_FUNCTION funcID, float fSeconds); -}; - -class CCScheduler : public CCObject -{ - float getTimeScale(void); - void setTimeScale(float fTimeScale); - - - unsigned int scheduleScriptFunc(LUA_FUNCTION funcID, float fInterval, bool bPaused); - void unscheduleScriptEntry(unsigned int uScheduleScriptEntryID); -}; diff --git a/tools/tolua++/CCSet.pkg b/tools/tolua++/CCSet.pkg deleted file mode 100644 index 529ca53368..0000000000 --- a/tools/tolua++/CCSet.pkg +++ /dev/null @@ -1,10 +0,0 @@ -class CCSet : public CCObject -{ - CCSet* copy(); - int count(); - void addObject(CCObject *pObject); - void removeObject(CCObject *pObject); - void removeAllObjects(); - bool containsObject(CCObject *pObject); - CCObject* anyObject(); -}; \ No newline at end of file diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg deleted file mode 100644 index f54f72becd..0000000000 --- a/tools/tolua++/CCSprite.pkg +++ /dev/null @@ -1,96 +0,0 @@ -/* -typedef enum { - //! Translate with it's parent - CC_HONOR_PARENT_TRANSFORM_TRANSLATE = 1 << 0, - //! Rotate with it's parent - CC_HONOR_PARENT_TRANSFORM_ROTATE = 1 << 1, - //! Scale with it's parent - CC_HONOR_PARENT_TRANSFORM_SCALE = 1 << 2, - //! Skew with it's parent - CC_HONOR_PARENT_TRANSFORM_SKEW = 1 << 3, - - //! All possible transformation enabled. Default value. - CC_HONOR_PARENT_TRANSFORM_ALL = CC_HONOR_PARENT_TRANSFORM_TRANSLATE | CC_HONOR_PARENT_TRANSFORM_ROTATE | CC_HONOR_PARENT_TRANSFORM_SCALE | CC_HONOR_PARENT_TRANSFORM_SKEW, - -} ccHonorParentTransform; -*/ -class CCSprite : public CCNodeRGBA -{ - void setDirty(bool bDirty); - bool isDirty(void) const; - - V3F_C4B_T2F_Quad getQuad(void); - - CCRect getTextureRect(void); - //bool isUsesBatchNode(void); - bool isTextureRectRotated(void); - - void setAtlasIndex(unsigned int uAtlasIndex); - unsigned int getAtlasIndex(void) const; - //void setUsesSpriteBatchNode(bool bUsesSpriteBatchNode); - void setTextureAtlas(CCTextureAtlas *pobTextureAtlas); - CCTextureAtlas* getTextureAtlas(void); - //void setSpriteBatchNode(CCSpriteBatchNode *pobSpriteBatchNode); - //CCSpriteBatchNode* getSpriteBatchNode(void); - //void setHonorParentTransform(ccHonorParentTransform eHonorParentTransform); - //ccHonorParentTransform getHonorParentTransform(void); - void setBlendFunc(const BlendFunc &blendFunc); - const BlendFunc& getBlendFunc(void); - - const CCPoint& getOffsetPosition(void) const; - - void ignoreAnchorPointForPosition(bool newValue); - void setFlipX(bool bFlipX); - void setFlipY(bool bFlipY); - bool isFlipX(void) const; - bool isFlipY(void) const; - - void removeChild(CCNode* pChild, bool bCleanUp); - void removeAllChildrenWithCleanup(bool bCleanup); - void reorderChild(CCNode* pChild, int zOrder); - void addChild(CCNode* pChild); - void addChild(CCNode* pChild, int zOrder); - void addChild(CCNode* pChild, int zOrder, int tag); - void sortAllChildren(); - //void setPosition(CCPoint pos); - void setRotation(float rotation); - void setSkewX(float sx); - void setSkewY(float sy); - void setScale(float fScale); - void setScaleX(float fScaleX); - void setScaleY(float fScaleY); - void setVertexZ(float fVertexZ); - void setAnchorPoint(const CCPoint & anchor); - void setVisible(bool bVisible); - - void setOpacity(GLubyte opacity); - - void setColor(Color3B color3); - Color3B getColor(void); - void setOpacityModifyRGB(bool bValue); - bool isOpacityModifyRGB(void) const; - - void setTexture(CCTexture2D *texture); - CCTexture2D* getTexture(void); - - void updateTransform(void); - //void useSelfRender(void); - void setTextureRect(CCRect rect); - void setTextureRect(CCRect rect, bool rotated, CCSize size); - void setVertexRect(CCRect rect); - //void useBatchNode(CCSpriteBatchNode *batchNode); - void setDisplayFrame(CCSpriteFrame *pNewFrame); - bool isFrameDisplayed(CCSpriteFrame *pFrame) const; - CCSpriteFrame* displayFrame(void); - void setBatchNode(CCSpriteBatchNode* pBatchNode); - CCSpriteBatchNode* getBatchNode(); - void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex); - - static CCSprite* createWithTexture(CCTexture2D *pTexture); - static CCSprite* createWithTexture(CCTexture2D *pTexture, CCRect rect); - static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); - static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); - static CCSprite* create(const char *pszFileName, CCRect rect); - static CCSprite* create(const char *pszFileName); - static CCSprite* create(); -}; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg deleted file mode 100644 index ecfb47e511..0000000000 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ /dev/null @@ -1,38 +0,0 @@ - -class CCSpriteBatchNode : public CCNode -{ - CCTextureAtlas* getTextureAtlas(void); - void setTextureAtlas(CCTextureAtlas* textureAtlas); - CCArray* getDescendants(void); - - void increaseAtlasCapacity(); - void removeChildAtIndex(unsigned int index, bool doCleanup); - void insertChild(CCSprite *child, unsigned int index); - void appendChild(CCSprite *child); - void removeSpriteFromAtlas(CCSprite *sprite); - - unsigned int rebuildIndexInOrder(CCSprite *parent, unsigned int index); - unsigned int highestAtlasIndexInChild(CCSprite *sprite); - unsigned int lowestAtlasIndexInChild(CCSprite *sprite); - unsigned int atlasIndexForChild(CCSprite *sprite, int z); - - void reorderBatch(bool reorder); - void setTexture(CCTexture2D *texture); - CCTexture2D* getTexture(void); - void setBlendFunc(const BlendFunc &blendFunc); - const BlendFunc& getBlendFunc(void); - - void addChild(CCNode * child); - void addChild(CCNode * child, int zOrder); - void addChild(CCNode * child, int zOrder, int tag); - void reorderChild(CCNode * child, int zOrder); - - void removeChild(CCNode* child, bool cleanup); - void removeAllChildrenWithCleanup(bool cleanup); - void sortAllChildren(); - - static CCSpriteBatchNode* createWithTexture(CCTexture2D *tex); - static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity); - static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity); - static CCSpriteBatchNode* create(const char* fileImage); -}; diff --git a/tools/tolua++/CCSpriteFrame.pkg b/tools/tolua++/CCSpriteFrame.pkg deleted file mode 100644 index d57db04172..0000000000 --- a/tools/tolua++/CCSpriteFrame.pkg +++ /dev/null @@ -1,32 +0,0 @@ - -class CCSpriteFrame : public CCObject -{ - CCRect getRectInPixels(void); - void setRectInPixels(CCRect rectInPixels); - - bool isRotated(void); - void setRotated(bool bRotated); - - CCRect getRect(void) const; - void setRect(CCRect rect); - - CCPoint getOffsetInPixels(void); - void setOffsetInPixels(CCPoint offsetInPixels); - - CCSize getOriginalSizeInPixels(void); - void setOriginalSizeInPixels(CCSize sizeInPixels); - - const CCSize & getOriginalSize(); - void setOriginalSize(const CCSize & size); - - CCTexture2D* getTexture(void); - void setTexture(CCTexture2D* pobTexture); - - const CCPoint & getOffset(); - void setOffset(const CCPoint & offsets); - - static CCSpriteFrame* create(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); - static CCSpriteFrame* create(const char* filename, CCRect rect); - static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); - static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture, CCRect rect); -}; diff --git a/tools/tolua++/CCSpriteFrameCache.pkg b/tools/tolua++/CCSpriteFrameCache.pkg deleted file mode 100644 index 207042b654..0000000000 --- a/tools/tolua++/CCSpriteFrameCache.pkg +++ /dev/null @@ -1,21 +0,0 @@ - -class CCSpriteFrameCache : public CCObject -{ - //void addSpriteFramesWithDictionary(CCDictionary *pobDictionary, CCTexture2D *pobTexture); - void addSpriteFramesWithFile(const char *pszPlist); - void addSpriteFramesWithFile(const char* plist, const char* textureFileName); - void addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture); - void addSpriteFrame(CCSpriteFrame *pobFrame, const char *pszFrameName); - - void removeSpriteFrames(void); - void removeUnusedSpriteFrames(void); - void removeSpriteFrameByName(const char *pszName); - void removeSpriteFramesFromFile(const char* plist); - //void removeSpriteFramesFromDictionary(CCDictionary *dictionary); - void removeSpriteFramesFromTexture(CCTexture2D* texture); - - CCSpriteFrame* getSpriteFrameByName(const char *pszName); - - static CCSpriteFrameCache* getInstance(); - static void destroyInstance(); -}; diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg deleted file mode 100644 index 1950324a13..0000000000 --- a/tools/tolua++/CCString.pkg +++ /dev/null @@ -1,19 +0,0 @@ - -class CCString : public CCObject -{ - int intValue() const; - unsigned int uintValue() const; - float floatValue() const; - double doubleValue() const; - bool boolValue() const; - const char* getCString() const; - unsigned int length() const; - - int compare(const char* str) const; - bool isEqual(const CCObject* pObject); - - static CCString* create(const char* pStr); - static CCString* createWithData(unsigned char* pData, unsigned long nLen); - static CCString* createWithContentsOfFile(const char* pszFileName); -}; - diff --git a/tools/tolua++/CCTMXLayer.pkg b/tools/tolua++/CCTMXLayer.pkg deleted file mode 100644 index b968c515fc..0000000000 --- a/tools/tolua++/CCTMXLayer.pkg +++ /dev/null @@ -1,37 +0,0 @@ - -class CCTMXLayer : public CCSpriteBatchNode -{ - void setLayerSize(CCSize val); - CCSize getLayerSize(); - - void setMapTileSize(CCSize val); - CCSize getMapTileSize(); - - void setTiles(unsigned int* pval); - unsigned int* getTiles(); - - void setTileSet(CCTMXTilesetInfo* pval); - CCTMXTilesetInfo* getTileSet(); - - void setLayerOrientation(unsigned int val); - unsigned int getLayerOrientation(); - - void setProperties(CCDictionary* pval); - CCDictionary* getProperties(); - - void releaseMap(); - - CCSprite* getTileAt(const CCPoint& tileCoordinate); - unsigned int getTileGIDAt(const CCPoint& tileCoordinate); - void setTileGID(unsigned int gid, const CCPoint& tileCoordinate); - void setTileGID(unsigned int gid, const CCPoint& tileCoordinate, ccTMXTileFlags flags); - void removeTileAt(CCPoint tileCoordinate); - CCPoint getPositionAt(CCPoint tileCoordinate); - CCString* getProperty(const char *propertyName) const; - void setupTiles(); - - void setLayerName(const char *layerName); - const char* getLayerName(); - - static CCTMXLayer * create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); -}; diff --git a/tools/tolua++/CCTMXObjectGroup.pkg b/tools/tolua++/CCTMXObjectGroup.pkg deleted file mode 100644 index f38bfd3c66..0000000000 --- a/tools/tolua++/CCTMXObjectGroup.pkg +++ /dev/null @@ -1,19 +0,0 @@ - -class CCTMXObjectGroup : public CCObject -{ - void setPositionOffset(CCPoint pt); - CCPoint getPositionOffset(); - - void setProperties(CCDictionary* pval); - CCDictionary* getProperties(); - - void setObjects(CCArray* val); - CCArray* getObjects(); - - void setGroupName(const char *groupName); - const char* getGroupName(); - - CCString* getProperty(const char* propertyName); - - CCDictionary* getObject(const char *objectName); -}; diff --git a/tools/tolua++/CCTMXTiledMap.pkg b/tools/tolua++/CCTMXTiledMap.pkg deleted file mode 100644 index 937d99ba4c..0000000000 --- a/tools/tolua++/CCTMXTiledMap.pkg +++ /dev/null @@ -1,36 +0,0 @@ - -enum -{ - /** Orthogonal orientation */ - CCTMXOrientationOrtho, - /** Hexagonal orientation */ - CCTMXOrientationHex, - /** Isometric orientation */ - CCTMXOrientationIso, -}; - -class CCTMXTiledMap : public CCNode -{ - void setMapSize(CCSize sz); - CCSize getMapSize(); - - void setTileSize(CCSize sz); - CCSize getTileSize(); - - void setMapOrientation(int val); - int getMapOrientation(); - - void setObjectGroups(CCArray* pval); - CCArray* getObjectGroups(); - - void setProperties(CCDictionary* pval); - CCDictionary* getProperties(); - - CCTMXLayer* getLayer(const char *layerName); - CCTMXObjectGroup* getObjectGroup(const char *groupName); - CCString* getProperty(const char *propertyName); - CCDictionary* getPropertiesForGID(int GID); - - static CCTMXTiledMap * create(const char *tmxFile); - static CCTMXTiledMap* createWithXML(const char* tmxString, const char* resourcePath); -}; diff --git a/tools/tolua++/CCTMXXMLParser.pkg b/tools/tolua++/CCTMXXMLParser.pkg deleted file mode 100644 index 4ddbf5b1ca..0000000000 --- a/tools/tolua++/CCTMXXMLParser.pkg +++ /dev/null @@ -1,76 +0,0 @@ - -enum { - TMXLayerAttribNone = 1 << 0, - TMXLayerAttribBase64 = 1 << 1, - TMXLayerAttribGzip = 1 << 2, - TMXLayerAttribZlib = 1 << 3, -}; - -enum { - TMXPropertyNone, - TMXPropertyMap, - TMXPropertyLayer, - TMXPropertyObjectGroup, - TMXPropertyObject, - TMXPropertyTile -}; - -typedef enum ccTMXTileFlags_ { - kCCTMXTileHorizontalFlag = 0x80000000, - kCCTMXTileVerticalFlag = 0x40000000, - kCCTMXTileDiagonalFlag = 0x20000000, - kCCFlipedAll = (kCCTMXTileHorizontalFlag|kCCTMXTileVerticalFlag|kCCTMXTileDiagonalFlag), - kCCFlippedMask = ~(kCCFlipedAll) -} ccTMXTileFlags; - -class CCTMXLayerInfo : public CCObject -{ - CCDictionary* getProperties(); - void setProperties(CCDictionary* pval); -}; - -class CCTMXTilesetInfo : public CCObject -{ - CCRect rectForGID(unsigned int gid); -}; - -class CCTMXMapInfo : public CCObject -{ - void setOrientation(int val); - int getOrientation(); - void setMapSize(CCSize sz); - CCSize getMapSize(); - void setTileSize(CCSize sz); - CCSize getTileSize(); - void setLayers(CCArray* pval); - CCArray* getLayers(); - void setTilesets(CCArray* pval); - CCArray* getTilesets(); - void setObjectGroups(CCArray* val); - CCArray* getObjectGroups(); - void setParentElement(int val); - int getParentElement(); - void setParentGID(unsigned int val); - unsigned int getParentGID(); - void setLayerAttribs(int val); - int getLayerAttribs(); - void setStoringCharacters(bool val); - bool isStoringCharacters() const; - void setProperties(CCDictionary* pval); - CCDictionary* getProperties(); - void setTileProperties(CCDictionary* tileProperties); - CCDictionary* getTileProperties(); - void setCurrentString(const char *currentString); - const char* getCurrentString(); - void setTMXFileName(const char *fileName); - const char* getTMXFileName(); - - void startElement(void *ctx, const char *name, const char **atts); - void endElement(void *ctx, const char *name); - void textHandler(void *ctx, const char *ch, int len); - bool parseXMLFile(const char *xmlFilename); - bool parseXMLString(const char *xmlString); - - static CCTMXMapInfo* create(const char *tmxFile); - static CCTMXMapInfo* createWithXML(const char* tmxString, const char* resourcePath); -}; diff --git a/tools/tolua++/CCTextFieldTTF.pkg b/tools/tolua++/CCTextFieldTTF.pkg deleted file mode 100644 index 8087596648..0000000000 --- a/tools/tolua++/CCTextFieldTTF.pkg +++ /dev/null @@ -1,18 +0,0 @@ - -class CCTextFieldTTF : public CCLabelTTF -{ - bool attachWithIME(); - bool detachWithIME(); - - int getCharCount(); - void setColorSpaceHolder(Color3B val); - Color3B getColorSpaceHolder(); - void setString(const char *text); - const char* getString(void) const; - - void setPlaceHolder(const char * text); - const char * getPlaceHolder(void); - - static CCTextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, CCSize dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); - static CCTextFieldTTF * textFieldWithPlaceHolder(const char *placeholder, const char *fontName, float fontSize); -}; diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg deleted file mode 100644 index e7ea419776..0000000000 --- a/tools/tolua++/CCTexture2D.pkg +++ /dev/null @@ -1,505 +0,0 @@ -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction (not supported in ES20) */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -// #define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -// #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -// #define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -// #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -// #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -// #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -// #define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -// #define GL_SHADER_BINARY_FORMATS 0x8DF8 -// #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -// #define GL_LOW_FLOAT 0x8DF0 -// #define GL_MEDIUM_FLOAT 0x8DF1 -// #define GL_HIGH_FLOAT 0x8DF2 -// #define GL_LOW_INT 0x8DF3 -// #define GL_MEDIUM_INT 0x8DF4 -// #define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -//comment nextline since it wasn't defined in glew.h of windows -// #define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -//comment nextline since it wasn't defined in gl.h of IOS7 sdk -//#define GL_STENCIL_INDEX 0x1901 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -//#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - - -typedef enum { -// kCCTexture2DPixelFormat_Automatic = 0, - //! 32-bit texture: RGBA8888 - kCCTexture2DPixelFormat_RGBA8888, - //! 24-bit texture: RGBA888 - kCCTexture2DPixelFormat_RGB888, - //! 16-bit texture without Alpha channel - kCCTexture2DPixelFormat_RGB565, - //! 8-bit textures used as masks - kCCTexture2DPixelFormat_A8, - //! 8-bit intensity texture - kCCTexture2DPixelFormat_I8, - //! 16-bit textures used as masks - kCCTexture2DPixelFormat_AI88, - //! 16-bit textures: RGBA4444 - kCCTexture2DPixelFormat_RGBA4444, - //! 16-bit textures: RGB5A1 - kCCTexture2DPixelFormat_RGB5A1, - //! 4-bit PVRTC-compressed texture: PVRTC4 - kCCTexture2DPixelFormat_PVRTC4, - //! 2-bit PVRTC-compressed texture: PVRTC2 - kCCTexture2DPixelFormat_PVRTC2, - - //! Default texture format: RGBA8888 - kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888, -} CCTexture2DPixelFormat; - - -class CCTexture2D : public CCObject -{ - -class TexParams { - TexParams(void); - GLuint minFilter; - GLuint magFilter; - GLuint wrapS; - GLuint wrapT; -}; - void releaseData(void* data); - void* keepData(void* data, unsigned int length); - - CCTexture2DPixelFormat getPixelFormat(); - - unsigned int getPixelsWide(); - unsigned int getPixelsHigh(); - - GLuint getName(); - - CCSize getContentSizeInPixels(); - - void setMaxS(GLfloat val); - GLfloat getMaxS(); - - GLfloat getMaxT(); - void setMaxT(GLfloat val); - - bool hasPremultipliedAlpha() const; - bool hasMipmaps() const; - - void drawAtPoint(CCPoint point); - void drawInRect(CCRect rect); - - CCSize getContentSize(void); - - void setTexParameters(const TexParams& texParams); - void setAntiAliasTexParameters(); - void setAliasTexParameters(); - void generateMipmap(); - - const char* getStringForFormat() const; - unsigned int getBitsPerPixelForFormat() const; - unsigned int getBitsPerPixelForFormat(CCTexture2DPixelFormat format) const; - - static void setDefaultAlphaPixelFormat(CCTexture2DPixelFormat format); - static CCTexture2DPixelFormat getDefaultAlphaPixelFormat(); -}; diff --git a/tools/tolua++/CCTextureAtlas.pkg b/tools/tolua++/CCTextureAtlas.pkg deleted file mode 100644 index 4d550ab5c0..0000000000 --- a/tools/tolua++/CCTextureAtlas.pkg +++ /dev/null @@ -1,30 +0,0 @@ - -class CCTextureAtlas : public CCObject -{ - unsigned int getTotalQuads(); - unsigned int getCapacity(); - - void setTexture(CCTexture2D* val); - CCTexture2D* getTexture(); - - void setQuads(V3F_C4B_T2F_Quad* val); - V3F_C4B_T2F_Quad* getQuads(); - - void updateQuad(V3F_C4B_T2F_Quad* quad, unsigned int index); - void insertQuad(V3F_C4B_T2F_Quad* quad, unsigned int index); - void insertQuadFromIndex(unsigned int fromIndex, unsigned int newIndex); - void removeQuadAtIndex(unsigned int index); - void removeAllQuads(); - bool resizeCapacity(unsigned int n); - void drawNumberOfQuads(unsigned int n); - void drawNumberOfQuads(unsigned int n, unsigned int start); - - void increaseTotalQuadsWith(unsigned int amount); - void moveQuadsFromIndex(unsigned int oldIndex, unsigned int amount, unsigned int newIndex); - void moveQuadsFromIndex(unsigned int index, unsigned int newIndex); - void fillWithEmptyQuadsFromIndex(unsigned int index, unsigned int amount); - void drawQuads(); - - static CCTextureAtlas* create(const char* file , unsigned int capacity); - static CCTextureAtlas* createWithTexture(CCTexture2D *texture, unsigned int capacity); -}; diff --git a/tools/tolua++/CCTextureCache.pkg b/tools/tolua++/CCTextureCache.pkg deleted file mode 100644 index b0dfa15d3d..0000000000 --- a/tools/tolua++/CCTextureCache.pkg +++ /dev/null @@ -1,18 +0,0 @@ - -class CCTextureCache : public CCObject -{ - CCTexture2D* addImage(const char* fileimage); - CCTexture2D* addUIImage(CCImage *image, const char *key); - CCTexture2D* textureForKey(const char* key); - - void removeAllTextures(); - void removeUnusedTextures(); - void removeTexture(CCTexture2D* texture); - void removeTextureForKey(const char *textureKeyName); - void dumpCachedTextureInfo(); - - static void reloadAllTextures(); - - static CCTextureCache * getInstance(); - static void destroyInstance(); -}; diff --git a/tools/tolua++/CCTileMapAtlas.pkg b/tools/tolua++/CCTileMapAtlas.pkg deleted file mode 100644 index 2e913f2aa4..0000000000 --- a/tools/tolua++/CCTileMapAtlas.pkg +++ /dev/null @@ -1,16 +0,0 @@ - - -// struct sImageTGA; - -class CCTileMapAtlas : public CCAtlasNode -{ - // struct sImageTGA* getTGAInfo(); - // void setTGAInfo(struct sImageTGA* val); - - void setTile(Color3B tile, CCPoint position); - void releaseMap(); - - Color3B getTileAt(const CCPoint & pos) const; - - static CCTileMapAtlas * create(const char *tile, const char *mapFile, int tileWidth, int tileHeight); -}; diff --git a/tools/tolua++/CCTouch.pkg b/tools/tolua++/CCTouch.pkg deleted file mode 100644 index a12fa53ea3..0000000000 --- a/tools/tolua++/CCTouch.pkg +++ /dev/null @@ -1,16 +0,0 @@ - -class CCTouch : public CCObject -{ - CCPoint getLocation() const; - CCPoint getPreviousLocation() const; - CCPoint getDelta() const; - CCPoint getLocationInView() const; - CCPoint getPreviousLocationInView() const; - - void setTouchInfo(int id, float x, float y); - int getID(); -}; - -class CCEvent : public CCObject -{ -}; diff --git a/tools/tolua++/CCTouchDispatcher.pkg b/tools/tolua++/CCTouchDispatcher.pkg deleted file mode 100644 index 8ef8227d07..0000000000 --- a/tools/tolua++/CCTouchDispatcher.pkg +++ /dev/null @@ -1,6 +0,0 @@ - -class CCTouchDispatcher : public CCObject -{ - bool isDispatchEvents(void); - void setDispatchEvents(bool bDispatchEvents); -}; diff --git a/tools/tolua++/CCTransition.pkg b/tools/tolua++/CCTransition.pkg deleted file mode 100644 index dcfb56e39e..0000000000 --- a/tools/tolua++/CCTransition.pkg +++ /dev/null @@ -1,168 +0,0 @@ - -typedef enum { - /// An horizontal orientation where the Left is nearer - kCCTransitionOrientationLeftOver = 0, - /// An horizontal orientation where the Right is nearer - kCCTransitionOrientationRightOver = 1, - /// A vertical orientation where the Up is nearer - kCCTransitionOrientationUpOver = 0, - /// A vertical orientation where the Bottom is nearer - kCCTransitionOrientationDownOver = 1, -} tOrientation; - -class CCTransitionScene : public CCScene -{ - static CCTransitionScene* create(float t, CCScene* scene); -}; - -class CCTransitionSceneOriented : public CCScene -{ - static CCTransitionSceneOriented* create(float t, CCScene* scene, tOrientation o); -}; - -class CCTransitionRotoZoom : public CCScene -{ - static CCTransitionRotoZoom* create(float t, CCScene* scene); -}; - -class CCTransitionJumpZoom : public CCScene -{ - static CCTransitionJumpZoom* create(float t, CCScene* scene); -}; - -class CCTransitionMoveInL : public CCScene -{ - static CCTransitionMoveInL* create(float t, CCScene* scene); -}; - -class CCTransitionMoveInR : public CCScene -{ - static CCTransitionMoveInR* create(float t, CCScene* scene); -}; - -class CCTransitionMoveInT : public CCScene -{ - static CCTransitionMoveInT* create(float t, CCScene* scene); -}; - -class CCTransitionMoveInB : public CCScene -{ - static CCTransitionMoveInB* create(float t, CCScene* scene); -}; - -class CCTransitionSlideInL : public CCScene -{ - static CCTransitionSlideInL* create(float t, CCScene* scene); -}; - -class CCTransitionSlideInR : public CCScene -{ - static CCTransitionSlideInR* create(float t, CCScene* scene); -}; - -class CCTransitionSlideInB : public CCScene -{ - static CCTransitionSlideInB* create(float t, CCScene* scene); -}; - -class CCTransitionSlideInT : public CCScene -{ - static CCTransitionSlideInT* create(float t, CCScene* scene); -}; - -class CCTransitionShrinkGrow : public CCScene -{ - static CCTransitionShrinkGrow* create(float t, CCScene* scene); -}; - -class CCTransitionFlipX : public CCScene -{ - static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationRightOver); -}; - -class CCTransitionFlipY : public CCScene -{ - static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationUpOver); -}; - -class CCTransitionFlipAngular : public CCScene -{ - static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationRightOver); -}; - -class CCTransitionZoomFlipX : public CCScene -{ - static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationRightOver); -}; - -class CCTransitionZoomFlipY : public CCScene -{ - static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationUpOver); -}; - -class CCTransitionZoomFlipAngular : public CCScene -{ - static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kCCTransitionOrientationRightOver); -}; - -class CCTransitionFade : public CCScene -{ - static CCTransitionFade* create(float duration,CCScene* scene, Color3B color = ccBLACK); -}; - -class CCTransitionCrossFade : public CCScene -{ - static CCTransitionCrossFade* create(float t, CCScene* scene); -}; - -class CCTransitionTurnOffTiles : public CCScene -{ - static CCTransitionTurnOffTiles* create(float t, CCScene* scene); -}; - -class CCTransitionSplitCols : public CCScene -{ - static CCTransitionSplitCols* create(float t, CCScene* scene); -}; - -class CCTransitionSplitRows : public CCScene -{ - static CCTransitionSplitRows* create(float t, CCScene* scene); -}; - -class CCTransitionFadeTR : public CCScene -{ - static CCTransitionFadeTR* create(float t, CCScene* scene); -}; - -class CCTransitionFadeBL : public CCScene -{ - static CCTransitionFadeBL* create(float t, CCScene* scene); -}; - -class CCTransitionFadeUp : public CCScene -{ - static CCTransitionFadeUp* create(float t, CCScene* scene); -}; - -class CCTransitionFadeDown : public CCScene -{ - static CCTransitionFadeDown* create(float t, CCScene* scene); -}; - -class CCTransitionProgressRadialCCW : public CCScene -{ - static CCTransitionProgressRadialCCW* create(float t, CCScene* scene); -}; - -class CCTransitionProgressRadialCW : public CCScene -{ - static CCTransitionProgressRadialCW* create(float t, CCScene* scene); -}; - -class CCTransitionPageTurn : public CCScene -{ - CCActionInterval* actionWithSize(CCSize vector); - - static CCTransitionPageTurn* create(float t,CCScene* scene,bool backwards); -}; diff --git a/tools/tolua++/CCTransitionProgress.pkg b/tools/tolua++/CCTransitionProgress.pkg deleted file mode 100644 index d7a4f5cc89..0000000000 --- a/tools/tolua++/CCTransitionProgress.pkg +++ /dev/null @@ -1,35 +0,0 @@ -class CCTransitionProgress : public CCTransitionScene -{ - static CCTransitionProgress* create(float t, CCScene* scene); -}; - -class CCTransitionProgressRadialCCW : public CCTransitionProgress -{ - static CCTransitionProgressRadialCCW* create(float t, CCScene* scene); -}; - -class CCTransitionProgressRadialCW : public CCTransitionProgress -{ - static CCTransitionProgressRadialCW* create(float t, CCScene* scene); -}; - -class CCTransitionProgressHorizontal : public CCTransitionProgress -{ - static CCTransitionProgressHorizontal* create(float t, CCScene* scene); -}; - -class CCTransitionProgressVertical : public CCTransitionProgress -{ - static CCTransitionProgressVertical* create(float t, CCScene* scene); -}; - -class CCTransitionProgressInOut : public CCTransitionProgress -{ - static CCTransitionProgressInOut* create(float t, CCScene* scene); -}; - -class CCTransitionProgressOutIn : public CCTransitionProgress -{ - static CCTransitionProgressOutIn* create(float t, CCScene* scene); -}; - diff --git a/tools/tolua++/CCUserDefault.pkg b/tools/tolua++/CCUserDefault.pkg deleted file mode 100644 index 57d9cdb9be..0000000000 --- a/tools/tolua++/CCUserDefault.pkg +++ /dev/null @@ -1,24 +0,0 @@ - -class CCUserDefault -{ - // get value methods - bool getBoolForKey(const char* pKey); - int getIntegerForKey(const char* pKey); - float getFloatForKey(const char* pKey); - double getDoubleForKey(const char* pKey); - std::string getStringForKey(const char* pKey); - - // set value methods - void setBoolForKey(const char* pKey, bool value); - void setIntegerForKey(const char* pKey, int value); - void setFloatForKey(const char* pKey, float value); - void setDoubleForKey(const char* pKey, double value); - void setStringForKey(const char* pKey, std::string value); - - void flush(); - - static CCUserDefault* getInstance(); - static void destroyInstance(); - - const static std::string& getXMLFilePath(); -}; diff --git a/tools/tolua++/Cocos2d.pkg b/tools/tolua++/Cocos2d.pkg deleted file mode 100644 index d0ff69ca65..0000000000 --- a/tools/tolua++/Cocos2d.pkg +++ /dev/null @@ -1,88 +0,0 @@ -$#include "LuaCocos2d.h" - -$pfile "matrix.pkg" -$pfile "ccTypes.pkg" -$pfile "CCObject.pkg" -$pfile "CCCommon.pkg" -$pfile "CCGeometry.pkg" -$pfile "CCArray.pkg" -$pfile "CCDictionary.pkg" -$pfile "CCString.pkg" -$pfile "CCPointExtension.pkg" -$pfile "CCEGLViewProtocol.pkg" - -$pfile "CCProtocols.pkg" -$pfile "CCFileUtils.pkg" -$pfile "CCAffineTransform.pkg" -$pfile "CCApplication.pkg" -$pfile "CCTouchDispatcher.pkg" -$pfile "CCDirector.pkg" -$pfile "CCUserDefault.pkg" -$pfile "CCNotificationCenter.pkg" -$pfile "CCKeypadDispatcher.pkg" - -$pfile "CCImage.pkg" -$pfile "CCNode.pkg" -$pfile "CCTexture2D.pkg" -$pfile "CCTextureAtlas.pkg" -$pfile "CCTextureCache.pkg" -$pfile "CCRenderTexture.pkg" -$pfile "CCSprite.pkg" -$pfile "CCSpriteBatchNode.pkg" -$pfile "CCSpriteFrame.pkg" -$pfile "CCSpriteFrameCache.pkg" -$pfile "CCLayer.pkg" -$pfile "CCScene.pkg" -$pfile "CCTransition.pkg" -$pfile "CCTransitionProgress.pkg" - -$pfile "CCScheduler.pkg" - -$pfile "CCAction.pkg" -$pfile "CCActionCamera.pkg" -$pfile "CCActionCatmullRom.pkg" -$pfile "CCActionEase.pkg" -$pfile "CCActionGrid.pkg" -$pfile "CCActionGrid3D.pkg" -$pfile "CCActionPageTurn3D.pkg" -$pfile "CCActionProgressTimer.pkg" -$pfile "CCActionTiledGrid.pkg" -$pfile "CCActionManager.pkg" -$pfile "CCMotionStreak.pkg" - -$pfile "CCAnimation.pkg" -$pfile "CCAnimationCache.pkg" -$pfile "CCAtlasNode.pkg" -$pfile "CCCamera.pkg" -$pfile "CCLabelAtlas.pkg" -$pfile "CCLabelBMFont.pkg" -$pfile "CCLabelTTF.pkg" -$pfile "CCMenu.pkg" -$pfile "CCMenuItem.pkg" -$pfile "CCParallaxNode.pkg" -$pfile "CCParticleSystem.pkg" -$pfile "CCParticleExamples.pkg" -$pfile "CCParticleBatchNode.pkg" -$pfile "CCProgressTimer.pkg" -$pfile "CCTextFieldTTF.pkg" -$pfile "CCTileMapAtlas.pkg" -$pfile "CCTMXLayer.pkg" -$pfile "CCTMXObjectGroup.pkg" -$pfile "CCTMXTiledMap.pkg" -$pfile "CCTMXXMLParser.pkg" -$pfile "CCTouch.pkg" - -$pfile "CCSet.pkg" - -$pfile "SimpleAudioEngine.pkg" -$pfile "CCScale9Sprite.pkg" -$pfile "CCControl.pkg" -$pfile "CCControlButton.pkg" -$pfile "CCControlSlider.pkg" -$pfile "CCControlColourPicker.pkg" -$pfile "CCControlSwitch.pkg" -$pfile "CCControlPotentiometer.pkg" -$pfile "CCControlStepper.pkg" -$pfile "CCEditBox.pkg" -$pfile "CCInteger.pkg" -$pfile "CCDrawNode.pkg" diff --git a/tools/tolua++/Makefile b/tools/tolua++/Makefile deleted file mode 100644 index 55bfb2a403..0000000000 --- a/tools/tolua++/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -../../scripting/lua/cocos2dx_support/LuaCocos2d.cpp: basic.lua *.pkg - ./build.sh diff --git a/tools/tolua++/README b/tools/tolua++/README deleted file mode 100644 index 9c718ec267..0000000000 --- a/tools/tolua++/README +++ /dev/null @@ -1,23 +0,0 @@ -1. Generating the lua<-->C bindings with tolua++ - - Build scripts for windows (build.bat) and unix (build.sh) are provided - to generate the relevant files after modifying the .pkg files. These - scripts basically run the following command: - - tolua++.exe -L basic.lua -o LuaCocos2d.cpp Cocos2d.pkg - - This will generate the bindings file and patch it with come cocos2dx - specific modifications. - - On POSIX systems you can also just run "make" to build the bindings - if/when you change .pkg files. - -2. Writing .pkg files - - 1) enum keeps the same - 2) remove CC_DLL for the class defines, pay attention to multi inherites - 3) remove inline keyword for declaration and implementation - 4) remove public protect and private - 5) remove the decalration of class member variable - 6) keep static keyword - 7) remove memeber functions that declared as private or protected diff --git a/tools/tolua++/SimpleAudioEngine.pkg b/tools/tolua++/SimpleAudioEngine.pkg deleted file mode 100644 index b49e83ab5c..0000000000 --- a/tools/tolua++/SimpleAudioEngine.pkg +++ /dev/null @@ -1,25 +0,0 @@ -class SimpleAudioEngine -{ - static SimpleAudioEngine* getInstance(); - void preloadBackgroundMusic(const char* pszFilePath); - void playBackgroundMusic(const char* pszFilePath, bool bLoop = false); - void stopBackgroundMusic(bool bReleaseData = false); - void pauseBackgroundMusic(); - void resumeBackgroundMusic(); - void rewindBackgroundMusic(); - bool willPlayBackgroundMusic(); - bool isBackgroundMusicPlaying(); - float getBackgroundMusicVolume(); - void setBackgroundMusicVolume(float volume); - float getEffectsVolume(); - void setEffectsVolume(float volume); - unsigned int playEffect(const char* pszFilePath, bool bLoop = false); - void stopEffect(unsigned int nSoundId); - void preloadEffect(const char* pszFilePath); - void unloadEffect(const char* pszFilePath); - void pauseEffect(unsigned int nSoundId); - void resumeEffect(unsigned int nSoundId); - void pauseAllEffects(); - void resumeAllEffects(); - void stopAllEffects(); -}; diff --git a/tools/tolua++/basic.lua b/tools/tolua++/basic.lua deleted file mode 100644 index 110591b59c..0000000000 --- a/tools/tolua++/basic.lua +++ /dev/null @@ -1,359 +0,0 @@ --- usage: (use instead of ant) --- tolua++ "-L" "basic.lua" "-o" "../../scripting/lua/cocos2dx_support/LuaCocos2d.cpp" "Cocos2d.pkg" - -_is_functions = _is_functions or {} -_to_functions = _to_functions or {} -_push_functions = _push_functions or {} - -local CCObjectTypes = { - "CCObject", - "CCAction", - "CCImage", - "CCFiniteTimeAction", - "CCActionInstant", - "CCFlipX", - "CCFlipY", - "CCHide", - "CCPlace", - "CCReuseGrid", - "CCShow", - "CCStopGrid", - "CCToggleVisibility", - "CCActionInterval", - "CCAccelAmplitude", - "CCAccelDeccelAmplitude", - "CCActionCamera", - "CCOrbitCamera", - "CCCardinalSplineTo", - "CCCardinalSplineBy", - "CCCatmullRomTo", - "CCCatmullRomBy", - "CCActionEase", - "CCEaseBackIn", - "CCEaseBackInOut", - "CCEaseBackOut", - "CCEaseBounce", - "CCEaseElastic", - "CCEaseExponentialIn", - "CCEaseExponentialInOut", - "CCEaseExponentialOut", - "CCEaseRateAction", - "CCEaseSineIn", - "CCEaseSineInOut", - "CCEaseSineOut", - "CCAnimate", - "CCBezierBy", - "CCBezierTo", - "CCBlink", - "CCDeccelAmplitude", - "CCDelayTime", - "CCFadeIn", - "CCFadeOut", - "CCFadeTo", - "CCGridAction", - "CCJumpBy", - "CCJumpTo", - "CCMoveTo", - "CCMoveBy", - "CCProgressFromTo", - "CCProgressTo", - "CCRepeat", - "CCRepeatForever", - "CCReverseTime", - "CCRotateBy", - "CCRotateTo", - "CCScaleTo", - "CCScaleBy", - "CCSequence", - "CCSkewTo", - "CCSkewBy", - "CCSpawn", - "CCTintBy", - "CCTintTo", - "CCActionManager", - "CCAnimation", - "CCAnimationCache", - "CCArray", - "CCAsyncObject", - "CCAutoreleasePool", - "CCBMFontConfiguration", - "CCCamera", - "CCConfiguration", - "CCData", - "CCDirector", - "CCDisplayLinkDirector", - "CCEvent", - "CCGrabber", - "CCGrid3D", - "CCTiledGrid3D", - "CCKeypadDispatcher", - "CCKeypadHandler", - "CCDictionary", - "CCNode", - "CCAtlasNode", - "CCLabelAtlas", - "CCTileMapAtlas", - "CCLayer", - "CCLayerColor", - "CCLayerGradient", - "CCLayerMultiplex", - "CCMenu", - "CCMenuItem", - "CCMenuItemLabel", - "CCMenuItemAtlasFont", - "CCMenuItemFont", - "CCMenuItemSprite", - "CCMenuItemImage", - "CCMenuItemToggle", - "CCMotionStreak", - "CCParallaxNode", - "CCParticleSystem", - "CCParticleBatchNode", - "CCParticleSystemQuad", - "CCProgressTimer", - "CCRenderTexture", - "CCRibbon", - "CCScene", - "CCTransitionScene", - "CCTransitionCrossFade", - "CCTransitionFade", - "CCTransitionFadeTR", - "CCTransitionFadeBL", - "CCTransitionFadeDown", - "CCTransitionFadeUp", - "CCTransitionJumpZoom", - "CCTransitionMoveInL", - "CCTransitionMoveInB", - "CCTransitionMoveInR", - "CCTransitionMoveInT", - "CCTransitionPageTurn", - "CCTransitionRotoZoom", - "CCTransitionSceneOriented", - "CCTransitionFlipAngular", - "CCTransitionFlipX", - "CCTransitionFlipY", - "CCTransitionZoomFlipAngular", - "CCTransitionZoomFlipX", - "CCTransitionZoomFlipY", - "CCTransitionShrinkGrow", - "CCTransitionSlideInL", - "CCTransitionSlideInB", - "CCTransitionSlideInR", - "CCTransitionSlideInT", - "CCTransitionSplitCols", - "CCTransitionSplitRows", - "CCTransitionTurnOffTiles", - "CCTransitionProgress", - "CCTransitionProgressRadialCCW", - "CCTransitionProgressRadialCW", - "CCTransitionProgressHorizontal", - "CCTransitionProgressVertical", - "CCTransitionProgressInOut", - "CCTransitionProgressOutIn", - "CCSprite", - "CCLabelTTF", - "CCTextFieldTTF", - "CCSpriteBatchNode", - "CCLabelBMFont", - "CCTMXLayer", - "CCTMXTiledMap", - "CCPointObject", - "CCProjectionProtocol", - "CCRibbonSegment", - "CCScheduler", - "CCSet", - "CCSpriteFrame", - "CCSpriteFrameCache", - "CCString", - "CCTexture2D", - "CCTextureAtlas", - "CCTextureCache", - "CCTexturePVR", - "CCTimer", - "CCTMXLayerInfo", - "CCTMXMapInfo", - "CCTMXObjectGroup", - "CCTMXTilesetInfo", - "CCTouch", - "CCTouchDispatcher", - "CCTouchHandler", - "CCParticleFire", - "CCParticleFireworks", - "CCParticleSun", - "CCParticleGalaxy", - "CCParticleFlower", - "CCParticleMeteor", - "CCParticleSpiral", - "CCParticleExplosion", - "CCParticleSmoke", - "CCParticleSnow", - "CCParticleRain", - "CCScale9Sprite", - "CCControl", - "CCControlButton", - "CCControlColourPicker", - "CCControlPotentiometer", - "CCControlSlider", - "CCControlStepper", - "CCControlSwitch", - "CCEditBox", - "CCInteger", - "CCDrawNode", -} - --- register CCObject types -for i = 1, #CCObjectTypes do - _push_functions[CCObjectTypes[i]] = "toluafix_pushusertype_ccobject" -end - --- register LUA_FUNCTION, LUA_TABLE, LUA_HANDLE type -_to_functions["LUA_FUNCTION"] = "toluafix_ref_function" -_is_functions["LUA_FUNCTION"] = "toluafix_isfunction" -_to_functions["LUA_TABLE"] = "toluafix_totable" -_is_functions["LUA_TABLE"] = "toluafix_istable" - -local toWrite = {} -local currentString = '' -local out -local WRITE, OUTPUT = write, output - -function output(s) - out = _OUTPUT - output = OUTPUT -- restore - output(s) -end - -function write(a) - if out == _OUTPUT then - currentString = currentString .. a - if string.sub(currentString,-1) == '\n' then - toWrite[#toWrite+1] = currentString - currentString = '' - end - else - WRITE(a) - end -end - -function post_output_hook(package) - local result = table.concat(toWrite) - local function replace(pattern, replacement) - local k = 0 - local nxt, currentString = 1, '' - repeat - local s, e = string.find(result, pattern, nxt, true) - if e then - currentString = currentString .. string.sub(result, nxt, s-1) .. replacement - nxt = e + 1 - k = k + 1 - end - until not e - result = currentString..string.sub(result, nxt) - if k == 0 then print('Pattern not replaced', pattern) end - end - - replace([[#ifndef __cplusplus -#include "stdlib.h" -#endif -#include "string.h" - -#include "tolua++.h"]], - [[/**************************************************************************** - Copyright (c) 2011 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -extern "C" { -#include "tolua_fix.h" -} - -#include -#include -#include "cocos2d.h" -#include "CCLuaEngine.h" -#include "SimpleAudioEngine.h" -#include "cocos-ext.h" - -using namespace cocos2d; -using namespace cocos2d::extension; -using namespace CocosDenshion;]]) - - replace([[/* Exported function */ -TOLUA_API int tolua_Cocos2d_open (lua_State* tolua_S);]], [[]]) - - replace([[*((LUA_FUNCTION*)]], [[(]]) - - replace([[unsigned void* tolua_ret = (unsigned void*) self->getTiles();]], - [[unsigned int* tolua_ret = (unsigned int*) self->getTiles();]]) - - replace([[Color3B color = *((Color3B*) tolua_tousertype(tolua_S,4,(void*)&(const Color3B)ccBLACK));]], - [[const Color3B clr = Color3B::BLACK; - Color3B color = *((Color3B*) tolua_tousertype(tolua_S,4,(void*)&clr));]]) - - replace([[tolua_usertype(tolua_S,"LUA_FUNCTION");]], [[]]) - - replace([[toluafix_pushusertype_ccobject(tolua_S,(void*)tolua_ret]], - [[int nID = (tolua_ret) ? (int)tolua_ret->_ID : -1; - int* pLuaID = (tolua_ret) ? &tolua_ret->_luaID : NULL; - toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)tolua_ret]]) - - replace('\t', ' ') - - - result = string.gsub(result, '(\"const )(CC%u%w*)', '%1_%2') - - local skip_contents = { "CCPointMake", "CCSizeMake", "CCRectMake", "CCLOG", "CCLog", "CCAssert", "CCTexture2DPixelFormat", "CCTextAlignment", "CCVerticalTextAlignment", "CCControlState", "CCControlEvent" } - - local function remove_prefix() - result = string.gsub(result, '[^_\"k]CC%u%w+', function(m) - local s, e - local count = table.getn(skip_contents) - local i = 1 - - for i = 1, count do - s, e = string.find(m, skip_contents[i]) - if s ~= nil then - return m - end - end - - return string.gsub(m, 'CC(%u%w+)', '%1') - end) - end - remove_prefix() - - - result = string.gsub(result, '(tolua_tonumber%(tolua_S,%d,)(kCC)', '%1(int)%2') - result = string.gsub(result, '(tolua_constant%(tolua_S,"k%w*",)(k)', '%1(int)%2') - result = string.gsub(result, '(tolua_constant%(tolua_S,"CCControl%w*",)(CCControl)', '%1(int)%2') - - result = string.gsub(result, "(self%->setEmitterMode%()", "%1(ParticleSystem::Mode)") - - result = string.gsub(result, '(tolua_constant%(tolua_S,"kCC[%w_]*",)(kCC)', '%1(int)%2') - - replace("Animation*", "cocos2d::Animation*") - replace("Animation::create", "cocos2d::Animation::create") - - result = string.gsub(result, '(\"const )_(CC%u%w*)', '%1%2') - - WRITE(result) -end diff --git a/tools/tolua++/build.bat b/tools/tolua++/build.bat deleted file mode 100644 index 84490f5188..0000000000 --- a/tools/tolua++/build.bat +++ /dev/null @@ -1 +0,0 @@ -tolua++ -L basic.lua -o "../../scripting/lua/cocos2dx_support/LuaCocos2d.cpp" Cocos2d.pkg diff --git a/tools/tolua++/build.sh b/tools/tolua++/build.sh deleted file mode 100755 index af219ef0c1..0000000000 --- a/tools/tolua++/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# -# Invoked build.xml, overriding the lolua++ property - -SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -TOLUA=`which tolua++` -if [ -z "${TOLUA}" ]; then - TOLUA=`which tolua++5.1` -fi - -if [ -z "${TOLUA}" ]; then - echo "Unable to find tolua++ (or tolua++5.1) in your PATH." - exit 1 -fi - -cd ${SCRIPT_DIR} -${TOLUA} -L basic.lua -o ../../scripting/lua/cocos2dx_support/LuaCocos2d.cpp Cocos2d.pkg diff --git a/tools/tolua++/ccTypes.pkg b/tools/tolua++/ccTypes.pkg deleted file mode 100644 index ddf54509c6..0000000000 --- a/tools/tolua++/ccTypes.pkg +++ /dev/null @@ -1,263 +0,0 @@ - -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 - -typedef unsigned char GLubyte; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef float GLfloat; -typedef short GLshort; -typedef unsigned int GLenum; - -struct Color3B -{ - Color3B(void); - Color3B(GLubyte _r, GLubyte _g, GLubyte _b); - bool equals(const Color3B &other); - GLubyte r; - GLubyte g; - GLubyte b; -}; - - -/** RGBA color composed of 4 bytes -@since v0.8 -*/ -struct Color4B -{ - Color4B(void); - Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a); - Color4B(const Color4F &color4F); - GLubyte r; - GLubyte g; - GLubyte b; - GLubyte a; -}; - - -/** RGBA color composed of 4 floats -@since v0.8 -*/ -struct Color4F -{ - Color4F(void); - Color4F(GLfloat _r, GLfloat _g, GLfloat _b, GLfloat _a); - Color4F(const Color3B &color3B); - Color4F(const Color4B &color4B); - bool equals(const Color4F &other); - GLfloat r; - GLfloat g; - GLfloat b; - GLfloat a; -}; - - -/** A vertex composed of 2 floats: x, y - @since v0.8 - */ -class Vertex2F -{ - Vertex2F(void); - Vertex2F(float _x, float _y); - GLfloat x; - GLfloat y; -}; - - -/** A vertex composed of 2 floats: x, y - @since v0.8 - */ -class Vertex3F -{ - Vertex3F(void); - Vertex3F(float _x, float _y, float _z); - GLfloat x; - GLfloat y; - GLfloat z; -}; - -/** A texcoord composed of 2 floats: u, y - @since v0.8 - */ -class Tex2F -{ - Tex2F(void); - Tex2F(float _u, float _v); - GLfloat u; - GLfloat v; -}; - - -//! Point Sprite component -class PointSprite -{ - PointSprite(void); - Vertex2F pos; // 8 bytes - Color4B color; // 4 bytes - GLfloat size; // 4 bytes -}; - -//! A 2D Quad. 4 * 2 floats -class Quad2 -{ - Quad2(void); - Vertex2F tl; - Vertex2F tr; - Vertex2F bl; - Vertex2F br; -}; - - -//! A 3D Quad. 4 * 3 floats -class Quad3 -{ - Quad3(void); - Vertex3F bl; - Vertex3F br; - Vertex3F tl; - Vertex3F tr; -}; - -//! a Point with a vertex point, a tex coord point and a color 4B -class V2F_C4B_T2F -{ - V2F_C4B_T2F(void); - //! vertices (2F) - Vertex2F vertices; - //! colors (4B) - Color4B colors; - //! tex coords (2F) - Tex2F texCoords; -}; - -//! a Point with a vertex point, a tex coord point and a color 4F -class V2F_C4F_T2F -{ - V2F_C4F_T2F(void); - //! vertices (2F) - Vertex2F vertices; - //! colors (4F) - Color4F colors; - //! tex coords (2F) - Tex2F texCoords; -}; - -//! a Point with a vertex point, a tex coord point and a color 4B -class V3F_C4B_T2F -{ - V3F_C4B_T2F(void); - //! vertices (3F) - Vertex3F vertices; // 12 bytes -// char __padding__[4]; - - //! colors (4B) - Color4B colors; // 4 bytes -// char __padding2__[4]; - - // tex coords (2F) - Tex2F texCoords; // 8 byts -}; - -//! 4 Vertex2FTex2FColor4B Quad -class V2F_C4B_T2F_Quad -{ - V2F_C4B_T2F_Quad(void); - //! bottom left - V2F_C4B_T2F bl; - //! bottom right - V2F_C4B_T2F br; - //! top left - V2F_C4B_T2F tl; - //! top right - V2F_C4B_T2F tr; -}; - -//! 4 Vertex3FTex2FColor4B -class V3F_C4B_T2F_Quad -{ - V3F_C4B_T2F_Quad(void); - //! top left - V3F_C4B_T2F tl; - //! bottom left - V3F_C4B_T2F bl; - //! top right - V3F_C4B_T2F tr; - //! bottom right - V3F_C4B_T2F br; -}; - -//! 4 Vertex2FTex2FColor4F Quad -class V2F_C4F_T2F_Quad -{ - V2F_C4F_T2F_Quad(void); - //! bottom left - V2F_C4F_T2F bl; - //! bottom right - V2F_C4F_T2F br; - //! top left - V2F_C4F_T2F tl; - //! top right - V2F_C4F_T2F tr; -}; - -//! Blend Function used for textures -class BlendFunc -{ - BlendFunc(void); - GLenum src; - GLenum dst; -}; - -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m -//! Vertical text alignment type -typedef enum -{ - kCCVerticalTextAlignmentTop, - kCCVerticalTextAlignmentCenter, - kCCVerticalTextAlignmentBottom, -} CCVerticalTextAlignment; - -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m -//! Horizontal text alignment type -typedef enum -{ - kCCTextAlignmentLeft, - kCCTextAlignmentCenter, - kCCTextAlignmentRight, -} CCTextAlignment; - -// types for animation in particle systems - -// texture coordinates for a quad -class T2F_Quad -{ - T2F_Quad(void); - //! bottom left - Tex2F bl; - //! bottom right - Tex2F br; - //! top left - Tex2F tl; - //! top right - Tex2F tr; -}; - -// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad -class AnimationFrameData -{ - AnimationFrameData(void); - T2F_Quad texCoords; - float delay; - CCSize size; -}; diff --git a/tools/tolua++/matrix.pkg b/tools/tolua++/matrix.pkg deleted file mode 100644 index 1bd3c67933..0000000000 --- a/tools/tolua++/matrix.pkg +++ /dev/null @@ -1,18 +0,0 @@ - -typedef unsigned int kmGLEnum; - -class kmMat4 { - float mat[16]; -}; - -void kmGLFreeAll(void); -void kmGLPushMatrix(void); -void kmGLPopMatrix(void); -void kmGLMatrixMode(kmGLEnum mode); -void kmGLLoadIdentity(void); -void kmGLLoadMatrix(const kmMat4* pIn); -void kmGLMultMatrix(const kmMat4* pIn); -void kmGLTranslatef(float x, float y, float z); -void kmGLRotatef(float angle, float x, float y, float z); -void kmGLScalef(float x, float y, float z); -void kmGLGetMatrix(kmGLEnum mode, kmMat4* pOut); diff --git a/tools/tolua++/tolua++.Mac.zip.REMOVED.git-id b/tools/tolua++/tolua++.Mac.zip.REMOVED.git-id deleted file mode 100644 index 52d16d82cb..0000000000 --- a/tools/tolua++/tolua++.Mac.zip.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -12a58290deb3c79169fcb192e45b92d7229da0b3 \ No newline at end of file diff --git a/tools/tolua++/tolua++.rar.REMOVED.git-id b/tools/tolua++/tolua++.rar.REMOVED.git-id deleted file mode 100644 index 6be0fb75bc..0000000000 --- a/tools/tolua++/tolua++.rar.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -eea7ee6d1eab766660efb216ab5fb16640957e75 \ No newline at end of file diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 2a89e7e837..4cff3e48da 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -37,7 +37,7 @@ classes = Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* skip = Node::[setGLServerState description getUserObject .*UserData getGLServerState .*schedule getPosition$], Sprite::[getQuad getBlendFunc ^setPosition$ setBlendFunc], - SpriteBatchNode::[getBlendFunc setBlendFunc], + SpriteBatchNode::[getBlendFunc setBlendFunc getDescendants], MotionStreak::[getBlendFunc setBlendFunc draw update], AtlasNode::[getBlendFunc setBlendFunc], ParticleBatchNode::[getBlendFunc setBlendFunc],