<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 中添加动画图像?

      How to add Animated Image In Cocos2D without use of TexturePacker?(如何在不使用 TexturePacker 的情况下在 Cocos2D 中添加动画图像?)

          <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 中添加动画图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                Resume game cocos2d(恢复游戏 cocos2d)
                Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)

                <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>
                  <tbody id='1OPq8'></tbody>
                  <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'>