【全新原创消除游戏】,劲爆来袭,欢迎体验。 顺便分享屏蔽多点触摸代码和简单shader

感觉很不错。

1赞

楼主,你的游戏里面,还是有多点触摸:joy:

:joy: 你咋点出来的啊?两个按钮一起点吗?

噢, 我知道了,button的点击和node的点击用的不是同一套事件。还需要给button的点击加一下就好了:joy:

我记得论坛里面好像分享了屏蔽多点触控的代码了的,通过获取点击事件的ID来决定是否对当前的点击事件进行响应,翻一翻应该还能找到那个帖子

是的,同时点击两个按钮

是这一个吗?
http://forum.cocos.com/t/creator/45139
但是这个 必须要自己在每个 touch_start和end中加判断,太麻烦了
所有我直接改的是引擎里面的
而且button也可以改

嗯嗯 谢谢啦:grin:
屏蔽多点触摸还需要修改的 地方
CCButton.js文件也要改一下
_onTouchBegan: function (event) {
if (!this.interactable || !this.enabledInHierarchy) return;

if(cc._currentTouchNode && cc._currentTouchNode.isValid && cc._currentTouchNode.activeInHierarchy){

return;

}

    this._pressed = true;
    this._updateState();
    event.stopPropagation();
},

_onTouchEnded: function (event) {

cc._currentTouchNode = null;

},

_onTouchCancel: function () {

cc._currentTouchNode = null;

},

各位有什么更好的办法也可以在这里说下,多谢啦:joy:

谢谢:grin:

可以的,随便看下你写的屏蔽多点触摸代码。之前我也写了,但感觉用的开关变量太多

楼主,我觉得做的非常棒,整个体验,感觉很不错,每个细节的特效有很用心,大赞

1赞

:joy:多谢支持,有人喜欢就好

shader怎么弄的啊?我是小白, 没弄过

你可以参照这个写法, 我游戏里面的云和水都是这么做的
参考 : http://forum.cocos.com/t/creator-shader/36388
在Update里面更新变量,就可以做动态效果了
var _default_vert = require("./ss/ccShader_Default_Vert.js");
var _default_vert_no_mvp = require("./ss/ccShader_Default_Vert_noMVP.js");
var _wave_h_frag = require("./ss/ccShader_Wave_H_Frag.js");

cc.Class({
extends: cc.Component,

properties: {
    _angle : {
        default : 3,
        visible : true
    },
    speed : 1,
},

onLoad: function () {
    // this._angle = 15;
    this._motion = 0;
    this._opacity = 1;
    
    this._use();
},

_use: function()
{
    this._program = new cc.GLProgram();
    if (cc.sys.isNative) {
        cc.log("use native GLProgram")
        this._program.initWithString(_default_vert_no_mvp, _wave_h_frag);
        this._program.link();
        this._program.updateUniforms();
    }else{
        this._program.initWithVertexShaderByteArray(_default_vert, _wave_h_frag);

        this._program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION);
        this._program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR);
        this._program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS);
        this._program.link();
        this._program.updateUniforms();
    }
    
    this._uniMotion = this._program.getUniformLocationForName( "motion" );
    this._uniAngle = this._program.getUniformLocationForName( "angle" );
    this._uniOpacity = this._program.getUniformLocationForName( "opacity" );
    

    if (cc.sys.isNative) {
        var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this._program);
        glProgram_state.setUniformFloat( this._uniAngle, this._angle );
        glProgram_state.setUniformFloat( this._uniOpacity, this._opacity );
    }else{
        this._program.setUniformLocationWith1f( this._uniAngle, this._angle );
        this._program.setUniformLocationWith1f( this._uniOpacity, this._opacity );
    }


    this.setProgram( this.node._sgNode, this._program );
},

// setOpacity(opacity){
//     this._opacity = opacity
// },

 setProgram:function (node, program) {
     if (cc.sys.isNative) {
         var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program);
         node.setGLProgramState(glProgram_state);
     }else{
         node.setShaderProgram(program);    
     }
    

     var children = node.children;
     if (!children)
         return;

     for (var i = 0; i < children.length; i++)
         this.setProgram(children[i], program);
 }, 

update: function( dt )
{
    if( this._program )
    {

        this._program.use();
        if(cc.sys.isNative){
            var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this._program);
            glProgram_state.setUniformFloat( this._uniMotion, ( this._motion += dt * this.speed ) );
            glProgram_state.setUniformFloat( this._uniOpacity, this._opacity );
        }else{
            this._program.setUniformLocationWith1f( this._uniMotion, ( this._motion += dt * this.speed ) );
            this._program.setUniformLocationWith1f( this._uniOpacity, this._opacity );
            this._program.updateUniforms();
        }
        
        if( Math.PI * 2 < this._motion ){ 
            this._motion -= Math.PI * 2; 
        }
    }
}

});

vert 文件
module.exports =
attribute vec4 a_position; attribute vec2 a_texCoord; attribute vec4 a_color; varying vec2 v_texCoord; varying vec4 v_fragmentColor; void main() { gl_Position = CC_PMatrix * a_position; v_fragmentColor = a_color; v_texCoord = a_texCoord; }

frag文件
/* 水平波浪 */

module.exports =
#ifdef GL_ES precision mediump float; #endif varying vec2 v_texCoord; uniform float motion; uniform float angle; uniform float opacity; void main() { vec2 tmp = v_texCoord; tmp.x = tmp.x + 0.05 * sin(motion + tmp.y * angle); gl_FragColor = texture2D(CC_Texture0, tmp); gl_FragColor.a = gl_FragColor.a * opacity; }

1赞

我也觉得玩法和噗哟噗哟很像 像是结合了puyo和消消乐 楼主可以看看这款游戏 很好玩的消除游戏

好的 , 我去看看:grinning:

多谢楼主 :grin:

握个抓 加个好友吧 能玩过噗哟噗哟的不多

mark