需要帮助来创建以下动作

时间:2011-07-14 16:49:12

标签: cocos2d-iphone

我想使用cocos2d的enter image description here

的moveTo或MoveBy方法创建以下动作

当我触摸对象时应移动到那里。是否可以在cocos2d中使用?

1 个答案:

答案 0 :(得分:0)

  • (void)ccTouchesBegan:(NSSet *)触及withEvent:(UIEvent *)事件{

    for(UITouch * touch in touches){

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

//创建精灵集像sprite.tag = 2;

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


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

            [spr runAction:move];