| 414 | } |
| 415 | |
| 416 | int LuaEngine::handleTouchEvent(void* data) |
| 417 | { |
| 418 | if (NULL == data) |
| 419 | return 0; |
| 420 | |
| 421 | TouchScriptData* touchScriptData = static_cast<TouchScriptData*>(data); |
| 422 | if (NULL == touchScriptData->nativeObject || NULL == touchScriptData->touch) |
| 423 | return 0; |
| 424 | |
| 425 | int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)touchScriptData->nativeObject, |
| 426 | ScriptHandlerMgr::HandlerType::TOUCHES); |
| 427 | |
| 428 | if (0 == handler) |
| 429 | return 0; |
| 430 | |
| 431 | switch (touchScriptData->actionType) |
| 432 | { |
| 433 | case EventTouch::EventCode::BEGAN: |
| 434 | _stack->pushString("began"); |
| 435 | break; |
| 436 | |
| 437 | case EventTouch::EventCode::MOVED: |
| 438 | _stack->pushString("moved"); |
| 439 | break; |
| 440 | |
| 441 | case EventTouch::EventCode::ENDED: |
| 442 | _stack->pushString("ended"); |
| 443 | break; |
| 444 | |
| 445 | case EventTouch::EventCode::CANCELLED: |
| 446 | _stack->pushString("cancelled"); |
| 447 | break; |
| 448 | |
| 449 | default: |
| 450 | return 0; |
| 451 | } |
| 452 | |
| 453 | int ret = 0; |
| 454 | |
| 455 | Touch* touch = touchScriptData->touch; |
| 456 | if (NULL != touch) |
| 457 | { |
| 458 | const ax::Vec2 pt = Director::getInstance()->convertToGL(touch->getLocationInView()); |
| 459 | _stack->pushFloat(pt.x); |
| 460 | _stack->pushFloat(pt.y); |
| 461 | ret = _stack->executeFunctionByHandler(handler, 3); |
| 462 | } |
| 463 | _stack->clean(); |
| 464 | return ret; |
| 465 | } |
| 466 | |
| 467 | int LuaEngine::handleTouchesEvent(void* data) |
| 468 | { |
nothing calls this directly
no test coverage detected