cocos2d how CCSprite to appear on screen - cocos2d-iphone

I want to animate the way a CCSprite appear on screen.
At the moment I'm using "addChild" to display the sprite on screen but I want it to appear on screen with animation.
Is is possible?
Thanks

Try reading through the Cocos2D programming guide, there is a subject on animation with source code there. http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:index.

Related

How to get hold of a sprite in cocos2d?

in cocos2d I need to drag a sprite in my project using finger. how do i get hold of that sprite? any help will be appreciated. thanx. i am using chipmunk engine.
You need to capture the touch began, work out what sprite is being touched and then track the movement of the touch. In touches moved you update the position of the sprite.
Sound complicated? It's not really. Here is a great tutorial for it.
http://www.raywenderlich.com/2343/how-to-drag-and-drop-sprites-with-cocos2d

Sprite without animation

I'm trying to add a SpriteSheet that is shown in the layer but not animated yet, I want to animate onClick.
The problem is when adding the sprite to the layer, the sprite is not shown if its not animated on start.
In Cocos2D-iphone I have not this problem.
Thanks in advance for any help provided.
Just have a look on the coocs2d-android master file :
cocos2d-master\cocos2d-android\src\org\cocos2d\tests\ActionTest.java
In this you can find the Animation class and compare your code with the test file...
or
write down your code ...
Alternatively, show a static image (first sprite) until user clicks, then load the sprites and start animation.

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

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];

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.