Cocos Creator 触摸输入代码

使用Cocos Creator 制作游戏,必不可少的就是与用户的交互——包括触摸,键盘,重力感应和鼠标。

[详情参见官方文档] http://docs.cocos.com/creator/manual/zh/scripting/internal-events.html
这里重点要说的是——触摸

     cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            onTouchBegan: function(touch, event) {
            //Do what things   
            },
            onTouchEnded: function(touch, event) {
            //Do what things
            }
        }, self.node);

添加上适当的代码可以实现手触输入,同时鼠标点击也会又相应的反应!

猜你喜欢

转载自blog.csdn.net/Inuyasha_1314/article/details/80277637