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

    2. <tfoot id='kDT26'></tfoot>

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

    3. cocos2d 从未来的特定时间开始粒子

      cocos2d starting particles from a specific time in the future(cocos2d 从未来的特定时间开始粒子)
      1. <tfoot id='v3Ead'></tfoot>

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

              <tbody id='v3Ead'></tbody>

              <legend id='v3Ead'><style id='v3Ead'><dir id='v3Ead'><q id='v3Ead'></q></dir></style></legend>
                <bdo id='v3Ead'></bdo><ul id='v3Ead'></ul>

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

                本文介绍了cocos2d 从未来的特定时间开始粒子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在开发一个基于 cocos2d 的具有空间背景的应用程序,在该应用程序中我正在利用 CCQuadParticleSystem 来制作闪烁的星星.我用 ParticleDesigner 生成了这个粒子系统.当我加载粒子系统时,代表星星的白点开始出现在背景中,一段时间后它们会淡出,这样,在粒子系统达到状态状态的几秒钟后,就会出现满是星星的夜空.

                I am developing a cocos2d based app with a space background in which I am exploiting a CCQuadParticleSystem to make blinking stars. I have generated this particle system with ParticleDesigner. As soon as I load the particle system white dots representing stars start appearing in the background and after a while they fade out so that, after few seconds in which the particle system reaches the regime state, a night sky full of stars comes out.

                我的问题是我想知道是否有办法让粒子系统从未来的特定时间(例如 t0 = 3sec)开始,这样我就不必等待所有的开始闪烁.

                My problem is that I would like to know if there is a way to make the particle system starting from a specific time in the future (for instance t0 = 3sec) so that I do not have to wait to have all the starts blinking.

                我希望我已经清楚地解释了问题

                I hope I have clearly explained the problem

                提前谢谢你

                安德烈亚

                推荐答案

                我假设您在游戏循环中使用某种 updateWithDelta: 方法来更新粒子.如果您希望粒子在某个时间间隔后启动,请制作您自己的计时器.

                I assume you are using some kind of updateWithDelta: method in your game loop in order to update the particles. If you want the particles to start after a certain interval, make your own timer.

                根据您在下面的评论,我的方法仍然很好,只是需要一些调整.您只需在粒子系统的 updateWithDelta: 方法中移除条件.这样,它仍然会在这 3 秒内更新,但不会渲染,因此看起来就像您描述的那样.

                Based on your comment below, my method is still good, it just needs some tweaking. You need only remove the condition in the updateWithDelta: method on the particle system. That way, it will still update for those 3 seconds, but will not render, and therefore look the way you are describing.

                在.h文件中:

                BOOL particleShouldUpdate;
                float particleTimer;
                

                在你的 init 方法中:

                particleShouldRender = NO;
                particleTimer = 3.0f;
                

                在您的 updateWithDelta: 方法中:

                if(!particleShouldRender){
                  particleTimer -= delta;
                  if(particleTimer < 0){
                    particleShouldRender = YES;
                  }
                }
                // update your particle.
                

                最后,在你的渲染方法中:

                Finally, in your render method:

                if(particleShouldRender){
                  // render your particle.
                }
                

                注意,从这里开始,如果你想停止它的渲染,你只需要像 init 方法那样重置 2 个变量,同样的效果会发生.

                Note that from this point, if you want to stop it rendering, you need only reset the 2 variables like as in the init method, and the same effect will occur.

                进一步澄清后,我们只需要修改你的粒子的 init 方法.我将在这里做出 2 个假设,您只需稍微更改它们即可满足您的需求.假设您的更新周期为每秒 60 帧,最小粒子寿命为 1.01,并且您希望在开始游戏之前进行 3 秒的更新.然后在init方法中,尝试:

                Upon further clarification, we only need to adapt the init method of your particle. I will make 2 assumptions here, and you need only change them slightly to fit your needs. Suppose that your update cycle is 60 frames per second, the minimum particle lifespan is 1.01, and that you want 3 seconds of updates before you start the game. Then in the init method, try:

                for(float delta = 0.0f; delta < 3.0f; delta += (1/60)){
                  [particle updateWithDelta:(float)(1/60)];
                }
                

                这将像往常一样更新您的粒子,但不会在每个时间间隔渲染,并且在其他任何内容更新之前.或者,如果您在更新粒子时担心速度,可以尝试:

                This will update your particle like it normally would, but without rendering at each interval, and before anything else gets updated. Alternatively, if you are worried about speed when updating your particle, you can try:

                for(int i = 0; i < 3; i++){
                  [particle updateWithDelta:1];
                  [particle updateWithDelta:0.02];
                }
                

                这会更快,但可能会有一些问题,具体取决于您的粒子参数.

                This will be faster, but may have a few issues depending on your particles parameters.

                因此进一步研究,cocos2D 出于某种原因不允许您这样做.我在网上找到了一个类似问题,他们建议你玩posVarspeed 使它们在过渡到场景时足够大,一旦完全过渡到场景中,将值重置为正常值.您可能想尝试一下!

                So looking into this further, cocos2D does not let you do this for some reason. I found a similar question online to this, and they suggested you play with the posVar and speed to make them large enough while you are transitioning into the scene, and once you have fully transitioned into the scene, reset the values to normal. You may want to give that a try!

                希望有帮助!

                这篇关于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 图形)
                Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  1. <tfoot id='3QcAX'></tfoot>
                  2. <small id='3QcAX'></small><noframes id='3QcAX'>

                      <bdo id='3QcAX'></bdo><ul id='3QcAX'></ul>

                            <tbody id='3QcAX'></tbody>

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