void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate) {
    	m_pAccelDelegates->remove(pDelegate);

    	if ( 0 == m_pAccelDelegates->size() ) {
    		disableAccelerometerJNI();
    	}
    }
static void gameIdle()
{
    if (PPSensor::sharedManager()) {
        PPSensorAndroid* a = (PPSensorAndroid*)PPSensor::sharedManager();
        if (a->_accelerometerEnabled) {
            if (!accelerometer) {
                accelerometer=true;
                enableAccelerometerJNI();
            }
        } else {
            if (accelerometer) {
                accelerometer=false;
                disableAccelerometerJNI();
            }
        }
    }
    //game->Clear();

    if (g) {
        game->setTouchCount(0);

        // if (touchesSet != NULL) {
        //   CCTouch *pTouch;
        //   CCSetIterator setIter;
        //   for (setIter = touchesSet->begin(); setIter != touchesSet->end(); ++setIter) {
        //     pTouch = (CCTouch *)(*setIter);
        //     CCPoint location = pTouch->locationInView(pTouch->view());
        //     game->setTouchPosition(location.x,location.y);
        //   }
        // }

        for (int i=0; i<MAX_JNI_TOUCH; i++) {
            if (touch[i].touch) {
                game->setTouchPosition(touch[i].x,touch[i].y);
            }
        }

        g->InitBuffer(PPGAME_MAX_POLY);
        g->st.screenWidth = win_width;
        g->st.screenHeight = win_height;
        game->screenWidth = win_width;
        game->screenHeight = win_height;

        // unsigned long key=getKey();
        unsigned long key=0;
        game->gameIdle(key);

//    if (game->exitGame) {
//      game->exitGame = false;
//      closeGame();
//    }
    }
}
Beispiel #3
0
    void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate) 
    {
        m_pAccelDelegate = pDelegate;

        if (pDelegate)
        {        
            enableAccelerometerJNI();
        }
        else
        {
            disableAccelerometerJNI();
        }
    }
    void CCAccelerometer::removeDelegate(CCAccelerometerDelegate* pDelegate) 
	{
		disableAccelerometerJNI();
    }