Cocos2d: Slowly reveal a sprite( think WoW spell cooldown ) - cocos2d-iphone

I'm wanting to create a WoW cooldown effect where a player does some action and is not able to do the action again until the sprite is fully shown again. I have a grayed out version of the same sprite and am wanting to slowly reveal the sprite until it is fully available again. So, there will be a slow blend vertically of the gray and colored sprite.
Is there a way to do this with built in functionality with Cocos2d and CCSprite?
I'm using v2 of Cocos2d so I could write a shader which I think would be pretty easy, but before I went this route I wanted to see if there is an easier way.

Take a look to the CCProgressTimer class. If I understand right, it will make what you want

You can use CCFadeIn to animate the colored sprite over the grayed sprite :
[coloredSprite runAction:[CCFadeIn actionWithDuration:1.0f];

Related

Best way to have animated background in cocos2d

I have seen some similar questions asked but no definitive answer.
I have a background image that I'm using for my main menu for a cocos2d game. I plan to have it animated but not sure what is the most efficient way to do this. One idea was to have multiple images to create the animation but I was thinking this may take up too much memory as each image would be quite big.
The other idea was having one background image as a sprite and then having child sprites of that image that are animated with ccaction. The only thing is I may not be able to create such an elaborate animation if I do this.
I just wanted to get some feedback on this to see what would be the best approach.
Thank you,
Making a frame-by-frame animation of the whole screen would make your app size litteraly explode.
You should definitely go with your 2nd idea, i.e have different sprites for each animated component and use actions to animate them.
Check out CocosBuilder: it provides a nice UI for designing such complex animations

Particles around a sprite

I'm new to the CoCos2D development. I have checked out some tutorials and went on trying to develop a little idea.
I have checked some partical tutorials and it all looks nice but I still have some questions about it. I have seen how to call a particle and let it follow wherever you click on the layer and so on but I need something more.
Let's say I have several circle shaped sprites on my Layer. Is it possible to do the following: click on a sprite and then a partical trail should go around the sprite so you as a player can see it is selected. The particale should keep circling around the sprite until I select another circle shaped sprite which result in dissappearing of the previous particle trail and appearing onto the new selected sprite.
Is this possible with the particle system or should I look for another way of doing this ? Any type of help is appreciated.
kind regards

Cocos2D for Android textures disappear

Some times textures disappear from sprites. I have a sprite that appears with white color and it should have a texture on it and a label that should have a text in it an it appears with black color. The labels are subclasses of sprite so this problem is related to Sprites. Could some one tell me what is the problem ? Did some one meet this bug to in Cococs2D on Android ? Thank's !
I had such a problem when I was doing navigation from "outside" of cocos2d i.e. i relied on Android's native back button's callback to change scenes. Apparently this callback doesn't work on the same thread as cocos and causes this problem (maybe something with WeakReferences in the TextureCache). Hope it helps :)
Are you using pvr? When I tried using pvr I was getting what sounds like the same issues. I switched to png and it fixed the problem for me.

Cocos2d sprite is drawn outside screen when transition

When I do page transition that shows the outside part of the stage (like CCTransitionFlipX), I can briefly see the sprites outside the screen while transition. It is really annoying. I thought I can manually check the position of the sprite in realtime and remove if it is off the screen. But that won't work if that sprite is partially outside. Is there something like UIKit's clipSubviews in cocos2d?
There's a ClippingNode class that might help.
Since the flip animation allows the user to see more than just the visible screen area, because the screen rotates, I think the behavior you observed may be expected.

cocos2d GL_SUBTRUCT problem when using CCRenderTexture

My game needs to implement night vision effect. I'm using a CCRenderTexture as a mask, and I plan to draw the visible areas onto the mask by using [rangeSprite visit];
However, it need GL_SUBTRUCT mode. I searched cocos2d's codes, but found nowhere the macro is used. Does it mean cocos2d do not support this?
Have you solved this? I have the same problem, and am approaching it currently by using a blendmode like this:
[light setBlendFunc:ccBlendFuncMake(GL_DST_ALPHA, GL_ZERO)];
...whereas light is a sprite I paint onto my CCRenderTexture, which gets laid over the screen.