开发者

need help to create following motion

开发者 https://www.devze.com 2023-03-20 04:10 出处:网络
I want to crea开发者_JAVA技巧te following motion using moveTo or MoveBy methods of cocos2d when I touch object should move there.Is it possible in cocos2d?

I want to crea开发者_JAVA技巧te following motion using moveTo or MoveBy methods of cocos2d

need help to create following motion

when I touch object should move there.Is it possible in cocos2d?


  • (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    for( UITouch *touch in touches ) {

    CGPoint location = [touch locationInView: [touch view]];
    
    location = [[CCDirector sharedDirector] convertToGL: location];
    

//while creating sprite set like sprite.tag=2;

            CCSprite *spr=[self getChildByTag:2];//use your sprite tag while creating


    id move = [CCMoveBy actionWithDuration:4 position:location];

            [spr runAction:move];
0

精彩评论

暂无评论...
验证码 换一张
取 消