Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am working in an android game using cocos2d. I want to dim the background screen when I click the pause button.

How can I do this ?

share|improve this question
1  
Do you mean dim the screen? The definitions I found of deem don't seem to fit your question unless I'm completely wrong. –  Milkboat Nov 22 '11 at 12:18
2  
Maybe start drawing a rectangular over the surface that get's darker over time... –  jco Nov 25 '11 at 9:28

2 Answers 2

I would need a bit of code to give a more detailed answer, but you probably want to use glClearColor when you "click the pause button".

share|improve this answer

I achieved this effect by using a specified pixel from a texture I was already using in this way:

  CCSprite *layer = [CCSprite spriteWithTexture:TEX_INTERFACE.textureAtlas.texture rect:CGRectMake(87, 143, 1, 1)];
  CGSize size = [[CCDirector sharedDirector] winSize];
  layer.scaleX = size.width;
  layer.scaleY = size.height;
  layer.position = ccp(size.width/2, size.height/2);
  layer.opacity = 0;
  [game addChild:layer z:100 tag:TAG_PAUSE_OVERLAY];
  id action = [CCEaseOut actionWithAction:[CCActionTween actionWithDuration:0.1 key:@"opacity" from:0 to:220] rate:2];
  [layer runAction:action];

Mind: this is Cocos2D for Objective-C, not for Android but translating it is straightforward

share|improve this answer
    
I have added one sprite to make the background color gray. But when i click resume button still the background is remain gray color. How can i remove the sprite when i click resume button. –  Laxmipriya Nov 28 '11 at 13:06
    
you have to remove the sprite you added with [parent removeChildByTag:TAG_PAUSE_OVERLAY] –  Jack Nov 28 '11 at 17:35
    
Thanks Jack . Really u r great !Its very helpful to me . Thanks so much for your help.please continue it in future... –  Laxmipriya Nov 29 '11 at 4:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.