简体   繁体   English

Cocos2D iPhone效果

[英]Cocos2D iPhone Effect

trying to play around with the Cocos2d effects and created to methods to display and stop the Liquid action. 尝试使用Cocos2d效果,并创建显示和停止Liquid动作的方法。 My application however drops from 60fps down to 30fps when the effect is applied but the fps doesnt increase again when the scheduled stop action is called. 但是,当应用效果时,我的应用程序从60fps下降到30fps,但是调用计划的停止动作时fps并没有再次增加。

I originally thought that while the action has been completed the effect is still being rendered but after reading through the EffectsTest.h/.m in the Cocos2D 0.8 zip I cant find any reference to how this is achieved. 我原本以为动作完成后仍会呈现效果,但在阅读Cocos2D 0.8 zip中的EffectsTest.h / .m之后,我找不到任何有关实现方式的参考。 Can anyone shed some light on this issue? 谁能阐明这个问题?

// effects
-(void)enableLiquidEffect
{
    id liquid = [Liquid actionWithWaves:6 amplitude:20 grid:ccg(15, 10) duration:3];

    [self schedule:@selector(disableLiquidEffect) interval:(3.0)];

    [self runAction:liquid];
}
-(void)disableLiquidEffect
{
    [self unschedule:@selector(disableLiquidEffect)];
    [self stopAllActions];
}


Cheers, 干杯,
AntonMills 安东·米尔斯

Just a little tip here i know this was asked years ago, but someone might still come here the code is a little bit overkill, here's how to do it: 这里有个小技巧,我知道这是几年前提出的,但是仍然有人可能会来这里,但代码有些过头了,这是怎么做的:

// effects
-(void)enableLiquidEffect
{
    id liquid = [Liquid actionWithWaves:6 amplitude:20 grid:ccg(15, 10) duration:3];
    //No need to unschedule after 3 seconds since you already set duration-^ to 3 seconds.
    [self runAction:liquid];
}
-(void)disableLiquidEffect
{
    [self stopAllActions];
}

besides that the code is perfect 除了代码是完美的

Just a guess but since the item will still have a transform set to liquid that it is still trying to apply a more complex transform then needed after its done. 只是一个猜测,但是由于该项目仍将变换设置为液体,因此它仍在尝试应用完成后需要的更复杂的变换。 Save off your transform prior to starting and then when it stops set it back. 在开始之前保存转换,然后在转换停止时将其重新设置。 You could try just setting it to nil. 您可以尝试将其设置为nil。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM