当前位置: 首页>>代码示例>>C++>>正文


C++ CCDirector::getAccelerometer方法代码示例

本文整理汇总了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);
    }
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:26,代码来源:CCLayer.cpp

示例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
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:8,代码来源:CCApplication.cpp

示例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);
        }
    }
}
开发者ID:0309,项目名称:cocos2d-x,代码行数:17,代码来源:CCInputDelegate.cpp

示例4: onEnterTransitionDidFinish

void CCLayer::onEnterTransitionDidFinish()
{
    if (m_bAccelerometerEnabled)
    {
        CCDirector* pDirector = CCDirector::sharedDirector();
        pDirector->getAccelerometer()->setDelegate(this);
    }

    CCNode::onEnterTransitionDidFinish();
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:10,代码来源:CCLayer.cpp

示例5: setAccelerometerInterval

void CCLayer::setAccelerometerInterval(double interval) {
    if (m_bAccelerometerEnabled)
    {
        if (m_bRunning)
        {
            CCDirector* pDirector = CCDirector::sharedDirector();
            pDirector->getAccelerometer()->setAccelerometerInterval(interval);
        }
    }
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:10,代码来源:CCLayer.cpp

示例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);
            }
        }
    }
}
开发者ID:Ivory27,项目名称:LoomSDK,代码行数:21,代码来源:CCLayer.cpp

示例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);
    }    
开发者ID:csdnnet,项目名称:hiygame,代码行数:12,代码来源:SensorJni.cpp

示例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();
}
开发者ID:136446529,项目名称:book-code,代码行数:23,代码来源:CCLayer.cpp

示例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();
}
开发者ID:BetaS,项目名称:cocos2d-x,代码行数:24,代码来源:CCLayer.cpp

示例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);
 }    
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:4,代码来源:Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp


注:本文中的CCDirector::getAccelerometer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。