mirror of https://github.com/axmolengine/axmol.git
fixed #702 tests crashs at the start on wophone device
This commit is contained in:
parent
ab470ad76d
commit
ab2a6cb2bb
|
@ -66,6 +66,8 @@ namespace cocos2d
|
|||
}
|
||||
|
||||
void CCAccelerometer::update(float x, float y, float z, long sensorTimeStamp)
|
||||
{
|
||||
if (m_pAccelDelegate)
|
||||
{
|
||||
m_obAccelerationValue.x = -((double)x / TG3_GRAVITY_EARTH);
|
||||
m_obAccelerationValue.y = -((double)y / TG3_GRAVITY_EARTH);
|
||||
|
@ -74,5 +76,6 @@ namespace cocos2d
|
|||
|
||||
m_pAccelDelegate->didAccelerate(&m_obAccelerationValue);
|
||||
}
|
||||
}
|
||||
} // end of namespace cococs2d
|
||||
|
||||
|
|
|
@ -68,6 +68,11 @@ static AccelerometerDispatcher* s_pAccelerometerDispatcher;
|
|||
|
||||
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
|
||||
{
|
||||
if (! delegate_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
acceleration_->x = acceleration.x;
|
||||
acceleration_->y = acceleration.y;
|
||||
acceleration_->z = acceleration.z;
|
||||
|
|
|
@ -64,7 +64,6 @@ CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
|||
void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate)
|
||||
{
|
||||
m_pDelegate = NULL;
|
||||
|
||||
m_pSensor->Release();
|
||||
m_pSensor = NULL;
|
||||
}
|
||||
|
@ -73,6 +72,13 @@ void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
|
|||
{
|
||||
m_pDelegate = pDelegate;
|
||||
|
||||
do
|
||||
{
|
||||
if (m_pSensor)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
m_pSensor = TCOM_Sensors_DataType_Client::GetInstance();
|
||||
|
||||
if (m_pSensor)
|
||||
|
@ -89,11 +95,16 @@ void CCAccelerometer::addDelegate(CCAccelerometerDelegate* pDelegate)
|
|||
{
|
||||
CCLOG("cocos2d: The Accelerometer Sensor Open failed");
|
||||
}
|
||||
} while (0);
|
||||
|
||||
}
|
||||
|
||||
void CCAccelerometer::didAccelerate(CCAcceleration* pAccelerationValue)
|
||||
{
|
||||
if (m_pDelegate)
|
||||
{
|
||||
m_pDelegate->didAccelerate(pAccelerationValue);
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace cocos2d
|
||||
|
|
|
@ -120,7 +120,8 @@ OBJECTS = \
|
|||
$(OBJECTS_DIR)/TransitionsTest.o \
|
||||
$(OBJECTS_DIR)/UserDefaultTest.o \
|
||||
$(OBJECTS_DIR)/ZwoptexTest.o \
|
||||
$(OBJECTS_DIR)/FontTest.o
|
||||
$(OBJECTS_DIR)/FontTest.o \
|
||||
$(OBJECTS_DIR)/CurrentLanguageTest.o
|
||||
|
||||
ADD_OBJECTS +=
|
||||
|
||||
|
@ -394,3 +395,6 @@ $(OBJECTS_DIR)/ZwoptexTest.o : ../tests/ZwoptexTest/ZwoptexTest.cpp
|
|||
$(OBJECTS_DIR)/FontTest.o : ../tests/FontTest/FontTest.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/FontTest.o ../tests/FontTest/FontTest.cpp
|
||||
|
||||
$(OBJECTS_DIR)/CurrentLanguageTest.o : ../tests/CurrentLanguageTest/CurrentLanguageTest.cpp
|
||||
$(CXX) -c $(CXX_FLAGS) $(INCLUDE_PATH) $(LAST_INCLUDE_PATH) -o $(OBJECTS_DIR)/CurrentLanguageTest.o ../tests/CurrentLanguageTest/CurrentLanguageTest.cpp
|
||||
|
||||
|
|
Loading…
Reference in New Issue