Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am developing an iphone app. It has following page structure, 1.List of game levels in a UITableView 2.Game page

I use "UIViewAnimationTransitionFlipFromRight" between pages

Game page has 3 views, One is a scrollView in that my game grid is drawn. Game grid is a sub class of UIView ,that added to Scrollview. To support zooming i use CATiledLayer to draw the grid(20*20).

MY problem is GameGrid shows white or last played puzzles grid contents for a few seconds and then refresh(flashing) to the new content.

My GameGrid class as follows

`

 @implementation GameGrid

+(Class)layerClass
{    
 return [CATiledLayer class];
}

 - (id)initWithFrame:(CGRect)frame {   
        if ((self = [super initWithFrame:frame])) {
           CATiledLayer *tempTiledLayer = (CATiledLayer*)self.layer;
           tempTiledLayer.levelsOfDetail = 5;
           tempTiledLayer.levelsOfDetailBias = 2;        
              self.opaque=YES;  
           }
             return self;
}

-(void)drawRect:(CGRect)r
{
 //empty
}

-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context
{
 // here i am drawing grid
// filling rect
 // lines
// string etc..
}
share|improve this question
add comment

1 Answer

That's pretty much supposed to happen, it's doing (some of) the drawing in a thread.

It's been a while since I worked on this, but I used

@interface FastCATiledLayer : CATiledLayer
@end

@implementation FastCATiledLayer

+(CFTimeInterval)fadeDuration
{
    return 0.0;     // Normally it’s 0.25
}

@end

because I didn't like the forced initial delay. That may help.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.