与cocos2d草图板的小问题

时间:2012-09-15 07:41:53

标签: ios cocos2d-iphone

我正在尝试添加“白板”,以便人们可以在其上画线。

唯一的问题是,如果我绘得非常快,它会将精灵空间隔开很远,所以如果它们试图绘制字母或数字,它几乎不可读。不同的精灵之间有很多空间。

这是我的方法,我认为大部分绘图正在发生。

-(void) update:(ccTime)delta
    {
        CCDirector* director = [CCDirector sharedDirector];
        CCRenderTexture* rtx = (CCRenderTexture*)[self getChildByTag:1];

        // explicitly don't clear the rendertexture
        [rtx begin];

        for (UITouch* touch in touches)
        {
            CGPoint touchLocation = [director convertToGL:[touch locationInView:director.openGLView]];
touchLocation = [rtx.sprite convertToNodeSpace:touchLocation];

        // because the rendertexture sprite is flipped along its Y axis the Y coordinate must be flipped:
        touchLocation.y = rtx.sprite.contentSize.height - touchLocation.y;


        CCSprite* sprite = [[CCSprite alloc] initWithFile:@"Cube_Ones.png"];
        sprite.position = touchLocation;
        sprite.scale = 0.1f;
        [self addChild:sprite];
        [placedSprites addObject:sprite];
    }

    [rtx end];
}


Maybe this is the cause?

[self scheduleUpdate];  

我不完全确定如何减少更新之间的时间。

提前致谢

0 个答案:

没有答案