各位:
刚开始接触cocos2d-x,网上的文档和教程都不是很多,所以问题比较弱。
我现在想实现一个 精灵,一直按住2秒后,响应一个事件,请问有什么好的方法可以直接使用吗?
下列是我实现的伪代码:
onTouchBegan
{
_pressed = true;
_lasttime = 当前时间戳; (不知道如何获取)
}
onTouchEnd
{
_pressed = flase;
}
updateSchedul (ccTime dt)
{
if (_pressed)
{
if(当前时间戳 - _lasttime > 2)
{
foo ();
_lastime = 当前时间戳;
}
....(略,处理不到时间内,如果松开了。)
}
}