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 have searched a lot on web and found some of help ful links as exact my question.

Link 1 Link 2

But still i am not success to achieve this,
i have done some of code lines, as like draw line by Touch methods. and i have some of questions also here as which i need help to better understand this mechanism.

1 -> Line has been cleared after draw complete (this might go in ccTouchesEnded method / UIPangesture state End.) //Whether i am not sure how it possible to draw custom shape by UIPanGesture or Touch methods.

2 -> Is there any differ method to capture whole game scenario for collision as like scheduleUpdate method. and How to get collision for randomly moving sprites and custom random draw shape ?

3 -> How to Check whether User drawn shape is close or open ?

4 -> How to check random moving sprites inside drawn shape or outside ?

here i have write some code lines, But i am not sure whether its use ful in this stuff or not.

//This code is in init method

linePoints = [[NSMutableArray alloc]init];
// create a simple rendertexture node and clear it with the color white
rtx = [CCRenderTexture renderTextureWithWidth:winSize.width height:winSize.height];
rtx.position = CGPointMake(winSize.width/2, winSize.height/2);
[self addChild:rtx z:6 tag:101];

brush = [[CCSprite spriteWithFile:@"Line1.png"] retain];
brush.scale = 5.0f;

Draw line by touch move method.

 -(void) ccTouchesMoved:(NSSet *)touchess withEvent:(UIEvent *)event
    {
        UITouch *touchMyMinge = [touchess anyObject];
        CGPoint start = [self convertTouchToNodeSpace:touchMyMinge];
        CGPoint end = [touchMyMinge previousLocationInView:touchMyMinge.view];
        end = [[CCDirector sharedDirector]convertToGL:end];
        end = [self convertToNodeSpace:end];

        NSValue *value= [NSValue valueWithCGPoint:start];
        [linePoints addObject:value ];

        [rtx begin];
        float distance = ccpDistance(start, end);

        for (int i = 0; i < distance; i++)
        {
            float difx = end.x - start.x;
            float dify = end.y - start.y;
            float delta = (float)i / distance;
            [brush setPosition:ccp(start.x + (difx * delta), start.y + (dify * delta))];
            [brush visit];
        }
        [rtx end];
    }

I have attached two screen shots here, For more clarification.

Please help me about on my technical query.

screen shot 1 Screen shot 2

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.