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

Method commandTouchSubCommandTap

core/base/Console.cpp:1163–1186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1161}
1162
1163void Console::commandTouchSubCommandTap(socket_native_type fd, std::string_view args)
1164{
1165 auto argv = Console::Utility::split(args, ' ');
1166
1167 if ((argv.size() == 3) && (Console::Utility::isFloat(argv[1]) && Console::Utility::isFloat(argv[2])))
1168 {
1169
1170 float x = (float)utils::atof(argv[1].c_str());
1171 float y = (float)utils::atof(argv[2].c_str());
1172
1173 std::srand((unsigned)time(nullptr));
1174 _touchId = rand();
1175 Scheduler* sched = Director::getInstance()->getScheduler();
1176 sched->runOnAxmolThread([&]() {
1177 Director::getInstance()->getRenderView()->handleTouchesBegin(1, &_touchId, &x, &y);
1178 Director::getInstance()->getRenderView()->handleTouchesEnd(1, &_touchId, &x, &y);
1179 });
1180 }
1181 else
1182 {
1183 const char msg[] = "touch: invalid arguments.\n";
1184 Console::Utility::sendToConsole(fd, msg, strlen(msg));
1185 }
1186}
1187
1188void Console::commandTouchSubCommandSwipe(socket_native_type fd, std::string_view args)
1189{

Callers

nothing calls this directly

Calls 8

atofFunction · 0.85
getInstanceFunction · 0.85
runOnAxmolThreadMethod · 0.80
handleTouchesBeginMethod · 0.80
handleTouchesEndMethod · 0.80
splitFunction · 0.70
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected