MCPcopy Create free account
hub / github.com/axmolengine/axmol / handleTouchEvent

Method handleTouchEvent

extensions/scripting/lua-bindings/manual/LuaEngine.cpp:416–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416int 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
467int LuaEngine::handleTouchesEvent(void* data)
468{

Callers

nothing calls this directly

Calls 8

getInstanceFunction · 0.85
getObjectHandlerMethod · 0.80
pushStringMethod · 0.80
convertToGLMethod · 0.80
pushFloatMethod · 0.80
getLocationInViewMethod · 0.45
cleanMethod · 0.45

Tested by

no test coverage detected