<bdo id='cYRp8'></bdo><ul id='cYRp8'></ul>

    1. <tfoot id='cYRp8'></tfoot>
    2. <legend id='cYRp8'><style id='cYRp8'><dir id='cYRp8'><q id='cYRp8'></q></dir></style></legend>
    3. <small id='cYRp8'></small><noframes id='cYRp8'>

    4. <i id='cYRp8'><tr id='cYRp8'><dt id='cYRp8'><q id='cYRp8'><span id='cYRp8'><b id='cYRp8'><form id='cYRp8'><ins id='cYRp8'></ins><ul id='cYRp8'></ul><sub id='cYRp8'></sub></form><legend id='cYRp8'></legend><bdo id='cYRp8'><pre id='cYRp8'><center id='cYRp8'></center></pre></bdo></b><th id='cYRp8'></th></span></q></dt></tr></i><div id='cYRp8'><tfoot id='cYRp8'></tfoot><dl id='cYRp8'><fieldset id='cYRp8'></fieldset></dl></div>

      如何在不使用 TexturePacker 的情况下在 Cocos2D 中添加动画图像?

      时间:2024-08-11

          <tbody id='bvLT9'></tbody>
          <bdo id='bvLT9'></bdo><ul id='bvLT9'></ul>

          1. <tfoot id='bvLT9'></tfoot>
            • <legend id='bvLT9'><style id='bvLT9'><dir id='bvLT9'><q id='bvLT9'></q></dir></style></legend>
              • <small id='bvLT9'></small><noframes id='bvLT9'>

                <i id='bvLT9'><tr id='bvLT9'><dt id='bvLT9'><q id='bvLT9'><span id='bvLT9'><b id='bvLT9'><form id='bvLT9'><ins id='bvLT9'></ins><ul id='bvLT9'></ul><sub id='bvLT9'></sub></form><legend id='bvLT9'></legend><bdo id='bvLT9'><pre id='bvLT9'><center id='bvLT9'></center></pre></bdo></b><th id='bvLT9'></th></span></q></dt></tr></i><div id='bvLT9'><tfoot id='bvLT9'></tfoot><dl id='bvLT9'><fieldset id='bvLT9'></fieldset></dl></div>
                本文介绍了如何在不使用 TexturePacker 的情况下在 Cocos2D 中添加动画图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I am New at iOS Development. I am also starting to learn Cocos2D.

                I've read this tutorial: http://www.raywenderlich.com/tutorials#cocos2d

                It is a superb tutorial for beginners, but I'm also interested in animating the image. How can I accomplish animation?

                So I read tutorial (describe from Above Link) about how to put animated image with simple Project.

                In This tutorial I used TexturePacker and it's working... but I want to know more about how to animate images without using TexturePacker.

                Is it possible? If so, then please explain how or link to tutorials on how to make it work.

                Thanks in advance.

                解决方案

                You can run animation from file.

                    CCSprite *coin = [CCSprite spriteWithFile:@"MyImage_1.png"];
                    coin.position  = ccp(mS.width*0.5f, mS.height*0.5f);
                    [self addChild:coin z:2];
                
                    {
                        NSString *animationName = @"UNIQUE_ANIMATION_NAME";
                
                        CCAnimation* animation = nil;
                        animation = [[CCAnimationCache sharedAnimationCache]  animationByName:animationName];
                
                        if(!animation)
                        {
                            NSMutableArray *animFrames = [NSMutableArray array];
                
                            for( int i=1;i<=5;i++)
                            {
                                NSString* path = [NSString stringWithFormat:@"MyImage_%d.png", i];
                                CCTexture2D* tex = [[CCTextureCache sharedTextureCache] addImage:path];
                                CGSize texSize = tex.contentSize;
                                CGRect texRect = CGRectMake(0, 0, texSize.width, texSize.height);
                                CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:tex rect:texRect];
                                [animFrames addObject:frame];
                            }
                
                            animation = [CCAnimation animationWithSpriteFrames:animFrames];
                
                            animation.delayPerUnit = 0.175f;
                            animation.restoreOriginalFrame = YES;
                
                            [[CCAnimationCache sharedAnimationCache] addAnimation:animation name:animationName];
                        }
                
                        if(animation)
                        {
                            CCAnimate *animAction  = [CCAnimate actionWithAnimation:animation];
                            [coin runAction:animAction];
                        }
                    }
                

                这篇关于如何在不使用 TexturePacker 的情况下在 Cocos2D 中添加动画图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:从 Iphone Native Client 使用 Google App Engine 进行身份验证 下一篇:更新 Cocos2d 中的标签值

                相关文章

                <i id='1OPq8'><tr id='1OPq8'><dt id='1OPq8'><q id='1OPq8'><span id='1OPq8'><b id='1OPq8'><form id='1OPq8'><ins id='1OPq8'></ins><ul id='1OPq8'></ul><sub id='1OPq8'></sub></form><legend id='1OPq8'></legend><bdo id='1OPq8'><pre id='1OPq8'><center id='1OPq8'></center></pre></bdo></b><th id='1OPq8'></th></span></q></dt></tr></i><div id='1OPq8'><tfoot id='1OPq8'></tfoot><dl id='1OPq8'><fieldset id='1OPq8'></fieldset></dl></div>
              • <legend id='1OPq8'><style id='1OPq8'><dir id='1OPq8'><q id='1OPq8'></q></dir></style></legend>
                1. <tfoot id='1OPq8'></tfoot>

                    <bdo id='1OPq8'></bdo><ul id='1OPq8'></ul>

                  1. <small id='1OPq8'></small><noframes id='1OPq8'>