zoukankan      html  css  js  c++  java
  • cocos2d-iphone心得

    源码下载地址:

    http://code.google.com/p/cocos2d-iphone/downloads/list

    https://github.com/cocos2d/cocos2d-iphone-classic/releases?after=release-0.2

    问题:[[CCDirector sharedDirector] runWithScene: [sysMenu scene]];导演是怎么把screen放到屏幕上的呢?

    找了老半天发现只有这个- (void) pushScene: (CCScene*) scene,把这个注了,就显示不了了,

    后来又找了很长时间终于找到了,

    EAGLView里

    - (void) layoutSubviews

    [director performSelectorOnMainThread:@selector(drawScene) withObject:nil waitUntilDone:YES];

    -(void) mainLoop
    {
    [self drawScene];
    }

    - (void) startAnimation
    {
    NSAssert( isRunning == NO, @"isRunning must be NO. Calling startAnimation twice?");

    // XXX:
    // XXX: release autorelease objects created
    // XXX: between "use fast director" and "runWithScene"
    // XXX:
    [autoreleasePool release];
    autoreleasePool = nil;

    if ( gettimeofday( &lastUpdate_, NULL) != 0 ) {
    CCLOG(@"cocos2d: Director: Error in gettimeofday");
    }

    isRunning = YES;

    SEL selector = @selector(mainLoop);
    NSMethodSignature* sig = [[[CCDirector sharedDirector] class]
    instanceMethodSignatureForSelector:selector];
    NSInvocation* invocation = [NSInvocation
    invocationWithMethodSignature:sig];
    [invocation setTarget:[CCDirector sharedDirector]];
    [invocation setSelector:selector];
    [invocation performSelectorOnMainThread:@selector(invokeWithTarget:)
    withObject:[CCDirector sharedDirector] waitUntilDone:NO];

    // NSInvocationOperation *loopOperation = [[[NSInvocationOperation alloc]
    // initWithTarget:self selector:@selector(mainLoop) object:nil]
    // autorelease];
    //
    // [loopOperation performSelectorOnMainThread:@selector(start) withObject:nil
    // waitUntilDone:NO];
    }

    - (void) startAnimation
    {
    NSAssert( displayLink == nil, @"displayLink must be nil. Calling startAnimation twice?");

    if ( gettimeofday( &lastUpdate_, NULL) != 0 ) {
    CCLOG(@"cocos2d: DisplayLinkDirector: Error on gettimeofday");
    }

    // approximate frame rate
    // assumes device refreshes at 60 fps
    int frameInterval = (int) floor(animationInterval_ * 60.0f);

    CCLOG(@"cocos2d: Frame interval: %d", frameInterval);

    displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(mainLoop:)];
    [displayLink setFrameInterval:frameInterval];
    [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    }

  • 相关阅读:
    hdu5945 Fxx and game
    hdu5937 Equation
    2016-2017 CT S03E06: Codeforces Trainings Season 3 Episode 6 The Baguette Master
    Canada Cup 2016 D. Contest Balloons
    hdu5798 Stabilization
    bzoj 4026 dC Loves Number Theory
    Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) C. Ray Tracing
    hdu5923 Prediction
    hdu5925 Coconuts
    2016弱校联盟十一专场10.2 Longest Increasing Subsequence
  • 原文地址:https://www.cnblogs.com/xuejinhui/p/4324090.html
Copyright © 2011-2022 走看看