I am trying to make animation in cocos2d, but instead of images it print only whites rectangles. All images becomes whites rectangles right after addChild(player);
in code.
When I give it to comments other images are shown good. Animation seems to be good, because I see the white rectangle of animated images is little changing. All images are in assets.
There is a code:
CGSize winSize = CCDirector.sharedDirector().displaySize();
CCSprite p = CCSprite.sprite("Player.png");
p.setPosition(CGPoint.ccp(p.getContentSize().width / 2.0f, winSize.height / 2.0f));
addChild(p, 1);
CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("player.plist");
CCSprite player = CCSprite.sprite(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("Player.png"));
player.setPosition(CGPoint.make(60, winSize.height / 3));
addChild(player);
CCAnimation anim = CCAnimation.animation("", 0.3f);
for (int i = 2; i <9; i++) {
anim.addFrame(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("PlayerWalk_0" + i + ".png"));
}
CCAction animaction = CCAnimate.action(2, anim, true);
player.runAction(animaction);
Thanks for replies.
EDIT:
I changed addChild(player);
to addChild(player, 2);
and first image is now shown correctly but animated image and fps are still white rectangles.
Texture and plist had diffrent names. I renamed them, so they was the same, just one ending with .plist and other with .png. Now it works. :)