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

    <small id='LT81A'></small><noframes id='LT81A'>

      <tfoot id='LT81A'></tfoot>
      1. 如何暂停和恢复应用于 ccSprite 的操作?

        时间:2024-08-12

          <small id='72hbk'></small><noframes id='72hbk'>

        • <tfoot id='72hbk'></tfoot>

                <tbody id='72hbk'></tbody>
                <bdo id='72hbk'></bdo><ul id='72hbk'></ul>
                <legend id='72hbk'><style id='72hbk'><dir id='72hbk'><q id='72hbk'></q></dir></style></legend>
                <i id='72hbk'><tr id='72hbk'><dt id='72hbk'><q id='72hbk'><span id='72hbk'><b id='72hbk'><form id='72hbk'><ins id='72hbk'></ins><ul id='72hbk'></ul><sub id='72hbk'></sub></form><legend id='72hbk'></legend><bdo id='72hbk'><pre id='72hbk'><center id='72hbk'></center></pre></bdo></b><th id='72hbk'></th></span></q></dt></tr></i><div id='72hbk'><tfoot id='72hbk'></tfoot><dl id='72hbk'><fieldset id='72hbk'></fieldset></dl></div>
                  本文介绍了如何暂停和恢复应用于 ccSprite 的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个类似

                          [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
                       @"Actor.plist"];
                      spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"Actor.pvr.ccz"];
                      [self addChild:spriteSheet];
                      NSMutableArray *walkAnimFrames = [NSMutableArray array];
                      for(int i = 1; i <= 8; ++i) {
                          [walkAnimFrames addObject:
                           [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
                            [NSString stringWithFormat:@"clip000%d.png", i]]];
                      }
                      CCAnimation *walkAnim = [CCAnimation 
                                               animationWithFrames:walkAnimFrames delay:0.07f];
                      playWalkSound = [CCCallFuncN actionWithTarget:self selector:@selector(PlayRunningSound:)];
                  
                      walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
                      [actor runAction:[CCSpawn actions:walkAction, nil]];
                  

                  我想在特定帧和特定触发器上暂停此动画.然后在特定触发后再次恢复动画.

                  I want to pause this animation on particular frame and particular trigger. and then again resume animation after particular trigger.

                  我尝试使用 stopAction,然后再次使用 runAction.但它在一些迭代后停止工作.我需要再次制作动画和动作才能再次运行该动画.

                  I tried using stopAction and then again runAction. But it stops working after some iteration. and i need to crate animation and action again in order to run that animation again.

                  我尝试使用 pauseSchedulerAndAction 和 resumeSchedulerandAction 但随后游戏暂停,如果我尝试再次触发暂停而不恢复游戏崩溃.

                  I tried using pauseSchedulerAndAction and resumeSchedulerandAction but then game get paused and if i try to trigger pause again without resuming game crashes.

                  是否有任何东西会暂停特定帧上的动画并从同一帧再次恢复.

                  is there anything that will pause the animation on particular frame and resum again from same frame.

                  推荐答案

                  我通过创建 1 帧动画解决了我的问题

                  I solved my problem by creating a animation with 1 frame

                  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
                   @"Actor.plist"];
                  spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"Actor.pvr.ccz"];
                  [self addChild:spriteSheet];
                  NSMutableArray *walkAnimFrames = [NSMutableArray array];
                  for(int i = 1; i <2; ++i) {
                      [walkAnimFrames addObject:
                       [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
                        [NSString stringWithFormat:@"clip000%d.png", i]]];
                  }
                  CCAnimation *walkAnim = [CCAnimation 
                                           animationWithFrames:walkAnimFrames delay:0.07f];
                  playWalkSound = [CCCallFuncN actionWithTarget:self selector:@selector(PlayRunningSound:)];
                  
                  walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
                  [actor runAction:[CCSpawn actions:walkAction, nil]];
                  

                  我使用上面的代码来暂停我的动画动作.并在我想恢复动画动作时添加以下代码.

                  i used the above code where i want to pause my animation action. and added following code when i want to resume the animation action.

                  [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
                       @"Actor.plist"];
                      spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"Actor.pvr.ccz"];
                      [self addChild:spriteSheet];
                      NSMutableArray *walkAnimFrames = [NSMutableArray array];
                      for(int i = 1; i <= 8; ++i) {
                          [walkAnimFrames addObject:
                           [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
                            [NSString stringWithFormat:@"clip000%d.png", i]]];
                      }
                      CCAnimation *walkAnim = [CCAnimation 
                                               animationWithFrames:walkAnimFrames delay:0.07f];
                      playWalkSound = [CCCallFuncN actionWithTarget:self selector:@selector(PlayRunningSound:)];
                  
                      walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
                      [actor runAction:[CCSpawn actions:walkAction, nil]];
                  

                  这篇关于如何暂停和恢复应用于 ccSprite 的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:cocos2d sprite 碰撞检测boundingbox 下一篇:cocos2d 在场景之间移动

                  相关文章

                    <tfoot id='nAazf'></tfoot>

                    <small id='nAazf'></small><noframes id='nAazf'>

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

                      <legend id='nAazf'><style id='nAazf'><dir id='nAazf'><q id='nAazf'></q></dir></style></legend>

                      • <bdo id='nAazf'></bdo><ul id='nAazf'></ul>