cocos2d的触摸​​HELP [英] Cocos2D Touch HELP

查看:315
本文介绍了cocos2d的触摸​​HELP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的新的Cocos2D图书馆,我libgdx和纯openGL的工作之前。我怎样才能为Android处理在cocos2d触摸事件?

I`m new to cocos2d library, I worked before with libgdx and pure openGL. How can I handle a touch event in Cocos2d for Android?

推荐答案

4种方法用于处理在Android触摸定义如下:

The 4 methods for handling touches on android are defined as follows:

public boolean ccTouchesBegan(MotionEvent event);

public boolean ccTouchesMoved(MotionEvent event);

public boolean ccTouchesEnded(MotionEvent event);

public boolean ccTouchesCancelled(MotionEvent event);

这是你应该使用侦听器。

These are the listeners you should use.

,并添加下面一行在你CCLayer类的构造函数来实现触摸事件。

And also add below line in constructor of your CCLayer class to enable touch event.

this.setIsTouchEnabled(true); 

这篇关于cocos2d的触摸​​HELP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆