CCDirector::drawScene() has no effect on Android?

CCDirector::drawScene() has no effect on Android?
0

#1

Changing a scene can take some time, so I want to change the color of a button before replacing the scene, so the user can tell that the button press was recognized.

I’m doing this:

settingsButtonSprite->setColor( ccc3(196,255,0) );
CCDirector::sharedDirector()->drawScene();

CCScene* scene = SettingsScreen::scene();
CCDirector::sharedDirector()->replaceScene( scene );

… but the scene is not being drawn before being replaced. Am I doing something wrong?


#2

ah… found the problem:

void CCEGLView::swapBuffers()
{
}

Seems like the timing of the view actually being presented on-screen is different on Android.

As a workaround, I keep a variable in my layer class to keep track of whether a button has been pressed and which one it was. When the button is pressed this variable is set. At the same time, a counter variable is also set to keep track of how many ticks have occurred since the button was pressed. Of course, the sprite color is also changed.

In the update function, these two variables are checked to see if a button was pressed, and if more than one tick has passed since the press. If so the scene is replaced.