效果是那种鼠标触屏 、移动时 ,总有图片跟着走,这种用了什么技术啊,谢谢大家!!

解决方案 »

  1.   

    有个moveto的事件啊  你在实现那个事件就可以啦
      

  2.   

    上面的记错了  应该是这个  你参考一下
    -  (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        lastTouch = [touch locationInView:self];
        
        if (shapeType == kImageShape) {
            CGFloat horizontalOffset = drawImage.size.width / 2;
            CGFloat verticalOffset = drawImage.size.height / 2;
            redrawRect = CGRectUnion(redrawRect, 
                                     CGRectMake(lastTouch.x - horizontalOffset,
                                                lastTouch.y - verticalOffset, 
                                                drawImage.size.width, 
                                                drawImage.size.height));
        }
        else
            redrawRect = CGRectUnion(redrawRect, self.currentRect);
        redrawRect = CGRectInset(redrawRect, -2.0, -2.0);
        [self setNeedsDisplayInRect:redrawRect];
    }-  (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch *touch = [touches anyObject];
        lastTouch = [touch locationInView:self];
        
        if (shapeType == kImageShape) {
            CGFloat horizontalOffset = drawImage.size.width / 2;
            CGFloat verticalOffset = drawImage.size.height / 2;
            redrawRect = CGRectUnion(redrawRect,
                                     CGRectMake(lastTouch.x - horizontalOffset,
                                                lastTouch.y - verticalOffset, 
                                                drawImage.size.width,
                                                drawImage.size.height));
        }
        redrawRect = CGRectUnion(redrawRect, self.currentRect);
        [self setNeedsDisplayInRect:redrawRect];
    }
      

  3.   

    -(void) ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
    {
        //获取触摸点位置
        CGPoint touchLocation = [self convertTouchToNodeSpace:touch];
        //获取上一个触摸点位置
        CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
        oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
        oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];
        //得到两个位置之间的向量
        CGPoint translation = ccpSub(touchLocation, oldTouchLocation);    attackPoint = touchLocation;
        //touchLocation = [[CCDirector sharedDirector] convertToGL:touchLocation];
        if (selmagic.magiccdend)
        {
            selmagic.magic_ring.opacity = 250;
            canmagic = YES;
            //移动后的触点位置
    CGPoint newPos = ccpAdd(selmagic.magic_ring.position, translation);
            //让释放魔法可移动精灵随触点移动
            selmagic.magic_ring.position = newPos;
        }
        
    }
    按照这个方法写就可以了
      

  4.   

    ccTouchbegin  ccTouchMoved  重设精灵的位置