首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Iphone >

cocos2d-x的跟随图片是如何做的

2013-08-06 
cocos2d-x的跟随图片是怎么做的啊效果是那种鼠标触屏 、移动时 ,总有图片跟着走,这种用了什么技术啊,谢谢大

cocos2d-x的跟随图片是怎么做的啊
效果是那种鼠标触屏 、移动时 ,总有图片跟着走,这种用了什么技术啊,谢谢大家!!
[解决办法]
-(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;
    }
    
}
按照这个方法写就可以了

热点排行