扑克翻牌效果教程.

文章地址
最后效果.







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) {

// },});
6赞

牌都被折断了啊…效果应该贴近现实中的搓牌效果,要不然画蛇添足不如不用了.

我也很绝望啊

这也是一种方法~

谢谢分享:2::2:

跟樓主一樣的方法做的,只是多加了陰影部分,
個人覺得麻煩的地方就在於mask只能掛載在parent對象,有位移之類的需求需要做child的座標換算,希望creator的mask功能能再進化,這樣能做的效果會多很多

5赞

是的,这方法稍微处理一下细节就可以了,因为我没这方面需求,只是提供个思路

厉害了呀

可以贴一下实现阴影跟变形那部分么?

确实,大神这个折叠是怎么做的?请教一下

学习一下

很不错的教程

可以贴一下实现阴影跟变形那部分吗

大神 能把代码发一下吗,学习一下 goul007@yeah.net 多谢了

可是你这个牌边上的圆弧角怎么弄的

你好,请问效果下面的变形你怎么做的