Question

I trying to develop a game for iPhone by using Cocos2d. I need 'DRAG' option in Cocos2d. Is it possible to implement drag option in Cocos2d ?

Was it helpful?

Solution

Its done well:

-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];

    CGPoint location = [touch locationInView: [touch view]];
    CGPoint convertedLocation = [[Director sharedDirector] convertCoordinate:location];
        //start ur logical code

}

OTHER TIPS

To drag you can simply set the sprite's center to the location of the current touch coordinates.

See the Apple Dev Sample: MoveMe I think this will help.

Are you trying to create a pathfinding game like Flight Control or Harbor Master? Please explain with more detail what you are trying to achieve.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top