Hi,
How can I dim the screen by percentage? I need to dim the screen little by little until it reach a certain percentage. Is there a way using this just by Scene? If not, how?
Here is what I am trying to achieve
Your guidance will be appreicated.
Hi,
How can I dim the screen by percentage? I need to dim the screen little by little until it reach a certain percentage. Is there a way using this just by Scene? If not, how?
Here is what I am trying to achieve
Your guidance will be appreicated.
How about make a DrawNode which draws a black rectangle that covers the whole screen, then set the opacity to the level of dimming that you need?
I just got an idea from you! Fantastic! Brilliant! Let me try that out.
Or you could just use a png image 1x1 black pixels and stretch it across the screen with opacity.
I usually go the LayerColor route, but they all lead to the same effect.
Yeah
Here is how i do it:
auto tint = cocos2d::LayerColor::create(cocos2d::Color4B(0, 0, 0, 200));
this->addChild(tint);
A lot of approaches, this is what I need. Very brilliant. I also like the 1x1 png image and stretch it to the sign of the screen. Very good!
Here is how i do it:
auto tint = cocos2d::LayerColor::create(cocos2d::Color4B(0, 0, 0, 200));
this->addChild(tint);
This cool as well! Thanks!
could you tell us what you have used @neonwarge04 ??
we would like to know what have you used… 
@neonwarge04
I just made my own implementation on dimming as suggested by milos1290.
What I did is to create layer. I set the max opacity to 200. And then when game over occurs. I raised the flag that is time to dim the screen.
Here is what my code looks like on the update function:
void MainGameScene::update(float elapsed)
{
mTimeElapsed += elapsed;
if (!mMineField->isGameOver() && mTimeElapsed >= 1.0f)
{
mTime--;
ostringstream ss; ss << mTime;
mTimerLabel->setString(ss.str().c_str());
mTimeElapsed = 0.0f;
}
if (mMineField->isGameOver() || (mTime <= 0 && mBombCount <= 0))
{
if (mScreenOpacity <= 200)
{
mScreenOpacity+= 20;
mLayerColor->setOpacity(mScreenOpacity);
}
if (mGameOverSprite->getPositionX() <= mGameOverStopPoint.x)
{
mGameOverSpriteCurrentWidth += 1100.0f * elapsed;
mGameOverSprite->setPosition(cocos2d::Vec2(mGameOverSpriteCurrentWidth , mGameOverSprite->getPositionY()));
}
}
}
Here’s how I did the layer:
mLayerColor = cocos2d::LayerColor::create(cocos2d::Color4B(0 , 0 , 0 , 0));
Then just add it:
this->addChild(mLayerColor);
Hope this helps.
yes, thanks for sharing… 
I’m seeing a huge drop in performance when adding a dim layer or draw node on top.
From 60FPS I’m getting about 30-40 FPS when adding a semi transparent layer.
Any ideas how to improve it or it is a fill rate limitation of the GPU?