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

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

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

      <tfoot id='IlgVe'></tfoot>

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

        cocos2d 在不同目标上按顺序运行序列

        时间:2024-08-12
        • <i id='xkhak'><tr id='xkhak'><dt id='xkhak'><q id='xkhak'><span id='xkhak'><b id='xkhak'><form id='xkhak'><ins id='xkhak'></ins><ul id='xkhak'></ul><sub id='xkhak'></sub></form><legend id='xkhak'></legend><bdo id='xkhak'><pre id='xkhak'><center id='xkhak'></center></pre></bdo></b><th id='xkhak'></th></span></q></dt></tr></i><div id='xkhak'><tfoot id='xkhak'></tfoot><dl id='xkhak'><fieldset id='xkhak'></fieldset></dl></div>
            <tbody id='xkhak'></tbody>

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

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

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

                • <tfoot id='xkhak'></tfoot>
                  本文介绍了cocos2d 在不同目标上按顺序运行序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以,我有一个基本的游戏场景:

                  So, i have a basic game scenerario:

                  一些单位靠近敌方单位,发射弹丸,然后调整敌方单位的生命.我的问题是我不确定如何安排这三个事件一个接一个地运行.如果所有这些操作都在同一个目标上完成,那么这将非常容易,但是有两个不同的目标.

                  Some unit moves close to an enemy unit, shoots projectile and then enemy unit's life is adjusted. My problem is that I am not sure how to schedule these three events to run one after another. If all these actions were done on the same target, then this would be super easy, but there are two different targets.

                  最好的方法是什么?

                  代码如下:

                  Unit* unit = [self getActiveUnit];
                  Unit* enemy = [self getEnemyInRange:unit];
                  
                  CGpoint A = unit.sprite.position;
                  CGPoint B = [self getPositionClose:enemy for:unit];
                  
                  CCSequence* unitMove = [self generateUnitMoveFrom:A to:B];
                  
                  Projectile* proj = [self generateProjectile];
                  CCSequence* projMove = [self generateProjMoveFrom:A to:B];
                  
                  CCSequence* attackDone = [self generateAttackDoneFor:unit enemy:enemy];
                  
                  // This is the part that i don't know how to do
                  // Execute these in order and sequentially, not at the same time
                  [unit.sprite runAction:unitMove];
                  [proj.sprite runAction:projMove];
                  [proj.sprite runAction:removeSprite];
                  [self runAction:attackDone];
                  

                  执行此操作的最佳方法是什么?即使使用 CCActionManager 它似乎仍然相当复杂,因为我认为我必须在所有这些操作之间添加一个额外的回调才能恢复下一个目标的预定操作.

                  What is the best approach to do this? Even using CCActionManager it still seems fairly complicated because i think i would have to add an extra call back between all these actions to resume scheduled actions for the next target.

                  有什么想法吗?

                  谢谢!

                  推荐答案

                  我会尝试使用 CCSequence

                  [self runAction:[CCSequence actions:
                    [CCCallFuncO actionWithTarget:unit.sprite selector:@selector(runAction:) object:unitMove],
                    [CCCallFuncO actionWithTarget:proj.sprite selector:@selector(runAction:) object:projMove],
                    [CCCallFuncO actionWithTarget:proj.sprite selector:@selector(runAction:) object:removeSprite],
                    [CCCallFunc actionWithTarget:self selector:@selector(attackDone)],
                                       nil]];
                  

                  这篇关于cocos2d 在不同目标上按顺序运行序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何检查 iPhone 的语言设置? 下一篇:cocos2d 错误:没有这样的文件或目录

                  相关文章

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