Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into developTableView

This commit is contained in:
samuele3 2013-11-22 11:52:32 +08:00
commit eb3f5eb629
6 changed files with 77 additions and 48 deletions

View File

@ -183,10 +183,6 @@ private:
CC_DEPRECATED_ATTRIBUTE int executeScriptTouchesHandler(EventTouch::EventCode eventType, const std::vector<Touch*>& touches);
};
#ifdef __apple__
#pragma mark -
#pragma mark LayerRGBA
#endif
/** LayerRGBA is a subclass of Layer that implements the RGBAProtocol protocol using a solid color as the background.

View File

@ -478,8 +478,7 @@ static CCEAGLView *__view = 0;
cocos2d::EGLView::getInstance()->handleTouchesCancel(i, (long*)ids, xs, ys);
}
#pragma mark -
#pragma mark UIView - Responder
#pragma mark - UIView - Responder
- (BOOL)canBecomeFirstResponder
{
@ -506,8 +505,7 @@ static CCEAGLView *__view = 0;
return [super resignFirstResponder];
}
#pragma mark -
#pragma mark UIKeyInput protocol
#pragma mark - UIKeyInput protocol
- (BOOL)hasText
@ -534,16 +532,14 @@ static CCEAGLView *__view = 0;
cocos2d::IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
}
#pragma mark -
#pragma mark UITextInputTrait protocol
#pragma mark - UITextInputTrait protocol
-(UITextAutocapitalizationType) autocapitalizationType
{
return UITextAutocapitalizationTypeNone;
}
#pragma mark -
#pragma mark UITextInput protocol
#pragma mark - UITextInput protocol
#pragma mark UITextInput - properties
@ -727,8 +723,7 @@ static CCEAGLView *__view = 0;
return nil;
}
#pragma mark -
#pragma mark UIKeyboard notification
#pragma mark - UIKeyboard notification
- (void)onUIKeyboardNotification:(NSNotification *)notif;
{

View File

@ -37,8 +37,7 @@
#import "ccConfig.h"
//NS_CC_BEGIN;
#pragma mark -
#pragma mark MouseEventDelegate
#pragma mark - MouseEventDelegate
/** MouseEventDelegate protocol.
Implement it in your node to receive any of mouse events
@ -135,8 +134,7 @@
@end
#pragma mark -
#pragma mark KeyboardEventDelegate
#pragma mark - KeyboardEventDelegate
/** KeyboardEventDelegate protocol.
Implement it in your node to receive any of keyboard events
@ -189,8 +187,7 @@
@end
#pragma mark -
#pragma mark EventDispatcher
#pragma mark - EventDispatcher
struct _listEntry;

View File

@ -77,8 +77,7 @@ float const kCD_GainDefault = 1.0f;
-(BOOL) _setUpSourceGroups:(int[]) definitions total:(NSUInteger) total;
@end
#pragma mark -
#pragma mark CDUtilities
#pragma mark - CDUtilities
@implementation CDUtilities
@ -1262,8 +1261,7 @@ static BOOL _mixerRateSet = NO;
@end
////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDAudioInterruptTargetGroup
#pragma mark - CDAudioInterruptTargetGroup
@implementation CDAudioInterruptTargetGroup
@ -1326,8 +1324,7 @@ static BOOL _mixerRateSet = NO;
////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDAsynchBufferLoader
#pragma mark - CDAsynchBufferLoader
@implementation CDAsynchBufferLoader
@ -1371,8 +1368,7 @@ static BOOL _mixerRateSet = NO;
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDBufferLoadRequest
#pragma mark - CDBufferLoadRequest
@implementation CDBufferLoadRequest
@ -1394,8 +1390,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDFloatInterpolator
#pragma mark - CDFloatInterpolator
@implementation CDFloatInterpolator
@synthesize start,end,interpolationType;
@ -1443,8 +1438,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDPropertyModifier
#pragma mark - CDPropertyModifier
@implementation CDPropertyModifier
@ -1542,8 +1536,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDSoundSourceFader
#pragma mark - CDSoundSourceFader
@implementation CDSoundSourceFader
@ -1566,8 +1559,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDSoundSourcePanner
#pragma mark - CDSoundSourcePanner
@implementation CDSoundSourcePanner
@ -1590,8 +1582,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDSoundSourcePitchBender
#pragma mark - CDSoundSourcePitchBender
@implementation CDSoundSourcePitchBender
@ -1614,8 +1605,7 @@ static BOOL _mixerRateSet = NO;
@end
///////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark CDSoundEngineFader
#pragma mark - CDSoundEngineFader
@implementation CDSoundEngineFader

View File

@ -293,19 +293,32 @@ void PhysicsBody::setDynamic(bool dynamic)
if (dynamic)
{
cpBodySetMass(_info->getBody(), _mass);
cpBodySetMoment(_info->getBody(), _moment);
if (_world != nullptr)
{
// reset the gravity enable
if (isGravityEnabled())
{
_gravityEnable = false;
setGravityEnable(true);
}
cpSpaceAddBody(_world->_info->getSpace(), _info->getBody());
}
}else
}
else
{
cpBodySetMass(_info->getBody(), PHYSICS_INFINITY);
if (_world != nullptr)
{
cpSpaceRemoveBody(_world->_info->getSpace(), _info->getBody());
}
// avoid incorrect collion simulation.
cpBodySetMass(_info->getBody(), PHYSICS_INFINITY);
cpBodySetMoment(_info->getBody(), PHYSICS_INFINITY);
cpBodySetVel(_info->getBody(), cpvzero);
cpBodySetAngVel(_info->getBody(), 0.0f);
}
}
@ -456,7 +469,11 @@ void PhysicsBody::setMass(float mass)
}
}
cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass));
// the static body's mass and moment is always infinity
if (_dynamic)
{
cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass));
}
}
void PhysicsBody::addMass(float mass)
@ -498,7 +515,11 @@ void PhysicsBody::addMass(float mass)
}
}
cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass));
// the static body's mass and moment is always infinity
if (_dynamic)
{
cpBodySetMass(_info->getBody(), PhysicsHelper::float2cpfloat(_mass));
}
}
void PhysicsBody::addMoment(float moment)
@ -537,7 +558,8 @@ void PhysicsBody::addMoment(float moment)
}
}
if (_rotationEnable)
// the static body's mass and moment is always infinity
if (_rotationEnable && _dynamic)
{
cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment));
}
@ -545,6 +567,12 @@ void PhysicsBody::addMoment(float moment)
void PhysicsBody::setVelocity(const Point& velocity)
{
if (!_dynamic)
{
CCLOG("physics warning: your cann't set velocity for a static body.");
return;
}
cpBodySetVel(_info->getBody(), PhysicsHelper::point2cpv(velocity));
}
@ -565,6 +593,12 @@ Point PhysicsBody::getVelocityAtWorldPoint(const Point& point)
void PhysicsBody::setAngularVelocity(float velocity)
{
if (!_dynamic)
{
CCLOG("physics warning: your cann't set angular velocity for a static body.");
return;
}
cpBodySetAngVel(_info->getBody(), PhysicsHelper::float2cpfloat(velocity));
}
@ -598,7 +632,8 @@ void PhysicsBody::setMoment(float moment)
_moment = moment;
_momentDefault = false;
if (_rotationEnable)
// the static body's mass and moment is always infinity
if (_rotationEnable && _dynamic)
{
cpBodySetMoment(_info->getBody(), PhysicsHelper::float2cpfloat(_moment));
}

View File

@ -481,9 +481,25 @@ void PhysicsWorld::removeBody(PhysicsBody* body)
// destory the body's joints
for (auto joint : body->_joints)
{
removeJoint(joint, true);
// set destroy param to false to keep the iterator available
removeJoint(joint, false);
PhysicsBody* other = (joint->getBodyA() == body ? joint->getBodyB() : body);
other->removeJoint(joint);
// test the distraction is delaied or not
if (_delayRemoveJoints.size() > 0 && _delayRemoveJoints.back() == joint)
{
joint->_destoryMark = true;
}
else
{
delete joint;
}
}
body->_joints.clear();
removeBodyOrDelay(body);
_bodies->removeObject(body);
body->_world = nullptr;