• <legend id='8qTPT'><style id='8qTPT'><dir id='8qTPT'><q id='8qTPT'></q></dir></style></legend>

    1. <tfoot id='8qTPT'></tfoot>

      <small id='8qTPT'></small><noframes id='8qTPT'>

        <bdo id='8qTPT'></bdo><ul id='8qTPT'></ul>
      <i id='8qTPT'><tr id='8qTPT'><dt id='8qTPT'><q id='8qTPT'><span id='8qTPT'><b id='8qTPT'><form id='8qTPT'><ins id='8qTPT'></ins><ul id='8qTPT'></ul><sub id='8qTPT'></sub></form><legend id='8qTPT'></legend><bdo id='8qTPT'><pre id='8qTPT'><center id='8qTPT'></center></pre></bdo></b><th id='8qTPT'></th></span></q></dt></tr></i><div id='8qTPT'><tfoot id='8qTPT'></tfoot><dl id='8qTPT'><fieldset id='8qTPT'></fieldset></dl></div>
      1. 滑动精灵时,如果精灵从一侧消失,它会绕到对面吗?

        When sliding sprite, if sprite disappears off the side, it will wrap around to the opposite side?(滑动精灵时,如果精灵从一侧消失,它会绕到对面吗?)

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

                • <tfoot id='TmLID'></tfoot>

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

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

                • 本文介绍了滑动精灵时,如果精灵从一侧消失,它会绕到对面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当滑动精灵时,如果精灵从一侧消失,我想让它环绕到另一侧,但我不知道如何在精灵同时被推离一侧时执行此操作我想要另一位你看不到像虫洞一样的循环出现在对面.

                  When sliding sprite, if sprite disappears off the side, i want to make it wrap around to the opposite side but I do not know how to do this while the sprite is simultaneously being pushed off one side i want the other bit that you can't see to appear on the opposite side like a loop some sort of wormhole thing.

                  到目前为止,这是我的代码,但它崩溃了,并且只有在整个精灵从侧面消失时才会传输精灵.循环也需要作为无限循环运行,直到有人退出应用程序.

                  here is my code so far but it crashes and it only transports the sprite once the whole of the sprite disappears of the side. Loop also needs to run as an infinite loop until someone quits the app.

                          for (int i =0; i<16; ++i) {
                          MyNode *currentSprite = [c1array objectAtIndex:i];
                          if (currentSprite.contentSize.height>=320 || currentSprite.position.y-currentSprite.contentSize.height/2<=0 ){
                              MyNode *Bsprite = currentSprite;
                              MyNode *Tsprite = currentSprite;
                              Bsprite.scale = 1.0;
                              Tsprite.scale = 1.0;
                  
                              if(currentSprite.position.y >=253){
                              Bsprite.position = ccp(currentSprite.position.x,-35);
                                  [self addChild:Bsprite];
                                  Bsprite.visible = TRUE;
                              }
                              if (currentSprite.position.y <=0) {
                                  Tsprite.position = ccp(currentSprite.position.x,324);
                                  [self addChild:Tsprite];
                                  Tsprite.visible = TRUE;
                              }
                              MyNode *isChanging;
                              if ((Tsprite.visible == TRUE && currentSprite.visible == TRUE) || (Bsprite.visible == TRUE && currentSprite.visible == TRUE)) {
                                  isChanging = TRUE;
                              }
                              if (isChanging == FALSE) {
                                  [self removeChild:Tsprite cleanup:YES];
                                  [self removeChild:Bsprite cleanup:YES];
                              }
                          }
                      }
                  

                  推荐答案

                  不可能只用一个精灵.但是你可以有两个精灵.通常情况下,当您的精灵在屏幕上滑动时,只会看到一个精灵.但是当它到达边界时,第二个也将可见.当第二个完全进入屏幕时 - 删除(或隐藏)第一个.

                  It is not possible to do with one sprite. But you can have two sprites. In common situation when your sprite is sliding along the screen only one sprite will be visible. But when it reaches the border the second one will be visible too. When the second one will completely enter the screen - remove (or hide) the first one.

                  实现这一点的最佳方法是创建一个 CCNode 子类,该子类将包含第一个和第二个精灵,并在需要时交换它们.这样,您的所有逻辑都将非常简单.您将只使用一个 CCNode(子类)并且不会考虑交换精灵 - 这将由您的类自动完成

                  The best way to implement this is to create a CCNode subclass that will contain first and second sprite and will swap them if required. In this way all your logic will be very simple. You will just work with one CCNode (subclass) and will not think about swaping sprites - it will be done automatically by your class

                  编辑

                  @interface MyNode : CCNode
                  {
                      CCSprite *sprite1;
                      CCSprite *sprite2;
                      CCSprite *currentSprite;
                      bool isChanging; //indicates that now two sprites are visible
                  }
                  @end
                  

                  这篇关于滑动精灵时,如果精灵从一侧消失,它会绕到对面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(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?)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  <legend id='nDHsh'><style id='nDHsh'><dir id='nDHsh'><q id='nDHsh'></q></dir></style></legend>
                      <i id='nDHsh'><tr id='nDHsh'><dt id='nDHsh'><q id='nDHsh'><span id='nDHsh'><b id='nDHsh'><form id='nDHsh'><ins id='nDHsh'></ins><ul id='nDHsh'></ul><sub id='nDHsh'></sub></form><legend id='nDHsh'></legend><bdo id='nDHsh'><pre id='nDHsh'><center id='nDHsh'></center></pre></bdo></b><th id='nDHsh'></th></span></q></dt></tr></i><div id='nDHsh'><tfoot id='nDHsh'></tfoot><dl id='nDHsh'><fieldset id='nDHsh'></fieldset></dl></div>

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

                          <tbody id='nDHsh'></tbody>
                          <bdo id='nDHsh'></bdo><ul id='nDHsh'></ul>
                            <tfoot id='nDHsh'></tfoot>