“掼蛋”一直是人们茶余饭后经久不衰的娱乐项目之一,淮安掼蛋 偶尔带点“彩头”(数额不大的钱财输赢)以增加刺激也是正常的事。本文介绍:淮安掼蛋源码之--选牌与出牌。
<1>选牌.
选牌结束,检查要出的牌,添加到出牌数组中.
void SeatUnit::checkSelCardEnd()
{
CardGroup::MODE mode = _pCards->getMode();
_ayToCards->removeAllObjects();
CCArray *array;CCObject *pObj;
if(mode==CardGroup::MODE_SINGLE){
array = _pCards->getArray();
CCARRAY_FOREACH(array, pObj){
CardUnit *one = (CardUnit*)pObj;
one->setSelColor(false);
one->setSelAction();
if(!one->getIsActivate())continue;
_ayToCards->addObject(one);
}
}else{
array = _pCards->getArray();
CCARRAY_FOREACH(array, pObj){
CardUnit *one = (CardUnit*)pObj;
if(!one->getIsSel())continue;
_ayToCards->addObject(one); //被选中的牌加入到要出的牌的牌组中
}
//展开
if(_ayToCards->count()>0){
_pCards->expandCardSel();
_isExpand = true;
}
}
codeSelCard();
}
<2>出牌.
选完牌后,点击clickGo进行出牌,出牌分为2步,1是发送出牌信息4006给服务器,2是收到服务器回调信息4001后,在其回调函数cfDesk中,调用runShowCards,在runShowCards中调用my_play_a_card进行出牌.也就是将手牌移除掉自己选中的牌.
void SeatUnit::my_play_a_card() //出牌的具体实现(调用时机是收到clickGo回调信息后,出牌)
{
if(_ayToCards->count()==0)return;
CCPoint showPoint = _pCardShow->getPosition();
CCObject *pObj;
CCARRAY_FOREACH(_ayToCards, pObj){
CardUnit *one = (CardUnit*)pObj;
CCPoint point = one->getLocForSrc()-showPoint;
_pCards->removeCard(one);
one->getSprite()->setPosition(point);
_pCardShow->addCard(one);
}
_pCardShow->tidyCard(1);
_ayToCards->removeAllObjects();
_pCards->reviseCardLoc();
itCardGroup();
}
总结:出牌就是将自己手中要出的牌从手牌数组中删除,同时挪动到出牌数组中.但是并没有进行removeChild和addChild这些操作,所以要想好,出牌的过程是怎样的,变化的是数据的交换,要把握本质.
淮安掼蛋源码之--选牌与出牌
最新推荐文章于 2024-06-28 23:45:00 发布