开发者

Cocos2d update:(ccTime)dt giving screwed up values

开发者 https://www.devze.com 2023-02-11 00:16 出处:网络
Inside of a class that subclasses CCNode, I have scheduled an -update:(ccTime)dt method. I also have a bunch of behavior objects that don\'t subclass CCNode, but also have an-update:(ccTime)dt method.

Inside of a class that subclasses CCNode, I have scheduled an -update:(ccTime)dt method. I also have a bunch of behavior objects that don't subclass CCNode, but also have an -update:(ccTime)dt method. Here's the inside of my CCNode's update method:

-(void)update:(ccTime)dt{
    for(Behavior *currentBehavior in behaviors开发者_运维百科){
        [currentBehavior update:dt];
    }
}

When I NSLog the dt value passed into my CCNode's update, it prints out normal values (0.116699, 0.162726). However, when I NSLog the dt value from inside the behaviors' update methods, the printed numbers are all of a sudden really screwed up (0.000, 36893488147419103232, -2.000). It's the strangest thing. When I debug it, I'll see that the first dt value is normal, and then I'll step inside the behavior's update, and the value will suddenly change to something crazy. What's going on?


I figured it out. I didn't have -update:(ccTime)dt in my behavior class's .m file, and my theory is that it took the complier extra time to look for the method selector, which therefore screwed up the ccTime.

0

精彩评论

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

关注公众号