[CocosCreator]扑克翻牌效果

处理效果,勉强能用吧,我这只是提供个简单思路.
工程下载
这里写图片描述

1.创建空节点,添加mask组件,大小调整为扑克大小
这里写图片描述

2.添加精灵,到mask下
这里写图片描述

3.添加移动扑克的mask
这里写图片描述

4.添加移动精灵扑克
这里写图片描述

5.移动扑克为负的它自己的高度.
这里写图片描述

6.添加脚本,指认控件.
这里写图片描述

7.脚本代码

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //    default: null,      // The default value will be used only when the component attaching
        //                           to a node for the first time
        //    url: cc.Texture2D,  // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        // },
        // ...
        m_ShowCard:cc.Sprite,
        m_ShowCardMask:cc.Node,

        m_BackCardMask:cc.Node,
        m_BackCard:cc.Node,
    },
    ctor:function()
    {
        this.m_bMove = false;
        this.m_LastPos = 0;
    },
    // use this for initialization
    onLoad: function () {
        this.node.on(cc.Node.EventType.TOUCH_START,this.onStart,this);
        this.node.on(cc.Node.EventType.TOUCH_END,this.onEnd,this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE,this.onMove,this);
    },

    onStart:function(event)
    {
        this.m_LastPos = event.touch.getLocation();
        this.m_bMove = true;
    },
    onEnd:function()
    {
        this.m_bMove = false;

    },
    onMove:function(event)
    {
        var pos = event.touch.getLocation();
        var y = pos.y - this.m_LastPos.y;
        this.m_LastPos = pos;
        this.m_ShowCard.node.y += y;
        this.m_ShowCardMask.y += y;
        this.m_BackCard.y -= y;
        this.m_BackCardMask.y += y;
    },
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});
  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
cocos creator中使用扑克牌,可以通过创建一个PokerNode节点,并在该***O纸牌作为参考,UNO纸牌是一款世界上最好玩的纸牌游戏之一,它包括108张牌和一张说明书。其中包括80张数字牌和28张特殊牌。数字牌分为红、黄、蓝、绿四种颜色,每种颜色有0到9号牌各两张。特殊牌包括“draw 2”(加两张牌)、“skip”(跳过下家)和“reverse”(逆转方向)各两张。此外,还有两张黑色特殊牌,分别是“wild”(转色)和“wild draw four”(转色并罚抽四张牌)。 你可以根据UNO纸牌游戏的规则和牌面设计,使用cocos creator创建相应的扑克牌,并实现相应的功能。这样就可以开发自己的扑克牌游戏了。你可以参考4399小游戏的UNO颜色纸牌,该游戏已打包为App,并在百度网盘上提供下载。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [cocos creator + TypeScript 实现翻牌效果](https://blog.csdn.net/lxt610/article/details/89517005)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [CocosCreator实现UNO纸牌游戏](https://blog.csdn.net/qq_42439862/article/details/119709040)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值