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


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

本文整理汇总了C++中Director::getAccelerometer方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::getAccelerometer方法的具体用法?C++ Director::getAccelerometer怎么用?C++ Director::getAccelerometer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Director的用法示例。


在下文中一共展示了Director::getAccelerometer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEnter

/// Callbacks
void Layer::onEnter()
{
    Director* pDirector = Director::getInstance();
    // register 'parent' nodes first
    // since events are propagated in reverse order
    if (_touchEnabled)
    {
        this->registerWithTouchDispatcher();
    }

    // then iterate over all the children
    Node::onEnter();

    // add this layer to concern the Accelerometer Sensor
    if (_accelerometerEnabled)
    {
        pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
    }

    // add this layer to concern the keypad msg
    if (_keypadEnabled)
    {
        pDirector->getKeypadDispatcher()->addDelegate(this);
    }
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:26,代码来源:CCLayer.cpp

示例2: onEnterTransitionDidFinish

void Layer::onEnterTransitionDidFinish()
{
    if (_accelerometerEnabled)
    {
        Director* pDirector = Director::getInstance();
        pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
    }
    
    Node::onEnterTransitionDidFinish();
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:10,代码来源:CCLayer.cpp

示例3: setAccelerometerInterval

void Layer::setAccelerometerInterval(double interval) {
    if (_accelerometerEnabled)
    {
        if (_running)
        {
            Director* pDirector = Director::getInstance();
            pDirector->getAccelerometer()->setAccelerometerInterval(interval);
        }
    }
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:10,代码来源:CCLayer.cpp

示例4: setAccelerometerEnabled

/// isAccelerometerEnabled setter
void Layer::setAccelerometerEnabled(bool enabled)
{
    if (enabled != _accelerometerEnabled)
    {
        _accelerometerEnabled = enabled;

        if (_running)
        {
            Director* pDirector = Director::getInstance();
            if (enabled)
            {
                pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(Layer::didAccelerate, this));
            }
            else
            {
                pDirector->getAccelerometer()->setDelegate(nullptr);
            }
        }
    }
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:21,代码来源:CCLayer.cpp

示例5: onExit

void Layer::onExit()
{
    Director* pDirector = Director::getInstance();
    if( _touchEnabled )
    {
        pDirector->getTouchDispatcher()->removeDelegate(this);
    }

    // remove this layer from the delegates who concern Accelerometer Sensor
    if (_accelerometerEnabled)
    {
		pDirector->getAccelerometer()->setDelegate(nullptr);
    }

    // remove this layer from the delegates who concern the keypad msg
    if (_keypadEnabled)
    {
        pDirector->getKeypadDispatcher()->removeDelegate(this);
    }

    Node::onExit();
}
开发者ID:KIngpon,项目名称:HXGame,代码行数:22,代码来源:CCLayer.cpp

示例6:

 JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxAccelerometer_onSensorChanged(JNIEnv*  env, jobject thiz, jfloat x, jfloat y, jfloat z, jlong timeStamp) {
     Director* pDirector = Director::getInstance();
     pDirector->getAccelerometer()->update(x, y, z, timeStamp);
 }    
开发者ID:Ben-Cortina,项目名称:GameBox,代码行数:4,代码来源:Java_org_cocos2dx_lib_Cocos2dxAccelerometer.cpp


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