//Get Position of EMPTY SPRITE
CCSprite *sprite = (CCSprite*)[self getChildByName:[NSString stringWithFormat:@"%d", kEMPTY] recursively:NO];
//GET DRAGGED SQUARE
CCSprite *spriteMove = (CCSprite*)[self getChildByName:[NSString stringWithFormat:@"%d", DragStartSquare] recursively:NO];
然后我试图通过
来获取EMPTY SPRITE的位置(它实际上不是空的)CGPoint worldCoord = [sprite convertToWorldSpace: sprite.position];
然后我用以下方式制作动画:
id action1 = [CCActionMoveTo actionWithDuration:duration position:worldCoord];
这会将精灵发送出屏幕。我做错了什么?
答案 0 :(得分:0)
您需要转换回目标精灵的节点空间:
CGPoint targetNodeCoord = [spriteMove convertToNodeSpace: [sprite convertToWorldSpace: sprite.position]];
CCAction *action1 = [CCActionMoveTo actionWithDuration:duration position:targetNodeCoord];