Sprite Sheet Animation Cocos2dx - c++

I've been working really hard for weeks now trying to get sprite sheet animation to work, and it isn't. I've tried, using this wiki page, http://www.cocos2d-x.org/wiki/Sprite_Sheet_Animation, and I've tried to make my own code, and neither have gotten e remotely close to where I want to be and I really have no idea what I'm doing here. Any help will be welcomed, and greatly appreciated. Thanks in advance.

For sprite sheet animation you have to make a plist for all your images.
Download texture packer : https://www.codeandweb.com/texturepacker
After installing the texture packer, add sprites to it and publish it.
It will create a plist.
Add that plist and png to the resources folder of your project.
Now add the following code to the init() of your GameLayer :
SpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BowArrow.plist");
for (int i = 1; i <= 9; i++) {
frame = String::createWithFormat("Bow%d.png", i);
frames.pushBack(
SpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(
frame->getCString()));
}
Now you have all the sprites of plist in a framecache and you can run animation on them in the way you want.
I hope it helps.

You can make animations using GIF, i made so in my game and never had performance issues, you can make a GIF from web GIF Maker

Related

CCLayerColor in SpriteKit

Is there something to replace CCLayerColor, CCLayerGradient etc inside Sprite Kit?
It was always easy to create simple filled rectangles in cocos2d, but I don't find any out of the box solutions in Sprite Kit so far.
As always, it should be platform independent so no iOS only code please (i.e., inside Sprite Kit).
Do you mean
SKSpriteNode *rect = [SKSpriteNode spriteNodeWithColor:[UIColor whiteColor] size:CGSizeMake(70, 70)];

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.

Coloring application using Cocos2D

I trying to make an empty CCSprite then I want to hand drawing on it using touch controls.
But, I don't have an idea how make it and don't know it's possible.
So, PLS help me or give me some advice.
Thanks
I wrote a demo program for CCRenderTexture which shows you how to draw sprites (or whatever you want) with touches:
Hi You can use CCRenderTexture example from Cocos2d for drawing..
Check out this link http://www.cocos2d-iphone.org/forum/topic/8474