思路:
node + node的子節點的錨點均設定為0;
第一步:記錄touch開始位置x3
第二步:擷取目前移動位置x4
第三步:計算node容器下的位元組點的position x1 x2
x1 = position.x;
x2 = positon.x + width + offset (offset是卡牌之間疊加的隐藏部分);
卡牌可能所處的位置如下
—x3-------x1--------x2-------x4— 形勢1 中間
—x1-------x3--------x2-------x4— 形勢2 前部
—x3-------x1--------x4-------x2— 形勢3 尾部
滿足上面任一條件,則子節點處于拖動選中範圍内。做相應操作。
效果如下:
demo位址:moveSelectedCards
cocos creator 棋牌 撲克 麻将 拖動手勢 選中