cocos2d-x-2.2.5 触摸机制

前端之家收集整理的这篇文章主要介绍了cocos2d-x-2.2.5 触摸机制前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<span style="white-space:pre">	</span>
<span style="white-space:pre">	</span>virtual void registerWithTouchDispatcher(void);
	virtual void ccTouchesBegan(CCSet *pTouches,CCEvent *pEvent);			// 触摸事件中开始时调用的回调函数
	virtual void ccTouchesMoved(CCSet *pTouches,CCEvent *pEvent);
        virtual void ccTouchesEnded(CCSet *pTouches,CCEvent *pEvent);
        virtual void ccTouchesCancelled(CCSet *pTouches,CCEvent *pEvent);



bool sjt::init()
{
<span style="white-space:pre">	// 1. super init first
<span style="white-space:pre">	</span>if(!CCLayer::init())
<span style="white-space:pre">	</span>{
<span style="white-space:pre">		</span>return false;
<span style="white-space:pre">	</span>}</span>
</pre><pre name="code" class="cpp"><span style="white-space:pre">	// for touch control
<span style="white-space:pre">	</span>setTouchEnabled(true);
<span style="white-space:pre">	</span>isTouchDown = false;</span>


void sjt::registerWithTouchDispatcher() 
{
	CCDirector::sharedDirector()->getTouchDispatcher()->addStandardDelegate(this,0);
}

猜你在找的Cocos2d-x相关文章