mirror of https://github.com/axmolengine/axmol.git
Merge branch 'merge-physics' of https://github.com/minggo/cocos2d-x into develop
This commit is contained in:
commit
ab26d63b86
|
@ -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
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<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";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
|
|
@ -1 +1 @@
|
|||
fad913317d2e64eb308c7066f450f3a351ee0aab
|
||||
29c3c2dfd8b683a800709d085839444c3a304a0d
|
|
@ -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)
|
||||
|
|
|
@ -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::string, std::vector<EventListenerItem*>*>();
|
||||
}
|
||||
|
||||
std::vector<EventListenerItem*>* listenerList = nullptr;
|
||||
|
||||
auto itr = _listeners->find(item->listener->type);
|
||||
if (itr == _listeners->end())
|
||||
if (_inDispatch == 0)
|
||||
{
|
||||
listenerList = new std::vector<EventListenerItem*>();
|
||||
listenerList->reserve(100);
|
||||
_listeners->insert(std::make_pair(item->listener->type, listenerList));
|
||||
std::vector<EventListenerItem*>* listenerList = nullptr;
|
||||
|
||||
auto itr = _listeners->find(item->listener->type);
|
||||
if (itr == _listeners->end())
|
||||
{
|
||||
listenerList = new std::vector<EventListenerItem*>();
|
||||
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<EventListenerItem*>* listenerList = nullptr;
|
||||
|
||||
for (auto& item : _toAddedListeners)
|
||||
{
|
||||
auto itr = _listeners->find(item->listener->type);
|
||||
if (itr == _listeners->end())
|
||||
{
|
||||
listenerList = new std::vector<EventListenerItem*>();
|
||||
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)
|
||||
|
|
|
@ -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<std::string, std::vector<EventListenerItem*>*>* _listeners;
|
||||
|
||||
std::vector<EventListenerItem*> _toAddedListeners;
|
||||
|
||||
int _inDispatch;
|
||||
bool _isEnabled;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<Touch*>& 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<Scene*>(this->getParent()) != nullptr)
|
||||
{
|
||||
dynamic_cast<Scene*>(this->getParent())->addChildToPhysicsWorld(child);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// LayerRGBA
|
||||
LayerRGBA::LayerRGBA()
|
||||
: _displayedOpacity(255)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Sprite*>(node) != nullptr)
|
||||
{
|
||||
Sprite* sp = dynamic_cast<Sprite*>(node);
|
||||
|
||||
if (sp->getPhysicsBody())
|
||||
{
|
||||
_physicsWorld->addChild(sp->getPhysicsBody());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if(dynamic_cast<Layer*>(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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -50,11 +50,6 @@ NS_CC_BEGIN
|
|||
class CC_DLL Menu : public LayerRGBA
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
HANDLER_PRIORITY = -128,
|
||||
};
|
||||
|
||||
enum class State
|
||||
{
|
||||
WAITING,
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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 <algorithm>
|
||||
|
||||
#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
|
|
@ -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 <vector>
|
||||
|
||||
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<PhysicsShape*>& 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<PhysicsJoint*>* 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<PhysicsJoint*> _joints;
|
||||
std::vector<PhysicsShape*> _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
|
|
@ -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
|
|
@ -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<bool(const PhysicsContact& contact)> 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<bool(const PhysicsContact& contact, const PhysicsContactPreSolve& solve)> 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<void(const PhysicsContact& contact, const PhysicsContactPostSolve& solve)> onContactPostSolve;
|
||||
/*
|
||||
* @brief it will called at two shapes separated, and only call it once.
|
||||
* onContactBegin and onContactEnd will called in pairs.
|
||||
*/
|
||||
std::function<void(const PhysicsContact& contact)> onContactEnd;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
#endif //__CCPHYSICS_CONTACT_H__
|
||||
|
||||
#endif // CC_USE_PHYSICS
|
|
@ -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
|
|
@ -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
|
|
@ -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__
|
|
@ -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
|
|
@ -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
|
|
@ -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<PhysicsWorld*>(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<PhysicsContact*>(arb->data));
|
||||
}
|
||||
|
||||
int PhysicsWorld::collisionPreSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data)
|
||||
{
|
||||
PhysicsWorld* world = static_cast<PhysicsWorld*>(data);
|
||||
return world->collisionPreSolveCallback(*static_cast<PhysicsContact*>(arb->data),
|
||||
PhysicsContactPreSolve());
|
||||
}
|
||||
|
||||
void PhysicsWorld::collisionPostSolveCallbackFunc(cpArbiter *arb, cpSpace *space, void *data)
|
||||
{
|
||||
PhysicsWorld* world = static_cast<PhysicsWorld*>(data);
|
||||
world->collisionPostSolveCallback(*static_cast<PhysicsContact*>(arb->data),
|
||||
PhysicsContactPostSolve());
|
||||
}
|
||||
|
||||
void PhysicsWorld::collisionSeparateCallbackFunc(cpArbiter *arb, cpSpace *space, void *data)
|
||||
{
|
||||
PhysicsWorld* world = static_cast<PhysicsWorld*>(data);
|
||||
PhysicsContact* contact = static_cast<PhysicsContact*>(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<PhysicsBody*>(child);
|
||||
|
||||
std::vector<PhysicsShape*> 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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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 <algorithm>
|
||||
NS_CC_BEGIN
|
||||
|
||||
std::map<cpShape*, PhysicsShapeInfo*> 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<cpShape*, PhysicsShapeInfo*>(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
|
|
@ -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 <vector>
|
||||
#include <map>
|
||||
#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<cpShape*> shapes;
|
||||
static std::map<cpShape*, PhysicsShapeInfo*> 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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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 <functional>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
void setAccelerometerInterval(float interval);
|
||||
void update(float x, float y, float z, long sensorTimeStamp);
|
||||
|
||||
private:
|
||||
std::function<void(Acceleration*)> _function;
|
||||
Acceleration _accelerationValue;
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Accelerometer.h
|
||||
*
|
||||
* Created on: Aug 9, 2011
|
||||
* Author: laschweinski
|
||||
*/
|
||||
|
||||
#ifndef CCACCELEROMETER_H_
|
||||
#define CCACCELEROMETER_H_
|
||||
|
||||
#include "platform/CCAccelerometerDelegate.h"
|
||||
#include <functional>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
||||
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif /* CCACCELEROMETER_H_ */
|
|
@ -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 <functional>
|
||||
#include "platform/CCAccelerometerDelegate.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
void setAccelerometerInterval(float interval);
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Accelerometer.h
|
||||
*
|
||||
* Created on: Aug 9, 2011
|
||||
* Author: laschweinski
|
||||
*/
|
||||
|
||||
#ifndef CCACCELEROMETER_H_
|
||||
#define CCACCELEROMETER_H_
|
||||
|
||||
#include "platform/CCAccelerometerDelegate.h"
|
||||
#include <functional>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
||||
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||
};
|
||||
|
||||
}//namespace cocos2d
|
||||
|
||||
#endif /* CCACCELEROMETER_H_ */
|
|
@ -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 <functional>
|
||||
#include "platform/CCAccelerometerDelegate.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL Accelerometer
|
||||
{
|
||||
public:
|
||||
Accelerometer() {}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer() {}
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function) { CC_UNUSED_PARAM(function); }
|
||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
|
@ -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 <functional>
|
||||
|
||||
namespace cocos2d {
|
||||
|
||||
class Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer(){}
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer(){}
|
||||
|
||||
static Accelerometer* sharedAccelerometer() { return NULL; };
|
||||
|
||||
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* __CCACCELEROMETER_H__ */
|
|
@ -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 <functional>
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
class CC_DLL Accelerometer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
Accelerometer();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~Accelerometer();
|
||||
|
||||
void setDelegate(std::function<void(Acceleration*)> function);
|
||||
void setAccelerometerInterval(float interval);
|
||||
void update( double x,double y,double z,double timestamp );
|
||||
private:
|
||||
Acceleration _accelerationValue;
|
||||
std::function<void(Acceleration*)> _function;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
||||
#endif
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
</PreBuildEvent>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<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;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
@ -211,6 +211,21 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
|||
<ClCompile Include="..\particle_nodes\CCParticleExamples.cpp" />
|
||||
<ClCompile Include="..\particle_nodes\CCParticleSystem.cpp" />
|
||||
<ClCompile Include="..\particle_nodes\CCParticleSystemQuad.cpp" />
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsBodyInfo.cpp" />
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsContactInfo.cpp" />
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsJointInfo.cpp" />
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsShapeInfo.cpp" />
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsWorldInfo.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsBody.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsContact.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsJoint.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsShape.cpp" />
|
||||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo.cpp" />
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo.cpp" />
|
||||
<ClCompile Include="..\platform\CCEGLViewProtocol.cpp" />
|
||||
<ClCompile Include="..\platform\CCFileUtils.cpp" />
|
||||
<ClCompile Include="..\platform\CCSAXParser.cpp" />
|
||||
|
@ -365,6 +380,24 @@ xcopy /Y /Q "$(ProjectDir)..\platform\third_party\win32\libraries\*.*" "$(OutDir
|
|||
<ClInclude Include="..\particle_nodes\CCParticleExamples.h" />
|
||||
<ClInclude Include="..\particle_nodes\CCParticleSystem.h" />
|
||||
<ClInclude Include="..\particle_nodes\CCParticleSystemQuad.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsBodyInfo.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsContactInfo.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsHelper.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsJointInfo.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsShapeInfo.h" />
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsWorldInfo.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsContact.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsJoint.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsSetting.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsShape.h" />
|
||||
<ClInclude Include="..\physics\CCPhysicsWorld.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo.h" />
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo.h" />
|
||||
<ClInclude Include="..\platform\CCApplicationProtocol.h" />
|
||||
<ClInclude Include="..\platform\CCCommon.h" />
|
||||
<ClInclude Include="..\platform\CCDevice.h" />
|
||||
|
|
|
@ -103,6 +103,15 @@
|
|||
<Filter Include="event_dispatcher">
|
||||
<UniqueIdentifier>{3ff2746c-a91b-4b86-93b7-43a9ec14825b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics">
|
||||
<UniqueIdentifier>{08593631-5bf5-46aa-9436-62595c4f7bf6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics\chipmunk">
|
||||
<UniqueIdentifier>{aeadfa95-9c89-4212-98ae-89ad57db596a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="physics\Box2D">
|
||||
<UniqueIdentifier>{b9880458-36e5-4f28-a34b-d01d9512a395}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\base_nodes\CCAtlasNode.cpp">
|
||||
|
@ -512,6 +521,51 @@
|
|||
<ClCompile Include="..\event_dispatcher\CCTouchEventListener.cpp">
|
||||
<Filter>event_dispatcher</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\CCPhysicsBody.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\CCPhysicsContact.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\CCPhysicsJoint.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\CCPhysicsShape.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\CCPhysicsWorld.cpp">
|
||||
<Filter>physics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsBodyInfo.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsContactInfo.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsJointInfo.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsShapeInfo.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\chipmunk\CCPhysicsWorldInfo.cpp">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsBodyInfo.cpp">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsContactInfo.cpp">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsJointInfo.cpp">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsShapeInfo.cpp">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\physics\Box2D\CCPhysicsWorldInfo.cpp">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\base_nodes\CCAtlasNode.h">
|
||||
|
@ -1035,5 +1089,59 @@
|
|||
<ClInclude Include="..\event_dispatcher\CCTouchEventListener.h">
|
||||
<Filter>event_dispatcher</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsContact.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsJoint.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsSetting.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsShape.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\CCPhysicsWorld.h">
|
||||
<Filter>physics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsBodyInfo.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsContactInfo.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsHelper.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsJointInfo.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsShapeInfo.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\chipmunk\CCPhysicsWorldInfo.h">
|
||||
<Filter>physics\chipmunk</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsBodyInfo.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsContactInfo.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsHelper.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsJointInfo.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsShapeInfo.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\physics\Box2D\CCPhysicsWorldInfo.h">
|
||||
<Filter>physics\Box2D</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -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
|
||||
//
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\cocos2dx;$(ProjectDir)..\..\..\..\cocos2dx\include;$(ProjectDir)..\..\..\..\cocos2dx\kazmath\include;$(ProjectDir)..\..\..\..\cocos2dx\platform\win32;$(ProjectDir)..\..\..\..\cocos2dx\platform\third_party\win32\OGLES;..\Classes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
@ -84,7 +84,7 @@
|
|||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<AdditionalDependencies>libcocos2d.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcocos2d.lib;libchipmunk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<Touch*>& 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);
|
||||
}
|
|
@ -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<Touch*>& 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
|
|
@ -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();
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
TestScene::TestScene(bool bPortrait)
|
||||
{
|
||||
|
||||
Scene::init();
|
||||
}
|
||||
|
||||
bool TestScene::initTest()
|
||||
{
|
||||
return Scene::init();
|
||||
}
|
||||
|
||||
void TestScene::onEnter()
|
||||
|
|
|
@ -11,6 +11,7 @@ class TestScene : public Scene
|
|||
{
|
||||
public:
|
||||
TestScene(bool bPortrait = false);
|
||||
virtual bool initTest();
|
||||
virtual void onEnter();
|
||||
|
||||
virtual void runThisTest() = 0;
|
||||
|
|
|
@ -65,5 +65,6 @@
|
|||
#include "TexturePackerEncryptionTest/TextureAtlasEncryptionTest.h"
|
||||
#include "DataVisitorTest/DataVisitorTest.h"
|
||||
#include "ConfigurationTest/ConfigurationTest.h"
|
||||
#include "PhysicsTest/PhysicsTest.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
5fe89fb5bd58cedf13b0363f97b20e3ea7ff255d
|
|
@ -0,0 +1 @@
|
|||
500d95937f3fd81659da66d2099b6c80d988a6b5
|
|
@ -0,0 +1 @@
|
|||
39179659c7b94b213b6ab7b24372c96378f61062
|
|
@ -0,0 +1 @@
|
|||
9975e4961272d5bda6d5f3bbd61ea0fc02222199
|
|
@ -0,0 +1 @@
|
|||
0a4ce85782909e964aa0e95e89bab8272d0c3d4e
|
|
@ -0,0 +1 @@
|
|||
0a77108d377ceb5f084f1aab1877159df9499428
|
|
@ -0,0 +1 @@
|
|||
39d29cbeb700598c3e4ad6d3ee0ac273a3385fcd
|
|
@ -0,0 +1 @@
|
|||
500d95937f3fd81659da66d2099b6c80d988a6b5
|
|
@ -0,0 +1 @@
|
|||
a6e5d948d0c85ecc42b7a2ebf5751e3990002bac
|
|
@ -0,0 +1 @@
|
|||
eff519b0334eaeb486f302ec2581771950b7cca2
|
|
@ -0,0 +1 @@
|
|||
021493cabd2489bf2c20c657e5523e24608df86c
|
|
@ -0,0 +1 @@
|
|||
9975e4961272d5bda6d5f3bbd61ea0fc02222199
|
|
@ -0,0 +1 @@
|
|||
0a4ce85782909e964aa0e95e89bab8272d0c3d4e
|
|
@ -0,0 +1 @@
|
|||
0a77108d377ceb5f084f1aab1877159df9499428
|
|
@ -0,0 +1 @@
|
|||
1a6a5a2f571c692a962e9159fca8ea5d6879a748
|
|
@ -0,0 +1 @@
|
|||
eff519b0334eaeb486f302ec2581771950b7cca2
|
|
@ -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)
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -146,6 +146,26 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
|||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\PlayerController.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\ProjectileController.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\SceneController.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocosGUIScene.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest\UICheckBoxTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest\UIDragPanelTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest\UIImageViewTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest\UILabelAtlasTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest\UILabelBMFontTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest\UILabelTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest\UIListViewTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest\UILoadingBarTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest\UINodeContainerTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest\UIPageViewTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest\UIPanelTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScene.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest\UIScrollViewTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest\UISliderTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest\UITextAreaTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest\UITextButtonTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest\UITextFieldTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioSceneTest\SceneEditorTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\ControlExtensionTest\CCControlPotentiometerTest\CCControlPotentiometerTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\ControlExtensionTest\CCControlStepperTest\CCControlStepperTest.cpp" />
|
||||
|
@ -160,6 +180,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
|||
<ClCompile Include="..\Classes\LabelTest\LabelTestNew.cpp" />
|
||||
<ClCompile Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.cpp" />
|
||||
<ClCompile Include="..\Classes\PerformanceTest\PerformanceAllocTest.cpp" />
|
||||
<ClCompile Include="..\Classes\PhysicsTest\PhysicsTest.cpp" />
|
||||
<ClCompile Include="..\Classes\ShaderTest\ShaderTest2.cpp" />
|
||||
<ClCompile Include="..\Classes\SpineTest\SpineTest.cpp" />
|
||||
<ClCompile Include="..\Classes\TexturePackerEncryptionTest\TextureAtlasEncryptionTest.cpp" />
|
||||
|
@ -260,6 +281,26 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
|||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\PlayerController.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\ProjectileController.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioComponentsTest\SceneController.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocosGUIScene.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest\UICheckBoxTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest\UIDragPanelTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest\UIImageViewTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest\UILabelAtlasTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest\UILabelBMFontTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest\UILabelTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest\UIListViewTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest\UILoadingBarTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest\UINodeContainerTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest\UIPageViewTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest\UIPanelTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScene.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest\UIScrollViewTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest\UISliderTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest\UITextAreaTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest\UITextButtonTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest\UITextFieldTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioSceneTest\SceneEditorTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\ControlExtensionTest\CCControlPotentiometerTest\CCControlPotentiometerTest.h" />
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\ControlExtensionTest\CCControlStepperTest\CCControlStepperTest.h" />
|
||||
|
@ -273,6 +314,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
|||
<ClInclude Include="..\Classes\FileUtilsTest\FileUtilsTest.h" />
|
||||
<ClInclude Include="..\Classes\LabelTest\LabelTestNew.h" />
|
||||
<ClInclude Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.h" />
|
||||
<ClInclude Include="..\Classes\PhysicsTest\PhysicsTest.h" />
|
||||
<ClInclude Include="..\Classes\ShaderTest\ShaderTest2.h" />
|
||||
<ClInclude Include="..\Classes\SpineTest\SpineTest.h" />
|
||||
<ClInclude Include="..\Classes\TexturePackerEncryptionTest\TextureAtlasEncryptionTest.h" />
|
||||
|
|
|
@ -240,6 +240,62 @@
|
|||
</Filter>
|
||||
<Filter Include="Classes\NewEventDispatcherTest">
|
||||
<UniqueIdentifier>{0b414789-7971-4a4c-86e3-40cc00936684}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\PhysicsTest">
|
||||
<UniqueIdentifier>{a83cb042-e3d6-4d3b-a4f6-30a4b3fcb3e9}</UniqueIdentifier>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest">
|
||||
<UniqueIdentifier>{9daecd38-37c6-4216-a999-86077af83beb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest">
|
||||
<UniqueIdentifier>{493fcd85-c749-482d-9404-905e99aa0103}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest">
|
||||
<UniqueIdentifier>{5c1960de-24ba-4b72-be18-cc160dd2a50d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest">
|
||||
<UniqueIdentifier>{175b363b-a41a-4b1d-bde1-970e77e64cff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest">
|
||||
<UniqueIdentifier>{2e08949f-bf73-4fdc-85e8-34b8c69aa978}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest">
|
||||
<UniqueIdentifier>{c57c0453-a096-44d7-830b-1cf24c712cfd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest">
|
||||
<UniqueIdentifier>{c4dbbfb3-0e91-492f-bbbf-f03fb26f3f54}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest">
|
||||
<UniqueIdentifier>{01097388-e538-4081-8e16-d1ff3a86292a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest">
|
||||
<UniqueIdentifier>{160da6f0-a0f1-4a53-8e5e-cf0a63ee82a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest">
|
||||
<UniqueIdentifier>{fadff96e-c19a-41f5-a755-547cf1f8a5fb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest">
|
||||
<UniqueIdentifier>{73c268e8-3872-49d6-9204-1e679ff72a42}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest">
|
||||
<UniqueIdentifier>{6e7f1d2a-c8c1-4f48-826f-930bc8a0556e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest">
|
||||
<UniqueIdentifier>{305e1c54-9321-49f7-8672-46d1286dbe83}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest">
|
||||
<UniqueIdentifier>{df6e9468-93f7-472d-be1d-d274d7de677e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest">
|
||||
<UniqueIdentifier>{dedcabba-959c-40e3-9959-7ccf4e31c792}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest">
|
||||
<UniqueIdentifier>{cfc87c30-a7b4-4b6f-bc5d-da45360466b6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest">
|
||||
<UniqueIdentifier>{5caf2179-ae22-4040-8bac-17e9f22efbf7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest">
|
||||
<UniqueIdentifier>{24f044ee-09a6-406b-98d7-8d5d759e5bb1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -570,6 +626,68 @@
|
|||
<ClCompile Include="..\Classes\ShaderTest\ShaderTest2.cpp" />
|
||||
<ClCompile Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.cpp">
|
||||
<Filter>Classes\NewEventDispatcherTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\PhysicsTest\PhysicsTest.cpp">
|
||||
<Filter>Classes\PhysicsTest</Filter>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest\UICheckBoxTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest\UIDragPanelTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest\UIImageViewTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest\UILabelAtlasTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest\UILabelBMFontTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest\UILabelTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest\UIListViewTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest\UILoadingBarTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest\UINodeContainerTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest\UIPageViewTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest\UIPanelTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest\UIScrollViewTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest\UISliderTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest\UITextAreaTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest\UITextButtonTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest\UITextFieldTest.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocosGUIScene.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScene.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.cpp">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1077,6 +1195,68 @@
|
|||
<ClInclude Include="..\Classes\ShaderTest\ShaderTest2.h" />
|
||||
<ClInclude Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.h">
|
||||
<Filter>Classes\NewEventDispatcherTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\PhysicsTest\PhysicsTest.h">
|
||||
<Filter>Classes\PhysicsTest</Filter>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest\UIButtonTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest\UICheckBoxTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UICheckBoxTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest\UIDragPanelTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIDragPanelTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest\UIImageViewTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIImageViewTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest\UILabelAtlasTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelAtlasTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest\UILabelBMFontTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelBMFontTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest\UILabelTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILabelTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest\UIListViewTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIListViewTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest\UILoadingBarTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UILoadingBarTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest\UINodeContainerTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UINodeContainerTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest\UIPageViewTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIPageViewTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest\UIPanelTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIPanelTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest\UIScrollViewTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UIScrollViewTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest\UISliderTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UISliderTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest\UITextAreaTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextAreaTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest\UITextButtonTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextButtonTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest\UITextFieldTest.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest\UITextFieldTest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\CocosGUIScene.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UIScene.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.h">
|
||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<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;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<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)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
|
@ -95,7 +95,7 @@
|
|||
<AdditionalIncludeDirectories>$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;websockets.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>libcocos2d.lib;libCocosDenshion.lib;liblua.lib;lua51.lib;libExtensions.lib;websockets.lib;libchipmunk.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue