本文整理汇总了C++中CCDirector::getAccelerometer方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getAccelerometer方法的具体用法?C++ CCDirector::getAccelerometer怎么用?C++ CCDirector::getAccelerometer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDirector
的用法示例。
在下文中一共展示了CCDirector::getAccelerometer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
/// Callbacks
void CCLayer::onEnter()
{
CCDirector* pDirector = CCDirector::sharedDirector();
// register 'parent' nodes first
// since events are propagated in reverse order
if (m_bTouchEnabled)
{
this->registerWithTouchDispatcher();
}
// then iterate over all the children
CCNode::onEnter();
// add this layer to concern the Accelerometer Sensor
if (m_bAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(this);
}
// add this layer to concern the keypad msg
if (m_bKeypadEnabled)
{
pDirector->getKeypadDispatcher()->addDelegate(this);
}
}
示例2: ccAccelerationUpdate
void CCApplication::ccAccelerationUpdate()
{
// Accelerometer doesn't work on Marmalade X86 MacOS-X simulator
#if !(defined(__APPLE__) && defined(I3D_ARCH_X86))
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->update((float)s3eAccelerometerGetX(), (float)s3eAccelerometerGetY(), (float)s3eAccelerometerGetZ(), s3eTimerGetMs()); // MH: Added casting to float
#endif
}
示例3: setAccelerometerEnabled
void CCInputDelegate::setAccelerometerEnabled(bool enabled)
{
if (enabled != m_bAccelerometerEnabled)
{
m_bAccelerometerEnabled = enabled;
CCDirector* pDirector = CCDirector::sharedDirector();
if (enabled)
{
pDirector->getAccelerometer()->setDelegate(this);
}
else
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
}
}
示例4: onEnterTransitionDidFinish
void CCLayer::onEnterTransitionDidFinish()
{
if (m_bAccelerometerEnabled)
{
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->setDelegate(this);
}
CCNode::onEnterTransitionDidFinish();
}
示例5: setAccelerometerInterval
void CCLayer::setAccelerometerInterval(double interval) {
if (m_bAccelerometerEnabled)
{
if (m_bRunning)
{
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->setAccelerometerInterval(interval);
}
}
}
示例6: setAccelerometerEnabled
/// isAccelerometerEnabled setter
void CCLayer::setAccelerometerEnabled(bool enabled)
{
if (enabled != m_bIsAccelerometerEnabled)
{
m_bIsAccelerometerEnabled = enabled;
if (m_bIsRunning)
{
CCDirector *pDirector = CCDirector::sharedDirector();
if (enabled)
{
pDirector->getAccelerometer()->setDelegate(this);
}
else
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
}
}
}
示例7:
void Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp)
{
// We need to invert to make it compatible with iOS.
CCRect rcRect = CCEGLView::sharedOpenGLView().getViewPort();
float fScreenScaleFactor = CCEGLView::sharedOpenGLView().getScreenScaleFactor();
// cocos2d::CCAccelerometer::sharedAccelerometer()->update((x - rcRect.origin.x) / fScreenScaleFactor,
// (y - rcRect.origin.y) / fScreenScaleFactor,
// z,
// timeStamp);
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->update(x, y, z, timeStamp);
}
示例8: onExit
void CCLayer::onExit()
{
CCDirector* pDirector = CCDirector::sharedDirector();
if( m_bIsTouchEnabled )
{
pDirector->getTouchDispatcher()->removeDelegate(this);
unregisterScriptTouchHandler();
}
// remove this layer from the delegates who concern Accelerometer Sensor
if (m_bIsAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the kaypad msg
if (m_bIsKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
CCNode::onExit();
}
示例9: onExit
void CCLayer::onExit()
{
CCDirector* pDirector = CCDirector::sharedDirector();
if( m_bTouchEnabled )
{
pDirector->getTouchDispatcher()->removeDelegate(this);
// [lua]:don't unregister script touch handler, or the handler will be destroyed
// unregisterScriptTouchHandler();
}
// remove this layer from the delegates who concern Accelerometer Sensor
if (m_bAccelerometerEnabled)
{
pDirector->getAccelerometer()->setDelegate(NULL);
}
// remove this layer from the delegates who concern the keypad msg
if (m_bKeypadEnabled)
{
pDirector->getKeypadDispatcher()->removeDelegate(this);
}
CCNode::onExit();
}
示例10:
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv* env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) {
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getAccelerometer()->update(x, y, z, timeStamp);
}