开发者

CCSprite not animated anymore as finger does not move on top UIView

开发者 https://www.devze.com 2023-03-13 20:09 出处:网络
Here is the problem: I\'m working with cocos2D and CCLayers, and I use a UIView to catch movements with a Gesture recognizer for a UIScrollMenu.

Here is the problem: I'm working with cocos2D and CCLayers, and I use a UIView to catch movements with a Gesture recognizer for a UIScrollMenu. On my layer, there are animated sprites that run an animation forever; when I drag the scrollMenu with the finger and I stop my finger held down, the CCLayer in background is not updated anymore, and the sprites does not move. As soon as I move the finger again, the sprites are updated. The problem should not come from the sprites, because when I stop and move again, the sprite does not play its next frame, but the frame that should have been displayed if it had continued to move normally. I think that the frames are still calculated, but the layer does not update its view anymore.

Would anyone have an i开发者_开发技巧dea to avoid that?

I don't do anything in order to update the CCSprites, I just launch on them a CCRepeatForever action, then I let their parent CCLayer care about them. I have tried to schedule this CCLayer, but the update function is not called anymore as soon as I am dragging an item with my finger...

`CCAction *hitAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:hitAnim restoreOriginalFrame:NO]];

[sprite runAction:hitAction];`

The function which is called when I move my finger again (and apparently allows the CCLayer to update) is - (void)scrollViewDidScroll:(UIScrollView *)scrollView


Well, you didn't post any code...but based on a problem I had once in the past this is my best guess. If you are updating your animation (or method calls to do animation) inside of CCTouchesMoved then stop doing that. Simply update any information you might need inside CCTouchesMoved and then update your animation inside of a timer method (like if you use [self scheduleUpdate].


I ended up by posting this question on the cocos2D forum, and here is the answer: http://www.cocos2d-iphone.org/forum/topic/17845

0

精彩评论

暂无评论...
验证码 换一张
取 消